Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <i2c.h> |
| 9 | #include <asm/io.h> |
| 10 | #include <asm/arch/immap_ls102xa.h> |
Xiubo Li | e87f3b3 | 2014-11-21 17:40:58 +0800 | [diff] [blame] | 11 | #include <asm/arch/ns_access.h> |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 12 | #include <asm/arch/clock.h> |
| 13 | #include <asm/arch/fsl_serdes.h> |
Xiubo Li | 660673a | 2014-11-21 17:40:59 +0800 | [diff] [blame] | 14 | #include <asm/arch/ls102xa_stream_id.h> |
Minghuan Lian | da41902 | 2014-10-31 13:43:44 +0800 | [diff] [blame] | 15 | #include <asm/pcie_layerscape.h> |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 16 | #include <hwconfig.h> |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 17 | #include <mmc.h> |
| 18 | #include <fsl_esdhc.h> |
| 19 | #include <fsl_ifc.h> |
Ruchika Gupta | 4ba4a09 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 20 | #include <fsl_sec.h> |
Alison Wang | 86949c2 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 21 | #include <spl.h> |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 22 | |
| 23 | #include "../common/qixis.h" |
| 24 | #include "ls1021aqds_qixis.h" |
Zhao Qiang | 63e75fd | 2014-09-26 16:25:32 +0800 | [diff] [blame] | 25 | #ifdef CONFIG_U_QE |
| 26 | #include "../../../drivers/qe/qe.h" |
| 27 | #endif |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 28 | |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 29 | #define PIN_MUX_SEL_CAN 0x03 |
| 30 | #define PIN_MUX_SEL_IIC2 0xa0 |
| 31 | #define PIN_MUX_SEL_RGMII 0x00 |
| 32 | #define PIN_MUX_SEL_SAI 0x0c |
| 33 | #define PIN_MUX_SEL_SDHC 0x00 |
| 34 | |
| 35 | #define SET_SDHC_MUX_SEL(reg, value) ((reg & 0x0f) | value) |
| 36 | #define SET_EC_MUX_SEL(reg, value) ((reg & 0xf0) | value) |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
| 39 | enum { |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 40 | MUX_TYPE_CAN, |
| 41 | MUX_TYPE_IIC2, |
| 42 | MUX_TYPE_RGMII, |
| 43 | MUX_TYPE_SAI, |
| 44 | MUX_TYPE_SDHC, |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 45 | MUX_TYPE_SD_PCI4, |
| 46 | MUX_TYPE_SD_PC_SA_SG_SG, |
| 47 | MUX_TYPE_SD_PC_SA_PC_SG, |
| 48 | MUX_TYPE_SD_PC_SG_SG, |
| 49 | }; |
| 50 | |
Alison Wang | 0f5e557 | 2014-12-09 17:38:23 +0800 | [diff] [blame] | 51 | enum { |
| 52 | GE0_CLK125, |
| 53 | GE2_CLK125, |
| 54 | GE1_CLK125, |
| 55 | }; |
| 56 | |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 57 | int checkboard(void) |
| 58 | { |
Alison Wang | d612f0a | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 59 | #ifndef CONFIG_QSPI_BOOT |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 60 | char buf[64]; |
Alison Wang | d612f0a | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 61 | #endif |
Alison Wang | 86949c2 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 62 | #if !defined(CONFIG_SD_BOOT) && !defined(CONFIG_QSPI_BOOT) |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 63 | u8 sw; |
Alison Wang | 86949c2 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 64 | #endif |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 65 | |
| 66 | puts("Board: LS1021AQDS\n"); |
| 67 | |
Alison Wang | 86949c2 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 68 | #ifdef CONFIG_SD_BOOT |
| 69 | puts("SD\n"); |
| 70 | #elif CONFIG_QSPI_BOOT |
| 71 | puts("QSPI\n"); |
| 72 | #else |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 73 | sw = QIXIS_READ(brdcfg[0]); |
| 74 | sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT; |
| 75 | |
| 76 | if (sw < 0x8) |
| 77 | printf("vBank: %d\n", sw); |
| 78 | else if (sw == 0x8) |
| 79 | puts("PromJet\n"); |
| 80 | else if (sw == 0x9) |
| 81 | puts("NAND\n"); |
| 82 | else if (sw == 0x15) |
| 83 | printf("IFCCard\n"); |
| 84 | else |
| 85 | printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH); |
Alison Wang | 86949c2 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 86 | #endif |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 87 | |
Alison Wang | d612f0a | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 88 | #ifndef CONFIG_QSPI_BOOT |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 89 | printf("Sys ID:0x%02x, Sys Ver: 0x%02x\n", |
| 90 | QIXIS_READ(id), QIXIS_READ(arch)); |
| 91 | |
| 92 | printf("FPGA: v%d (%s), build %d\n", |
| 93 | (int)QIXIS_READ(scver), qixis_read_tag(buf), |
| 94 | (int)qixis_read_minor()); |
Alison Wang | d612f0a | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 95 | #endif |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 96 | |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | unsigned long get_board_sys_clk(void) |
| 101 | { |
| 102 | u8 sysclk_conf = QIXIS_READ(brdcfg[1]); |
| 103 | |
| 104 | switch (sysclk_conf & 0x0f) { |
| 105 | case QIXIS_SYSCLK_64: |
| 106 | return 64000000; |
| 107 | case QIXIS_SYSCLK_83: |
| 108 | return 83333333; |
| 109 | case QIXIS_SYSCLK_100: |
| 110 | return 100000000; |
| 111 | case QIXIS_SYSCLK_125: |
| 112 | return 125000000; |
| 113 | case QIXIS_SYSCLK_133: |
| 114 | return 133333333; |
| 115 | case QIXIS_SYSCLK_150: |
| 116 | return 150000000; |
| 117 | case QIXIS_SYSCLK_160: |
| 118 | return 160000000; |
| 119 | case QIXIS_SYSCLK_166: |
| 120 | return 166666666; |
| 121 | } |
| 122 | return 66666666; |
| 123 | } |
| 124 | |
| 125 | unsigned long get_board_ddr_clk(void) |
| 126 | { |
| 127 | u8 ddrclk_conf = QIXIS_READ(brdcfg[1]); |
| 128 | |
| 129 | switch ((ddrclk_conf & 0x30) >> 4) { |
| 130 | case QIXIS_DDRCLK_100: |
| 131 | return 100000000; |
| 132 | case QIXIS_DDRCLK_125: |
| 133 | return 125000000; |
| 134 | case QIXIS_DDRCLK_133: |
| 135 | return 133333333; |
| 136 | } |
| 137 | return 66666666; |
| 138 | } |
| 139 | |
Chenhui Zhao | afff137 | 2014-11-06 10:51:59 +0800 | [diff] [blame] | 140 | int select_i2c_ch_pca9547(u8 ch) |
| 141 | { |
| 142 | int ret; |
| 143 | |
| 144 | ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1); |
| 145 | if (ret) { |
| 146 | puts("PCA: failed to select proper channel\n"); |
| 147 | return ret; |
| 148 | } |
| 149 | |
| 150 | return 0; |
| 151 | } |
| 152 | |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 153 | int dram_init(void) |
| 154 | { |
Chenhui Zhao | afff137 | 2014-11-06 10:51:59 +0800 | [diff] [blame] | 155 | /* |
| 156 | * When resuming from deep sleep, the I2C channel may not be |
| 157 | * in the default channel. So, switch to the default channel |
| 158 | * before accessing DDR SPD. |
| 159 | */ |
| 160 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 161 | gd->ram_size = initdram(0); |
| 162 | |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | #ifdef CONFIG_FSL_ESDHC |
| 167 | struct fsl_esdhc_cfg esdhc_cfg[1] = { |
| 168 | {CONFIG_SYS_FSL_ESDHC_ADDR}, |
| 169 | }; |
| 170 | |
| 171 | int board_mmc_init(bd_t *bis) |
| 172 | { |
| 173 | esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); |
| 174 | |
| 175 | return fsl_esdhc_initialize(bis, &esdhc_cfg[0]); |
| 176 | } |
| 177 | #endif |
| 178 | |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 179 | int board_early_init_f(void) |
| 180 | { |
| 181 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR; |
| 182 | struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR; |
| 183 | |
| 184 | #ifdef CONFIG_TSEC_ENET |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 185 | out_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR); |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 186 | #endif |
| 187 | |
| 188 | #ifdef CONFIG_FSL_IFC |
| 189 | init_early_memctl_regs(); |
| 190 | #endif |
| 191 | |
Alison Wang | d612f0a | 2014-12-09 17:38:02 +0800 | [diff] [blame] | 192 | #ifdef CONFIG_FSL_QSPI |
| 193 | out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL); |
| 194 | #endif |
| 195 | |
Xiubo Li | dd04832 | 2014-12-16 14:50:33 +0800 | [diff] [blame^] | 196 | #ifdef CONFIG_FSL_DCU_FB |
| 197 | out_be32(&scfg->pixclkcr, SCFG_PIXCLKCR_PXCKEN); |
| 198 | #endif |
| 199 | |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 200 | /* Workaround for the issue that DDR could not respond to |
| 201 | * barrier transaction which is generated by executing DSB/ISB |
| 202 | * instruction. Set CCI-400 control override register to |
| 203 | * terminate the barrier transaction. After DDR is initialized, |
| 204 | * allow barrier transaction to DDR again */ |
| 205 | out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER); |
| 206 | |
| 207 | return 0; |
| 208 | } |
| 209 | |
Alison Wang | 86949c2 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 210 | #ifdef CONFIG_SPL_BUILD |
| 211 | void board_init_f(ulong dummy) |
| 212 | { |
| 213 | struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR; |
| 214 | |
Alison Wang | 8ab967b | 2014-12-09 17:38:14 +0800 | [diff] [blame] | 215 | #ifdef CONFIG_NAND_BOOT |
| 216 | struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR; |
| 217 | u32 porsr1, pinctl; |
| 218 | |
| 219 | /* |
| 220 | * There is LS1 SoC issue where NOR, FPGA are inaccessible during |
| 221 | * NAND boot because IFC signals > IFC_AD7 are not enabled. |
| 222 | * This workaround changes RCW source to make all signals enabled. |
| 223 | */ |
| 224 | porsr1 = in_be32(&gur->porsr1); |
| 225 | pinctl = ((porsr1 & ~(DCFG_CCSR_PORSR1_RCW_MASK)) | |
| 226 | DCFG_CCSR_PORSR1_RCW_SRC_I2C); |
| 227 | out_be32((unsigned int *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1), |
| 228 | pinctl); |
| 229 | #endif |
| 230 | |
Alison Wang | 86949c2 | 2014-12-03 15:00:47 +0800 | [diff] [blame] | 231 | /* Clear the BSS */ |
| 232 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 233 | |
| 234 | #ifdef CONFIG_FSL_IFC |
| 235 | init_early_memctl_regs(); |
| 236 | #endif |
| 237 | |
| 238 | get_clocks(); |
| 239 | |
| 240 | preloader_console_init(); |
| 241 | |
| 242 | #ifdef CONFIG_SPL_I2C_SUPPORT |
| 243 | i2c_init_all(); |
| 244 | #endif |
| 245 | out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER); |
| 246 | |
| 247 | dram_init(); |
| 248 | |
| 249 | board_init_r(NULL, 0); |
| 250 | } |
| 251 | #endif |
| 252 | |
Alison Wang | 0f5e557 | 2014-12-09 17:38:23 +0800 | [diff] [blame] | 253 | void config_etseccm_source(int etsec_gtx_125_mux) |
| 254 | { |
| 255 | struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR; |
| 256 | |
| 257 | switch (etsec_gtx_125_mux) { |
| 258 | case GE0_CLK125: |
| 259 | out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE0_CLK125); |
| 260 | debug("etseccm set to GE0_CLK125\n"); |
| 261 | break; |
| 262 | |
| 263 | case GE2_CLK125: |
| 264 | out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125); |
| 265 | debug("etseccm set to GE2_CLK125\n"); |
| 266 | break; |
| 267 | |
| 268 | case GE1_CLK125: |
| 269 | out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE1_CLK125); |
| 270 | debug("etseccm set to GE1_CLK125\n"); |
| 271 | break; |
| 272 | |
| 273 | default: |
| 274 | printf("Error! trying to set etseccm to invalid value\n"); |
| 275 | break; |
| 276 | } |
| 277 | } |
| 278 | |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 279 | int config_board_mux(int ctrl_type) |
| 280 | { |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 281 | u8 reg12, reg14; |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 282 | |
| 283 | reg12 = QIXIS_READ(brdcfg[12]); |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 284 | reg14 = QIXIS_READ(brdcfg[14]); |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 285 | |
| 286 | switch (ctrl_type) { |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 287 | case MUX_TYPE_CAN: |
Alison Wang | 0f5e557 | 2014-12-09 17:38:23 +0800 | [diff] [blame] | 288 | config_etseccm_source(GE2_CLK125); |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 289 | reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_CAN); |
| 290 | break; |
| 291 | case MUX_TYPE_IIC2: |
| 292 | reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_IIC2); |
| 293 | break; |
| 294 | case MUX_TYPE_RGMII: |
| 295 | reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_RGMII); |
| 296 | break; |
| 297 | case MUX_TYPE_SAI: |
Alison Wang | 0f5e557 | 2014-12-09 17:38:23 +0800 | [diff] [blame] | 298 | config_etseccm_source(GE2_CLK125); |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 299 | reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_SAI); |
| 300 | break; |
| 301 | case MUX_TYPE_SDHC: |
| 302 | reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_SDHC); |
| 303 | break; |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 304 | case MUX_TYPE_SD_PCI4: |
| 305 | reg12 = 0x38; |
| 306 | break; |
| 307 | case MUX_TYPE_SD_PC_SA_SG_SG: |
| 308 | reg12 = 0x01; |
| 309 | break; |
| 310 | case MUX_TYPE_SD_PC_SA_PC_SG: |
| 311 | reg12 = 0x01; |
| 312 | break; |
| 313 | case MUX_TYPE_SD_PC_SG_SG: |
| 314 | reg12 = 0x21; |
| 315 | break; |
| 316 | default: |
| 317 | printf("Wrong mux interface type\n"); |
| 318 | return -1; |
| 319 | } |
| 320 | |
| 321 | QIXIS_WRITE(brdcfg[12], reg12); |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 322 | QIXIS_WRITE(brdcfg[14], reg14); |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 323 | |
| 324 | return 0; |
| 325 | } |
| 326 | |
| 327 | int config_serdes_mux(void) |
| 328 | { |
| 329 | struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_FSL_GUTS_ADDR; |
| 330 | u32 cfg; |
| 331 | |
| 332 | cfg = in_be32(&gur->rcwsr[4]) & RCWSR4_SRDS1_PRTCL_MASK; |
| 333 | cfg >>= RCWSR4_SRDS1_PRTCL_SHIFT; |
| 334 | |
| 335 | switch (cfg) { |
| 336 | case 0x0: |
| 337 | config_board_mux(MUX_TYPE_SD_PCI4); |
| 338 | break; |
| 339 | case 0x30: |
| 340 | config_board_mux(MUX_TYPE_SD_PC_SA_SG_SG); |
| 341 | break; |
| 342 | case 0x60: |
| 343 | config_board_mux(MUX_TYPE_SD_PC_SG_SG); |
| 344 | break; |
| 345 | case 0x70: |
| 346 | config_board_mux(MUX_TYPE_SD_PC_SA_PC_SG); |
| 347 | break; |
| 348 | default: |
| 349 | printf("SRDS1 prtcl:0x%x\n", cfg); |
| 350 | break; |
| 351 | } |
| 352 | |
| 353 | return 0; |
| 354 | } |
| 355 | |
Ruchika Gupta | 4ba4a09 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 356 | int misc_init_r(void) |
| 357 | { |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 358 | int conflict_flag; |
| 359 | |
| 360 | /* some signals can not enable simultaneous*/ |
| 361 | conflict_flag = 0; |
| 362 | if (hwconfig("sdhc")) |
| 363 | conflict_flag++; |
| 364 | if (hwconfig("iic2")) |
| 365 | conflict_flag++; |
| 366 | if (conflict_flag > 1) { |
| 367 | printf("WARNING: pin conflict !\n"); |
| 368 | return 0; |
| 369 | } |
| 370 | |
| 371 | conflict_flag = 0; |
| 372 | if (hwconfig("rgmii")) |
| 373 | conflict_flag++; |
| 374 | if (hwconfig("can")) |
| 375 | conflict_flag++; |
| 376 | if (hwconfig("sai")) |
| 377 | conflict_flag++; |
| 378 | if (conflict_flag > 1) { |
| 379 | printf("WARNING: pin conflict !\n"); |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | if (hwconfig("can")) |
| 384 | config_board_mux(MUX_TYPE_CAN); |
| 385 | else if (hwconfig("rgmii")) |
| 386 | config_board_mux(MUX_TYPE_RGMII); |
| 387 | else if (hwconfig("sai")) |
| 388 | config_board_mux(MUX_TYPE_SAI); |
| 389 | |
| 390 | if (hwconfig("iic2")) |
| 391 | config_board_mux(MUX_TYPE_IIC2); |
| 392 | else if (hwconfig("sdhc")) |
| 393 | config_board_mux(MUX_TYPE_SDHC); |
| 394 | |
Ruchika Gupta | 4ba4a09 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 395 | #ifdef CONFIG_FSL_CAAM |
| 396 | return sec_init(); |
| 397 | #endif |
Yao Yuan | bca11bd | 2014-11-26 14:54:33 +0800 | [diff] [blame] | 398 | return 0; |
Ruchika Gupta | 4ba4a09 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 399 | } |
Ruchika Gupta | 4ba4a09 | 2014-10-15 11:39:06 +0530 | [diff] [blame] | 400 | |
Xiubo Li | e87f3b3 | 2014-11-21 17:40:58 +0800 | [diff] [blame] | 401 | #ifdef CONFIG_LS102XA_NS_ACCESS |
| 402 | static struct csu_ns_dev ns_dev[] = { |
| 403 | { CSU_CSLX_PCIE2_IO, CSU_ALL_RW }, |
| 404 | { CSU_CSLX_PCIE1_IO, CSU_ALL_RW }, |
| 405 | { CSU_CSLX_MG2TPR_IP, CSU_ALL_RW }, |
| 406 | { CSU_CSLX_IFC_MEM, CSU_ALL_RW }, |
| 407 | { CSU_CSLX_OCRAM, CSU_ALL_RW }, |
| 408 | { CSU_CSLX_GIC, CSU_ALL_RW }, |
| 409 | { CSU_CSLX_PCIE1, CSU_ALL_RW }, |
| 410 | { CSU_CSLX_OCRAM2, CSU_ALL_RW }, |
| 411 | { CSU_CSLX_QSPI_MEM, CSU_ALL_RW }, |
| 412 | { CSU_CSLX_PCIE2, CSU_ALL_RW }, |
| 413 | { CSU_CSLX_SATA, CSU_ALL_RW }, |
| 414 | { CSU_CSLX_USB3, CSU_ALL_RW }, |
| 415 | { CSU_CSLX_SERDES, CSU_ALL_RW }, |
| 416 | { CSU_CSLX_QDMA, CSU_ALL_RW }, |
| 417 | { CSU_CSLX_LPUART2, CSU_ALL_RW }, |
| 418 | { CSU_CSLX_LPUART1, CSU_ALL_RW }, |
| 419 | { CSU_CSLX_LPUART4, CSU_ALL_RW }, |
| 420 | { CSU_CSLX_LPUART3, CSU_ALL_RW }, |
| 421 | { CSU_CSLX_LPUART6, CSU_ALL_RW }, |
| 422 | { CSU_CSLX_LPUART5, CSU_ALL_RW }, |
| 423 | { CSU_CSLX_DSPI2, CSU_ALL_RW }, |
| 424 | { CSU_CSLX_DSPI1, CSU_ALL_RW }, |
| 425 | { CSU_CSLX_QSPI, CSU_ALL_RW }, |
| 426 | { CSU_CSLX_ESDHC, CSU_ALL_RW }, |
| 427 | { CSU_CSLX_2D_ACE, CSU_ALL_RW }, |
| 428 | { CSU_CSLX_IFC, CSU_ALL_RW }, |
| 429 | { CSU_CSLX_I2C1, CSU_ALL_RW }, |
| 430 | { CSU_CSLX_USB2, CSU_ALL_RW }, |
| 431 | { CSU_CSLX_I2C3, CSU_ALL_RW }, |
| 432 | { CSU_CSLX_I2C2, CSU_ALL_RW }, |
| 433 | { CSU_CSLX_DUART2, CSU_ALL_RW }, |
| 434 | { CSU_CSLX_DUART1, CSU_ALL_RW }, |
| 435 | { CSU_CSLX_WDT2, CSU_ALL_RW }, |
| 436 | { CSU_CSLX_WDT1, CSU_ALL_RW }, |
| 437 | { CSU_CSLX_EDMA, CSU_ALL_RW }, |
| 438 | { CSU_CSLX_SYS_CNT, CSU_ALL_RW }, |
| 439 | { CSU_CSLX_DMA_MUX2, CSU_ALL_RW }, |
| 440 | { CSU_CSLX_DMA_MUX1, CSU_ALL_RW }, |
| 441 | { CSU_CSLX_DDR, CSU_ALL_RW }, |
| 442 | { CSU_CSLX_QUICC, CSU_ALL_RW }, |
| 443 | { CSU_CSLX_DCFG_CCU_RCPM, CSU_ALL_RW }, |
| 444 | { CSU_CSLX_SECURE_BOOTROM, CSU_ALL_RW }, |
| 445 | { CSU_CSLX_SFP, CSU_ALL_RW }, |
| 446 | { CSU_CSLX_TMU, CSU_ALL_RW }, |
| 447 | { CSU_CSLX_SECURE_MONITOR, CSU_ALL_RW }, |
| 448 | { CSU_CSLX_RESERVED0, CSU_ALL_RW }, |
| 449 | { CSU_CSLX_ETSEC1, CSU_ALL_RW }, |
| 450 | { CSU_CSLX_SEC5_5, CSU_ALL_RW }, |
| 451 | { CSU_CSLX_ETSEC3, CSU_ALL_RW }, |
| 452 | { CSU_CSLX_ETSEC2, CSU_ALL_RW }, |
| 453 | { CSU_CSLX_GPIO2, CSU_ALL_RW }, |
| 454 | { CSU_CSLX_GPIO1, CSU_ALL_RW }, |
| 455 | { CSU_CSLX_GPIO4, CSU_ALL_RW }, |
| 456 | { CSU_CSLX_GPIO3, CSU_ALL_RW }, |
| 457 | { CSU_CSLX_PLATFORM_CONT, CSU_ALL_RW }, |
| 458 | { CSU_CSLX_CSU, CSU_ALL_RW }, |
| 459 | { CSU_CSLX_ASRC, CSU_ALL_RW }, |
| 460 | { CSU_CSLX_SPDIF, CSU_ALL_RW }, |
| 461 | { CSU_CSLX_FLEXCAN2, CSU_ALL_RW }, |
| 462 | { CSU_CSLX_FLEXCAN1, CSU_ALL_RW }, |
| 463 | { CSU_CSLX_FLEXCAN4, CSU_ALL_RW }, |
| 464 | { CSU_CSLX_FLEXCAN3, CSU_ALL_RW }, |
| 465 | { CSU_CSLX_SAI2, CSU_ALL_RW }, |
| 466 | { CSU_CSLX_SAI1, CSU_ALL_RW }, |
| 467 | { CSU_CSLX_SAI4, CSU_ALL_RW }, |
| 468 | { CSU_CSLX_SAI3, CSU_ALL_RW }, |
| 469 | { CSU_CSLX_FTM2, CSU_ALL_RW }, |
| 470 | { CSU_CSLX_FTM1, CSU_ALL_RW }, |
| 471 | { CSU_CSLX_FTM4, CSU_ALL_RW }, |
| 472 | { CSU_CSLX_FTM3, CSU_ALL_RW }, |
| 473 | { CSU_CSLX_FTM6, CSU_ALL_RW }, |
| 474 | { CSU_CSLX_FTM5, CSU_ALL_RW }, |
| 475 | { CSU_CSLX_FTM8, CSU_ALL_RW }, |
| 476 | { CSU_CSLX_FTM7, CSU_ALL_RW }, |
| 477 | { CSU_CSLX_COP_DCSR, CSU_ALL_RW }, |
| 478 | { CSU_CSLX_EPU, CSU_ALL_RW }, |
| 479 | { CSU_CSLX_GDI, CSU_ALL_RW }, |
| 480 | { CSU_CSLX_DDI, CSU_ALL_RW }, |
| 481 | { CSU_CSLX_RESERVED1, CSU_ALL_RW }, |
| 482 | { CSU_CSLX_USB3_PHY, CSU_ALL_RW }, |
| 483 | { CSU_CSLX_RESERVED2, CSU_ALL_RW }, |
| 484 | }; |
| 485 | #endif |
| 486 | |
Xiubo Li | 660673a | 2014-11-21 17:40:59 +0800 | [diff] [blame] | 487 | struct smmu_stream_id dev_stream_id[] = { |
| 488 | { 0x100, 0x01, "ETSEC MAC1" }, |
| 489 | { 0x104, 0x02, "ETSEC MAC2" }, |
| 490 | { 0x108, 0x03, "ETSEC MAC3" }, |
| 491 | { 0x10c, 0x04, "PEX1" }, |
| 492 | { 0x110, 0x05, "PEX2" }, |
| 493 | { 0x114, 0x06, "qDMA" }, |
| 494 | { 0x118, 0x07, "SATA" }, |
| 495 | { 0x11c, 0x08, "USB3" }, |
| 496 | { 0x120, 0x09, "QE" }, |
| 497 | { 0x124, 0x0a, "eSDHC" }, |
| 498 | { 0x128, 0x0b, "eMA" }, |
| 499 | { 0x14c, 0x0c, "2D-ACE" }, |
| 500 | { 0x150, 0x0d, "USB2" }, |
| 501 | { 0x18c, 0x0e, "DEBUG" }, |
| 502 | }; |
| 503 | |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 504 | int board_init(void) |
| 505 | { |
| 506 | struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR; |
| 507 | |
| 508 | /* Set CCI-400 control override register to |
| 509 | * enable barrier transaction */ |
| 510 | out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER); |
Jason Jin | 644bc7e | 2014-10-17 15:26:32 +0800 | [diff] [blame] | 511 | /* |
| 512 | * Set CCI-400 Slave interface S0, S1, S2 Shareable Override Register |
| 513 | * All transactions are treated as non-shareable |
| 514 | */ |
| 515 | out_le32(&cci->slave[0].sha_ord, CCI400_SHAORD_NON_SHAREABLE); |
| 516 | out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE); |
| 517 | out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE); |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 518 | |
| 519 | select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT); |
| 520 | |
| 521 | #ifndef CONFIG_SYS_FSL_NO_SERDES |
| 522 | fsl_serdes_init(); |
| 523 | config_serdes_mux(); |
| 524 | #endif |
Zhao Qiang | 63e75fd | 2014-09-26 16:25:32 +0800 | [diff] [blame] | 525 | |
Xiubo Li | 660673a | 2014-11-21 17:40:59 +0800 | [diff] [blame] | 526 | ls102xa_config_smmu_stream_id(dev_stream_id, |
| 527 | ARRAY_SIZE(dev_stream_id)); |
| 528 | |
Xiubo Li | e87f3b3 | 2014-11-21 17:40:58 +0800 | [diff] [blame] | 529 | #ifdef CONFIG_LS102XA_NS_ACCESS |
| 530 | enable_devices_ns_access(ns_dev, ARRAY_SIZE(ns_dev)); |
| 531 | #endif |
| 532 | |
Zhao Qiang | 63e75fd | 2014-09-26 16:25:32 +0800 | [diff] [blame] | 533 | #ifdef CONFIG_U_QE |
| 534 | u_qe_init(); |
| 535 | #endif |
| 536 | |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 537 | return 0; |
| 538 | } |
| 539 | |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 540 | int ft_board_setup(void *blob, bd_t *bd) |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 541 | { |
| 542 | ft_cpu_setup(blob, bd); |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 543 | |
Minghuan Lian | da41902 | 2014-10-31 13:43:44 +0800 | [diff] [blame] | 544 | #ifdef CONFIG_PCIE_LAYERSCAPE |
| 545 | ft_pcie_setup(blob, bd); |
| 546 | #endif |
| 547 | |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 548 | return 0; |
Wang Huan | 550e3dc | 2014-09-05 13:52:44 +0800 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | u8 flash_read8(void *addr) |
| 552 | { |
| 553 | return __raw_readb(addr + 1); |
| 554 | } |
| 555 | |
| 556 | void flash_write16(u16 val, void *addr) |
| 557 | { |
| 558 | u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00)); |
| 559 | |
| 560 | __raw_writew(shftval, addr); |
| 561 | } |
| 562 | |
| 563 | u16 flash_read16(void *addr) |
| 564 | { |
| 565 | u16 val = __raw_readw(addr); |
| 566 | |
| 567 | return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00); |
| 568 | } |