1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2016 Freescale Semiconductor, Inc.
8 #include <fdt_support.h>
10 #include <semihosting.h>
12 #include <asm/global_data.h>
14 #include <asm/arch/clock.h>
15 #include <asm/arch/fsl_serdes.h>
16 #include <asm/arch/ppa.h>
17 #include <asm/arch/soc.h>
18 #include <asm/arch-fsl-layerscape/fsl_icid.h>
25 #include <fsl_esdhc.h>
26 #include <power/mc34vr500_pmic.h>
30 DECLARE_GLOBAL_DATA_PTR;
32 struct serial_device *default_serial_console(void)
34 #if IS_ENABLED(CONFIG_SEMIHOSTING_SERIAL)
35 if (semihosting_enabled())
36 return &serial_smh_device;
38 return &eserial1_device;
41 int board_early_init_f(void)
43 fsl_lsch2_early_init_f();
48 #ifndef CONFIG_SPL_BUILD
51 static const char *freq[2] = {"100.00MHZ", "156.25MHZ"};
52 u8 cfg_rcw_src1, cfg_rcw_src2;
56 puts("Board: LS1046ARDB, boot from ");
58 cfg_rcw_src1 = CPLD_READ(cfg_rcw_src1);
59 cfg_rcw_src2 = CPLD_READ(cfg_rcw_src2);
60 cpld_rev_bit(&cfg_rcw_src1);
61 cfg_rcw_src = cfg_rcw_src1;
62 cfg_rcw_src = (cfg_rcw_src << 1) | cfg_rcw_src2;
64 if (cfg_rcw_src == 0x44)
65 printf("QSPI vBank %d\n", CPLD_READ(vbank));
66 else if (cfg_rcw_src == 0x40)
69 puts("Invalid setting of SW5\n");
71 printf("CPLD: V%x.%x\nPCBA: V%x.0\n", CPLD_READ(cpld_ver),
72 CPLD_READ(cpld_ver_sub), CPLD_READ(pcba_ver));
74 puts("SERDES Reference Clocks:\n");
75 sd1refclk_sel = CPLD_READ(sd1refclk_sel);
76 printf("SD1_CLK1 = %s, SD1_CLK2 = %s\n", freq[sd1refclk_sel], freq[0]);
83 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
85 #ifdef CONFIG_NXP_ESBC
87 * In case of Secure Boot, the IBR configures the SMMU
88 * to allow only Secure transactions.
89 * SMMU must be reset in bypass mode.
90 * Set the ClientPD bit and Clear the USFCFG Bit
93 val = (in_le32(SMMU_SCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
94 out_le32(SMMU_SCR0, val);
95 val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
96 out_le32(SMMU_NSCR0, val);
99 #ifdef CONFIG_FSL_CAAM
103 #ifdef CONFIG_FSL_LS_PPA
107 #if !defined(CONFIG_SYS_EARLY_PCI_INIT) && defined(CONFIG_DM_ETH)
111 /* invert AQR105 IRQ pins polarity */
112 out_be32(&scfg->intpcr, AQR105_IRQ_MASK);
117 int board_setup_core_volt(u32 vdd)
121 en_0v9 = (vdd == 900) ? true : false;
122 cpld_select_core_volt(en_0v9);
127 int get_serdes_volt(void)
129 return mc34vr500_get_sw_volt(SW4);
132 int set_serdes_volt(int svdd)
134 return mc34vr500_set_sw_volt(SW4, svdd);
137 int power_init_board(void)
141 ret = power_mc34vr500_init(0);
150 void config_board_mux(void)
152 #ifdef CONFIG_HAS_FSL_XHCI_USB
153 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
156 /* USB3 is not used, configure mux to IIC4_SCL/IIC4_SDA */
157 out_be32(&scfg->rcwpmuxcr0, 0x3300);
158 out_be32(&scfg->usbdrvvbus_selcr, SCFG_USBDRVVBUS_SELCR_USB1);
159 usb_pwrfault = (SCFG_USBPWRFAULT_DEDICATED <<
160 SCFG_USBPWRFAULT_USB3_SHIFT) |
161 (SCFG_USBPWRFAULT_DEDICATED <<
162 SCFG_USBPWRFAULT_USB2_SHIFT) |
163 (SCFG_USBPWRFAULT_SHARED <<
164 SCFG_USBPWRFAULT_USB1_SHIFT);
165 out_be32(&scfg->usbpwrfault_selcr, usb_pwrfault);
169 #ifdef CONFIG_MISC_INIT_R
170 int misc_init_r(void)
177 int ft_board_setup(void *blob, struct bd_info *bd)
179 u64 base[CONFIG_NR_DRAM_BANKS];
180 u64 size[CONFIG_NR_DRAM_BANKS];
182 /* fixup DT for the two DDR banks */
183 base[0] = gd->bd->bi_dram[0].start;
184 size[0] = gd->bd->bi_dram[0].size;
185 base[1] = gd->bd->bi_dram[1].start;
186 size[1] = gd->bd->bi_dram[1].size;
188 fdt_fixup_memory_banks(blob, base, size, 2);
189 ft_cpu_setup(blob, bd);
191 #ifdef CONFIG_SYS_DPAA_FMAN
192 #ifndef CONFIG_DM_ETH
193 fdt_fixup_fman_ethernet(blob);
197 fdt_fixup_icid(blob);