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