Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Toradex Colibri PXA270 Support |
| 4 | * |
| 5 | * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com> |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 6 | * Copyright (C) 2016-2019 Marcel Ziswiler <marcel.ziswiler@toradex.com> |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | 1d91ba7 | 2019-11-14 12:57:37 -0700 | [diff] [blame] | 10 | #include <cpu_func.h> |
Simon Glass | 11c89f3 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 11 | #include <dm.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 12 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 13 | #include <net.h> |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 14 | #include <asm/arch/hardware.h> |
Marek Vasut | 71d058b | 2011-11-26 11:17:32 +0100 | [diff] [blame] | 15 | #include <asm/arch/pxa.h> |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame] | 16 | #include <asm/arch/regs-mmc.h> |
| 17 | #include <asm/arch/regs-uart.h> |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 18 | #include <asm/io.h> |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame] | 19 | #include <dm/platdata.h> |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 20 | #include <dm/platform_data/pxa_mmc_gen.h> |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame] | 21 | #include <dm/platform_data/serial_pxa.h> |
| 22 | #include <netdev.h> |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 23 | #include <serial.h> |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 24 | #include <usb.h> |
Simon Glass | 0ffb9d6 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 25 | #include <asm/mach-types.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 26 | #include <linux/delay.h> |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 27 | #include "../common/tdx-common.h" |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 28 | |
| 29 | DECLARE_GLOBAL_DATA_PTR; |
| 30 | |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 31 | int board_init(void) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 32 | { |
Marek Vasut | 2021299 | 2010-10-20 20:15:11 +0200 | [diff] [blame] | 33 | /* We have RAM, disable cache */ |
| 34 | dcache_disable(); |
| 35 | icache_disable(); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 36 | |
Marcel Ziswiler | b706365 | 2015-03-01 00:53:08 +0100 | [diff] [blame] | 37 | /* arch number of Toradex Colibri PXA270 */ |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 38 | gd->bd->bi_arch_number = MACH_TYPE_COLIBRI; |
| 39 | |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 40 | /* address of boot parameters */ |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 41 | gd->bd->bi_boot_params = 0xa0000100; |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
Marcel Ziswiler | d92dee5 | 2016-11-16 17:49:23 +0100 | [diff] [blame] | 46 | int checkboard(void) |
| 47 | { |
| 48 | puts("Model: Toradex Colibri PXA270\n"); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 53 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 54 | int ft_board_setup(void *blob, struct bd_info *bd) |
Stefan Agner | 98ffd0f | 2016-11-30 13:41:53 -0800 | [diff] [blame] | 55 | { |
| 56 | return ft_common_board_setup(blob, bd); |
| 57 | } |
| 58 | #endif |
| 59 | |
Marek Vasut | 2021299 | 2010-10-20 20:15:11 +0200 | [diff] [blame] | 60 | int dram_init(void) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 61 | { |
Marek Vasut | 08341be | 2011-11-26 11:18:57 +0100 | [diff] [blame] | 62 | pxa2xx_dram_init(); |
Marek Vasut | 2021299 | 2010-10-20 20:15:11 +0200 | [diff] [blame] | 63 | gd->ram_size = PHYS_SDRAM_1_SIZE; |
| 64 | return 0; |
| 65 | } |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 66 | |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 67 | #ifdef CONFIG_CMD_USB |
Troy Kisky | de8ae7b | 2013-10-10 15:27:55 -0700 | [diff] [blame] | 68 | int board_usb_init(int index, enum usb_init_type init) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 69 | { |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 70 | writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) & |
| 71 | ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE), |
| 72 | UHCHR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 73 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 74 | writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 75 | |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 76 | while (UHCHR & UHCHR_FSBIR) |
| 77 | ; |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 78 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 79 | writel(readl(UHCHR) & ~UHCHR_SSE, UHCHR); |
| 80 | writel((UHCHIE_UPRIE | UHCHIE_RWIE), UHCHIE); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 81 | |
| 82 | /* Clear any OTG Pin Hold */ |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 83 | if (readl(PSSR) & PSSR_OTGPH) |
| 84 | writel(readl(PSSR) | PSSR_OTGPH, PSSR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 85 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 86 | writel(readl(UHCRHDA) & ~(0x200), UHCRHDA); |
| 87 | writel(readl(UHCRHDA) | 0x100, UHCRHDA); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 88 | |
| 89 | /* Set port power control mask bits, only 3 ports. */ |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 90 | writel(readl(UHCRHDB) | (0x7 << 17), UHCRHDB); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 91 | |
| 92 | /* enable port 2 */ |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 93 | writel(readl(UP2OCR) | UP2OCR_HXOE | UP2OCR_HXS | |
| 94 | UP2OCR_DMPDE | UP2OCR_DPPDE, UP2OCR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 95 | |
| 96 | return 0; |
| 97 | } |
| 98 | |
Troy Kisky | de8ae7b | 2013-10-10 15:27:55 -0700 | [diff] [blame] | 99 | int board_usb_cleanup(int index, enum usb_init_type init) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 100 | { |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 101 | return 0; |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | void usb_board_stop(void) |
| 105 | { |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 106 | writel(readl(UHCHR) | UHCHR_FHR, UHCHR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 107 | udelay(11); |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 108 | writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 109 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 110 | writel(readl(UHCCOMS) | 1, UHCCOMS); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 111 | udelay(10); |
| 112 | |
Marek Vasut | 2db1e96 | 2010-09-09 09:50:39 +0200 | [diff] [blame] | 113 | writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN); |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 114 | } |
| 115 | #endif |
| 116 | |
| 117 | #ifdef CONFIG_DRIVER_DM9000 |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 118 | int board_eth_init(struct bd_info *bis) |
Marek Vasut | 163551a | 2010-05-11 04:31:44 +0200 | [diff] [blame] | 119 | { |
| 120 | return dm9000_initialize(bis); |
| 121 | } |
| 122 | #endif |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 123 | |
| 124 | #ifdef CONFIG_CMD_MMC |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 125 | #if !CONFIG_IS_ENABLED(DM_MMC) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 126 | int board_mmc_init(struct bd_info *bis) |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 127 | { |
| 128 | pxa_mmc_register(0); |
| 129 | return 0; |
| 130 | } |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 131 | #else /* !CONFIG_IS_ENABLED(DM_MMC) */ |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 132 | static const struct pxa_mmc_plat mmc_plat = { |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 133 | .base = (struct pxa_mmc_regs *)MMC0_BASE, |
| 134 | }; |
| 135 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame^] | 136 | U_BOOT_DRVINFO(pxa_mmcs) = { |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 137 | .name = "pxa_mmc", |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 138 | .plat = &mmc_plat, |
Marcel Ziswiler | 6ad69a4 | 2019-05-20 02:45:01 +0200 | [diff] [blame] | 139 | }; |
| 140 | #endif /* !CONFIG_IS_ENABLED(DM_MMC) */ |
Marek Vasut | e326a23 | 2011-11-26 07:15:36 +0100 | [diff] [blame] | 141 | #endif |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame] | 142 | |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 143 | static const struct pxa_serial_plat serial_plat = { |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame] | 144 | .base = (struct pxa_uart_regs *)FFUART_BASE, |
| 145 | .port = FFUART_INDEX, |
| 146 | .baudrate = CONFIG_BAUDRATE, |
| 147 | }; |
| 148 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame^] | 149 | U_BOOT_DRVINFO(pxa_serials) = { |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame] | 150 | .name = "serial_pxa", |
Simon Glass | b75b15b | 2020-12-03 16:55:23 -0700 | [diff] [blame] | 151 | .plat = &serial_plat, |
Marcel Ziswiler | 15fc272 | 2016-11-14 21:40:28 +0100 | [diff] [blame] | 152 | }; |