1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014-2015 Freescale Semiconductor
9 #include <asm/arch/fsl_serdes.h>
10 #include <asm/arch/soc.h>
12 #include <asm/global_data.h>
13 #include <asm/arch-fsl-layerscape/config.h>
14 #include <asm/arch-fsl-layerscape/ns_access.h>
15 #include <asm/arch-fsl-layerscape/fsl_icid.h>
16 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
19 #ifdef CONFIG_SYS_FSL_DDR
20 #include <fsl_ddr_sdram.h>
23 #ifdef CONFIG_CHAIN_OF_TRUST
24 #include <fsl_validate.h>
26 #include <fsl_immap.h>
28 #include <environment.h>
29 DECLARE_GLOBAL_DATA_PTR;
32 bool soc_has_dp_ddr(void)
34 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
35 u32 svr = gur_in32(&gur->svr);
37 /* LS2085A, LS2088A, LS2048A has DP_DDR */
38 if ((SVR_SOC_VER(svr) == SVR_LS2085A) ||
39 (SVR_SOC_VER(svr) == SVR_LS2088A) ||
40 (SVR_SOC_VER(svr) == SVR_LS2048A))
46 bool soc_has_aiop(void)
48 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
49 u32 svr = gur_in32(&gur->svr);
51 /* LS2085A has AIOP */
52 if (SVR_SOC_VER(svr) == SVR_LS2085A)
58 static inline void set_usb_txvreftune(u32 __iomem *scfg, u32 offset)
60 scfg_clrsetbits32(scfg + offset / 4,
62 SCFG_USB_TXVREFTUNE << 6);
65 static void erratum_a009008(void)
67 #ifdef CONFIG_SYS_FSL_ERRATUM_A009008
68 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
70 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
71 defined(CONFIG_ARCH_LS1012A)
72 set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB1);
73 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
74 set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB2);
75 set_usb_txvreftune(scfg, SCFG_USB3PRM1CR_USB3);
77 #elif defined(CONFIG_ARCH_LS2080A)
78 set_usb_txvreftune(scfg, SCFG_USB3PRM1CR);
80 #endif /* CONFIG_SYS_FSL_ERRATUM_A009008 */
83 static inline void set_usb_sqrxtune(u32 __iomem *scfg, u32 offset)
85 scfg_clrbits32(scfg + offset / 4,
86 SCFG_USB_SQRXTUNE_MASK << 23);
89 static void erratum_a009798(void)
91 #ifdef CONFIG_SYS_FSL_ERRATUM_A009798
92 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
94 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
95 defined(CONFIG_ARCH_LS1012A)
96 set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB1);
97 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
98 set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB2);
99 set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR_USB3);
101 #elif defined(CONFIG_ARCH_LS2080A)
102 set_usb_sqrxtune(scfg, SCFG_USB3PRM1CR);
104 #endif /* CONFIG_SYS_FSL_ERRATUM_A009798 */
107 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
108 defined(CONFIG_ARCH_LS1012A)
109 static inline void set_usb_pcstxswingfull(u32 __iomem *scfg, u32 offset)
111 scfg_clrsetbits32(scfg + offset / 4,
113 SCFG_USB_PCSTXSWINGFULL << 9);
117 static void erratum_a008997(void)
119 #ifdef CONFIG_SYS_FSL_ERRATUM_A008997
120 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
121 defined(CONFIG_ARCH_LS1012A)
122 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
124 set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB1);
125 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
126 set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB2);
127 set_usb_pcstxswingfull(scfg, SCFG_USB3PRM2CR_USB3);
129 #elif defined(CONFIG_ARCH_LS1028A)
130 clrsetbits_le32(DCSR_BASE + DCSR_USB_IOCR1,
132 DCSR_USB_PCSTXSWINGFULL << 11);
134 #endif /* CONFIG_SYS_FSL_ERRATUM_A008997 */
137 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
138 defined(CONFIG_ARCH_LS1012A)
140 #define PROGRAM_USB_PHY_RX_OVRD_IN_HI(phy) \
141 out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_1); \
142 out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_2); \
143 out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_3); \
144 out_be16((phy) + SCFG_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_4)
146 #elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A) || \
147 defined(CONFIG_ARCH_LS1028A)
149 #define PROGRAM_USB_PHY_RX_OVRD_IN_HI(phy) \
150 out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_1); \
151 out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_2); \
152 out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_3); \
153 out_le16((phy) + DCSR_USB_PHY_RX_OVRD_IN_HI, USB_PHY_RX_EQ_VAL_4)
157 static void erratum_a009007(void)
159 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A) || \
160 defined(CONFIG_ARCH_LS1012A)
161 void __iomem *usb_phy = (void __iomem *)SCFG_USB_PHY1;
163 PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
164 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
165 usb_phy = (void __iomem *)SCFG_USB_PHY2;
166 PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
168 usb_phy = (void __iomem *)SCFG_USB_PHY3;
169 PROGRAM_USB_PHY_RX_OVRD_IN_HI(usb_phy);
171 #elif defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LS1088A) || \
172 defined(CONFIG_ARCH_LS1028A)
173 void __iomem *dcsr = (void __iomem *)DCSR_BASE;
175 PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY1);
176 PROGRAM_USB_PHY_RX_OVRD_IN_HI(dcsr + DCSR_USB_PHY2);
177 #endif /* CONFIG_SYS_FSL_ERRATUM_A009007 */
180 #if defined(CONFIG_FSL_LSCH3)
182 * This erratum requires setting a value to eddrtqcr1 to
183 * optimal the DDR performance.
185 static void erratum_a008336(void)
187 #ifdef CONFIG_SYS_FSL_ERRATUM_A008336
190 #ifdef CONFIG_SYS_FSL_DCSR_DDR_ADDR
191 eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR_ADDR + 0x800;
192 if (fsl_ddr_get_version(0) == 0x50200)
193 out_le32(eddrtqcr1, 0x63b30002);
195 #ifdef CONFIG_SYS_FSL_DCSR_DDR2_ADDR
196 eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR2_ADDR + 0x800;
197 if (fsl_ddr_get_version(0) == 0x50200)
198 out_le32(eddrtqcr1, 0x63b30002);
204 * This erratum requires a register write before being Memory
205 * controller 3 being enabled.
207 static void erratum_a008514(void)
209 #ifdef CONFIG_SYS_FSL_ERRATUM_A008514
212 #ifdef CONFIG_SYS_FSL_DCSR_DDR3_ADDR
213 eddrtqcr1 = (void *)CONFIG_SYS_FSL_DCSR_DDR3_ADDR + 0x800;
214 out_le32(eddrtqcr1, 0x63b20002);
218 #ifdef CONFIG_SYS_FSL_ERRATUM_A009635
219 #define PLATFORM_CYCLE_ENV_VAR "a009635_interval_val"
221 static unsigned long get_internval_val_mhz(void)
223 char *interval = env_get(PLATFORM_CYCLE_ENV_VAR);
225 * interval is the number of platform cycles(MHz) between
226 * wake up events generated by EPU.
228 ulong interval_mhz = get_bus_freq(0) / (1000 * 1000);
231 interval_mhz = simple_strtoul(interval, NULL, 10);
236 void erratum_a009635(void)
239 unsigned long interval_mhz = get_internval_val_mhz();
244 val = in_le32(DCSR_CGACRE5);
245 writel(val | 0x00000200, DCSR_CGACRE5);
247 val = in_le32(EPU_EPCMPR5);
248 writel(interval_mhz, EPU_EPCMPR5);
249 val = in_le32(EPU_EPCCR5);
250 writel(val | 0x82820000, EPU_EPCCR5);
251 val = in_le32(EPU_EPSMCR5);
252 writel(val | 0x002f0000, EPU_EPSMCR5);
253 val = in_le32(EPU_EPECR5);
254 writel(val | 0x20000000, EPU_EPECR5);
255 val = in_le32(EPU_EPGCR);
256 writel(val | 0x80000000, EPU_EPGCR);
258 #endif /* CONFIG_SYS_FSL_ERRATUM_A009635 */
260 static void erratum_rcw_src(void)
262 #if defined(CONFIG_SPL) && defined(CONFIG_NAND_BOOT)
263 u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
264 u32 __iomem *dcfg_dcsr = (u32 __iomem *)DCFG_DCSR_BASE;
267 val = in_le32(dcfg_ccsr + DCFG_PORSR1 / 4);
268 val &= ~DCFG_PORSR1_RCW_SRC;
269 val |= DCFG_PORSR1_RCW_SRC_NOR;
270 out_le32(dcfg_dcsr + DCFG_DCSR_PORCR1 / 4, val);
274 #define I2C_DEBUG_REG 0x6
275 #define I2C_GLITCH_EN 0x8
277 * This erratum requires setting glitch_en bit to enable
278 * digital glitch filter to improve clock stability.
280 #ifdef CONFIG_SYS_FSL_ERRATUM_A009203
281 static void erratum_a009203(void)
283 #ifdef CONFIG_SYS_I2C
285 #ifdef I2C1_BASE_ADDR
286 ptr = (u8 __iomem *)(I2C1_BASE_ADDR + I2C_DEBUG_REG);
288 writeb(I2C_GLITCH_EN, ptr);
290 #ifdef I2C2_BASE_ADDR
291 ptr = (u8 __iomem *)(I2C2_BASE_ADDR + I2C_DEBUG_REG);
293 writeb(I2C_GLITCH_EN, ptr);
295 #ifdef I2C3_BASE_ADDR
296 ptr = (u8 __iomem *)(I2C3_BASE_ADDR + I2C_DEBUG_REG);
298 writeb(I2C_GLITCH_EN, ptr);
300 #ifdef I2C4_BASE_ADDR
301 ptr = (u8 __iomem *)(I2C4_BASE_ADDR + I2C_DEBUG_REG);
303 writeb(I2C_GLITCH_EN, ptr);
309 void bypass_smmu(void)
312 val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
313 out_le32(SMMU_SCR0, val);
314 val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
315 out_le32(SMMU_NSCR0, val);
317 void fsl_lsch3_early_init_f(void)
320 #ifdef CONFIG_FSL_IFC
321 init_early_memctl_regs(); /* tighten IFC timing */
323 #ifdef CONFIG_SYS_FSL_ERRATUM_A009203
332 #ifdef CONFIG_CHAIN_OF_TRUST
333 /* In case of Secure Boot, the IBR configures the SMMU
334 * to allow only Secure transactions.
335 * SMMU must be reset in bypass mode.
336 * Set the ClientPD bit and Clear the USFCFG Bit
338 if (fsl_check_boot_mode_secure() == 1)
343 /* Get VDD in the unit mV from voltage ID */
344 int get_core_volt_from_fuse(void)
346 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
351 /* get the voltage ID from fuse status register */
352 fusesr = in_le32(&gur->dcfg_fusesr);
353 debug("%s: fusesr = 0x%x\n", __func__, fusesr);
354 vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_ALTVID_SHIFT) &
355 FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK;
356 if ((vid == 0) || (vid == FSL_CHASSIS3_DCFG_FUSESR_ALTVID_MASK)) {
357 vid = (fusesr >> FSL_CHASSIS3_DCFG_FUSESR_VID_SHIFT) &
358 FSL_CHASSIS3_DCFG_FUSESR_VID_MASK;
360 debug("%s: VID = 0x%x\n", __func__, vid);
362 case 0x00: /* VID isn't supported */
364 debug("%s: The VID feature is not supported\n", __func__);
366 case 0x08: /* 0.9V silicon */
369 case 0x10: /* 1.0V silicon */
372 default: /* Other core voltage */
374 debug("%s: The VID(%x) isn't supported\n", __func__, vid);
377 debug("%s: The required minimum volt of CORE is %dmV\n", __func__, vdd);
382 #elif defined(CONFIG_FSL_LSCH2)
384 static void erratum_a009929(void)
386 #ifdef CONFIG_SYS_FSL_ERRATUM_A009929
387 struct ccsr_gur *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
388 u32 __iomem *dcsr_cop_ccp = (void *)CONFIG_SYS_DCSR_COP_CCP_ADDR;
389 u32 rstrqmr1 = gur_in32(&gur->rstrqmr1);
391 rstrqmr1 |= 0x00000400;
392 gur_out32(&gur->rstrqmr1, rstrqmr1);
393 writel(0x01000000, dcsr_cop_ccp);
398 * This erratum requires setting a value to eddrtqcr1 to optimal
399 * the DDR performance. The eddrtqcr1 register is in SCFG space
400 * of LS1043A and the offset is 0x157_020c.
402 #if defined(CONFIG_SYS_FSL_ERRATUM_A009660) \
403 && defined(CONFIG_SYS_FSL_ERRATUM_A008514)
404 #error A009660 and A008514 can not be both enabled.
407 static void erratum_a009660(void)
409 #ifdef CONFIG_SYS_FSL_ERRATUM_A009660
410 u32 *eddrtqcr1 = (void *)CONFIG_SYS_FSL_SCFG_ADDR + 0x20c;
411 out_be32(eddrtqcr1, 0x63b20042);
415 static void erratum_a008850_early(void)
417 #ifdef CONFIG_SYS_FSL_ERRATUM_A008850
419 struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR +
420 CONFIG_SYS_CCI400_OFFSET);
421 struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
423 /* Skip if running at lower exception level */
424 if (current_el() < 3)
427 /* disables propagation of barrier transactions to DDRC from CCI400 */
428 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
430 /* disable the re-ordering in DDRC */
431 ddr_out32(&ddr->eor, DDR_EOR_RD_REOD_DIS | DDR_EOR_WD_REOD_DIS);
435 void erratum_a008850_post(void)
437 #ifdef CONFIG_SYS_FSL_ERRATUM_A008850
439 struct ccsr_cci400 __iomem *cci = (void *)(CONFIG_SYS_IMMR +
440 CONFIG_SYS_CCI400_OFFSET);
441 struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
444 /* Skip if running at lower exception level */
445 if (current_el() < 3)
448 /* enable propagation of barrier transactions to DDRC from CCI400 */
449 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
451 /* enable the re-ordering in DDRC */
452 tmp = ddr_in32(&ddr->eor);
453 tmp &= ~(DDR_EOR_RD_REOD_DIS | DDR_EOR_WD_REOD_DIS);
454 ddr_out32(&ddr->eor, tmp);
458 #ifdef CONFIG_SYS_FSL_ERRATUM_A010315
459 void erratum_a010315(void)
463 for (i = PCIE1; i <= PCIE4; i++)
464 if (!is_serdes_configured(i)) {
465 debug("PCIe%d: disabled all R/W permission!\n", i);
466 set_pcie_ns_access(i, 0);
471 static void erratum_a010539(void)
473 #if defined(CONFIG_SYS_FSL_ERRATUM_A010539) && defined(CONFIG_QSPI_BOOT)
474 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
477 porsr1 = in_be32(&gur->porsr1);
478 porsr1 &= ~FSL_CHASSIS2_CCSR_PORSR1_RCW_MASK;
479 out_be32((void *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1),
481 out_be32((void *)(CONFIG_SYS_FSL_SCFG_ADDR + 0x1a8), 0xffffffff);
485 /* Get VDD in the unit mV from voltage ID */
486 int get_core_volt_from_fuse(void)
488 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
493 fusesr = in_be32(&gur->dcfg_fusesr);
494 debug("%s: fusesr = 0x%x\n", __func__, fusesr);
495 vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_ALTVID_SHIFT) &
496 FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK;
497 if ((vid == 0) || (vid == FSL_CHASSIS2_DCFG_FUSESR_ALTVID_MASK)) {
498 vid = (fusesr >> FSL_CHASSIS2_DCFG_FUSESR_VID_SHIFT) &
499 FSL_CHASSIS2_DCFG_FUSESR_VID_MASK;
501 debug("%s: VID = 0x%x\n", __func__, vid);
503 case 0x00: /* VID isn't supported */
505 debug("%s: The VID feature is not supported\n", __func__);
507 case 0x08: /* 0.9V silicon */
510 case 0x10: /* 1.0V silicon */
513 default: /* Other core voltage */
515 printf("%s: The VID(%x) isn't supported\n", __func__, vid);
518 debug("%s: The required minimum volt of CORE is %dmV\n", __func__, vdd);
523 __weak int board_switch_core_volt(u32 vdd)
528 static int setup_core_volt(u32 vdd)
530 return board_setup_core_volt(vdd);
533 #ifdef CONFIG_SYS_FSL_DDR
534 static void ddr_enable_0v9_volt(bool en)
536 struct ccsr_ddr __iomem *ddr = (void *)CONFIG_SYS_FSL_DDR_ADDR;
539 tmp = ddr_in32(&ddr->ddr_cdr1);
542 tmp |= DDR_CDR1_V0PT9_EN;
544 tmp &= ~DDR_CDR1_V0PT9_EN;
546 ddr_out32(&ddr->ddr_cdr1, tmp);
550 int setup_chip_volt(void)
554 vdd = get_core_volt_from_fuse();
555 /* Nothing to do for silicons doesn't support VID */
559 if (setup_core_volt(vdd))
560 printf("%s: Switch core VDD to %dmV failed\n", __func__, vdd);
561 #ifdef CONFIG_SYS_HAS_SERDES
562 if (setup_serdes_volt(vdd))
563 printf("%s: Switch SVDD to %dmV failed\n", __func__, vdd);
566 #ifdef CONFIG_SYS_FSL_DDR
568 ddr_enable_0v9_volt(true);
574 #ifdef CONFIG_FSL_PFE
575 void init_pfe_scfg_dcfg_regs(void)
577 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
580 out_be32(&scfg->pfeasbcr,
581 in_be32(&scfg->pfeasbcr) | SCFG_PFEASBCR_AWCACHE0);
582 out_be32(&scfg->pfebsbcr,
583 in_be32(&scfg->pfebsbcr) | SCFG_PFEASBCR_AWCACHE0);
585 /* CCI-400 QoS settings for PFE */
586 out_be32(&scfg->wr_qos1, (unsigned int)(SCFG_WR_QOS1_PFE1_QOS
587 | SCFG_WR_QOS1_PFE2_QOS));
588 out_be32(&scfg->rd_qos1, (unsigned int)(SCFG_RD_QOS1_PFE1_QOS
589 | SCFG_RD_QOS1_PFE2_QOS));
591 ecccr2 = in_be32(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_ECCCR2);
592 out_be32((void *)CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_ECCCR2,
593 ecccr2 | (unsigned int)DISABLE_PFE_ECC);
597 void fsl_lsch2_early_init_f(void)
599 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
600 CONFIG_SYS_CCI400_OFFSET);
601 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
602 #if defined(CONFIG_FSL_QSPI) && defined(CONFIG_TFABOOT)
606 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
607 enable_layerscape_ns_access();
610 #ifdef CONFIG_FSL_IFC
611 init_early_memctl_regs(); /* tighten IFC timing */
614 #if defined(CONFIG_FSL_QSPI) && defined(CONFIG_TFABOOT)
615 src = get_boot_src();
616 if (src != BOOT_SOURCE_QSPI_NOR)
617 out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
619 #if defined(CONFIG_FSL_QSPI) && !defined(CONFIG_QSPI_BOOT)
620 out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
623 /* Make SEC reads and writes snoopable */
624 setbits_be32(&scfg->snpcnfgcr, SCFG_SNPCNFGCR_SECRDSNP |
625 SCFG_SNPCNFGCR_SECWRSNP |
626 SCFG_SNPCNFGCR_SATARDSNP |
627 SCFG_SNPCNFGCR_SATAWRSNP);
630 * Enable snoop requests and DVM message requests for
631 * Slave insterface S4 (A53 core cluster)
633 if (current_el() == 3) {
634 out_le32(&cci->slave[4].snoop_ctrl,
635 CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
639 * Program Central Security Unit (CSU) to grant access
640 * permission for USB 2.0 controller
642 #if defined(CONFIG_ARCH_LS1012A) && defined(CONFIG_USB_EHCI_FSL)
643 if (current_el() == 3)
644 set_devices_ns_access(CSU_CSLX_USB_2, CSU_ALL_RW);
647 erratum_a008850_early(); /* part 1 of 2 */
656 #if defined(CONFIG_ARCH_LS1043A) || defined(CONFIG_ARCH_LS1046A)
662 #ifdef CONFIG_QSPI_AHB_INIT
663 /* Enable 4bytes address support and fast read */
664 int qspi_ahb_init(void)
666 u32 *qspi_lut, lut_key, *qspi_key;
668 qspi_key = (void *)SYS_FSL_QSPI_ADDR + 0x300;
669 qspi_lut = (void *)SYS_FSL_QSPI_ADDR + 0x310;
671 lut_key = in_be32(qspi_key);
673 if (lut_key == 0x5af05af0) {
674 /* That means the register is BE */
675 out_be32(qspi_key, 0x5af05af0);
676 /* Unlock the lut table */
677 out_be32(qspi_key + 1, 0x00000002);
678 out_be32(qspi_lut, 0x0820040c);
679 out_be32(qspi_lut + 1, 0x1c080c08);
680 out_be32(qspi_lut + 2, 0x00002400);
681 /* Lock the lut table */
682 out_be32(qspi_key, 0x5af05af0);
683 out_be32(qspi_key + 1, 0x00000001);
685 /* That means the register is LE */
686 out_le32(qspi_key, 0x5af05af0);
687 /* Unlock the lut table */
688 out_le32(qspi_key + 1, 0x00000002);
689 out_le32(qspi_lut, 0x0820040c);
690 out_le32(qspi_lut + 1, 0x1c080c08);
691 out_le32(qspi_lut + 2, 0x00002400);
692 /* Lock the lut table */
693 out_le32(qspi_key, 0x5af05af0);
694 out_le32(qspi_key + 1, 0x00000001);
701 #ifdef CONFIG_TFABOOT
702 #define MAX_BOOTCMD_SIZE 512
704 int fsl_setenv_bootcmd(void)
707 enum boot_src src = get_boot_src();
708 char bootcmd_str[MAX_BOOTCMD_SIZE];
711 #ifdef IFC_NOR_BOOTCOMMAND
712 case BOOT_SOURCE_IFC_NOR:
713 sprintf(bootcmd_str, IFC_NOR_BOOTCOMMAND);
716 #ifdef QSPI_NOR_BOOTCOMMAND
717 case BOOT_SOURCE_QSPI_NOR:
718 sprintf(bootcmd_str, QSPI_NOR_BOOTCOMMAND);
721 #ifdef XSPI_NOR_BOOTCOMMAND
722 case BOOT_SOURCE_XSPI_NOR:
723 sprintf(bootcmd_str, XSPI_NOR_BOOTCOMMAND);
726 #ifdef IFC_NAND_BOOTCOMMAND
727 case BOOT_SOURCE_IFC_NAND:
728 sprintf(bootcmd_str, IFC_NAND_BOOTCOMMAND);
731 #ifdef QSPI_NAND_BOOTCOMMAND
732 case BOOT_SOURCE_QSPI_NAND:
733 sprintf(bootcmd_str, QSPI_NAND_BOOTCOMMAND);
736 #ifdef XSPI_NAND_BOOTCOMMAND
737 case BOOT_SOURCE_XSPI_NAND:
738 sprintf(bootcmd_str, XSPI_NAND_BOOTCOMMAND);
741 #ifdef SD_BOOTCOMMAND
742 case BOOT_SOURCE_SD_MMC:
743 sprintf(bootcmd_str, SD_BOOTCOMMAND);
746 #ifdef SD2_BOOTCOMMAND
747 case BOOT_SOURCE_SD_MMC2:
748 sprintf(bootcmd_str, SD2_BOOTCOMMAND);
752 #ifdef QSPI_NOR_BOOTCOMMAND
753 sprintf(bootcmd_str, QSPI_NOR_BOOTCOMMAND);
758 ret = env_set("bootcmd", bootcmd_str);
760 printf("Failed to set bootcmd: ret = %d\n", ret);
766 int fsl_setenv_mcinitcmd(void)
769 enum boot_src src = get_boot_src();
772 #ifdef IFC_MC_INIT_CMD
773 case BOOT_SOURCE_IFC_NAND:
774 case BOOT_SOURCE_IFC_NOR:
775 ret = env_set("mcinitcmd", IFC_MC_INIT_CMD);
778 #ifdef QSPI_MC_INIT_CMD
779 case BOOT_SOURCE_QSPI_NAND:
780 case BOOT_SOURCE_QSPI_NOR:
781 ret = env_set("mcinitcmd", QSPI_MC_INIT_CMD);
784 #ifdef XSPI_MC_INIT_CMD
785 case BOOT_SOURCE_XSPI_NAND:
786 case BOOT_SOURCE_XSPI_NOR:
787 ret = env_set("mcinitcmd", XSPI_MC_INIT_CMD);
790 #ifdef SD_MC_INIT_CMD
791 case BOOT_SOURCE_SD_MMC:
792 ret = env_set("mcinitcmd", SD_MC_INIT_CMD);
795 #ifdef SD2_MC_INIT_CMD
796 case BOOT_SOURCE_SD_MMC2:
797 ret = env_set("mcinitcmd", SD2_MC_INIT_CMD);
801 #ifdef QSPI_MC_INIT_CMD
802 ret = env_set("mcinitcmd", QSPI_MC_INIT_CMD);
808 printf("Failed to set mcinitcmd: ret = %d\n", ret);
815 #ifdef CONFIG_BOARD_LATE_INIT
816 int board_late_init(void)
818 #ifdef CONFIG_CHAIN_OF_TRUST
819 fsl_setenv_chain_of_trust();
821 #ifdef CONFIG_TFABOOT
823 * check if gd->env_addr is default_environment; then setenv bootcmd
826 if (gd->env_addr + gd->reloc_off == (ulong)&default_environment[0]) {
827 fsl_setenv_bootcmd();
828 fsl_setenv_mcinitcmd();
832 * If the boot mode is secure, default environment is not present then
833 * setenv command needs to be run by default
835 #ifdef CONFIG_CHAIN_OF_TRUST
836 if ((fsl_check_boot_mode_secure() == 1)) {
837 fsl_setenv_bootcmd();
838 fsl_setenv_mcinitcmd();
842 #ifdef CONFIG_QSPI_AHB_INIT