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