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