Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2015 Freescale Semiconductor |
Alison Wang | 160a435 | 2018-06-18 20:25:05 +0800 | [diff] [blame] | 4 | * Copyright 2017 NXP |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 5 | */ |
| 6 | #include <common.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 7 | #include <env.h> |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 8 | #include <malloc.h> |
| 9 | #include <errno.h> |
| 10 | #include <netdev.h> |
| 11 | #include <fsl_ifc.h> |
| 12 | #include <fsl_ddr.h> |
| 13 | #include <asm/io.h> |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 14 | #include <hwconfig.h> |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 15 | #include <fdt_support.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 16 | #include <linux/libfdt.h> |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 17 | #include <fsl-mc/fsl_mc.h> |
Simon Glass | 9d1f619 | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 18 | #include <env_internal.h> |
Alexander Graf | 34f8e97 | 2016-11-17 01:02:59 +0100 | [diff] [blame] | 19 | #include <efi_loader.h> |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 20 | #include <i2c.h> |
York Sun | 729f2d1 | 2017-03-06 09:02:34 -0800 | [diff] [blame] | 21 | #include <asm/arch/mmu.h> |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 22 | #include <asm/arch/soc.h> |
Santan Kumar | c61c699 | 2017-03-07 11:21:03 +0530 | [diff] [blame] | 23 | #include <asm/arch/ppa.h> |
Saksham Jain | c0c38d2 | 2016-03-23 16:24:35 +0530 | [diff] [blame] | 24 | #include <fsl_sec.h> |
Laurentiu Tudor | 4adff39 | 2019-10-18 09:01:54 +0000 | [diff] [blame] | 25 | #include <asm/arch-fsl-layerscape/fsl_icid.h> |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 26 | |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 27 | #ifdef CONFIG_FSL_QIXIS |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 28 | #include "../common/qixis.h" |
Prabhakar Kushwaha | 122bcfd | 2015-11-09 16:42:07 +0530 | [diff] [blame] | 29 | #include "ls2080ardb_qixis.h" |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 30 | #endif |
Rai Harninder | 6aa1f3b | 2016-03-23 17:04:38 +0530 | [diff] [blame] | 31 | #include "../common/vid.h" |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 32 | |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 33 | #define PIN_MUX_SEL_SDHC 0x00 |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 34 | #define PIN_MUX_SEL_DSPI 0x0a |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 35 | |
| 36 | #define SET_SDHC_MUX_SEL(reg, value) ((reg & 0xf0) | value) |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 39 | enum { |
| 40 | MUX_TYPE_SDHC, |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 41 | MUX_TYPE_DSPI, |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 42 | }; |
| 43 | |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 44 | unsigned long long get_qixis_addr(void) |
| 45 | { |
| 46 | unsigned long long addr; |
| 47 | |
| 48 | if (gd->flags & GD_FLG_RELOC) |
| 49 | addr = QIXIS_BASE_PHYS; |
| 50 | else |
| 51 | addr = QIXIS_BASE_PHYS_EARLY; |
| 52 | |
| 53 | /* |
| 54 | * IFC address under 256MB is mapped to 0x30000000, any address above |
| 55 | * is mapped to 0x5_10000000 up to 4GB. |
| 56 | */ |
| 57 | addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000; |
| 58 | |
| 59 | return addr; |
| 60 | } |
| 61 | |
| 62 | int checkboard(void) |
| 63 | { |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 64 | #ifdef CONFIG_FSL_QIXIS |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 65 | u8 sw; |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 66 | #endif |
Prabhakar Kushwaha | 67f2e9c | 2015-05-28 14:54:07 +0530 | [diff] [blame] | 67 | char buf[15]; |
| 68 | |
| 69 | cpu_name(buf); |
| 70 | printf("Board: %s-RDB, ", buf); |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 71 | |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 72 | #ifdef CONFIG_TARGET_LS2081ARDB |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 73 | #ifdef CONFIG_FSL_QIXIS |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 74 | sw = QIXIS_READ(arch); |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 75 | printf("Board version: %c, ", (sw & 0xf) + 'A'); |
| 76 | |
| 77 | sw = QIXIS_READ(brdcfg[0]); |
Priyanka Jain | 7598579 | 2018-01-08 12:20:42 +0530 | [diff] [blame] | 78 | sw = (sw >> QIXIS_QMAP_SHIFT) & QIXIS_QMAP_MASK; |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 79 | switch (sw) { |
| 80 | case 0: |
| 81 | puts("boot from QSPI DEV#0\n"); |
| 82 | puts("QSPI_CSA_1 mapped to QSPI DEV#1\n"); |
| 83 | break; |
| 84 | case 1: |
| 85 | puts("boot from QSPI DEV#1\n"); |
| 86 | puts("QSPI_CSA_1 mapped to QSPI DEV#0\n"); |
| 87 | break; |
| 88 | case 2: |
| 89 | puts("boot from QSPI EMU\n"); |
| 90 | puts("QSPI_CSA_1 mapped to QSPI DEV#0\n"); |
| 91 | break; |
| 92 | case 3: |
| 93 | puts("boot from QSPI EMU\n"); |
| 94 | puts("QSPI_CSA_1 mapped to QSPI DEV#1\n"); |
| 95 | break; |
| 96 | case 4: |
| 97 | puts("boot from QSPI DEV#0\n"); |
| 98 | puts("QSPI_CSA_1 mapped to QSPI EMU\n"); |
| 99 | break; |
| 100 | default: |
| 101 | printf("invalid setting of SW%u\n", sw); |
| 102 | break; |
| 103 | } |
Priyanka Jain | 6e9d295 | 2018-01-08 12:59:31 +0530 | [diff] [blame] | 104 | printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata)); |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 105 | #endif |
| 106 | puts("SERDES1 Reference : "); |
| 107 | printf("Clock1 = 100MHz "); |
| 108 | printf("Clock2 = 161.13MHz"); |
| 109 | #else |
| 110 | #ifdef CONFIG_FSL_QIXIS |
| 111 | sw = QIXIS_READ(arch); |
| 112 | printf("Board Arch: V%d, ", sw >> 4); |
Prabhakar Kushwaha | 8368a59 | 2015-05-28 14:54:04 +0530 | [diff] [blame] | 113 | printf("Board version: %c, boot from ", (sw & 0xf) + 'A'); |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 114 | |
| 115 | sw = QIXIS_READ(brdcfg[0]); |
| 116 | sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; |
| 117 | |
| 118 | if (sw < 0x8) |
| 119 | printf("vBank: %d\n", sw); |
| 120 | else if (sw == 0x9) |
| 121 | puts("NAND\n"); |
| 122 | else |
| 123 | printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); |
| 124 | |
| 125 | printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata)); |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 126 | #endif |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 127 | puts("SERDES1 Reference : "); |
| 128 | printf("Clock1 = 156.25MHz "); |
| 129 | printf("Clock2 = 156.25MHz"); |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 130 | #endif |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 131 | |
| 132 | puts("\nSERDES2 Reference : "); |
| 133 | printf("Clock1 = 100MHz "); |
| 134 | printf("Clock2 = 100MHz\n"); |
| 135 | |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | unsigned long get_board_sys_clk(void) |
| 140 | { |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 141 | #ifdef CONFIG_FSL_QIXIS |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 142 | u8 sysclk_conf = QIXIS_READ(brdcfg[1]); |
| 143 | |
| 144 | switch (sysclk_conf & 0x0F) { |
| 145 | case QIXIS_SYSCLK_83: |
| 146 | return 83333333; |
| 147 | case QIXIS_SYSCLK_100: |
| 148 | return 100000000; |
| 149 | case QIXIS_SYSCLK_125: |
| 150 | return 125000000; |
| 151 | case QIXIS_SYSCLK_133: |
| 152 | return 133333333; |
| 153 | case QIXIS_SYSCLK_150: |
| 154 | return 150000000; |
| 155 | case QIXIS_SYSCLK_160: |
| 156 | return 160000000; |
| 157 | case QIXIS_SYSCLK_166: |
| 158 | return 166666666; |
| 159 | } |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 160 | #endif |
| 161 | return 100000000; |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | int select_i2c_ch_pca9547(u8 ch) |
| 165 | { |
| 166 | int ret; |
| 167 | |
Chuanhua Han | e9f2f9a | 2019-07-22 16:36:42 +0800 | [diff] [blame] | 168 | #ifndef CONFIG_DM_I2C |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 169 | ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1); |
Chuanhua Han | e9f2f9a | 2019-07-22 16:36:42 +0800 | [diff] [blame] | 170 | #else |
| 171 | struct udevice *dev; |
| 172 | |
| 173 | ret = i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, &dev); |
| 174 | if (!ret) |
| 175 | ret = dm_i2c_write(dev, 0, &ch, 1); |
| 176 | #endif |
| 177 | |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 178 | if (ret) { |
| 179 | puts("PCA: failed to select proper channel\n"); |
| 180 | return ret; |
| 181 | } |
| 182 | |
| 183 | return 0; |
| 184 | } |
| 185 | |
Rai Harninder | 6aa1f3b | 2016-03-23 17:04:38 +0530 | [diff] [blame] | 186 | int i2c_multiplexer_select_vid_channel(u8 channel) |
| 187 | { |
| 188 | return select_i2c_ch_pca9547(channel); |
| 189 | } |
| 190 | |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 191 | int config_board_mux(int ctrl_type) |
| 192 | { |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 193 | #ifdef CONFIG_FSL_QIXIS |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 194 | u8 reg5; |
| 195 | |
| 196 | reg5 = QIXIS_READ(brdcfg[5]); |
| 197 | |
| 198 | switch (ctrl_type) { |
| 199 | case MUX_TYPE_SDHC: |
| 200 | reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_SDHC); |
| 201 | break; |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 202 | case MUX_TYPE_DSPI: |
| 203 | reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_DSPI); |
| 204 | break; |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 205 | default: |
| 206 | printf("Wrong mux interface type\n"); |
| 207 | return -1; |
| 208 | } |
| 209 | |
| 210 | QIXIS_WRITE(brdcfg[5], reg5); |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 211 | #endif |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | int board_init(void) |
| 216 | { |
York Sun | 8cbc195 | 2016-05-26 13:59:03 -0700 | [diff] [blame] | 217 | #ifdef CONFIG_FSL_MC_ENET |
Shaohui Xie | 8c7ce82 | 2016-01-28 15:38:15 +0800 | [diff] [blame] | 218 | u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE; |
York Sun | 8cbc195 | 2016-05-26 13:59:03 -0700 | [diff] [blame] | 219 | #endif |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 220 | |
| 221 | init_final_memctl_regs(); |
| 222 | |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 223 | #ifdef CONFIG_ENV_IS_NOWHERE |
| 224 | gd->env_addr = (ulong)&default_environment[0]; |
| 225 | #endif |
| 226 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); |
| 227 | |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 228 | #ifdef CONFIG_FSL_QIXIS |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 229 | QIXIS_WRITE(rst_ctl, QIXIS_RST_CTL_RESET_EN); |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 230 | #endif |
Udit Agarwal | c83ea8a | 2017-08-16 07:13:29 -0400 | [diff] [blame] | 231 | |
| 232 | #ifdef CONFIG_FSL_CAAM |
| 233 | sec_init(); |
| 234 | #endif |
Santan Kumar | c61c699 | 2017-03-07 11:21:03 +0530 | [diff] [blame] | 235 | #ifdef CONFIG_FSL_LS_PPA |
| 236 | ppa_init(); |
| 237 | #endif |
| 238 | |
York Sun | 8cbc195 | 2016-05-26 13:59:03 -0700 | [diff] [blame] | 239 | #ifdef CONFIG_FSL_MC_ENET |
Shaohui Xie | 8c7ce82 | 2016-01-28 15:38:15 +0800 | [diff] [blame] | 240 | /* invert AQR405 IRQ pins polarity */ |
| 241 | out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR405_IRQ_MASK); |
York Sun | 8cbc195 | 2016-05-26 13:59:03 -0700 | [diff] [blame] | 242 | #endif |
Udit Agarwal | 62ed9a8 | 2017-02-03 22:53:38 +0530 | [diff] [blame] | 243 | #ifdef CONFIG_FSL_CAAM |
| 244 | sec_init(); |
| 245 | #endif |
Shaohui Xie | 8c7ce82 | 2016-01-28 15:38:15 +0800 | [diff] [blame] | 246 | |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | int board_early_init_f(void) |
| 251 | { |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 252 | #ifdef CONFIG_SYS_I2C_EARLY_INIT |
| 253 | i2c_early_init_f(); |
| 254 | #endif |
Haikun.Wang@freescale.com | b8a258c | 2015-06-26 19:58:24 +0800 | [diff] [blame] | 255 | fsl_lsch3_early_init_f(); |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | int misc_init_r(void) |
| 260 | { |
Santan Kumar | 0ce3f40 | 2017-06-15 17:07:01 +0530 | [diff] [blame] | 261 | char *env_hwconfig; |
| 262 | u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE; |
| 263 | u32 val; |
Priyanka Jain | 0915dda | 2017-09-15 10:19:48 +0530 | [diff] [blame] | 264 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 265 | u32 svr = gur_in32(&gur->svr); |
Santan Kumar | 0ce3f40 | 2017-06-15 17:07:01 +0530 | [diff] [blame] | 266 | |
| 267 | val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4); |
| 268 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 269 | env_hwconfig = env_get("hwconfig"); |
Santan Kumar | 0ce3f40 | 2017-06-15 17:07:01 +0530 | [diff] [blame] | 270 | |
| 271 | if (hwconfig_f("dspi", env_hwconfig) && |
| 272 | DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8))) |
| 273 | config_board_mux(MUX_TYPE_DSPI); |
| 274 | else |
| 275 | config_board_mux(MUX_TYPE_SDHC); |
| 276 | |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 277 | /* |
Santan Kumar | 20e7f5a | 2017-06-09 11:48:05 +0530 | [diff] [blame] | 278 | * LS2081ARDB RevF board has smart voltage translator |
Priyanka Jain | d158718 | 2017-04-25 10:12:31 +0530 | [diff] [blame] | 279 | * which needs to be programmed to enable high speed SD interface |
| 280 | * by setting GPIO4_10 output to zero |
| 281 | */ |
Santan Kumar | 20e7f5a | 2017-06-09 11:48:05 +0530 | [diff] [blame] | 282 | #ifdef CONFIG_TARGET_LS2081ARDB |
Priyanka Jain | d158718 | 2017-04-25 10:12:31 +0530 | [diff] [blame] | 283 | out_le32(GPIO4_GPDIR_ADDR, (1 << 21 | |
| 284 | in_le32(GPIO4_GPDIR_ADDR))); |
| 285 | out_le32(GPIO4_GPDAT_ADDR, (~(1 << 21) & |
| 286 | in_le32(GPIO4_GPDAT_ADDR))); |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 287 | #endif |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 288 | if (hwconfig("sdhc")) |
| 289 | config_board_mux(MUX_TYPE_SDHC); |
| 290 | |
Rai Harninder | 6aa1f3b | 2016-03-23 17:04:38 +0530 | [diff] [blame] | 291 | if (adjust_vdd(0)) |
| 292 | printf("Warning: Adjusting core voltage failed.\n"); |
Priyanka Jain | 0915dda | 2017-09-15 10:19:48 +0530 | [diff] [blame] | 293 | /* |
| 294 | * Default value of board env is based on filename which is |
| 295 | * ls2080ardb. Modify board env for other supported SoCs |
| 296 | */ |
| 297 | if ((SVR_SOC_VER(svr) == SVR_LS2088A) || |
| 298 | (SVR_SOC_VER(svr) == SVR_LS2048A)) |
| 299 | env_set("board", "ls2088ardb"); |
| 300 | else if ((SVR_SOC_VER(svr) == SVR_LS2081A) || |
| 301 | (SVR_SOC_VER(svr) == SVR_LS2041A)) |
| 302 | env_set("board", "ls2081ardb"); |
Rai Harninder | 6aa1f3b | 2016-03-23 17:04:38 +0530 | [diff] [blame] | 303 | |
Yangbo Lu | cf00555 | 2015-05-28 14:53:55 +0530 | [diff] [blame] | 304 | return 0; |
| 305 | } |
| 306 | |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 307 | void detail_board_ddr_info(void) |
| 308 | { |
| 309 | puts("\nDDR "); |
| 310 | print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, ""); |
| 311 | print_ddr_info(0); |
Prabhakar Kushwaha | 122bcfd | 2015-11-09 16:42:07 +0530 | [diff] [blame] | 312 | #ifdef CONFIG_SYS_FSL_HAS_DP_DDR |
York Sun | cbe8e1c | 2016-04-04 11:41:26 -0700 | [diff] [blame] | 313 | if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) { |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 314 | puts("\nDP-DDR "); |
| 315 | print_size(gd->bd->bi_dram[2].size, ""); |
| 316 | print_ddr_info(CONFIG_DP_DDR_CTRL); |
| 317 | } |
Prabhakar Kushwaha | 122bcfd | 2015-11-09 16:42:07 +0530 | [diff] [blame] | 318 | #endif |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 319 | } |
| 320 | |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 321 | #ifdef CONFIG_FSL_MC_ENET |
| 322 | void fdt_fixup_board_enet(void *fdt) |
| 323 | { |
| 324 | int offset; |
| 325 | |
Stuart Yoder | a346615 | 2016-03-02 16:37:13 -0600 | [diff] [blame] | 326 | offset = fdt_path_offset(fdt, "/soc/fsl-mc"); |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 327 | |
| 328 | if (offset < 0) |
Stuart Yoder | a346615 | 2016-03-02 16:37:13 -0600 | [diff] [blame] | 329 | offset = fdt_path_offset(fdt, "/fsl-mc"); |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 330 | |
| 331 | if (offset < 0) { |
| 332 | printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n", |
| 333 | __func__, offset); |
| 334 | return; |
| 335 | } |
| 336 | |
Mian Yousaf Kaukab | 9712465 | 2018-12-18 14:01:17 +0100 | [diff] [blame] | 337 | if (get_mc_boot_status() == 0 && |
| 338 | (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0)) |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 339 | fdt_status_okay(fdt, offset); |
| 340 | else |
| 341 | fdt_status_fail(fdt, offset); |
| 342 | } |
Alexander Graf | 2ebeb44 | 2016-11-17 01:02:57 +0100 | [diff] [blame] | 343 | |
| 344 | void board_quiesce_devices(void) |
| 345 | { |
| 346 | fsl_mc_ldpaa_exit(gd->bd); |
| 347 | } |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 348 | #endif |
| 349 | |
| 350 | #ifdef CONFIG_OF_BOARD_SETUP |
Santan Kumar | 39ea8bf | 2017-07-05 18:05:08 +0530 | [diff] [blame] | 351 | void fsl_fdt_fixup_flash(void *fdt) |
| 352 | { |
| 353 | int offset; |
Rajesh Bhagat | d5691be | 2018-12-27 04:37:59 +0000 | [diff] [blame] | 354 | #ifdef CONFIG_TFABOOT |
| 355 | u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE; |
| 356 | u32 val; |
| 357 | #endif |
Santan Kumar | 39ea8bf | 2017-07-05 18:05:08 +0530 | [diff] [blame] | 358 | |
| 359 | /* |
| 360 | * IFC and QSPI are muxed on board. |
| 361 | * So disable IFC node in dts if QSPI is enabled or |
| 362 | * disable QSPI node in dts in case QSPI is not enabled. |
| 363 | */ |
Rajesh Bhagat | d5691be | 2018-12-27 04:37:59 +0000 | [diff] [blame] | 364 | #ifdef CONFIG_TFABOOT |
| 365 | enum boot_src src = get_boot_src(); |
| 366 | bool disable_ifc = false; |
| 367 | |
| 368 | switch (src) { |
| 369 | case BOOT_SOURCE_IFC_NOR: |
| 370 | disable_ifc = false; |
| 371 | break; |
| 372 | case BOOT_SOURCE_QSPI_NOR: |
| 373 | disable_ifc = true; |
| 374 | break; |
| 375 | default: |
| 376 | val = in_le32(dcfg_ccsr + DCFG_RCWSR15 / 4); |
| 377 | if (DCFG_RCWSR15_IFCGRPABASE_QSPI == (val & (u32)0x3)) |
| 378 | disable_ifc = true; |
| 379 | break; |
| 380 | } |
| 381 | |
| 382 | if (disable_ifc) { |
| 383 | offset = fdt_path_offset(fdt, "/soc/ifc"); |
| 384 | |
| 385 | if (offset < 0) |
| 386 | offset = fdt_path_offset(fdt, "/ifc"); |
| 387 | } else { |
| 388 | offset = fdt_path_offset(fdt, "/soc/quadspi"); |
| 389 | |
| 390 | if (offset < 0) |
| 391 | offset = fdt_path_offset(fdt, "/quadspi"); |
| 392 | } |
| 393 | |
| 394 | #else |
Santan Kumar | 39ea8bf | 2017-07-05 18:05:08 +0530 | [diff] [blame] | 395 | #ifdef CONFIG_FSL_QSPI |
| 396 | offset = fdt_path_offset(fdt, "/soc/ifc"); |
| 397 | |
| 398 | if (offset < 0) |
| 399 | offset = fdt_path_offset(fdt, "/ifc"); |
| 400 | #else |
| 401 | offset = fdt_path_offset(fdt, "/soc/quadspi"); |
| 402 | |
| 403 | if (offset < 0) |
| 404 | offset = fdt_path_offset(fdt, "/quadspi"); |
| 405 | #endif |
Rajesh Bhagat | d5691be | 2018-12-27 04:37:59 +0000 | [diff] [blame] | 406 | #endif |
| 407 | |
Santan Kumar | 39ea8bf | 2017-07-05 18:05:08 +0530 | [diff] [blame] | 408 | if (offset < 0) |
| 409 | return; |
| 410 | |
| 411 | fdt_status_disabled(fdt, offset); |
| 412 | } |
| 413 | |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 414 | int ft_board_setup(void *blob, bd_t *bd) |
| 415 | { |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 416 | int i; |
| 417 | u16 mc_memory_bank = 0; |
| 418 | |
| 419 | u64 *base; |
| 420 | u64 *size; |
| 421 | u64 mc_memory_base = 0; |
| 422 | u64 mc_memory_size = 0; |
| 423 | u16 total_memory_banks; |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 424 | |
| 425 | ft_cpu_setup(blob, bd); |
| 426 | |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 427 | fdt_fixup_mc_ddr(&mc_memory_base, &mc_memory_size); |
| 428 | |
| 429 | if (mc_memory_base != 0) |
| 430 | mc_memory_bank++; |
| 431 | |
| 432 | total_memory_banks = CONFIG_NR_DRAM_BANKS + mc_memory_bank; |
| 433 | |
| 434 | base = calloc(total_memory_banks, sizeof(u64)); |
| 435 | size = calloc(total_memory_banks, sizeof(u64)); |
| 436 | |
Bhupesh Sharma | 0b10a1a | 2015-05-28 14:54:10 +0530 | [diff] [blame] | 437 | /* fixup DT for the two GPP DDR banks */ |
| 438 | base[0] = gd->bd->bi_dram[0].start; |
| 439 | size[0] = gd->bd->bi_dram[0].size; |
| 440 | base[1] = gd->bd->bi_dram[1].start; |
| 441 | size[1] = gd->bd->bi_dram[1].size; |
| 442 | |
York Sun | 4de24ef | 2017-03-06 09:02:28 -0800 | [diff] [blame] | 443 | #ifdef CONFIG_RESV_RAM |
| 444 | /* reduce size if reserved memory is within this bank */ |
| 445 | if (gd->arch.resv_ram >= base[0] && |
| 446 | gd->arch.resv_ram < base[0] + size[0]) |
| 447 | size[0] = gd->arch.resv_ram - base[0]; |
| 448 | else if (gd->arch.resv_ram >= base[1] && |
| 449 | gd->arch.resv_ram < base[1] + size[1]) |
| 450 | size[1] = gd->arch.resv_ram - base[1]; |
| 451 | #endif |
| 452 | |
Meenakshi Aggarwal | d67ae48 | 2019-05-23 15:13:43 +0530 | [diff] [blame] | 453 | if (mc_memory_base != 0) { |
| 454 | for (i = 0; i <= total_memory_banks; i++) { |
| 455 | if (base[i] == 0 && size[i] == 0) { |
| 456 | base[i] = mc_memory_base; |
| 457 | size[i] = mc_memory_size; |
| 458 | break; |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | fdt_fixup_memory_banks(blob, base, size, total_memory_banks); |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 464 | |
Nipun Gupta | d691264 | 2018-08-20 16:01:14 +0530 | [diff] [blame] | 465 | fdt_fsl_mc_fixup_iommu_map_entry(blob); |
| 466 | |
Sriram Dash | 9fd465c | 2016-09-16 17:12:15 +0530 | [diff] [blame] | 467 | fsl_fdt_fixup_dr_usb(blob, bd); |
Sriram Dash | 0182095 | 2016-06-13 09:58:36 +0530 | [diff] [blame] | 468 | |
Santan Kumar | 39ea8bf | 2017-07-05 18:05:08 +0530 | [diff] [blame] | 469 | fsl_fdt_fixup_flash(blob); |
| 470 | |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 471 | #ifdef CONFIG_FSL_MC_ENET |
| 472 | fdt_fixup_board_enet(blob); |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 473 | #endif |
| 474 | |
Laurentiu Tudor | 4adff39 | 2019-10-18 09:01:54 +0000 | [diff] [blame] | 475 | fdt_fixup_icid(blob); |
| 476 | |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 477 | return 0; |
| 478 | } |
| 479 | #endif |
| 480 | |
| 481 | void qixis_dump_switch(void) |
| 482 | { |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 483 | #ifdef CONFIG_FSL_QIXIS |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 484 | int i, nr_of_cfgsw; |
| 485 | |
| 486 | QIXIS_WRITE(cms[0], 0x00); |
| 487 | nr_of_cfgsw = QIXIS_READ(cms[1]); |
| 488 | |
| 489 | puts("DIP switch settings dump:\n"); |
| 490 | for (i = 1; i <= nr_of_cfgsw; i++) { |
| 491 | QIXIS_WRITE(cms[0], i); |
| 492 | printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1])); |
| 493 | } |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 494 | #endif |
York Sun | e12abcb | 2015-03-20 19:28:24 -0700 | [diff] [blame] | 495 | } |
York Sun | ac192a9 | 2015-05-28 14:54:09 +0530 | [diff] [blame] | 496 | |
| 497 | /* |
| 498 | * Board rev C and earlier has duplicated I2C addresses for 2nd controller. |
| 499 | * Both slots has 0x54, resulting 2nd slot unusable. |
| 500 | */ |
| 501 | void update_spd_address(unsigned int ctrl_num, |
| 502 | unsigned int slot, |
| 503 | unsigned int *addr) |
| 504 | { |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 505 | #ifndef CONFIG_TARGET_LS2081ARDB |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 506 | #ifdef CONFIG_FSL_QIXIS |
York Sun | ac192a9 | 2015-05-28 14:54:09 +0530 | [diff] [blame] | 507 | u8 sw; |
| 508 | |
| 509 | sw = QIXIS_READ(arch); |
| 510 | if ((sw & 0xf) < 0x3) { |
| 511 | if (ctrl_num == 1 && slot == 0) |
| 512 | *addr = SPD_EEPROM_ADDRESS4; |
| 513 | else if (ctrl_num == 1 && slot == 1) |
| 514 | *addr = SPD_EEPROM_ADDRESS3; |
| 515 | } |
Priyanka Jain | 6720d0a | 2017-04-28 10:41:34 +0530 | [diff] [blame] | 516 | #endif |
Priyanka Jain | 75cd67f | 2017-04-27 15:08:07 +0530 | [diff] [blame] | 517 | #endif |
York Sun | ac192a9 | 2015-05-28 14:54:09 +0530 | [diff] [blame] | 518 | } |