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