1 // SPDX-License-Identifier: GPL-2.0+
12 #include <fdt_support.h>
13 #include <linux/libfdt.h>
14 #include <env_internal.h>
15 #include <asm/arch-fsl-layerscape/soc.h>
16 #include <asm/arch-fsl-layerscape/fsl_icid.h>
18 #include <asm/arch/soc.h>
19 #ifdef CONFIG_FSL_LS_PPA
20 #include <asm/arch/ppa.h>
22 #include <fsl_immap.h>
27 #include "../common/qixis.h"
28 #include "../drivers/net/fsl_enetc.h"
30 DECLARE_GLOBAL_DATA_PTR;
32 int config_board_mux(void)
34 #if defined(CONFIG_TARGET_LS1028AQDS) && defined(CONFIG_FSL_QIXIS)
37 reg = QIXIS_READ(brdcfg[13]);
39 * 7-6 | Controls I2C3 routing (net CFG_MUX_I2C3):
40 * I2C3 | 10= Routes {SCL, SDA} to CAN1 transceiver as {TX, RX}.
41 * 5-4 | Controls I2C4 routing (net CFG_MUX_I2C4):
42 * I2C4 |11= Routes {SCL, SDA} to CAN2 transceiver as {TX, RX}.
46 QIXIS_WRITE(brdcfg[13], reg);
48 reg = QIXIS_READ(brdcfg[15]);
50 * 7 | Controls the CAN1 transceiver (net CFG_CAN1_STBY):
51 * CAN1 | 0= CAN #1 transceiver enabled
52 * 6 | Controls the CAN2 transceiver (net CFG_CAN2_STBY):
53 * CAN2 | 0= CAN #2 transceiver enabled
56 QIXIS_WRITE(brdcfg[15], reg);
63 #ifdef CONFIG_ENV_IS_NOWHERE
64 gd->env_addr = (ulong)&default_environment[0];
67 #ifdef CONFIG_FSL_CAAM
71 #ifdef CONFIG_FSL_LS_PPA
75 #ifndef CONFIG_SYS_EARLY_PCI_INIT
79 #if defined(CONFIG_TARGET_LS1028ARDB)
80 u8 val = I2C_MUX_CH_DEFAULT;
83 i2c_write(I2C_MUX_PCA_ADDR_PRI, 0x0b, 1, &val, 1);
87 if (!i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, &dev))
88 dm_i2c_write(dev, 0x0b, &val, 1);
92 #if defined(CONFIG_TARGET_LS1028ARDB)
95 reg = QIXIS_READ(brdcfg[4]);
98 * 3 | DisplayPort Power Enable (net DP_PWR_EN):
99 * DPPWR | 0= DP_PWR is enabled.
101 reg &= ~(DP_PWD_EN_DEFAULT_MASK);
102 QIXIS_WRITE(brdcfg[4], reg);
107 int board_eth_init(bd_t *bis)
109 return pci_eth_init(bis);
112 #ifdef CONFIG_MISC_INIT_R
113 int misc_init_r(void)
121 int board_early_init_f(void)
123 #ifdef CONFIG_SYS_I2C_EARLY_INIT
127 fsl_lsch3_early_init_f();
131 void detail_board_ddr_info(void)
134 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
138 int esdhc_status_fixup(void *blob, const char *compat)
140 void __iomem *dcfg_ccsr = (void __iomem *)DCFG_BASE;
141 char esdhc1_path[] = "/soc/mmc@2140000";
142 char esdhc2_path[] = "/soc/mmc@2150000";
143 char dspi1_path[] = "/soc/spi@2100000";
144 char dspi2_path[] = "/soc/spi@2110000";
145 u32 mux_sdhc1, mux_sdhc2;
149 * The PMUX IO-expander for mux select is used to control
150 * the muxing of various onboard interfaces.
153 io = in_le32(dcfg_ccsr + DCFG_RCWSR12);
154 mux_sdhc1 = (io >> DCFG_RCWSR12_SDHC_SHIFT) & DCFG_RCWSR12_SDHC_MASK;
156 /* Disable esdhc1/dspi1 if not selected. */
158 do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
159 sizeof("disabled"), 1);
161 do_fixup_by_path(blob, dspi1_path, "status", "disabled",
162 sizeof("disabled"), 1);
164 io = in_le32(dcfg_ccsr + DCFG_RCWSR13);
165 mux_sdhc2 = (io >> DCFG_RCWSR13_SDHC_SHIFT) & DCFG_RCWSR13_SDHC_MASK;
167 /* Disable esdhc2/dspi2 if not selected. */
169 do_fixup_by_path(blob, esdhc2_path, "status", "disabled",
170 sizeof("disabled"), 1);
172 do_fixup_by_path(blob, dspi2_path, "status", "disabled",
173 sizeof("disabled"), 1);
178 #ifdef CONFIG_OF_BOARD_SETUP
179 int ft_board_setup(void *blob, bd_t *bd)
181 u64 base[CONFIG_NR_DRAM_BANKS];
182 u64 size[CONFIG_NR_DRAM_BANKS];
184 ft_cpu_setup(blob, bd);
186 /* fixup DT for the two GPP DDR banks */
187 base[0] = gd->bd->bi_dram[0].start;
188 size[0] = gd->bd->bi_dram[0].size;
189 base[1] = gd->bd->bi_dram[1].start;
190 size[1] = gd->bd->bi_dram[1].size;
192 #ifdef CONFIG_RESV_RAM
193 /* reduce size if reserved memory is within this bank */
194 if (gd->arch.resv_ram >= base[0] &&
195 gd->arch.resv_ram < base[0] + size[0])
196 size[0] = gd->arch.resv_ram - base[0];
197 else if (gd->arch.resv_ram >= base[1] &&
198 gd->arch.resv_ram < base[1] + size[1])
199 size[1] = gd->arch.resv_ram - base[1];
202 fdt_fixup_memory_banks(blob, base, size, 2);
204 fdt_fixup_icid(blob);
206 #ifdef CONFIG_FSL_ENETC
207 fdt_fixup_enetc_mac(blob);
214 #ifdef CONFIG_FSL_QIXIS
217 #ifdef CONFIG_TFABOOT
218 enum boot_src src = get_boot_src();
225 static const char *freq[6] = {"100.00", "125.00", "156.25",
226 "161.13", "322.26", "100.00 SS"};
229 /* find the board details */
247 sw = QIXIS_READ(arch);
248 printf("Board: %s-%s, Version: %c, boot from ",
249 buf, board, (sw & 0xf) + 'A' - 1);
251 sw = QIXIS_READ(brdcfg[0]);
252 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
254 #ifdef CONFIG_TFABOOT
255 if (src == BOOT_SOURCE_SD_MMC) {
257 } else if (src == BOOT_SOURCE_SD_MMC2) {
261 #ifdef CONFIG_SD_BOOT
263 #elif defined(CONFIG_EMMC_BOOT)
275 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
279 #ifdef CONFIG_TFABOOT
283 printf("FPGA: v%d (%s)\n", QIXIS_READ(scver), board);
284 puts("SERDES1 Reference : ");
286 sw = QIXIS_READ(brdcfg[2]);
287 #ifdef CONFIG_TARGET_LS1028ARDB
288 clock = (sw >> 6) & 3;
290 clock = (sw >> 4) & 0xf;
293 printf("Clock1 = %sMHz ", freq[clock]);
294 #ifdef CONFIG_TARGET_LS1028ARDB
295 clock = (sw >> 4) & 3;
299 printf("Clock2 = %sMHz\n", freq[clock]);