Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 4 | * Copyright 2020 NXP |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 9 | #include <image.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 11 | #include <net.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 12 | #include <asm/global_data.h> |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 13 | #include <asm/processor.h> |
| 14 | #include <asm/mmu.h> |
| 15 | #include <asm/cache.h> |
| 16 | #include <asm/immap_85xx.h> |
| 17 | #include <asm/io.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 18 | #include <env.h> |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 19 | #include <miiphy.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 20 | #include <linux/libfdt.h> |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 21 | #include <fdt_support.h> |
| 22 | #include <fsl_mdio.h> |
| 23 | #include <tsec.h> |
| 24 | #include <mmc.h> |
| 25 | #include <netdev.h> |
| 26 | #include <pci.h> |
| 27 | #include <asm/fsl_serdes.h> |
York Sun | 37562f6 | 2013-10-22 12:39:02 -0700 | [diff] [blame] | 28 | #include <fsl_ifc.h> |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 29 | #include <asm/fsl_pci.h> |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 30 | #include <hwconfig.h> |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 31 | #include <i2c.h> |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
| 35 | #define GPIO4_PCIE_RESET_SET 0x08000000 |
| 36 | #define MUX_CPLD_CAN_UART 0x00 |
| 37 | #define MUX_CPLD_TDM 0x01 |
| 38 | #define MUX_CPLD_SPICS0_FLASH 0x00 |
| 39 | #define MUX_CPLD_SPICS0_SLIC 0x02 |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 40 | #define PMUXCR1_IFC_MASK 0x00ffff00 |
| 41 | #define PMUXCR1_SDHC_MASK 0x00fff000 |
| 42 | #define PMUXCR1_SDHC_ENABLE 0x00555000 |
| 43 | |
| 44 | enum { |
| 45 | MUX_TYPE_IFC, |
| 46 | MUX_TYPE_SDHC, |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 47 | MUX_TYPE_SPIFLASH, |
| 48 | MUX_TYPE_TDM, |
| 49 | MUX_TYPE_CAN, |
| 50 | MUX_TYPE_CS0_NOR, |
| 51 | MUX_TYPE_CS0_NAND, |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 52 | }; |
| 53 | |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 54 | enum { |
| 55 | I2C_READ_BANK, |
| 56 | I2C_READ_PCB_VER, |
| 57 | }; |
| 58 | |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 59 | static uint sd_ifc_mux; |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 60 | |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 61 | struct cpld_data { |
| 62 | u8 cpld_ver; /* cpld revision */ |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 63 | #if defined(CONFIG_TARGET_P1010RDB_PA) |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 64 | u8 pcba_ver; /* pcb revision number */ |
| 65 | u8 twindie_ddr3; |
| 66 | u8 res1[6]; |
| 67 | u8 bank_sel; /* NOR Flash bank */ |
| 68 | u8 res2[5]; |
| 69 | u8 usb2_sel; |
| 70 | u8 res3[1]; |
| 71 | u8 porsw_sel; |
| 72 | u8 tdm_can_sel; |
| 73 | u8 spi_cs0_sel; /* SPI CS0 SLIC/SPI Flash */ |
| 74 | u8 por0; /* POR Options */ |
| 75 | u8 por1; /* POR Options */ |
| 76 | u8 por2; /* POR Options */ |
| 77 | u8 por3; /* POR Options */ |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 78 | #elif defined(CONFIG_TARGET_P1010RDB_PB) |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 79 | u8 rom_loc; |
| 80 | #endif |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 81 | }; |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 82 | |
| 83 | int board_early_init_f(void) |
| 84 | { |
| 85 | ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR); |
Jaiprakash Singh | dd88806 | 2015-03-20 19:28:27 -0700 | [diff] [blame] | 86 | struct fsl_ifc ifc = {(void *)CONFIG_SYS_IFC_ADDR, (void *)NULL}; |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 87 | /* Clock configuration to access CPLD using IFC(GPCM) */ |
Jaiprakash Singh | dd88806 | 2015-03-20 19:28:27 -0700 | [diff] [blame] | 88 | setbits_be32(&ifc.gregs->ifc_gcr, 1 << IFC_GCR_TBCTL_TRN_TIME_SHIFT); |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 89 | /* |
| 90 | * Reset PCIe slots via GPIO4 |
| 91 | */ |
| 92 | setbits_be32(&pgpio->gpdir, GPIO4_PCIE_RESET_SET); |
| 93 | setbits_be32(&pgpio->gpdat, GPIO4_PCIE_RESET_SET); |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | int board_early_init_r(void) |
| 99 | { |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 100 | const unsigned int flashbase = CONFIG_SYS_FLASH_BASE; |
York Sun | 220c346 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 101 | int flash_esel = find_tlb_idx((void *)flashbase, 1); |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 102 | |
| 103 | /* |
| 104 | * Remap Boot flash region to caching-inhibited |
| 105 | * so that flash can be erased properly. |
| 106 | */ |
| 107 | |
| 108 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 109 | flush_dcache(); |
| 110 | invalidate_icache(); |
| 111 | |
York Sun | 220c346 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 112 | if (flash_esel == -1) { |
| 113 | /* very unlikely unless something is messed up */ |
| 114 | puts("Error: Could not find TLB for FLASH BASE\n"); |
| 115 | flash_esel = 2; /* give our best effort to continue */ |
| 116 | } else { |
| 117 | /* invalidate existing TLB entry for flash */ |
| 118 | disable_tlb(flash_esel); |
| 119 | } |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 120 | |
| 121 | set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, |
| 122 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 123 | 0, flash_esel, BOOKE_PAGESZ_16M, 1); |
| 124 | |
| 125 | set_tlb(1, flashbase + 0x1000000, |
| 126 | CONFIG_SYS_FLASH_BASE_PHYS + 0x1000000, |
| 127 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 128 | 0, flash_esel+1, BOOKE_PAGESZ_16M, 1); |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 129 | return 0; |
| 130 | } |
| 131 | |
Hou Zhiqiang | 0e49eb4 | 2020-05-01 19:06:27 +0800 | [diff] [blame] | 132 | #if defined(CONFIG_PCI) && !defined(CONFIG_DM_PCI) |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 133 | void pci_init_board(void) |
| 134 | { |
| 135 | fsl_pcie_init_board(0); |
| 136 | } |
| 137 | #endif /* ifdef CONFIG_PCI */ |
| 138 | |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 139 | int config_board_mux(int ctrl_type) |
| 140 | { |
| 141 | ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 142 | u8 tmp; |
| 143 | |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame^] | 144 | #if CONFIG_IS_ENABLED(DM_I2C) |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 145 | struct udevice *dev; |
| 146 | int ret; |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 147 | #if defined(CONFIG_TARGET_P1010RDB_PA) |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 148 | struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); |
| 149 | |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 150 | ret = i2c_get_chip_for_busnum(I2C_PCA9557_BUS_NUM, |
| 151 | I2C_PCA9557_ADDR1, 1, &dev); |
| 152 | if (ret) { |
| 153 | printf("%s: Cannot find udev for a bus %d\n", |
| 154 | __func__, I2C_PCA9557_BUS_NUM); |
| 155 | return ret; |
| 156 | } |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 157 | switch (ctrl_type) { |
| 158 | case MUX_TYPE_IFC: |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 159 | tmp = 0xf0; |
| 160 | dm_i2c_write(dev, 3, &tmp, 1); |
| 161 | tmp = 0x01; |
| 162 | dm_i2c_write(dev, 1, &tmp, 1); |
| 163 | sd_ifc_mux = MUX_TYPE_IFC; |
| 164 | clrbits_be32(&gur->pmuxcr, PMUXCR1_IFC_MASK); |
| 165 | break; |
| 166 | case MUX_TYPE_SDHC: |
| 167 | tmp = 0xf0; |
| 168 | dm_i2c_write(dev, 3, &tmp, 1); |
| 169 | tmp = 0x05; |
| 170 | dm_i2c_write(dev, 1, &tmp, 1); |
| 171 | sd_ifc_mux = MUX_TYPE_SDHC; |
| 172 | clrsetbits_be32(&gur->pmuxcr, PMUXCR1_SDHC_MASK, |
| 173 | PMUXCR1_SDHC_ENABLE); |
| 174 | break; |
| 175 | case MUX_TYPE_SPIFLASH: |
| 176 | out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_FLASH); |
| 177 | break; |
| 178 | case MUX_TYPE_TDM: |
| 179 | out_8(&cpld_data->tdm_can_sel, MUX_CPLD_TDM); |
| 180 | out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_SLIC); |
| 181 | break; |
| 182 | case MUX_TYPE_CAN: |
| 183 | out_8(&cpld_data->tdm_can_sel, MUX_CPLD_CAN_UART); |
| 184 | break; |
| 185 | default: |
| 186 | break; |
| 187 | } |
| 188 | #elif defined(CONFIG_TARGET_P1010RDB_PB) |
| 189 | ret = i2c_get_chip_for_busnum(I2C_PCA9557_BUS_NUM, |
| 190 | I2C_PCA9557_ADDR2, 1, &dev); |
| 191 | if (ret) { |
| 192 | printf("%s: Cannot find udev for a bus %d\n", |
| 193 | __func__, I2C_PCA9557_BUS_NUM); |
| 194 | return ret; |
| 195 | } |
| 196 | switch (ctrl_type) { |
| 197 | case MUX_TYPE_IFC: |
| 198 | dm_i2c_read(dev, 0, &tmp, 1); |
| 199 | clrbits_8(&tmp, 0x04); |
| 200 | dm_i2c_write(dev, 1, &tmp, 1); |
| 201 | dm_i2c_read(dev, 3, &tmp, 1); |
| 202 | clrbits_8(&tmp, 0x04); |
| 203 | dm_i2c_write(dev, 3, &tmp, 1); |
| 204 | sd_ifc_mux = MUX_TYPE_IFC; |
| 205 | clrbits_be32(&gur->pmuxcr, PMUXCR1_IFC_MASK); |
| 206 | break; |
| 207 | case MUX_TYPE_SDHC: |
| 208 | dm_i2c_read(dev, 0, &tmp, 1); |
| 209 | setbits_8(&tmp, 0x04); |
| 210 | dm_i2c_write(dev, 1, &tmp, 1); |
| 211 | dm_i2c_read(dev, 3, &tmp, 1); |
| 212 | clrbits_8(&tmp, 0x04); |
| 213 | dm_i2c_write(dev, 3, &tmp, 1); |
| 214 | sd_ifc_mux = MUX_TYPE_SDHC; |
| 215 | clrsetbits_be32(&gur->pmuxcr, PMUXCR1_SDHC_MASK, |
| 216 | PMUXCR1_SDHC_ENABLE); |
| 217 | break; |
| 218 | case MUX_TYPE_SPIFLASH: |
| 219 | dm_i2c_read(dev, 0, &tmp, 1); |
| 220 | clrbits_8(&tmp, 0x80); |
| 221 | dm_i2c_write(dev, 1, &tmp, 1); |
| 222 | dm_i2c_read(dev, 3, &tmp, 1); |
| 223 | clrbits_8(&tmp, 0x80); |
| 224 | dm_i2c_write(dev, 3, &tmp, 1); |
| 225 | break; |
| 226 | case MUX_TYPE_TDM: |
| 227 | dm_i2c_read(dev, 0, &tmp, 1); |
| 228 | setbits_8(&tmp, 0x82); |
| 229 | dm_i2c_write(dev, 1, &tmp, 1); |
| 230 | dm_i2c_read(dev, 3, &tmp, 1); |
| 231 | clrbits_8(&tmp, 0x82); |
| 232 | dm_i2c_write(dev, 3, &tmp, 1); |
| 233 | break; |
| 234 | case MUX_TYPE_CAN: |
| 235 | dm_i2c_read(dev, 0, &tmp, 1); |
| 236 | clrbits_8(&tmp, 0x02); |
| 237 | dm_i2c_write(dev, 1, &tmp, 1); |
| 238 | dm_i2c_read(dev, 3, &tmp, 1); |
| 239 | clrbits_8(&tmp, 0x02); |
| 240 | dm_i2c_write(dev, 3, &tmp, 1); |
| 241 | break; |
| 242 | case MUX_TYPE_CS0_NOR: |
| 243 | dm_i2c_read(dev, 0, &tmp, 1); |
| 244 | clrbits_8(&tmp, 0x08); |
| 245 | dm_i2c_write(dev, 1, &tmp, 1); |
| 246 | dm_i2c_read(dev, 3, &tmp, 1); |
| 247 | clrbits_8(&tmp, 0x08); |
| 248 | dm_i2c_write(dev, 3, &tmp, 1); |
| 249 | break; |
| 250 | case MUX_TYPE_CS0_NAND: |
| 251 | dm_i2c_read(dev, 0, &tmp, 1); |
| 252 | setbits_8(&tmp, 0x08); |
| 253 | dm_i2c_write(dev, 1, &tmp, 1); |
| 254 | dm_i2c_read(dev, 3, &tmp, 1); |
| 255 | clrbits_8(&tmp, 0x08); |
| 256 | dm_i2c_write(dev, 3, &tmp, 1); |
| 257 | break; |
| 258 | default: |
| 259 | break; |
| 260 | } |
| 261 | #endif |
| 262 | #else |
| 263 | #if defined(CONFIG_TARGET_P1010RDB_PA) |
| 264 | struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); |
| 265 | |
| 266 | switch (ctrl_type) { |
| 267 | case MUX_TYPE_IFC: |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 268 | i2c_set_bus_num(I2C_PCA9557_BUS_NUM); |
| 269 | tmp = 0xf0; |
| 270 | i2c_write(I2C_PCA9557_ADDR1, 3, 1, &tmp, 1); |
| 271 | tmp = 0x01; |
| 272 | i2c_write(I2C_PCA9557_ADDR1, 1, 1, &tmp, 1); |
| 273 | sd_ifc_mux = MUX_TYPE_IFC; |
| 274 | clrbits_be32(&gur->pmuxcr, PMUXCR1_IFC_MASK); |
| 275 | break; |
| 276 | case MUX_TYPE_SDHC: |
| 277 | i2c_set_bus_num(I2C_PCA9557_BUS_NUM); |
| 278 | tmp = 0xf0; |
| 279 | i2c_write(I2C_PCA9557_ADDR1, 3, 1, &tmp, 1); |
| 280 | tmp = 0x05; |
| 281 | i2c_write(I2C_PCA9557_ADDR1, 1, 1, &tmp, 1); |
| 282 | sd_ifc_mux = MUX_TYPE_SDHC; |
| 283 | clrsetbits_be32(&gur->pmuxcr, PMUXCR1_SDHC_MASK, |
| 284 | PMUXCR1_SDHC_ENABLE); |
| 285 | break; |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 286 | case MUX_TYPE_SPIFLASH: |
| 287 | out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_FLASH); |
| 288 | break; |
| 289 | case MUX_TYPE_TDM: |
| 290 | out_8(&cpld_data->tdm_can_sel, MUX_CPLD_TDM); |
| 291 | out_8(&cpld_data->spi_cs0_sel, MUX_CPLD_SPICS0_SLIC); |
| 292 | break; |
| 293 | case MUX_TYPE_CAN: |
| 294 | out_8(&cpld_data->tdm_can_sel, MUX_CPLD_CAN_UART); |
| 295 | break; |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 296 | default: |
| 297 | break; |
| 298 | } |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 299 | #elif defined(CONFIG_TARGET_P1010RDB_PB) |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 300 | uint orig_bus = i2c_get_bus_num(); |
| 301 | i2c_set_bus_num(I2C_PCA9557_BUS_NUM); |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 302 | |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 303 | switch (ctrl_type) { |
| 304 | case MUX_TYPE_IFC: |
| 305 | i2c_read(I2C_PCA9557_ADDR2, 0, 1, &tmp, 1); |
| 306 | clrbits_8(&tmp, 0x04); |
| 307 | i2c_write(I2C_PCA9557_ADDR2, 1, 1, &tmp, 1); |
| 308 | i2c_read(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 309 | clrbits_8(&tmp, 0x04); |
| 310 | i2c_write(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 311 | sd_ifc_mux = MUX_TYPE_IFC; |
| 312 | clrbits_be32(&gur->pmuxcr, PMUXCR1_IFC_MASK); |
| 313 | break; |
| 314 | case MUX_TYPE_SDHC: |
| 315 | i2c_read(I2C_PCA9557_ADDR2, 0, 1, &tmp, 1); |
| 316 | setbits_8(&tmp, 0x04); |
| 317 | i2c_write(I2C_PCA9557_ADDR2, 1, 1, &tmp, 1); |
| 318 | i2c_read(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 319 | clrbits_8(&tmp, 0x04); |
| 320 | i2c_write(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 321 | sd_ifc_mux = MUX_TYPE_SDHC; |
| 322 | clrsetbits_be32(&gur->pmuxcr, PMUXCR1_SDHC_MASK, |
| 323 | PMUXCR1_SDHC_ENABLE); |
| 324 | break; |
| 325 | case MUX_TYPE_SPIFLASH: |
| 326 | i2c_read(I2C_PCA9557_ADDR2, 0, 1, &tmp, 1); |
| 327 | clrbits_8(&tmp, 0x80); |
| 328 | i2c_write(I2C_PCA9557_ADDR2, 1, 1, &tmp, 1); |
| 329 | i2c_read(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 330 | clrbits_8(&tmp, 0x80); |
| 331 | i2c_write(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 332 | break; |
| 333 | case MUX_TYPE_TDM: |
| 334 | i2c_read(I2C_PCA9557_ADDR2, 0, 1, &tmp, 1); |
| 335 | setbits_8(&tmp, 0x82); |
| 336 | i2c_write(I2C_PCA9557_ADDR2, 1, 1, &tmp, 1); |
| 337 | i2c_read(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 338 | clrbits_8(&tmp, 0x82); |
| 339 | i2c_write(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 340 | break; |
| 341 | case MUX_TYPE_CAN: |
| 342 | i2c_read(I2C_PCA9557_ADDR2, 0, 1, &tmp, 1); |
| 343 | clrbits_8(&tmp, 0x02); |
| 344 | i2c_write(I2C_PCA9557_ADDR2, 1, 1, &tmp, 1); |
| 345 | i2c_read(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 346 | clrbits_8(&tmp, 0x02); |
| 347 | i2c_write(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 348 | break; |
| 349 | case MUX_TYPE_CS0_NOR: |
| 350 | i2c_read(I2C_PCA9557_ADDR2, 0, 1, &tmp, 1); |
| 351 | clrbits_8(&tmp, 0x08); |
| 352 | i2c_write(I2C_PCA9557_ADDR2, 1, 1, &tmp, 1); |
| 353 | i2c_read(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 354 | clrbits_8(&tmp, 0x08); |
| 355 | i2c_write(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 356 | break; |
| 357 | case MUX_TYPE_CS0_NAND: |
| 358 | i2c_read(I2C_PCA9557_ADDR2, 0, 1, &tmp, 1); |
| 359 | setbits_8(&tmp, 0x08); |
| 360 | i2c_write(I2C_PCA9557_ADDR2, 1, 1, &tmp, 1); |
| 361 | i2c_read(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 362 | clrbits_8(&tmp, 0x08); |
| 363 | i2c_write(I2C_PCA9557_ADDR2, 3, 1, &tmp, 1); |
| 364 | break; |
| 365 | default: |
| 366 | break; |
| 367 | } |
| 368 | i2c_set_bus_num(orig_bus); |
| 369 | #endif |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 370 | #endif |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 371 | return 0; |
| 372 | } |
| 373 | |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 374 | #ifdef CONFIG_TARGET_P1010RDB_PB |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 375 | int i2c_pca9557_read(int type) |
| 376 | { |
| 377 | u8 val; |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 378 | int bus_num = I2C_PCA9557_BUS_NUM; |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 379 | |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame^] | 380 | #if CONFIG_IS_ENABLED(DM_I2C) |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 381 | struct udevice *dev; |
| 382 | int ret; |
| 383 | |
| 384 | ret = i2c_get_chip_for_busnum(bus_num, I2C_PCA9557_ADDR2, 1, &dev); |
| 385 | if (ret) { |
| 386 | printf("%s: Cannot find udev for a bus %d\n", |
| 387 | __func__, bus_num); |
| 388 | return ret; |
| 389 | } |
| 390 | dm_i2c_read(dev, 0, &val, 1); |
| 391 | #else |
| 392 | i2c_set_bus_num(bus_num); |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 393 | i2c_read(I2C_PCA9557_ADDR2, 0, 1, &val, 1); |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 394 | #endif |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 395 | |
| 396 | switch (type) { |
| 397 | case I2C_READ_BANK: |
| 398 | val = (val & 0x10) >> 4; |
| 399 | break; |
| 400 | case I2C_READ_PCB_VER: |
| 401 | val = ((val & 0x60) >> 5) + 1; |
| 402 | break; |
| 403 | default: |
| 404 | break; |
| 405 | } |
| 406 | |
| 407 | return val; |
| 408 | } |
| 409 | #endif |
| 410 | |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 411 | int checkboard(void) |
| 412 | { |
| 413 | struct cpu_type *cpu; |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 414 | struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE); |
| 415 | u8 val; |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 416 | |
Simon Glass | a8b5739 | 2012-12-13 20:48:48 +0000 | [diff] [blame] | 417 | cpu = gd->arch.cpu; |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 418 | #if defined(CONFIG_TARGET_P1010RDB_PA) |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 419 | printf("Board: %sRDB-PA, ", cpu->name); |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 420 | #elif defined(CONFIG_TARGET_P1010RDB_PB) |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 421 | printf("Board: %sRDB-PB, ", cpu->name); |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame^] | 422 | #if CONFIG_IS_ENABLED(DM_I2C) |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 423 | struct udevice *dev; |
| 424 | int ret; |
| 425 | |
| 426 | ret = i2c_get_chip_for_busnum(I2C_PCA9557_BUS_NUM, I2C_PCA9557_ADDR2, |
| 427 | 1, &dev); |
| 428 | if (ret) { |
| 429 | printf("%s: Cannot find udev for a bus %d\n", __func__, |
| 430 | I2C_PCA9557_BUS_NUM); |
| 431 | return ret; |
| 432 | } |
| 433 | val = 0x0; /* no polarity inversion */ |
| 434 | dm_i2c_write(dev, 2, &val, 1); |
| 435 | #else |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 436 | i2c_set_bus_num(I2C_PCA9557_BUS_NUM); |
| 437 | i2c_init(CONFIG_SYS_FSL_I2C_SPEED, CONFIG_SYS_FSL_I2C_SLAVE); |
| 438 | val = 0x0; /* no polarity inversion */ |
| 439 | i2c_write(I2C_PCA9557_ADDR2, 2, 1, &val, 1); |
| 440 | #endif |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 441 | #endif |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 442 | |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 443 | #ifdef CONFIG_SDCARD |
| 444 | /* switch to IFC to read info from CPLD */ |
| 445 | config_board_mux(MUX_TYPE_IFC); |
| 446 | #endif |
| 447 | |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 448 | #if defined(CONFIG_TARGET_P1010RDB_PA) |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 449 | val = (in_8(&cpld_data->pcba_ver) & 0xf); |
| 450 | printf("PCB: v%x.0\n", val); |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 451 | #elif defined(CONFIG_TARGET_P1010RDB_PB) |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 452 | val = in_8(&cpld_data->cpld_ver); |
| 453 | printf("CPLD: v%x.%x, ", val >> 4, val & 0xf); |
| 454 | printf("PCB: v%x.0, ", i2c_pca9557_read(I2C_READ_PCB_VER)); |
| 455 | val = in_8(&cpld_data->rom_loc) & 0xf; |
| 456 | puts("Boot from: "); |
| 457 | switch (val) { |
| 458 | case 0xf: |
| 459 | config_board_mux(MUX_TYPE_CS0_NOR); |
| 460 | printf("NOR vBank%d\n", i2c_pca9557_read(I2C_READ_BANK)); |
| 461 | break; |
| 462 | case 0xe: |
| 463 | puts("SDHC\n"); |
| 464 | val = 0x60; /* set pca9557 pin input/output */ |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame^] | 465 | #if CONFIG_IS_ENABLED(DM_I2C) |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 466 | dm_i2c_write(dev, 3, &val, 1); |
| 467 | #else |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 468 | i2c_write(I2C_PCA9557_ADDR2, 3, 1, &val, 1); |
Biwen Li | 6a2d8d1 | 2020-05-01 20:04:13 +0800 | [diff] [blame] | 469 | #endif |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 470 | break; |
| 471 | case 0x5: |
| 472 | config_board_mux(MUX_TYPE_IFC); |
| 473 | config_board_mux(MUX_TYPE_CS0_NAND); |
| 474 | puts("NAND\n"); |
| 475 | break; |
| 476 | case 0x6: |
| 477 | config_board_mux(MUX_TYPE_IFC); |
| 478 | puts("SPI\n"); |
| 479 | break; |
| 480 | default: |
| 481 | puts("unknown\n"); |
| 482 | break; |
| 483 | } |
| 484 | #endif |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 485 | return 0; |
| 486 | } |
| 487 | |
Hou Zhiqiang | 7a6855f | 2020-09-21 15:15:04 +0530 | [diff] [blame] | 488 | #ifndef CONFIG_DM_ETH |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 489 | int board_eth_init(struct bd_info *bis) |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 490 | { |
Bin Meng | e52fb1c | 2016-01-11 22:41:16 -0800 | [diff] [blame] | 491 | #ifdef CONFIG_TSEC_ENET |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 492 | struct fsl_pq_mdio_info mdio_info; |
| 493 | struct tsec_info_struct tsec_info[4]; |
| 494 | struct cpu_type *cpu; |
| 495 | int num = 0; |
| 496 | |
Simon Glass | a8b5739 | 2012-12-13 20:48:48 +0000 | [diff] [blame] | 497 | cpu = gd->arch.cpu; |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 498 | |
| 499 | #ifdef CONFIG_TSEC1 |
| 500 | SET_STD_TSEC_INFO(tsec_info[num], 1); |
| 501 | num++; |
| 502 | #endif |
| 503 | #ifdef CONFIG_TSEC2 |
| 504 | SET_STD_TSEC_INFO(tsec_info[num], 2); |
| 505 | num++; |
| 506 | #endif |
| 507 | #ifdef CONFIG_TSEC3 |
| 508 | /* P1014 and it's derivatives do not support eTSEC3 */ |
York Sun | 8cb6548 | 2012-07-06 17:10:33 -0500 | [diff] [blame] | 509 | if (cpu->soc_ver != SVR_P1014) { |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 510 | SET_STD_TSEC_INFO(tsec_info[num], 3); |
| 511 | num++; |
| 512 | } |
| 513 | #endif |
| 514 | if (!num) { |
| 515 | printf("No TSECs initialized\n"); |
| 516 | return 0; |
| 517 | } |
| 518 | |
| 519 | mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR; |
| 520 | mdio_info.name = DEFAULT_MII_NAME; |
| 521 | |
| 522 | fsl_pq_mdio_init(bis, &mdio_info); |
| 523 | |
| 524 | tsec_eth_init(bis, tsec_info, num); |
Bin Meng | e52fb1c | 2016-01-11 22:41:16 -0800 | [diff] [blame] | 525 | #endif |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 526 | |
| 527 | return pci_eth_init(bis); |
| 528 | } |
Hou Zhiqiang | 7a6855f | 2020-09-21 15:15:04 +0530 | [diff] [blame] | 529 | #endif |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 530 | |
| 531 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 532 | void fdt_del_flexcan(void *blob) |
| 533 | { |
| 534 | int nodeoff = 0; |
| 535 | |
| 536 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
Shengzhou Liu | a5b0ded | 2013-03-25 07:30:09 +0000 | [diff] [blame] | 537 | "fsl,p1010-flexcan")) >= 0) { |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 538 | fdt_del_node(blob, nodeoff); |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | void fdt_del_spi_flash(void *blob) |
| 543 | { |
| 544 | int nodeoff = 0; |
| 545 | |
| 546 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
| 547 | "spansion,s25sl12801")) >= 0) { |
| 548 | fdt_del_node(blob, nodeoff); |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | void fdt_del_spi_slic(void *blob) |
| 553 | { |
| 554 | int nodeoff = 0; |
| 555 | |
| 556 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
| 557 | "zarlink,le88266")) >= 0) { |
| 558 | fdt_del_node(blob, nodeoff); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | void fdt_del_tdm(void *blob) |
| 563 | { |
| 564 | int nodeoff = 0; |
| 565 | |
| 566 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
| 567 | "fsl,starlite-tdm")) >= 0) { |
| 568 | fdt_del_node(blob, nodeoff); |
| 569 | } |
| 570 | } |
| 571 | |
Shengzhou Liu | ceb705c | 2012-04-25 23:43:24 +0000 | [diff] [blame] | 572 | void fdt_del_sdhc(void *blob) |
| 573 | { |
| 574 | int nodeoff = 0; |
| 575 | |
| 576 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
| 577 | "fsl,esdhc")) >= 0) { |
| 578 | fdt_del_node(blob, nodeoff); |
| 579 | } |
| 580 | } |
| 581 | |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 582 | void fdt_del_ifc(void *blob) |
| 583 | { |
| 584 | int nodeoff = 0; |
| 585 | |
| 586 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
| 587 | "fsl,ifc")) >= 0) { |
| 588 | fdt_del_node(blob, nodeoff); |
| 589 | } |
| 590 | } |
| 591 | |
Shengzhou Liu | ceb705c | 2012-04-25 23:43:24 +0000 | [diff] [blame] | 592 | void fdt_disable_uart1(void *blob) |
| 593 | { |
| 594 | int nodeoff; |
| 595 | |
| 596 | nodeoff = fdt_node_offset_by_compat_reg(blob, "fsl,ns16550", |
| 597 | CONFIG_SYS_NS16550_COM2); |
| 598 | |
| 599 | if (nodeoff > 0) { |
| 600 | fdt_status_disabled(blob, nodeoff); |
| 601 | } else { |
| 602 | printf("WARNING unable to set status for fsl,ns16550 " |
| 603 | "uart1: %s\n", fdt_strerror(nodeoff)); |
| 604 | } |
| 605 | } |
| 606 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 607 | int ft_board_setup(void *blob, struct bd_info *bd) |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 608 | { |
| 609 | phys_addr_t base; |
| 610 | phys_size_t size; |
| 611 | struct cpu_type *cpu; |
| 612 | |
Simon Glass | a8b5739 | 2012-12-13 20:48:48 +0000 | [diff] [blame] | 613 | cpu = gd->arch.cpu; |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 614 | |
| 615 | ft_cpu_setup(blob, bd); |
| 616 | |
Simon Glass | da1a134 | 2017-08-03 12:22:15 -0600 | [diff] [blame] | 617 | base = env_get_bootm_low(); |
| 618 | size = env_get_bootm_size(); |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 619 | |
Hou Zhiqiang | 0e49eb4 | 2020-05-01 19:06:27 +0800 | [diff] [blame] | 620 | #if defined(CONFIG_PCI) && !defined(CONFIG_DM_PCI) |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 621 | FT_FSL_PCI_SETUP; |
| 622 | #endif |
| 623 | |
| 624 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 625 | |
Ramneek Mehresh | 59c48b4 | 2011-11-08 10:21:28 +0530 | [diff] [blame] | 626 | #if defined(CONFIG_HAS_FSL_DR_USB) |
Sriram Dash | 9fd465c | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 627 | fsl_fdt_fixup_dr_usb(blob, bd); |
Ramneek Mehresh | 59c48b4 | 2011-11-08 10:21:28 +0530 | [diff] [blame] | 628 | #endif |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 629 | |
| 630 | /* P1014 and it's derivatives don't support CAN and eTSEC3 */ |
York Sun | 8cb6548 | 2012-07-06 17:10:33 -0500 | [diff] [blame] | 631 | if (cpu->soc_ver == SVR_P1014) { |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 632 | fdt_del_flexcan(blob); |
| 633 | fdt_del_node_and_alias(blob, "ethernet2"); |
| 634 | } |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 635 | |
| 636 | /* Delete IFC node as IFC pins are multiplexing with SDHC */ |
| 637 | if (sd_ifc_mux != MUX_TYPE_IFC) |
| 638 | fdt_del_ifc(blob); |
| 639 | else |
| 640 | fdt_del_sdhc(blob); |
| 641 | |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 642 | if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "can")) { |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 643 | fdt_del_tdm(blob); |
| 644 | fdt_del_spi_slic(blob); |
Shengzhou Liu | ceb705c | 2012-04-25 23:43:24 +0000 | [diff] [blame] | 645 | } else if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "tdm")) { |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 646 | fdt_del_flexcan(blob); |
| 647 | fdt_del_spi_flash(blob); |
Shengzhou Liu | ceb705c | 2012-04-25 23:43:24 +0000 | [diff] [blame] | 648 | fdt_disable_uart1(blob); |
| 649 | } else { |
| 650 | /* |
| 651 | * If we don't set fsl_p1010mux:tdm_can to "can" or "tdm" |
| 652 | * explicitly, defaultly spi_cs_sel to spi-flash instead of |
| 653 | * to tdm/slic. |
| 654 | */ |
| 655 | fdt_del_tdm(blob); |
| 656 | fdt_del_flexcan(blob); |
| 657 | fdt_disable_uart1(blob); |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 658 | } |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 659 | |
| 660 | return 0; |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 661 | } |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 662 | #endif |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 663 | |
| 664 | #ifdef CONFIG_SDCARD |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 665 | int board_mmc_init(struct bd_info *bis) |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 666 | { |
| 667 | config_board_mux(MUX_TYPE_SDHC); |
| 668 | return -1; |
| 669 | } |
| 670 | #else |
| 671 | void board_reset(void) |
| 672 | { |
| 673 | /* mux to IFC to enable CPLD for reset */ |
| 674 | if (sd_ifc_mux != MUX_TYPE_IFC) |
| 675 | config_board_mux(MUX_TYPE_IFC); |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 676 | } |
| 677 | #endif |
| 678 | |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 679 | |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 680 | int misc_init_r(void) |
| 681 | { |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 682 | ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 683 | |
| 684 | if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "can")) { |
| 685 | clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN1_TDM | |
| 686 | MPC85xx_PMUXCR_CAN1_UART | |
| 687 | MPC85xx_PMUXCR_CAN2_TDM | |
| 688 | MPC85xx_PMUXCR_CAN2_UART); |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 689 | config_board_mux(MUX_TYPE_CAN); |
Shengzhou Liu | ceb705c | 2012-04-25 23:43:24 +0000 | [diff] [blame] | 690 | } else if (hwconfig_subarg_cmp("fsl_p1010mux", "tdm_can", "tdm")) { |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 691 | clrbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN2_UART | |
| 692 | MPC85xx_PMUXCR_CAN1_UART); |
| 693 | setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_CAN2_TDM | |
| 694 | MPC85xx_PMUXCR_CAN1_TDM); |
| 695 | clrbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_GPIO); |
| 696 | setbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_UART_TDM); |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 697 | config_board_mux(MUX_TYPE_TDM); |
Shengzhou Liu | ceb705c | 2012-04-25 23:43:24 +0000 | [diff] [blame] | 698 | } else { |
| 699 | /* defaultly spi_cs_sel to flash */ |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 700 | config_board_mux(MUX_TYPE_SPIFLASH); |
Shengzhou Liu | ceb705c | 2012-04-25 23:43:24 +0000 | [diff] [blame] | 701 | } |
| 702 | |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 703 | if (hwconfig("esdhc")) |
| 704 | config_board_mux(MUX_TYPE_SDHC); |
| 705 | else if (hwconfig("ifc")) |
| 706 | config_board_mux(MUX_TYPE_IFC); |
| 707 | |
York Sun | 7f945ca | 2016-11-16 13:30:06 -0800 | [diff] [blame] | 708 | #ifdef CONFIG_TARGET_P1010RDB_PB |
Shengzhou Liu | f0af438 | 2013-09-13 14:46:03 +0800 | [diff] [blame] | 709 | setbits_be32(&gur->pmuxcr2, MPC85xx_PMUXCR2_GPIO01_DRVVBUS); |
| 710 | #endif |
Poonam Aggrwal | a2ec135 | 2011-02-09 19:17:53 +0000 | [diff] [blame] | 711 | return 0; |
| 712 | } |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 713 | |
Tom Rini | 9774e32 | 2018-01-03 09:13:04 -0500 | [diff] [blame] | 714 | #ifndef CONFIG_SPL_BUILD |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 715 | static int pin_mux_cmd(struct cmd_tbl *cmdtp, int flag, int argc, |
| 716 | char *const argv[]) |
Shengzhou Liu | 36446ef | 2013-09-13 14:46:02 +0800 | [diff] [blame] | 717 | { |
| 718 | if (argc < 2) |
| 719 | return CMD_RET_USAGE; |
| 720 | if (strcmp(argv[1], "ifc") == 0) |
| 721 | config_board_mux(MUX_TYPE_IFC); |
| 722 | else if (strcmp(argv[1], "sdhc") == 0) |
| 723 | config_board_mux(MUX_TYPE_SDHC); |
| 724 | else |
| 725 | return CMD_RET_USAGE; |
| 726 | return 0; |
| 727 | } |
| 728 | |
| 729 | U_BOOT_CMD( |
| 730 | mux, 2, 0, pin_mux_cmd, |
| 731 | "configure multiplexing pin for IFC/SDHC bus in runtime", |
| 732 | "bus_type (e.g. mux sdhc)" |
| 733 | ); |
Tom Rini | 9774e32 | 2018-01-03 09:13:04 -0500 | [diff] [blame] | 734 | #endif |