1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2019-2022 NXP
12 #include <asm/global_data.h>
15 #include <fdt_support.h>
16 #include <linux/libfdt.h>
17 #include <env_internal.h>
18 #include <asm/arch-fsl-layerscape/soc.h>
19 #include <asm/arch-fsl-layerscape/fsl_icid.h>
21 #include <asm/arch/soc.h>
22 #ifdef CONFIG_FSL_LS_PPA
23 #include <asm/arch/ppa.h>
25 #include <fsl_immap.h>
30 #include "../common/qixis.h"
31 #include "../drivers/net/fsl_enetc.h"
33 DECLARE_GLOBAL_DATA_PTR;
35 int config_board_mux(void)
38 #if defined(CONFIG_TARGET_LS1028AQDS) && defined(CONFIG_FSL_QIXIS)
41 reg = QIXIS_READ(brdcfg[13]);
43 * 7-6 | Controls I2C3 routing (net CFG_MUX_I2C3):
44 * I2C3 | 10= Routes {SCL, SDA} to CAN1 transceiver as {TX, RX}.
45 * 5-4 | Controls I2C4 routing (net CFG_MUX_I2C4):
46 * I2C4 |11= Routes {SCL, SDA} to CAN2 transceiver as {TX, RX}.
50 QIXIS_WRITE(brdcfg[13], reg);
52 reg = QIXIS_READ(brdcfg[15]);
54 * 7 | Controls the CAN1 transceiver (net CFG_CAN1_STBY):
55 * CAN1 | 0= CAN #1 transceiver enabled
56 * 6 | Controls the CAN2 transceiver (net CFG_CAN2_STBY):
57 * CAN2 | 0= CAN #2 transceiver enabled
60 QIXIS_WRITE(brdcfg[15], reg);
68 u32 get_lpuart_clk(void)
70 return gd->bus_clk / CONFIG_SYS_FSL_LPUART_CLK_DIV;
76 #ifdef CONFIG_FSL_LS_PPA
80 #ifndef CONFIG_SYS_EARLY_PCI_INIT
84 #if defined(CONFIG_TARGET_LS1028ARDB)
85 u8 val = I2C_MUX_CH_DEFAULT;
87 #if !CONFIG_IS_ENABLED(DM_I2C)
88 i2c_write(I2C_MUX_PCA_ADDR_PRI, 0x0b, 1, &val, 1);
92 if (!i2c_get_chip_for_busnum(0, I2C_MUX_PCA_ADDR_PRI, 1, &dev))
93 dm_i2c_write(dev, 0x0b, &val, 1);
97 #if defined(CONFIG_TARGET_LS1028ARDB)
100 reg = QIXIS_READ(brdcfg[4]);
103 * 3 | DisplayPort Power Enable (net DP_PWR_EN):
104 * DPPWR | 0= DP_PWR is enabled.
106 reg &= ~(DP_PWD_EN_DEFAULT_MASK);
107 QIXIS_WRITE(brdcfg[4], reg);
112 int board_eth_init(struct bd_info *bis)
114 return pci_eth_init(bis);
117 #ifdef CONFIG_MISC_INIT_R
118 int misc_init_r(void)
126 int board_early_init_f(void)
132 #if defined(CONFIG_SYS_I2C_EARLY_INIT) && defined(CONFIG_SPL_BUILD)
136 fsl_lsch3_early_init_f();
141 * --------------------------------------------------------------
142 * 7-6 | Controls I2C3 routing (net CFG_MUX_I2C3):
143 * I2C3 | 11= Routes {SCL, SDA} to LPUART1 header as {SOUT, SIN}.
144 * --------------------------------------------------------------
145 * 5-4 | Controls I2C4 routing (net CFG_MUX_I2C4):
146 * I2C4 |11= Routes {SCL, SDA} to LPUART1 header as {CTS_B, RTS_B}.
148 /* use lpuart0 as system console */
149 uart = QIXIS_READ(brdcfg[13]);
150 uart &= ~CFG_LPUART_MUX_MASK;
151 uart |= CFG_LPUART_EN;
152 QIXIS_WRITE(brdcfg[13], uart);
158 void detail_board_ddr_info(void)
161 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
165 int esdhc_status_fixup(void *blob, const char *compat)
167 void __iomem *dcfg_ccsr = (void __iomem *)DCFG_BASE;
168 char esdhc1_path[] = "/soc/mmc@2140000";
169 char esdhc2_path[] = "/soc/mmc@2150000";
170 char dspi1_path[] = "/soc/spi@2100000";
171 char dspi2_path[] = "/soc/spi@2110000";
172 u32 mux_sdhc1, mux_sdhc2;
176 * The PMUX IO-expander for mux select is used to control
177 * the muxing of various onboard interfaces.
180 io = in_le32(dcfg_ccsr + DCFG_RCWSR12);
181 mux_sdhc1 = (io >> DCFG_RCWSR12_SDHC_SHIFT) & DCFG_RCWSR12_SDHC_MASK;
183 /* Disable esdhc1/dspi1 if not selected. */
185 do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
186 sizeof("disabled"), 1);
188 do_fixup_by_path(blob, dspi1_path, "status", "disabled",
189 sizeof("disabled"), 1);
191 io = in_le32(dcfg_ccsr + DCFG_RCWSR13);
192 mux_sdhc2 = (io >> DCFG_RCWSR13_SDHC_SHIFT) & DCFG_RCWSR13_SDHC_MASK;
194 /* Disable esdhc2/dspi2 if not selected. */
196 do_fixup_by_path(blob, esdhc2_path, "status", "disabled",
197 sizeof("disabled"), 1);
199 do_fixup_by_path(blob, dspi2_path, "status", "disabled",
200 sizeof("disabled"), 1);
205 #ifdef CONFIG_OF_BOARD_SETUP
206 int ft_board_setup(void *blob, struct bd_info *bd)
208 u64 base[CONFIG_NR_DRAM_BANKS];
209 u64 size[CONFIG_NR_DRAM_BANKS];
211 ft_cpu_setup(blob, bd);
213 /* fixup DT for the two GPP DDR banks */
214 base[0] = gd->bd->bi_dram[0].start;
215 size[0] = gd->bd->bi_dram[0].size;
216 base[1] = gd->bd->bi_dram[1].start;
217 size[1] = gd->bd->bi_dram[1].size;
219 #ifdef CONFIG_RESV_RAM
220 /* reduce size if reserved memory is within this bank */
221 if (gd->arch.resv_ram >= base[0] &&
222 gd->arch.resv_ram < base[0] + size[0])
223 size[0] = gd->arch.resv_ram - base[0];
224 else if (gd->arch.resv_ram >= base[1] &&
225 gd->arch.resv_ram < base[1] + size[1])
226 size[1] = gd->arch.resv_ram - base[1];
229 fdt_fixup_memory_banks(blob, base, size, 2);
231 fdt_fixup_icid(blob);
233 #ifdef CONFIG_FSL_ENETC
234 fdt_fixup_enetc_mac(blob);
241 #ifdef CONFIG_FSL_QIXIS
244 #ifdef CONFIG_TFABOOT
245 enum boot_src src = get_boot_src();
252 static const char *freq[6] = {"100.00", "125.00", "156.25",
253 "161.13", "322.26", "100.00 SS"};
256 /* find the board details */
274 sw = QIXIS_READ(arch);
275 printf("Board: %s-%s, Version: %c, boot from ",
276 buf, board, (sw & 0xf) + 'A' - 1);
278 sw = QIXIS_READ(brdcfg[0]);
279 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
281 #ifdef CONFIG_TFABOOT
282 if (src == BOOT_SOURCE_SD_MMC) {
284 } else if (src == BOOT_SOURCE_SD_MMC2) {
288 #ifdef CONFIG_SD_BOOT
290 #elif defined(CONFIG_EMMC_BOOT)
302 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
306 #ifdef CONFIG_TFABOOT
310 printf("FPGA: v%d (%s)\n", QIXIS_READ(scver), board);
311 puts("SERDES1 Reference : ");
313 sw = QIXIS_READ(brdcfg[2]);
314 #ifdef CONFIG_TARGET_LS1028ARDB
315 clock = (sw >> 6) & 3;
317 clock = (sw >> 4) & 0xf;
320 printf("Clock1 = %sMHz ", freq[clock]);
321 #ifdef CONFIG_TARGET_LS1028ARDB
322 clock = (sw >> 4) & 3;
326 printf("Clock2 = %sMHz\n", freq[clock]);
332 void *video_hw_init(void)