Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2014 Freescale Semiconductor, Inc. |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 4 | * Copyright 2020 NXP |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 9 | #include <env.h> |
Simon Glass | 3bbe70c | 2019-12-28 10:44:54 -0700 | [diff] [blame] | 10 | #include <fdt_support.h> |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 11 | #include <i2c.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 12 | #include <image.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 13 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 14 | #include <log.h> |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 15 | #include <netdev.h> |
| 16 | #include <linux/compiler.h> |
| 17 | #include <asm/mmu.h> |
| 18 | #include <asm/processor.h> |
| 19 | #include <asm/cache.h> |
| 20 | #include <asm/immap_85xx.h> |
| 21 | #include <asm/fsl_law.h> |
| 22 | #include <asm/fsl_serdes.h> |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 23 | #include <asm/fsl_liodn.h> |
| 24 | #include <fm_eth.h> |
| 25 | #include <hwconfig.h> |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 26 | #include "../common/qixis.h" |
| 27 | #include "t102xqds.h" |
| 28 | #include "t102xqds_qixis.h" |
tang yuantian | bcf0465 | 2014-12-18 09:55:07 +0800 | [diff] [blame] | 29 | #include "../common/sleep.h" |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 30 | |
| 31 | DECLARE_GLOBAL_DATA_PTR; |
| 32 | |
| 33 | int checkboard(void) |
| 34 | { |
| 35 | char buf[64]; |
| 36 | struct cpu_type *cpu = gd->arch.cpu; |
| 37 | static const char *const freq[] = {"100", "125", "156.25", "100.0"}; |
| 38 | int clock; |
| 39 | u8 sw = QIXIS_READ(arch); |
| 40 | |
| 41 | printf("Board: %sQDS, ", cpu->name); |
| 42 | printf("Sys ID: 0x%02x, Board Arch: V%d, ", QIXIS_READ(id), sw >> 4); |
| 43 | printf("Board Version: %c, boot from ", (sw & 0xf) + 'A' - 1); |
| 44 | |
| 45 | #ifdef CONFIG_SDCARD |
| 46 | puts("SD/MMC\n"); |
| 47 | #elif CONFIG_SPIFLASH |
| 48 | puts("SPI\n"); |
| 49 | #else |
| 50 | sw = QIXIS_READ(brdcfg[0]); |
| 51 | sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; |
| 52 | |
| 53 | if (sw < 0x8) |
| 54 | printf("vBank: %d\n", sw); |
| 55 | else if (sw == 0x8) |
| 56 | puts("PromJet\n"); |
| 57 | else if (sw == 0x9) |
| 58 | puts("NAND\n"); |
| 59 | else if (sw == 0x15) |
| 60 | printf("IFC Card\n"); |
| 61 | else |
| 62 | printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); |
| 63 | #endif |
| 64 | |
| 65 | printf("FPGA: v%d (%s), build %d", |
| 66 | (int)QIXIS_READ(scver), qixis_read_tag(buf), |
| 67 | (int)qixis_read_minor()); |
| 68 | /* the timestamp string contains "\n" at the end */ |
| 69 | printf(" on %s", qixis_read_time(buf)); |
| 70 | |
| 71 | puts("SERDES Reference: "); |
| 72 | sw = QIXIS_READ(brdcfg[2]); |
| 73 | clock = (sw >> 6) & 3; |
| 74 | printf("Clock1=%sMHz ", freq[clock]); |
| 75 | clock = (sw >> 4) & 3; |
| 76 | printf("Clock2=%sMHz\n", freq[clock]); |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 81 | int select_i2c_ch_pca9547(u8 ch, int bus_num) |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 82 | { |
| 83 | int ret; |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 84 | #ifdef CONFIG_DM_I2C |
| 85 | struct udevice *dev; |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 86 | |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 87 | ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI, |
| 88 | 1, &dev); |
| 89 | if (ret) { |
| 90 | printf("%s: Cannot find udev for a bus %d\n", __func__, |
| 91 | bus_num); |
| 92 | return ret; |
| 93 | } |
| 94 | |
| 95 | ret = dm_i2c_write(dev, 0, &ch, 1); |
| 96 | #else |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 97 | ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1); |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 98 | #endif |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 99 | if (ret) { |
| 100 | puts("PCA: failed to select proper channel\n"); |
| 101 | return ret; |
| 102 | } |
| 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | static int board_mux_lane_to_slot(void) |
| 108 | { |
| 109 | ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 110 | u32 srds_prtcl_s1; |
| 111 | u8 brdcfg9; |
| 112 | |
| 113 | srds_prtcl_s1 = in_be32(&gur->rcwsr[4]) & |
| 114 | FSL_CORENET2_RCWSR4_SRDS1_PRTCL; |
| 115 | srds_prtcl_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT; |
| 116 | |
| 117 | |
| 118 | brdcfg9 = QIXIS_READ(brdcfg[9]); |
| 119 | QIXIS_WRITE(brdcfg[9], brdcfg9 | BRDCFG9_XFI_TX_DISABLE); |
| 120 | |
| 121 | switch (srds_prtcl_s1) { |
| 122 | case 0: |
| 123 | /* SerDes1 is not enabled */ |
| 124 | break; |
| 125 | case 0xd5: |
| 126 | case 0x5b: |
| 127 | case 0x6b: |
| 128 | case 0x77: |
| 129 | case 0x6f: |
| 130 | case 0x7f: |
| 131 | QIXIS_WRITE(brdcfg[12], 0x8c); |
| 132 | break; |
| 133 | case 0x40: |
| 134 | QIXIS_WRITE(brdcfg[12], 0xfc); |
| 135 | break; |
| 136 | case 0xd6: |
| 137 | case 0x5a: |
| 138 | case 0x6a: |
| 139 | case 0x56: |
| 140 | QIXIS_WRITE(brdcfg[12], 0x88); |
| 141 | break; |
| 142 | case 0x47: |
| 143 | QIXIS_WRITE(brdcfg[12], 0xcc); |
| 144 | break; |
| 145 | case 0x46: |
| 146 | QIXIS_WRITE(brdcfg[12], 0xc8); |
| 147 | break; |
| 148 | case 0x95: |
| 149 | case 0x99: |
| 150 | brdcfg9 &= ~BRDCFG9_XFI_TX_DISABLE; |
| 151 | QIXIS_WRITE(brdcfg[9], brdcfg9); |
| 152 | QIXIS_WRITE(brdcfg[12], 0x8c); |
| 153 | break; |
| 154 | case 0x116: |
| 155 | QIXIS_WRITE(brdcfg[12], 0x00); |
| 156 | break; |
| 157 | case 0x115: |
| 158 | case 0x119: |
| 159 | case 0x129: |
| 160 | case 0x12b: |
| 161 | /* Aurora, PCIe, SGMII, SATA */ |
| 162 | QIXIS_WRITE(brdcfg[12], 0x04); |
| 163 | break; |
| 164 | default: |
| 165 | printf("WARNING: unsupported for SerDes Protocol %d\n", |
| 166 | srds_prtcl_s1); |
| 167 | return -1; |
| 168 | } |
| 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
York Sun | 7d29dd6 | 2016-11-18 13:01:34 -0800 | [diff] [blame] | 173 | #ifdef CONFIG_ARCH_T1024 |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 174 | static void board_mux_setup(void) |
| 175 | { |
| 176 | u8 brdcfg15; |
| 177 | |
| 178 | brdcfg15 = QIXIS_READ(brdcfg[15]); |
| 179 | brdcfg15 &= ~BRDCFG15_DIUSEL_MASK; |
| 180 | |
| 181 | if (hwconfig_arg_cmp("pin_mux", "tdm")) { |
| 182 | /* Route QE_TDM multiplexed signals to TDM Riser slot */ |
| 183 | QIXIS_WRITE(brdcfg[15], brdcfg15 | BRDCFG15_DIUSEL_TDM); |
| 184 | QIXIS_WRITE(brdcfg[13], BRDCFG13_TDM_INTERFACE << 2); |
Shengzhou Liu | 57430ee | 2014-11-24 17:11:58 +0800 | [diff] [blame] | 185 | QIXIS_WRITE(brdcfg[5], (QIXIS_READ(brdcfg[5]) & |
| 186 | ~BRDCFG5_SPIRTE_MASK) | BRDCFG5_SPIRTE_TDM); |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 187 | } else if (hwconfig_arg_cmp("pin_mux", "ucc")) { |
| 188 | /* to UCC (ProfiBus) interface */ |
| 189 | QIXIS_WRITE(brdcfg[15], brdcfg15 | BRDCFG15_DIUSEL_UCC); |
| 190 | } else if (hwconfig_arg_cmp("pin_mux", "hdmi")) { |
| 191 | /* to DVI (HDMI) encoder */ |
| 192 | QIXIS_WRITE(brdcfg[15], brdcfg15 | BRDCFG15_DIUSEL_HDMI); |
| 193 | } else if (hwconfig_arg_cmp("pin_mux", "lcd")) { |
| 194 | /* to DFP (LCD) encoder */ |
| 195 | QIXIS_WRITE(brdcfg[15], brdcfg15 | BRDCFG15_LCDFM | |
| 196 | BRDCFG15_LCDPD | BRDCFG15_DIUSEL_LCD); |
| 197 | } |
Shengzhou Liu | 57430ee | 2014-11-24 17:11:58 +0800 | [diff] [blame] | 198 | |
| 199 | if (hwconfig_arg_cmp("adaptor", "sdxc")) |
| 200 | /* Route SPI_CS multiplexed signals to SD slot */ |
| 201 | QIXIS_WRITE(brdcfg[5], (QIXIS_READ(brdcfg[5]) & |
| 202 | ~BRDCFG5_SPIRTE_MASK) | BRDCFG5_SPIRTE_SDHC); |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 203 | } |
| 204 | #endif |
| 205 | |
Shengzhou Liu | f847bcc | 2014-11-24 17:18:28 +0800 | [diff] [blame] | 206 | void board_retimer_ds125df111_init(void) |
| 207 | { |
| 208 | u8 reg; |
| 209 | |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 210 | #ifdef CONFIG_DM_I2C |
| 211 | struct udevice *dev; |
| 212 | int ret, bus_num = 0; |
| 213 | |
| 214 | ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_PRI, |
| 215 | 1, &dev); |
| 216 | if (ret) |
| 217 | goto failed; |
| 218 | |
Shengzhou Liu | f847bcc | 2014-11-24 17:18:28 +0800 | [diff] [blame] | 219 | /* Retimer DS125DF111 is connected to I2C1_CH7_CH5 */ |
| 220 | reg = I2C_MUX_CH7; |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 221 | dm_i2c_write(dev, 0, ®, 1); |
| 222 | |
| 223 | ret = i2c_get_chip_for_busnum(bus_num, I2C_MUX_PCA_ADDR_SEC, |
| 224 | 1, &dev); |
| 225 | if (ret) |
| 226 | goto failed; |
| 227 | |
| 228 | reg = I2C_MUX_CH5; |
| 229 | dm_i2c_write(dev, 0, ®, 1); |
| 230 | |
| 231 | /* Access to Control/Shared register */ |
| 232 | ret = i2c_get_chip_for_busnum(bus_num, I2C_RETIMER_ADDR, |
| 233 | 1, &dev); |
| 234 | if (ret) |
| 235 | goto failed; |
| 236 | reg = 0x0; |
| 237 | dm_i2c_write(dev, 0xff, ®, 1); |
| 238 | |
| 239 | /* Read device revision and ID */ |
| 240 | dm_i2c_read(dev, 1, ®, 1); |
| 241 | debug("Retimer version id = 0x%x\n", reg); |
| 242 | |
| 243 | /* Enable Broadcast */ |
| 244 | reg = 0x0c; |
| 245 | dm_i2c_write(dev, 0xff, ®, 1); |
| 246 | |
| 247 | /* Reset Channel Registers */ |
| 248 | dm_i2c_read(dev, 0, ®, 1); |
| 249 | reg |= 0x4; |
| 250 | dm_i2c_write(dev, 0, ®, 1); |
| 251 | |
| 252 | /* Enable override divider select and Enable Override Output Mux */ |
| 253 | dm_i2c_read(dev, 9, ®, 1); |
| 254 | reg |= 0x24; |
| 255 | dm_i2c_write(dev, 9, ®, 1); |
| 256 | |
| 257 | /* Select VCO Divider to full rate (000) */ |
| 258 | dm_i2c_read(dev, 0x18, ®, 1); |
| 259 | reg &= 0x8f; |
| 260 | dm_i2c_write(dev, 0x18, ®, 1); |
| 261 | |
| 262 | /* Select active PFD MUX input as re-timed data (001) */ |
| 263 | dm_i2c_read(dev, 0x1e, ®, 1); |
| 264 | reg &= 0x3f; |
| 265 | reg |= 0x20; |
| 266 | dm_i2c_write(dev, 0x1e, ®, 1); |
| 267 | |
| 268 | /* Set data rate as 10.3125 Gbps */ |
| 269 | reg = 0x0; |
| 270 | dm_i2c_write(dev, 0x60, ®, 1); |
| 271 | reg = 0xb2; |
| 272 | dm_i2c_write(dev, 0x61, ®, 1); |
| 273 | reg = 0x90; |
| 274 | dm_i2c_write(dev, 0x62, ®, 1); |
| 275 | reg = 0xb3; |
| 276 | dm_i2c_write(dev, 0x63, ®, 1); |
| 277 | reg = 0xcd; |
| 278 | dm_i2c_write(dev, 0x64, ®, 1); |
| 279 | return; |
| 280 | |
| 281 | failed: |
| 282 | printf("%s: Cannot find udev for a bus %d\n", __func__, |
| 283 | bus_num); |
| 284 | return; |
| 285 | #else |
| 286 | /* Retimer DS125DF111 is connected to I2C1_CH7_CH5 */ |
| 287 | reg = I2C_MUX_CH7; |
Shengzhou Liu | f847bcc | 2014-11-24 17:18:28 +0800 | [diff] [blame] | 288 | i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, ®, 1); |
| 289 | reg = I2C_MUX_CH5; |
| 290 | i2c_write(I2C_MUX_PCA_ADDR_SEC, 0, 1, ®, 1); |
| 291 | |
| 292 | /* Access to Control/Shared register */ |
| 293 | reg = 0x0; |
| 294 | i2c_write(I2C_RETIMER_ADDR, 0xff, 1, ®, 1); |
| 295 | |
| 296 | /* Read device revision and ID */ |
| 297 | i2c_read(I2C_RETIMER_ADDR, 1, 1, ®, 1); |
| 298 | debug("Retimer version id = 0x%x\n", reg); |
| 299 | |
| 300 | /* Enable Broadcast */ |
| 301 | reg = 0x0c; |
| 302 | i2c_write(I2C_RETIMER_ADDR, 0xff, 1, ®, 1); |
| 303 | |
| 304 | /* Reset Channel Registers */ |
| 305 | i2c_read(I2C_RETIMER_ADDR, 0, 1, ®, 1); |
| 306 | reg |= 0x4; |
| 307 | i2c_write(I2C_RETIMER_ADDR, 0, 1, ®, 1); |
| 308 | |
| 309 | /* Enable override divider select and Enable Override Output Mux */ |
| 310 | i2c_read(I2C_RETIMER_ADDR, 9, 1, ®, 1); |
| 311 | reg |= 0x24; |
| 312 | i2c_write(I2C_RETIMER_ADDR, 9, 1, ®, 1); |
| 313 | |
| 314 | /* Select VCO Divider to full rate (000) */ |
| 315 | i2c_read(I2C_RETIMER_ADDR, 0x18, 1, ®, 1); |
| 316 | reg &= 0x8f; |
| 317 | i2c_write(I2C_RETIMER_ADDR, 0x18, 1, ®, 1); |
| 318 | |
| 319 | /* Select active PFD MUX input as re-timed data (001) */ |
| 320 | i2c_read(I2C_RETIMER_ADDR, 0x1e, 1, ®, 1); |
| 321 | reg &= 0x3f; |
| 322 | reg |= 0x20; |
| 323 | i2c_write(I2C_RETIMER_ADDR, 0x1e, 1, ®, 1); |
| 324 | |
| 325 | /* Set data rate as 10.3125 Gbps */ |
| 326 | reg = 0x0; |
| 327 | i2c_write(I2C_RETIMER_ADDR, 0x60, 1, ®, 1); |
| 328 | reg = 0xb2; |
| 329 | i2c_write(I2C_RETIMER_ADDR, 0x61, 1, ®, 1); |
| 330 | reg = 0x90; |
| 331 | i2c_write(I2C_RETIMER_ADDR, 0x62, 1, ®, 1); |
| 332 | reg = 0xb3; |
| 333 | i2c_write(I2C_RETIMER_ADDR, 0x63, 1, ®, 1); |
| 334 | reg = 0xcd; |
| 335 | i2c_write(I2C_RETIMER_ADDR, 0x64, 1, ®, 1); |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 336 | #endif |
Shengzhou Liu | f847bcc | 2014-11-24 17:18:28 +0800 | [diff] [blame] | 337 | } |
| 338 | |
tang yuantian | bcf0465 | 2014-12-18 09:55:07 +0800 | [diff] [blame] | 339 | int board_early_init_f(void) |
| 340 | { |
| 341 | #if defined(CONFIG_DEEP_SLEEP) |
| 342 | if (is_warm_boot()) |
| 343 | fsl_dp_disable_console(); |
| 344 | #endif |
| 345 | |
| 346 | return 0; |
| 347 | } |
| 348 | |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 349 | int board_early_init_r(void) |
| 350 | { |
| 351 | #ifdef CONFIG_SYS_FLASH_BASE |
| 352 | const unsigned int flashbase = CONFIG_SYS_FLASH_BASE; |
| 353 | int flash_esel = find_tlb_idx((void *)flashbase, 1); |
| 354 | |
| 355 | /* |
| 356 | * Remap Boot flash + PROMJET region to caching-inhibited |
| 357 | * so that flash can be erased properly. |
| 358 | */ |
| 359 | |
| 360 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 361 | flush_dcache(); |
| 362 | invalidate_icache(); |
| 363 | |
| 364 | if (flash_esel == -1) { |
| 365 | /* very unlikely unless something is messed up */ |
| 366 | puts("Error: Could not find TLB for FLASH BASE\n"); |
| 367 | flash_esel = 2; /* give our best effort to continue */ |
| 368 | } else { |
| 369 | /* invalidate existing TLB entry for flash + promjet */ |
| 370 | disable_tlb(flash_esel); |
| 371 | } |
| 372 | |
| 373 | set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, |
| 374 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 375 | 0, flash_esel, BOOKE_PAGESZ_256M, 1); |
| 376 | #endif |
Biwen Li | 6b63c54 | 2020-05-01 20:04:11 +0800 | [diff] [blame] | 377 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0); |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 378 | board_mux_lane_to_slot(); |
Shengzhou Liu | f847bcc | 2014-11-24 17:18:28 +0800 | [diff] [blame] | 379 | board_retimer_ds125df111_init(); |
Shengzhou Liu | be51cbd | 2014-11-24 17:12:00 +0800 | [diff] [blame] | 380 | |
| 381 | /* Increase IO drive strength to address FCS error on RGMII */ |
| 382 | out_be32((unsigned *)CONFIG_SYS_FSL_SCFG_IODSECR1_ADDR, 0xbfdb7800); |
| 383 | |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 384 | return 0; |
| 385 | } |
| 386 | |
| 387 | unsigned long get_board_sys_clk(void) |
| 388 | { |
| 389 | u8 sysclk_conf = QIXIS_READ(brdcfg[1]); |
| 390 | |
| 391 | switch (sysclk_conf & 0x0F) { |
| 392 | case QIXIS_SYSCLK_64: |
| 393 | return 64000000; |
| 394 | case QIXIS_SYSCLK_83: |
| 395 | return 83333333; |
| 396 | case QIXIS_SYSCLK_100: |
| 397 | return 100000000; |
| 398 | case QIXIS_SYSCLK_125: |
| 399 | return 125000000; |
| 400 | case QIXIS_SYSCLK_133: |
| 401 | return 133333333; |
| 402 | case QIXIS_SYSCLK_150: |
| 403 | return 150000000; |
| 404 | case QIXIS_SYSCLK_160: |
| 405 | return 160000000; |
| 406 | case QIXIS_SYSCLK_166: |
| 407 | return 166666666; |
| 408 | } |
| 409 | return 66666666; |
| 410 | } |
| 411 | |
| 412 | unsigned long get_board_ddr_clk(void) |
| 413 | { |
| 414 | u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); |
| 415 | |
| 416 | switch ((ddrclk_conf & 0x30) >> 4) { |
| 417 | case QIXIS_DDRCLK_100: |
| 418 | return 100000000; |
| 419 | case QIXIS_DDRCLK_125: |
| 420 | return 125000000; |
| 421 | case QIXIS_DDRCLK_133: |
| 422 | return 133333333; |
| 423 | } |
| 424 | return 66666666; |
| 425 | } |
| 426 | |
| 427 | #define NUM_SRDS_PLL 2 |
| 428 | int misc_init_r(void) |
| 429 | { |
York Sun | 7d29dd6 | 2016-11-18 13:01:34 -0800 | [diff] [blame] | 430 | #ifdef CONFIG_ARCH_T1024 |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 431 | board_mux_setup(); |
| 432 | #endif |
| 433 | return 0; |
| 434 | } |
| 435 | |
Shengzhou Liu | 57430ee | 2014-11-24 17:11:58 +0800 | [diff] [blame] | 436 | void fdt_fixup_spi_mux(void *blob) |
| 437 | { |
| 438 | int nodeoff = 0; |
| 439 | |
| 440 | if (hwconfig_arg_cmp("pin_mux", "tdm")) { |
| 441 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
| 442 | "eon,en25s64")) >= 0) { |
| 443 | fdt_del_node(blob, nodeoff); |
| 444 | } |
| 445 | } else { |
| 446 | /* remove tdm node */ |
| 447 | while ((nodeoff = fdt_node_offset_by_compatible(blob, 0, |
| 448 | "maxim,ds26522")) >= 0) { |
| 449 | fdt_del_node(blob, nodeoff); |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 454 | int ft_board_setup(void *blob, bd_t *bd) |
| 455 | { |
| 456 | phys_addr_t base; |
| 457 | phys_size_t size; |
| 458 | |
| 459 | ft_cpu_setup(blob, bd); |
| 460 | |
Simon Glass | da1a134 | 2017-08-03 12:22:15 -0600 | [diff] [blame] | 461 | base = env_get_bootm_low(); |
| 462 | size = env_get_bootm_size(); |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 463 | |
| 464 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 465 | |
| 466 | #ifdef CONFIG_PCI |
| 467 | pci_of_setup(blob, bd); |
| 468 | #endif |
| 469 | |
| 470 | fdt_fixup_liodn(blob); |
| 471 | |
| 472 | #ifdef CONFIG_HAS_FSL_DR_USB |
Sriram Dash | 9fd465c | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 473 | fsl_fdt_fixup_dr_usb(blob, bd); |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 474 | #endif |
| 475 | |
| 476 | #ifdef CONFIG_SYS_DPAA_FMAN |
Madalin Bucur | 7084851 | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 477 | #ifndef CONFIG_DM_ETH |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 478 | fdt_fixup_fman_ethernet(blob); |
Madalin Bucur | 7084851 | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 479 | #endif |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 480 | fdt_fixup_board_enet(blob); |
| 481 | #endif |
Shengzhou Liu | 57430ee | 2014-11-24 17:11:58 +0800 | [diff] [blame] | 482 | fdt_fixup_spi_mux(blob); |
Shengzhou Liu | 9eca55f | 2014-11-24 17:11:55 +0800 | [diff] [blame] | 483 | |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | void qixis_dump_switch(void) |
| 488 | { |
| 489 | int i, nr_of_cfgsw; |
| 490 | |
| 491 | QIXIS_WRITE(cms[0], 0x00); |
| 492 | nr_of_cfgsw = QIXIS_READ(cms[1]); |
| 493 | |
| 494 | puts("DIP switch settings dump:\n"); |
| 495 | for (i = 1; i <= nr_of_cfgsw; i++) { |
| 496 | QIXIS_WRITE(cms[0], i); |
| 497 | printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1])); |
| 498 | } |
| 499 | } |