Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2009-2013 Freescale Semiconductor, Inc. |
Biwen Li | 07b3dcf | 2020-05-01 20:04:19 +0800 | [diff] [blame] | 4 | * Copyright 2020 NXP |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +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 | 0788694 | 2013-11-22 17:39:11 +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 | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 15 | #include <netdev.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 16 | #include <asm/global_data.h> |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 17 | #include <linux/compiler.h> |
| 18 | #include <asm/mmu.h> |
| 19 | #include <asm/processor.h> |
| 20 | #include <asm/immap_85xx.h> |
| 21 | #include <asm/fsl_law.h> |
| 22 | #include <asm/fsl_serdes.h> |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 23 | #include <asm/fsl_liodn.h> |
| 24 | #include <fm_eth.h> |
Stephen Carlson | 9107ef6 | 2021-06-22 16:43:48 -0700 | [diff] [blame] | 25 | #include "../common/i2c_mux.h" |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 26 | |
| 27 | #include "../common/qixis.h" |
| 28 | #include "../common/vsc3316_3308.h" |
Ying Zhang | 8876a51 | 2014-10-31 18:06:18 +0800 | [diff] [blame] | 29 | #include "../common/vid.h" |
Shengzhou Liu | 031228a | 2014-02-21 13:16:19 +0800 | [diff] [blame] | 30 | #include "t208xqds.h" |
| 31 | #include "t208xqds_qixis.h" |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
| 35 | int checkboard(void) |
| 36 | { |
| 37 | char buf[64]; |
| 38 | u8 sw; |
| 39 | struct cpu_type *cpu = gd->arch.cpu; |
| 40 | static const char *freq[4] = { |
| 41 | "100.00MHZ(from 8T49N222A)", "125.00MHz", |
| 42 | "156.25MHZ", "100.00MHz" |
| 43 | }; |
| 44 | |
| 45 | printf("Board: %sQDS, ", cpu->name); |
| 46 | sw = QIXIS_READ(arch); |
| 47 | printf("Sys ID: 0x%02x, Board Arch: V%d, ", QIXIS_READ(id), sw >> 4); |
| 48 | printf("Board Version: %c, boot from ", (sw & 0xf) + 'A' - 1); |
| 49 | |
Shengzhou Liu | 7fcbd1f | 2014-01-03 14:48:44 +0800 | [diff] [blame] | 50 | #ifdef CONFIG_SDCARD |
| 51 | puts("SD/MMC\n"); |
| 52 | #elif CONFIG_SPIFLASH |
| 53 | puts("SPI\n"); |
| 54 | #else |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 55 | sw = QIXIS_READ(brdcfg[0]); |
| 56 | sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; |
| 57 | |
| 58 | if (sw < 0x8) |
| 59 | printf("vBank%d\n", sw); |
| 60 | else if (sw == 0x8) |
| 61 | puts("Promjet\n"); |
| 62 | else if (sw == 0x9) |
| 63 | puts("NAND\n"); |
| 64 | else |
| 65 | printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); |
Shengzhou Liu | 7fcbd1f | 2014-01-03 14:48:44 +0800 | [diff] [blame] | 66 | #endif |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 67 | |
| 68 | printf("FPGA: v%d (%s), build %d", (int)QIXIS_READ(scver), |
| 69 | qixis_read_tag(buf), (int)qixis_read_minor()); |
| 70 | /* the timestamp string contains "\n" at the end */ |
| 71 | printf(" on %s", qixis_read_time(buf)); |
| 72 | |
| 73 | puts("SERDES Reference Clocks:\n"); |
| 74 | sw = QIXIS_READ(brdcfg[2]); |
| 75 | printf("SD1_CLK1=%s, SD1_CLK2=%s\n", freq[sw >> 6], |
| 76 | freq[(sw >> 4) & 0x3]); |
| 77 | printf("SD2_CLK1=%s, SD2_CLK2=%s\n", freq[(sw & 0xf) >> 2], |
| 78 | freq[sw & 0x3]); |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
Ying Zhang | 8876a51 | 2014-10-31 18:06:18 +0800 | [diff] [blame] | 83 | int i2c_multiplexer_select_vid_channel(u8 channel) |
| 84 | { |
Biwen Li | 07b3dcf | 2020-05-01 20:04:19 +0800 | [diff] [blame] | 85 | return select_i2c_ch_pca9547(channel, 0); |
Ying Zhang | 8876a51 | 2014-10-31 18:06:18 +0800 | [diff] [blame] | 86 | } |
| 87 | |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 88 | int brd_mux_lane_to_slot(void) |
| 89 | { |
| 90 | ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Shengzhou Liu | 031228a | 2014-02-21 13:16:19 +0800 | [diff] [blame] | 91 | u32 srds_prtcl_s1; |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 92 | |
| 93 | srds_prtcl_s1 = in_be32(&gur->rcwsr[4]) & |
| 94 | FSL_CORENET2_RCWSR4_SRDS1_PRTCL; |
| 95 | srds_prtcl_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT; |
York Sun | c68b12d | 2016-12-28 08:43:36 -0800 | [diff] [blame] | 96 | #if defined(CONFIG_TARGET_T2080QDS) |
Shengzhou Liu | 031228a | 2014-02-21 13:16:19 +0800 | [diff] [blame] | 97 | u32 srds_prtcl_s2 = in_be32(&gur->rcwsr[4]) & |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 98 | FSL_CORENET2_RCWSR4_SRDS2_PRTCL; |
| 99 | srds_prtcl_s2 >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT; |
Shengzhou Liu | 031228a | 2014-02-21 13:16:19 +0800 | [diff] [blame] | 100 | #endif |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 101 | |
| 102 | switch (srds_prtcl_s1) { |
| 103 | case 0: |
| 104 | /* SerDes1 is not enabled */ |
| 105 | break; |
York Sun | c68b12d | 2016-12-28 08:43:36 -0800 | [diff] [blame] | 106 | #if defined(CONFIG_TARGET_T2080QDS) |
Shengzhou Liu | 03e2dc8 | 2014-05-15 19:24:11 +0800 | [diff] [blame] | 107 | case 0x1b: |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 108 | case 0x1c: |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 109 | case 0xa2: |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 110 | /* SD1(A:D) => SLOT3 SGMII |
| 111 | * SD1(G:H) => SLOT1 SGMII |
| 112 | */ |
Shengzhou Liu | 7fcbd1f | 2014-01-03 14:48:44 +0800 | [diff] [blame] | 113 | QIXIS_WRITE(brdcfg[12], 0x1a); |
| 114 | break; |
| 115 | case 0x94: |
| 116 | case 0x95: |
| 117 | /* SD1(A:B) => SLOT3 SGMII@1.25bps |
| 118 | * SD1(C:D) => SFP Module, SGMII@3.125bps |
| 119 | * SD1(E:H) => SLOT1 SGMII@1.25bps |
| 120 | */ |
| 121 | case 0x96: |
| 122 | /* SD1(A:B) => SLOT3 SGMII@1.25bps |
| 123 | * SD1(C) => SFP Module, SGMII@3.125bps |
| 124 | * SD1(D) => SFP Module, SGMII@1.25bps |
| 125 | * SD1(E:H) => SLOT1 PCIe4 x4 |
| 126 | */ |
| 127 | QIXIS_WRITE(brdcfg[12], 0x3a); |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 128 | break; |
Shengzhou Liu | 03e2dc8 | 2014-05-15 19:24:11 +0800 | [diff] [blame] | 129 | case 0x50: |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 130 | case 0x51: |
| 131 | /* SD1(A:D) => SLOT3 XAUI |
| 132 | * SD1(E) => SLOT1 PCIe4 |
| 133 | * SD1(F:H) => SLOT2 SGMII |
| 134 | */ |
| 135 | QIXIS_WRITE(brdcfg[12], 0x15); |
| 136 | break; |
| 137 | case 0x66: |
| 138 | case 0x67: |
Vladimir Oltean | 6a6e402 | 2021-09-18 15:32:34 +0300 | [diff] [blame] | 139 | /* SD1(A:D) => 10GBase-R cage |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 140 | * SD1(E:H) => SLOT1 PCIe4 |
| 141 | */ |
| 142 | QIXIS_WRITE(brdcfg[12], 0xfe); |
| 143 | break; |
Shengzhou Liu | 03e2dc8 | 2014-05-15 19:24:11 +0800 | [diff] [blame] | 144 | case 0x6a: |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 145 | case 0x6b: |
Vladimir Oltean | 6a6e402 | 2021-09-18 15:32:34 +0300 | [diff] [blame] | 146 | /* SD1(A:D) => 10GBase-R cage |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 147 | * SD1(E) => SLOT1 PCIe4 |
| 148 | * SD1(F:H) => SLOT2 SGMII |
| 149 | */ |
| 150 | QIXIS_WRITE(brdcfg[12], 0xf1); |
| 151 | break; |
| 152 | case 0x6c: |
| 153 | case 0x6d: |
Vladimir Oltean | 6a6e402 | 2021-09-18 15:32:34 +0300 | [diff] [blame] | 154 | /* SD1(A:B) => 10GBase-R cage |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 155 | * SD1(C:D) => SLOT3 SGMII |
| 156 | * SD1(E:H) => SLOT1 PCIe4 |
| 157 | */ |
| 158 | QIXIS_WRITE(brdcfg[12], 0xda); |
| 159 | break; |
Shengzhou Liu | 7fcbd1f | 2014-01-03 14:48:44 +0800 | [diff] [blame] | 160 | case 0x6e: |
Vladimir Oltean | 6a6e402 | 2021-09-18 15:32:34 +0300 | [diff] [blame] | 161 | /* SD1(A:B) => SFP Module, 10GBase-R |
Shengzhou Liu | 7fcbd1f | 2014-01-03 14:48:44 +0800 | [diff] [blame] | 162 | * SD1(C:D) => SLOT3 SGMII |
| 163 | * SD1(E:F) => SLOT1 PCIe4 x2 |
| 164 | * SD1(G:H) => SLOT2 SGMII |
| 165 | */ |
| 166 | QIXIS_WRITE(brdcfg[12], 0xd9); |
| 167 | break; |
| 168 | case 0xda: |
| 169 | /* SD1(A:H) => SLOT3 PCIe3 x8 |
| 170 | */ |
| 171 | QIXIS_WRITE(brdcfg[12], 0x0); |
| 172 | break; |
| 173 | case 0xc8: |
| 174 | /* SD1(A) => SLOT3 PCIe3 x1 |
| 175 | * SD1(B) => SFP Module, SGMII@1.25bps |
| 176 | * SD1(C:D) => SFP Module, SGMII@3.125bps |
| 177 | * SD1(E:F) => SLOT1 PCIe4 x2 |
| 178 | * SD1(G:H) => SLOT2 SGMII |
| 179 | */ |
| 180 | QIXIS_WRITE(brdcfg[12], 0x79); |
| 181 | break; |
| 182 | case 0xab: |
| 183 | /* SD1(A:D) => SLOT3 PCIe3 x4 |
| 184 | * SD1(E:H) => SLOT1 PCIe4 x4 |
| 185 | */ |
| 186 | QIXIS_WRITE(brdcfg[12], 0x1a); |
| 187 | break; |
Shengzhou Liu | 031228a | 2014-02-21 13:16:19 +0800 | [diff] [blame] | 188 | #endif |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 189 | default: |
| 190 | printf("WARNING: unsupported for SerDes1 Protocol %d\n", |
| 191 | srds_prtcl_s1); |
| 192 | return -1; |
| 193 | } |
| 194 | |
York Sun | c68b12d | 2016-12-28 08:43:36 -0800 | [diff] [blame] | 195 | #ifdef CONFIG_TARGET_T2080QDS |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 196 | switch (srds_prtcl_s2) { |
| 197 | case 0: |
| 198 | /* SerDes2 is not enabled */ |
| 199 | break; |
| 200 | case 0x01: |
| 201 | case 0x02: |
| 202 | /* SD2(A:H) => SLOT4 PCIe1 */ |
Shengzhou Liu | 7fcbd1f | 2014-01-03 14:48:44 +0800 | [diff] [blame] | 203 | QIXIS_WRITE(brdcfg[13], 0x10); |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 204 | break; |
| 205 | case 0x15: |
| 206 | case 0x16: |
| 207 | /* |
| 208 | * SD2(A:D) => SLOT4 PCIe1 |
| 209 | * SD2(E:F) => SLOT5 PCIe2 |
| 210 | * SD2(G:H) => SATA1,SATA2 |
| 211 | */ |
| 212 | QIXIS_WRITE(brdcfg[13], 0xb0); |
| 213 | break; |
| 214 | case 0x18: |
| 215 | /* |
| 216 | * SD2(A:D) => SLOT4 PCIe1 |
| 217 | * SD2(E:F) => SLOT5 Aurora |
| 218 | * SD2(G:H) => SATA1,SATA2 |
| 219 | */ |
Shengzhou Liu | 7fcbd1f | 2014-01-03 14:48:44 +0800 | [diff] [blame] | 220 | QIXIS_WRITE(brdcfg[13], 0x78); |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 221 | break; |
| 222 | case 0x1f: |
| 223 | /* |
| 224 | * SD2(A:D) => SLOT4 PCIe1 |
| 225 | * SD2(E:H) => SLOT5 PCIe2 |
| 226 | */ |
| 227 | QIXIS_WRITE(brdcfg[13], 0xa0); |
| 228 | break; |
| 229 | case 0x29: |
| 230 | case 0x2d: |
| 231 | case 0x2e: |
| 232 | /* |
| 233 | * SD2(A:D) => SLOT4 SRIO2 |
| 234 | * SD2(E:H) => SLOT5 SRIO1 |
| 235 | */ |
Shengzhou Liu | 7fcbd1f | 2014-01-03 14:48:44 +0800 | [diff] [blame] | 236 | QIXIS_WRITE(brdcfg[13], 0xa0); |
| 237 | break; |
| 238 | case 0x36: |
| 239 | /* |
| 240 | * SD2(A:D) => SLOT4 SRIO2 |
| 241 | * SD2(E:F) => Aurora |
| 242 | * SD2(G:H) => SATA1,SATA2 |
| 243 | */ |
| 244 | QIXIS_WRITE(brdcfg[13], 0x78); |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 245 | break; |
| 246 | default: |
| 247 | printf("WARNING: unsupported for SerDes2 Protocol %d\n", |
| 248 | srds_prtcl_s2); |
| 249 | return -1; |
| 250 | } |
Shengzhou Liu | 031228a | 2014-02-21 13:16:19 +0800 | [diff] [blame] | 251 | #endif |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 252 | return 0; |
| 253 | } |
| 254 | |
Yangbo Lu | f9049b2 | 2020-06-17 18:08:58 +0800 | [diff] [blame] | 255 | static void esdhc_adapter_card_ident(void) |
| 256 | { |
| 257 | u8 card_id, value; |
| 258 | |
| 259 | card_id = QIXIS_READ(present) & QIXIS_SDID_MASK; |
| 260 | |
| 261 | switch (card_id) { |
| 262 | case QIXIS_ESDHC_ADAPTER_TYPE_EMMC45: |
| 263 | value = QIXIS_READ(brdcfg[5]); |
| 264 | value |= (QIXIS_DAT4 | QIXIS_DAT5_6_7); |
| 265 | QIXIS_WRITE(brdcfg[5], value); |
| 266 | break; |
| 267 | case QIXIS_ESDHC_ADAPTER_TYPE_SDMMC_LEGACY: |
| 268 | value = QIXIS_READ(pwr_ctl[1]); |
| 269 | value |= QIXIS_EVDD_BY_SDHC_VS; |
| 270 | QIXIS_WRITE(pwr_ctl[1], value); |
| 271 | break; |
| 272 | case QIXIS_ESDHC_ADAPTER_TYPE_EMMC44: |
| 273 | value = QIXIS_READ(brdcfg[5]); |
| 274 | value |= (QIXIS_SDCLKIN | QIXIS_SDCLKOUT); |
| 275 | QIXIS_WRITE(brdcfg[5], value); |
| 276 | break; |
| 277 | default: |
| 278 | break; |
| 279 | } |
| 280 | } |
| 281 | |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 282 | int board_early_init_r(void) |
| 283 | { |
| 284 | const unsigned int flashbase = CONFIG_SYS_FLASH_BASE; |
York Sun | 220c346 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 285 | int flash_esel = find_tlb_idx((void *)flashbase, 1); |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 286 | |
| 287 | /* |
| 288 | * Remap Boot flash + PROMJET region to caching-inhibited |
| 289 | * so that flash can be erased properly. |
| 290 | */ |
| 291 | |
| 292 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 293 | flush_dcache(); |
| 294 | invalidate_icache(); |
| 295 | |
York Sun | 220c346 | 2014-06-24 21:16:20 -0700 | [diff] [blame] | 296 | if (flash_esel == -1) { |
| 297 | /* very unlikely unless something is messed up */ |
| 298 | puts("Error: Could not find TLB for FLASH BASE\n"); |
| 299 | flash_esel = 2; /* give our best effort to continue */ |
| 300 | } else { |
| 301 | /* invalidate existing TLB entry for flash + promjet */ |
| 302 | disable_tlb(flash_esel); |
| 303 | } |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 304 | |
| 305 | set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, |
| 306 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 307 | 0, flash_esel, BOOKE_PAGESZ_256M, 1); |
| 308 | |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 309 | /* Disable remote I2C connection to qixis fpga */ |
| 310 | QIXIS_WRITE(brdcfg[5], QIXIS_READ(brdcfg[5]) & ~BRDCFG5_IRE); |
| 311 | |
Ying Zhang | 8876a51 | 2014-10-31 18:06:18 +0800 | [diff] [blame] | 312 | /* |
| 313 | * Adjust core voltage according to voltage ID |
| 314 | * This function changes I2C mux to channel 2. |
| 315 | */ |
| 316 | if (adjust_vdd(0)) |
| 317 | printf("Warning: Adjusting core voltage failed.\n"); |
| 318 | |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 319 | brd_mux_lane_to_slot(); |
Biwen Li | 07b3dcf | 2020-05-01 20:04:19 +0800 | [diff] [blame] | 320 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT, 0); |
Yangbo Lu | f9049b2 | 2020-06-17 18:08:58 +0800 | [diff] [blame] | 321 | esdhc_adapter_card_ident(); |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | unsigned long get_board_sys_clk(void) |
| 326 | { |
| 327 | u8 sysclk_conf = QIXIS_READ(brdcfg[1]); |
| 328 | #ifdef CONFIG_FSL_QIXIS_CLOCK_MEASUREMENT |
| 329 | /* use accurate clock measurement */ |
| 330 | int freq = QIXIS_READ(clk_freq[0]) << 8 | QIXIS_READ(clk_freq[1]); |
| 331 | int base = QIXIS_READ(clk_base[0]) << 8 | QIXIS_READ(clk_base[1]); |
| 332 | u32 val; |
| 333 | |
| 334 | val = freq * base; |
| 335 | if (val) { |
| 336 | debug("SYS Clock measurement is: %d\n", val); |
| 337 | return val; |
| 338 | } else { |
| 339 | printf("Warning: SYS clock measurement is invalid, "); |
| 340 | printf("using value from brdcfg1.\n"); |
| 341 | } |
| 342 | #endif |
| 343 | |
| 344 | switch (sysclk_conf & 0x0F) { |
| 345 | case QIXIS_SYSCLK_83: |
| 346 | return 83333333; |
| 347 | case QIXIS_SYSCLK_100: |
| 348 | return 100000000; |
| 349 | case QIXIS_SYSCLK_125: |
| 350 | return 125000000; |
| 351 | case QIXIS_SYSCLK_133: |
| 352 | return 133333333; |
| 353 | case QIXIS_SYSCLK_150: |
| 354 | return 150000000; |
| 355 | case QIXIS_SYSCLK_160: |
| 356 | return 160000000; |
| 357 | case QIXIS_SYSCLK_166: |
| 358 | return 166666666; |
| 359 | } |
| 360 | return 66666666; |
| 361 | } |
| 362 | |
| 363 | unsigned long get_board_ddr_clk(void) |
| 364 | { |
| 365 | u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); |
| 366 | #ifdef CONFIG_FSL_QIXIS_CLOCK_MEASUREMENT |
| 367 | /* use accurate clock measurement */ |
| 368 | int freq = QIXIS_READ(clk_freq[2]) << 8 | QIXIS_READ(clk_freq[3]); |
| 369 | int base = QIXIS_READ(clk_base[0]) << 8 | QIXIS_READ(clk_base[1]); |
| 370 | u32 val; |
| 371 | |
| 372 | val = freq * base; |
| 373 | if (val) { |
| 374 | debug("DDR Clock measurement is: %d\n", val); |
| 375 | return val; |
| 376 | } else { |
| 377 | printf("Warning: DDR clock measurement is invalid, "); |
| 378 | printf("using value from brdcfg1.\n"); |
| 379 | } |
| 380 | #endif |
| 381 | |
| 382 | switch ((ddrclk_conf & 0x30) >> 4) { |
| 383 | case QIXIS_DDRCLK_100: |
| 384 | return 100000000; |
| 385 | case QIXIS_DDRCLK_125: |
| 386 | return 125000000; |
| 387 | case QIXIS_DDRCLK_133: |
| 388 | return 133333333; |
| 389 | } |
| 390 | return 66666666; |
| 391 | } |
| 392 | |
| 393 | int misc_init_r(void) |
| 394 | { |
| 395 | return 0; |
| 396 | } |
| 397 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 398 | int ft_board_setup(void *blob, struct bd_info *bd) |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 399 | { |
| 400 | phys_addr_t base; |
| 401 | phys_size_t size; |
| 402 | |
| 403 | ft_cpu_setup(blob, bd); |
| 404 | |
Simon Glass | da1a134 | 2017-08-03 12:22:15 -0600 | [diff] [blame] | 405 | base = env_get_bootm_low(); |
| 406 | size = env_get_bootm_size(); |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 407 | |
| 408 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 409 | |
| 410 | #ifdef CONFIG_PCI |
| 411 | pci_of_setup(blob, bd); |
| 412 | #endif |
| 413 | |
| 414 | fdt_fixup_liodn(blob); |
Sriram Dash | 9fd465c | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 415 | fsl_fdt_fixup_dr_usb(blob, bd); |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 416 | |
| 417 | #ifdef CONFIG_SYS_DPAA_FMAN |
Madalin Bucur | 7084851 | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 418 | #ifndef CONFIG_DM_ETH |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 419 | fdt_fixup_fman_ethernet(blob); |
Madalin Bucur | 7084851 | 2020-04-30 15:59:58 +0300 | [diff] [blame] | 420 | #endif |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 421 | fdt_fixup_board_enet(blob); |
| 422 | #endif |
Simon Glass | 2aec3cc | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 423 | |
| 424 | return 0; |
Shengzhou Liu | 0788694 | 2013-11-22 17:39:11 +0800 | [diff] [blame] | 425 | } |