xref: /openbmc/u-boot/board/freescale/ls2080ardb/ls2080ardb.c (revision 77c07e7ed36cae250a3562ee4bed0fa537960354)
183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
244937214SPrabhakar Kushwaha /*
344937214SPrabhakar Kushwaha  * Copyright 2015 Freescale Semiconductor
4a7943fd4SAlison Wang  * Copyright 2017 NXP
544937214SPrabhakar Kushwaha  */
644937214SPrabhakar Kushwaha #include <common.h>
744937214SPrabhakar Kushwaha #include <malloc.h>
844937214SPrabhakar Kushwaha #include <errno.h>
944937214SPrabhakar Kushwaha #include <netdev.h>
1044937214SPrabhakar Kushwaha #include <fsl_ifc.h>
1144937214SPrabhakar Kushwaha #include <fsl_ddr.h>
1244937214SPrabhakar Kushwaha #include <asm/io.h>
1344937214SPrabhakar Kushwaha #include <hwconfig.h>
1444937214SPrabhakar Kushwaha #include <fdt_support.h>
15b08c8c48SMasahiro Yamada #include <linux/libfdt.h>
1644937214SPrabhakar Kushwaha #include <fsl-mc/fsl_mc.h>
1744937214SPrabhakar Kushwaha #include <environment.h>
18215b1fb9SAlexander Graf #include <efi_loader.h>
1944937214SPrabhakar Kushwaha #include <i2c.h>
204961eafcSYork Sun #include <asm/arch/mmu.h>
2144937214SPrabhakar Kushwaha #include <asm/arch/soc.h>
2254ad7b5aSSantan Kumar #include <asm/arch/ppa.h>
23fcfdb6d5SSaksham Jain #include <fsl_sec.h>
2444937214SPrabhakar Kushwaha 
25d1418c15SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
2644937214SPrabhakar Kushwaha #include "../common/qixis.h"
2744937214SPrabhakar Kushwaha #include "ls2080ardb_qixis.h"
28d1418c15SPriyanka Jain #endif
29ed2530d0SRai Harninder #include "../common/vid.h"
3044937214SPrabhakar Kushwaha 
3144937214SPrabhakar Kushwaha #define PIN_MUX_SEL_SDHC	0x00
3244937214SPrabhakar Kushwaha #define PIN_MUX_SEL_DSPI	0x0a
3344937214SPrabhakar Kushwaha 
3444937214SPrabhakar Kushwaha #define SET_SDHC_MUX_SEL(reg, value)	((reg & 0xf0) | value)
3544937214SPrabhakar Kushwaha DECLARE_GLOBAL_DATA_PTR;
3644937214SPrabhakar Kushwaha 
3744937214SPrabhakar Kushwaha enum {
3844937214SPrabhakar Kushwaha 	MUX_TYPE_SDHC,
3944937214SPrabhakar Kushwaha 	MUX_TYPE_DSPI,
4044937214SPrabhakar Kushwaha };
4144937214SPrabhakar Kushwaha 
get_qixis_addr(void)4244937214SPrabhakar Kushwaha unsigned long long get_qixis_addr(void)
4344937214SPrabhakar Kushwaha {
4444937214SPrabhakar Kushwaha 	unsigned long long addr;
4544937214SPrabhakar Kushwaha 
4644937214SPrabhakar Kushwaha 	if (gd->flags & GD_FLG_RELOC)
4744937214SPrabhakar Kushwaha 		addr = QIXIS_BASE_PHYS;
4844937214SPrabhakar Kushwaha 	else
4944937214SPrabhakar Kushwaha 		addr = QIXIS_BASE_PHYS_EARLY;
5044937214SPrabhakar Kushwaha 
5144937214SPrabhakar Kushwaha 	/*
5244937214SPrabhakar Kushwaha 	 * IFC address under 256MB is mapped to 0x30000000, any address above
5344937214SPrabhakar Kushwaha 	 * is mapped to 0x5_10000000 up to 4GB.
5444937214SPrabhakar Kushwaha 	 */
5544937214SPrabhakar Kushwaha 	addr = addr  > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000;
5644937214SPrabhakar Kushwaha 
5744937214SPrabhakar Kushwaha 	return addr;
5844937214SPrabhakar Kushwaha }
5944937214SPrabhakar Kushwaha 
checkboard(void)6044937214SPrabhakar Kushwaha int checkboard(void)
6144937214SPrabhakar Kushwaha {
62d1418c15SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
6344937214SPrabhakar Kushwaha 	u8 sw;
64d1418c15SPriyanka Jain #endif
6544937214SPrabhakar Kushwaha 	char buf[15];
6644937214SPrabhakar Kushwaha 
6744937214SPrabhakar Kushwaha 	cpu_name(buf);
6844937214SPrabhakar Kushwaha 	printf("Board: %s-RDB, ", buf);
6944937214SPrabhakar Kushwaha 
703049a583SPriyanka Jain #ifdef CONFIG_TARGET_LS2081ARDB
713049a583SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
723049a583SPriyanka Jain 	sw = QIXIS_READ(arch);
733049a583SPriyanka Jain 	printf("Board version: %c, ", (sw & 0xf) + 'A');
743049a583SPriyanka Jain 
753049a583SPriyanka Jain 	sw = QIXIS_READ(brdcfg[0]);
76da28a03eSPriyanka Jain 	sw = (sw >> QIXIS_QMAP_SHIFT) & QIXIS_QMAP_MASK;
773049a583SPriyanka Jain 	switch (sw) {
783049a583SPriyanka Jain 	case 0:
793049a583SPriyanka Jain 		puts("boot from QSPI DEV#0\n");
803049a583SPriyanka Jain 		puts("QSPI_CSA_1 mapped to QSPI DEV#1\n");
813049a583SPriyanka Jain 		break;
823049a583SPriyanka Jain 	case 1:
833049a583SPriyanka Jain 		puts("boot from QSPI DEV#1\n");
843049a583SPriyanka Jain 		puts("QSPI_CSA_1 mapped to QSPI DEV#0\n");
853049a583SPriyanka Jain 		break;
863049a583SPriyanka Jain 	case 2:
873049a583SPriyanka Jain 		puts("boot from QSPI EMU\n");
883049a583SPriyanka Jain 		puts("QSPI_CSA_1 mapped to QSPI DEV#0\n");
893049a583SPriyanka Jain 		break;
903049a583SPriyanka Jain 	case 3:
913049a583SPriyanka Jain 		puts("boot from QSPI EMU\n");
923049a583SPriyanka Jain 		puts("QSPI_CSA_1 mapped to QSPI DEV#1\n");
933049a583SPriyanka Jain 		break;
943049a583SPriyanka Jain 	case 4:
953049a583SPriyanka Jain 		puts("boot from QSPI DEV#0\n");
963049a583SPriyanka Jain 		puts("QSPI_CSA_1 mapped to QSPI EMU\n");
973049a583SPriyanka Jain 		break;
983049a583SPriyanka Jain 	default:
993049a583SPriyanka Jain 		printf("invalid setting of SW%u\n", sw);
1003049a583SPriyanka Jain 		break;
1013049a583SPriyanka Jain 	}
102f436fbfeSPriyanka Jain 	printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
1033049a583SPriyanka Jain #endif
1043049a583SPriyanka Jain 	puts("SERDES1 Reference : ");
1053049a583SPriyanka Jain 	printf("Clock1 = 100MHz ");
1063049a583SPriyanka Jain 	printf("Clock2 = 161.13MHz");
1073049a583SPriyanka Jain #else
108d1418c15SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
10944937214SPrabhakar Kushwaha 	sw = QIXIS_READ(arch);
11044937214SPrabhakar Kushwaha 	printf("Board Arch: V%d, ", sw >> 4);
11144937214SPrabhakar Kushwaha 	printf("Board version: %c, boot from ", (sw & 0xf) + 'A');
11244937214SPrabhakar Kushwaha 
11344937214SPrabhakar Kushwaha 	sw = QIXIS_READ(brdcfg[0]);
11444937214SPrabhakar Kushwaha 	sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
11544937214SPrabhakar Kushwaha 
11644937214SPrabhakar Kushwaha 	if (sw < 0x8)
11744937214SPrabhakar Kushwaha 		printf("vBank: %d\n", sw);
11844937214SPrabhakar Kushwaha 	else if (sw == 0x9)
11944937214SPrabhakar Kushwaha 		puts("NAND\n");
12044937214SPrabhakar Kushwaha 	else
12144937214SPrabhakar Kushwaha 		printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
12244937214SPrabhakar Kushwaha 
12344937214SPrabhakar Kushwaha 	printf("FPGA: v%d.%d\n", QIXIS_READ(scver), QIXIS_READ(tagdata));
124d1418c15SPriyanka Jain #endif
12544937214SPrabhakar Kushwaha 	puts("SERDES1 Reference : ");
12644937214SPrabhakar Kushwaha 	printf("Clock1 = 156.25MHz ");
12744937214SPrabhakar Kushwaha 	printf("Clock2 = 156.25MHz");
1283049a583SPriyanka Jain #endif
12944937214SPrabhakar Kushwaha 
13044937214SPrabhakar Kushwaha 	puts("\nSERDES2 Reference : ");
13144937214SPrabhakar Kushwaha 	printf("Clock1 = 100MHz ");
13244937214SPrabhakar Kushwaha 	printf("Clock2 = 100MHz\n");
13344937214SPrabhakar Kushwaha 
13444937214SPrabhakar Kushwaha 	return 0;
13544937214SPrabhakar Kushwaha }
13644937214SPrabhakar Kushwaha 
get_board_sys_clk(void)13744937214SPrabhakar Kushwaha unsigned long get_board_sys_clk(void)
13844937214SPrabhakar Kushwaha {
139d1418c15SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
14044937214SPrabhakar Kushwaha 	u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
14144937214SPrabhakar Kushwaha 
14244937214SPrabhakar Kushwaha 	switch (sysclk_conf & 0x0F) {
14344937214SPrabhakar Kushwaha 	case QIXIS_SYSCLK_83:
14444937214SPrabhakar Kushwaha 		return 83333333;
14544937214SPrabhakar Kushwaha 	case QIXIS_SYSCLK_100:
14644937214SPrabhakar Kushwaha 		return 100000000;
14744937214SPrabhakar Kushwaha 	case QIXIS_SYSCLK_125:
14844937214SPrabhakar Kushwaha 		return 125000000;
14944937214SPrabhakar Kushwaha 	case QIXIS_SYSCLK_133:
15044937214SPrabhakar Kushwaha 		return 133333333;
15144937214SPrabhakar Kushwaha 	case QIXIS_SYSCLK_150:
15244937214SPrabhakar Kushwaha 		return 150000000;
15344937214SPrabhakar Kushwaha 	case QIXIS_SYSCLK_160:
15444937214SPrabhakar Kushwaha 		return 160000000;
15544937214SPrabhakar Kushwaha 	case QIXIS_SYSCLK_166:
15644937214SPrabhakar Kushwaha 		return 166666666;
15744937214SPrabhakar Kushwaha 	}
158d1418c15SPriyanka Jain #endif
159d1418c15SPriyanka Jain 	return 100000000;
16044937214SPrabhakar Kushwaha }
16144937214SPrabhakar Kushwaha 
select_i2c_ch_pca9547(u8 ch)16244937214SPrabhakar Kushwaha int select_i2c_ch_pca9547(u8 ch)
16344937214SPrabhakar Kushwaha {
16444937214SPrabhakar Kushwaha 	int ret;
16544937214SPrabhakar Kushwaha 
16644937214SPrabhakar Kushwaha 	ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
16744937214SPrabhakar Kushwaha 	if (ret) {
16844937214SPrabhakar Kushwaha 		puts("PCA: failed to select proper channel\n");
16944937214SPrabhakar Kushwaha 		return ret;
17044937214SPrabhakar Kushwaha 	}
17144937214SPrabhakar Kushwaha 
17244937214SPrabhakar Kushwaha 	return 0;
17344937214SPrabhakar Kushwaha }
17444937214SPrabhakar Kushwaha 
i2c_multiplexer_select_vid_channel(u8 channel)175ed2530d0SRai Harninder int i2c_multiplexer_select_vid_channel(u8 channel)
176ed2530d0SRai Harninder {
177ed2530d0SRai Harninder 	return select_i2c_ch_pca9547(channel);
178ed2530d0SRai Harninder }
179ed2530d0SRai Harninder 
config_board_mux(int ctrl_type)18044937214SPrabhakar Kushwaha int config_board_mux(int ctrl_type)
18144937214SPrabhakar Kushwaha {
182d1418c15SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
18344937214SPrabhakar Kushwaha 	u8 reg5;
18444937214SPrabhakar Kushwaha 
18544937214SPrabhakar Kushwaha 	reg5 = QIXIS_READ(brdcfg[5]);
18644937214SPrabhakar Kushwaha 
18744937214SPrabhakar Kushwaha 	switch (ctrl_type) {
18844937214SPrabhakar Kushwaha 	case MUX_TYPE_SDHC:
18944937214SPrabhakar Kushwaha 		reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_SDHC);
19044937214SPrabhakar Kushwaha 		break;
19144937214SPrabhakar Kushwaha 	case MUX_TYPE_DSPI:
19244937214SPrabhakar Kushwaha 		reg5 = SET_SDHC_MUX_SEL(reg5, PIN_MUX_SEL_DSPI);
19344937214SPrabhakar Kushwaha 		break;
19444937214SPrabhakar Kushwaha 	default:
19544937214SPrabhakar Kushwaha 		printf("Wrong mux interface type\n");
19644937214SPrabhakar Kushwaha 		return -1;
19744937214SPrabhakar Kushwaha 	}
19844937214SPrabhakar Kushwaha 
19944937214SPrabhakar Kushwaha 	QIXIS_WRITE(brdcfg[5], reg5);
200d1418c15SPriyanka Jain #endif
20144937214SPrabhakar Kushwaha 	return 0;
20244937214SPrabhakar Kushwaha }
20344937214SPrabhakar Kushwaha 
board_init(void)20444937214SPrabhakar Kushwaha int board_init(void)
20544937214SPrabhakar Kushwaha {
206931e8751SYork Sun #ifdef CONFIG_FSL_MC_ENET
207abc7d0f7SShaohui Xie 	u32 __iomem *irq_ccsr = (u32 __iomem *)ISC_BASE;
208931e8751SYork Sun #endif
20944937214SPrabhakar Kushwaha 
21044937214SPrabhakar Kushwaha 	init_final_memctl_regs();
21144937214SPrabhakar Kushwaha 
21244937214SPrabhakar Kushwaha #ifdef CONFIG_ENV_IS_NOWHERE
21344937214SPrabhakar Kushwaha 	gd->env_addr = (ulong)&default_environment[0];
21444937214SPrabhakar Kushwaha #endif
21544937214SPrabhakar Kushwaha 	select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
21644937214SPrabhakar Kushwaha 
217d1418c15SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
21844937214SPrabhakar Kushwaha 	QIXIS_WRITE(rst_ctl, QIXIS_RST_CTL_RESET_EN);
219d1418c15SPriyanka Jain #endif
22015e7c681SUdit Agarwal 
22115e7c681SUdit Agarwal #ifdef CONFIG_FSL_CAAM
22215e7c681SUdit Agarwal 	sec_init();
22315e7c681SUdit Agarwal #endif
22454ad7b5aSSantan Kumar #ifdef CONFIG_FSL_LS_PPA
22554ad7b5aSSantan Kumar 	ppa_init();
22654ad7b5aSSantan Kumar #endif
22754ad7b5aSSantan Kumar 
228931e8751SYork Sun #ifdef CONFIG_FSL_MC_ENET
229abc7d0f7SShaohui Xie 	/* invert AQR405 IRQ pins polarity */
230abc7d0f7SShaohui Xie 	out_le32(irq_ccsr + IRQCR_OFFSET / 4, AQR405_IRQ_MASK);
231931e8751SYork Sun #endif
232a8c6fd4eSUdit Agarwal #ifdef CONFIG_FSL_CAAM
233a8c6fd4eSUdit Agarwal 	sec_init();
234a8c6fd4eSUdit Agarwal #endif
235abc7d0f7SShaohui Xie 
23644937214SPrabhakar Kushwaha 	return 0;
23744937214SPrabhakar Kushwaha }
23844937214SPrabhakar Kushwaha 
board_early_init_f(void)23944937214SPrabhakar Kushwaha int board_early_init_f(void)
24044937214SPrabhakar Kushwaha {
2413049a583SPriyanka Jain #ifdef CONFIG_SYS_I2C_EARLY_INIT
2423049a583SPriyanka Jain 	i2c_early_init_f();
2433049a583SPriyanka Jain #endif
24444937214SPrabhakar Kushwaha 	fsl_lsch3_early_init_f();
24544937214SPrabhakar Kushwaha 	return 0;
24644937214SPrabhakar Kushwaha }
24744937214SPrabhakar Kushwaha 
misc_init_r(void)24844937214SPrabhakar Kushwaha int misc_init_r(void)
24944937214SPrabhakar Kushwaha {
250263536a6SSantan Kumar 	char *env_hwconfig;
251263536a6SSantan Kumar 	u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
252263536a6SSantan Kumar 	u32 val;
253b5dfd475SPriyanka Jain 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
254b5dfd475SPriyanka Jain 	u32 svr = gur_in32(&gur->svr);
255263536a6SSantan Kumar 
256263536a6SSantan Kumar 	val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4);
257263536a6SSantan Kumar 
25800caae6dSSimon Glass 	env_hwconfig = env_get("hwconfig");
259263536a6SSantan Kumar 
260263536a6SSantan Kumar 	if (hwconfig_f("dspi", env_hwconfig) &&
261263536a6SSantan Kumar 	    DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8)))
262263536a6SSantan Kumar 		config_board_mux(MUX_TYPE_DSPI);
263263536a6SSantan Kumar 	else
264263536a6SSantan Kumar 		config_board_mux(MUX_TYPE_SDHC);
265263536a6SSantan Kumar 
2663049a583SPriyanka Jain 	/*
2676cc914efSSantan Kumar 	 * LS2081ARDB RevF board has smart voltage translator
2685193405aSPriyanka Jain 	 * which needs to be programmed to enable high speed SD interface
2695193405aSPriyanka Jain 	 * by setting GPIO4_10 output to zero
2705193405aSPriyanka Jain 	 */
2716cc914efSSantan Kumar #ifdef CONFIG_TARGET_LS2081ARDB
2725193405aSPriyanka Jain 		out_le32(GPIO4_GPDIR_ADDR, (1 << 21 |
2735193405aSPriyanka Jain 					    in_le32(GPIO4_GPDIR_ADDR)));
2745193405aSPriyanka Jain 		out_le32(GPIO4_GPDAT_ADDR, (~(1 << 21) &
2755193405aSPriyanka Jain 					    in_le32(GPIO4_GPDAT_ADDR)));
2765193405aSPriyanka Jain #endif
27744937214SPrabhakar Kushwaha 	if (hwconfig("sdhc"))
27844937214SPrabhakar Kushwaha 		config_board_mux(MUX_TYPE_SDHC);
27944937214SPrabhakar Kushwaha 
280ed2530d0SRai Harninder 	if (adjust_vdd(0))
281ed2530d0SRai Harninder 		printf("Warning: Adjusting core voltage failed.\n");
282b5dfd475SPriyanka Jain 	/*
283b5dfd475SPriyanka Jain 	 * Default value of board env is based on filename which is
284b5dfd475SPriyanka Jain 	 * ls2080ardb. Modify board env for other supported SoCs
285b5dfd475SPriyanka Jain 	 */
286b5dfd475SPriyanka Jain 	if ((SVR_SOC_VER(svr) == SVR_LS2088A) ||
287b5dfd475SPriyanka Jain 	    (SVR_SOC_VER(svr) == SVR_LS2048A))
288b5dfd475SPriyanka Jain 		env_set("board", "ls2088ardb");
289b5dfd475SPriyanka Jain 	else if ((SVR_SOC_VER(svr) == SVR_LS2081A) ||
290b5dfd475SPriyanka Jain 	    (SVR_SOC_VER(svr) == SVR_LS2041A))
291b5dfd475SPriyanka Jain 		env_set("board", "ls2081ardb");
292ed2530d0SRai Harninder 
29344937214SPrabhakar Kushwaha 	return 0;
29444937214SPrabhakar Kushwaha }
29544937214SPrabhakar Kushwaha 
detail_board_ddr_info(void)29644937214SPrabhakar Kushwaha void detail_board_ddr_info(void)
29744937214SPrabhakar Kushwaha {
29844937214SPrabhakar Kushwaha 	puts("\nDDR    ");
29944937214SPrabhakar Kushwaha 	print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
30044937214SPrabhakar Kushwaha 	print_ddr_info(0);
30144937214SPrabhakar Kushwaha #ifdef CONFIG_SYS_FSL_HAS_DP_DDR
3023c1d218aSYork Sun 	if (soc_has_dp_ddr() && gd->bd->bi_dram[2].size) {
30344937214SPrabhakar Kushwaha 		puts("\nDP-DDR ");
30444937214SPrabhakar Kushwaha 		print_size(gd->bd->bi_dram[2].size, "");
30544937214SPrabhakar Kushwaha 		print_ddr_info(CONFIG_DP_DDR_CTRL);
30644937214SPrabhakar Kushwaha 	}
30744937214SPrabhakar Kushwaha #endif
30844937214SPrabhakar Kushwaha }
30944937214SPrabhakar Kushwaha 
31044937214SPrabhakar Kushwaha #if defined(CONFIG_ARCH_MISC_INIT)
arch_misc_init(void)31144937214SPrabhakar Kushwaha int arch_misc_init(void)
31244937214SPrabhakar Kushwaha {
31344937214SPrabhakar Kushwaha 	return 0;
31444937214SPrabhakar Kushwaha }
31544937214SPrabhakar Kushwaha #endif
31644937214SPrabhakar Kushwaha 
31744937214SPrabhakar Kushwaha #ifdef CONFIG_FSL_MC_ENET
fdt_fixup_board_enet(void * fdt)31844937214SPrabhakar Kushwaha void fdt_fixup_board_enet(void *fdt)
31944937214SPrabhakar Kushwaha {
32044937214SPrabhakar Kushwaha 	int offset;
32144937214SPrabhakar Kushwaha 
322e91f1decSStuart Yoder 	offset = fdt_path_offset(fdt, "/soc/fsl-mc");
32344937214SPrabhakar Kushwaha 
32444937214SPrabhakar Kushwaha 	if (offset < 0)
325e91f1decSStuart Yoder 		offset = fdt_path_offset(fdt, "/fsl-mc");
32644937214SPrabhakar Kushwaha 
32744937214SPrabhakar Kushwaha 	if (offset < 0) {
32844937214SPrabhakar Kushwaha 		printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
32944937214SPrabhakar Kushwaha 		       __func__, offset);
33044937214SPrabhakar Kushwaha 		return;
33144937214SPrabhakar Kushwaha 	}
33244937214SPrabhakar Kushwaha 
333*7e968049SMian Yousaf Kaukab 	if (get_mc_boot_status() == 0 &&
334*7e968049SMian Yousaf Kaukab 	    (is_lazy_dpl_addr_valid() || get_dpl_apply_status() == 0))
33544937214SPrabhakar Kushwaha 		fdt_status_okay(fdt, offset);
33644937214SPrabhakar Kushwaha 	else
33744937214SPrabhakar Kushwaha 		fdt_status_fail(fdt, offset);
33844937214SPrabhakar Kushwaha }
339b7b8410aSAlexander Graf 
board_quiesce_devices(void)340b7b8410aSAlexander Graf void board_quiesce_devices(void)
341b7b8410aSAlexander Graf {
342b7b8410aSAlexander Graf 	fsl_mc_ldpaa_exit(gd->bd);
343b7b8410aSAlexander Graf }
34444937214SPrabhakar Kushwaha #endif
34544937214SPrabhakar Kushwaha 
34644937214SPrabhakar Kushwaha #ifdef CONFIG_OF_BOARD_SETUP
fsl_fdt_fixup_flash(void * fdt)3477794d9abSSantan Kumar void fsl_fdt_fixup_flash(void *fdt)
3487794d9abSSantan Kumar {
3497794d9abSSantan Kumar 	int offset;
3509570df03SRajesh Bhagat #ifdef CONFIG_TFABOOT
3519570df03SRajesh Bhagat 	u32 __iomem *dcfg_ccsr = (u32 __iomem *)DCFG_BASE;
3529570df03SRajesh Bhagat 	u32 val;
3539570df03SRajesh Bhagat #endif
3547794d9abSSantan Kumar 
3557794d9abSSantan Kumar /*
3567794d9abSSantan Kumar  * IFC and QSPI are muxed on board.
3577794d9abSSantan Kumar  * So disable IFC node in dts if QSPI is enabled or
3587794d9abSSantan Kumar  * disable QSPI node in dts in case QSPI is not enabled.
3597794d9abSSantan Kumar  */
3609570df03SRajesh Bhagat #ifdef CONFIG_TFABOOT
3619570df03SRajesh Bhagat 	enum boot_src src = get_boot_src();
3629570df03SRajesh Bhagat 	bool disable_ifc = false;
3639570df03SRajesh Bhagat 
3649570df03SRajesh Bhagat 	switch (src) {
3659570df03SRajesh Bhagat 	case BOOT_SOURCE_IFC_NOR:
3669570df03SRajesh Bhagat 		disable_ifc = false;
3679570df03SRajesh Bhagat 		break;
3689570df03SRajesh Bhagat 	case BOOT_SOURCE_QSPI_NOR:
3699570df03SRajesh Bhagat 		disable_ifc = true;
3709570df03SRajesh Bhagat 		break;
3719570df03SRajesh Bhagat 	default:
3729570df03SRajesh Bhagat 		val = in_le32(dcfg_ccsr + DCFG_RCWSR15 / 4);
3739570df03SRajesh Bhagat 		if (DCFG_RCWSR15_IFCGRPABASE_QSPI == (val & (u32)0x3))
3749570df03SRajesh Bhagat 			disable_ifc = true;
3759570df03SRajesh Bhagat 		break;
3769570df03SRajesh Bhagat 	}
3779570df03SRajesh Bhagat 
3789570df03SRajesh Bhagat 	if (disable_ifc) {
3799570df03SRajesh Bhagat 		offset = fdt_path_offset(fdt, "/soc/ifc");
3809570df03SRajesh Bhagat 
3819570df03SRajesh Bhagat 		if (offset < 0)
3829570df03SRajesh Bhagat 			offset = fdt_path_offset(fdt, "/ifc");
3839570df03SRajesh Bhagat 	} else {
3849570df03SRajesh Bhagat 		offset = fdt_path_offset(fdt, "/soc/quadspi");
3859570df03SRajesh Bhagat 
3869570df03SRajesh Bhagat 		if (offset < 0)
3879570df03SRajesh Bhagat 			offset = fdt_path_offset(fdt, "/quadspi");
3889570df03SRajesh Bhagat 	}
3899570df03SRajesh Bhagat 
3909570df03SRajesh Bhagat #else
3917794d9abSSantan Kumar #ifdef CONFIG_FSL_QSPI
3927794d9abSSantan Kumar 	offset = fdt_path_offset(fdt, "/soc/ifc");
3937794d9abSSantan Kumar 
3947794d9abSSantan Kumar 	if (offset < 0)
3957794d9abSSantan Kumar 		offset = fdt_path_offset(fdt, "/ifc");
3967794d9abSSantan Kumar #else
3977794d9abSSantan Kumar 	offset = fdt_path_offset(fdt, "/soc/quadspi");
3987794d9abSSantan Kumar 
3997794d9abSSantan Kumar 	if (offset < 0)
4007794d9abSSantan Kumar 		offset = fdt_path_offset(fdt, "/quadspi");
4017794d9abSSantan Kumar #endif
4029570df03SRajesh Bhagat #endif
4039570df03SRajesh Bhagat 
4047794d9abSSantan Kumar 	if (offset < 0)
4057794d9abSSantan Kumar 		return;
4067794d9abSSantan Kumar 
4077794d9abSSantan Kumar 	fdt_status_disabled(fdt, offset);
4087794d9abSSantan Kumar }
4097794d9abSSantan Kumar 
ft_board_setup(void * blob,bd_t * bd)41044937214SPrabhakar Kushwaha int ft_board_setup(void *blob, bd_t *bd)
41144937214SPrabhakar Kushwaha {
41244937214SPrabhakar Kushwaha 	u64 base[CONFIG_NR_DRAM_BANKS];
41344937214SPrabhakar Kushwaha 	u64 size[CONFIG_NR_DRAM_BANKS];
41444937214SPrabhakar Kushwaha 
41544937214SPrabhakar Kushwaha 	ft_cpu_setup(blob, bd);
41644937214SPrabhakar Kushwaha 
41744937214SPrabhakar Kushwaha 	/* fixup DT for the two GPP DDR banks */
41844937214SPrabhakar Kushwaha 	base[0] = gd->bd->bi_dram[0].start;
41944937214SPrabhakar Kushwaha 	size[0] = gd->bd->bi_dram[0].size;
42044937214SPrabhakar Kushwaha 	base[1] = gd->bd->bi_dram[1].start;
42144937214SPrabhakar Kushwaha 	size[1] = gd->bd->bi_dram[1].size;
42244937214SPrabhakar Kushwaha 
42336cc0de0SYork Sun #ifdef CONFIG_RESV_RAM
42436cc0de0SYork Sun 	/* reduce size if reserved memory is within this bank */
42536cc0de0SYork Sun 	if (gd->arch.resv_ram >= base[0] &&
42636cc0de0SYork Sun 	    gd->arch.resv_ram < base[0] + size[0])
42736cc0de0SYork Sun 		size[0] = gd->arch.resv_ram - base[0];
42836cc0de0SYork Sun 	else if (gd->arch.resv_ram >= base[1] &&
42936cc0de0SYork Sun 		 gd->arch.resv_ram < base[1] + size[1])
43036cc0de0SYork Sun 		size[1] = gd->arch.resv_ram - base[1];
43136cc0de0SYork Sun #endif
43236cc0de0SYork Sun 
43344937214SPrabhakar Kushwaha 	fdt_fixup_memory_banks(blob, base, size, 2);
43444937214SPrabhakar Kushwaha 
435a78df40cSNipun Gupta 	fdt_fsl_mc_fixup_iommu_map_entry(blob);
436a78df40cSNipun Gupta 
437a5c289b9SSriram Dash 	fsl_fdt_fixup_dr_usb(blob, bd);
438ef53b8c4SSriram Dash 
4397794d9abSSantan Kumar 	fsl_fdt_fixup_flash(blob);
4407794d9abSSantan Kumar 
44144937214SPrabhakar Kushwaha #ifdef CONFIG_FSL_MC_ENET
44244937214SPrabhakar Kushwaha 	fdt_fixup_board_enet(blob);
44344937214SPrabhakar Kushwaha #endif
44444937214SPrabhakar Kushwaha 
44544937214SPrabhakar Kushwaha 	return 0;
44644937214SPrabhakar Kushwaha }
44744937214SPrabhakar Kushwaha #endif
44844937214SPrabhakar Kushwaha 
qixis_dump_switch(void)44944937214SPrabhakar Kushwaha void qixis_dump_switch(void)
45044937214SPrabhakar Kushwaha {
451d1418c15SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
45244937214SPrabhakar Kushwaha 	int i, nr_of_cfgsw;
45344937214SPrabhakar Kushwaha 
45444937214SPrabhakar Kushwaha 	QIXIS_WRITE(cms[0], 0x00);
45544937214SPrabhakar Kushwaha 	nr_of_cfgsw = QIXIS_READ(cms[1]);
45644937214SPrabhakar Kushwaha 
45744937214SPrabhakar Kushwaha 	puts("DIP switch settings dump:\n");
45844937214SPrabhakar Kushwaha 	for (i = 1; i <= nr_of_cfgsw; i++) {
45944937214SPrabhakar Kushwaha 		QIXIS_WRITE(cms[0], i);
46044937214SPrabhakar Kushwaha 		printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1]));
46144937214SPrabhakar Kushwaha 	}
462d1418c15SPriyanka Jain #endif
46344937214SPrabhakar Kushwaha }
46444937214SPrabhakar Kushwaha 
46544937214SPrabhakar Kushwaha /*
46644937214SPrabhakar Kushwaha  * Board rev C and earlier has duplicated I2C addresses for 2nd controller.
46744937214SPrabhakar Kushwaha  * Both slots has 0x54, resulting 2nd slot unusable.
46844937214SPrabhakar Kushwaha  */
update_spd_address(unsigned int ctrl_num,unsigned int slot,unsigned int * addr)46944937214SPrabhakar Kushwaha void update_spd_address(unsigned int ctrl_num,
47044937214SPrabhakar Kushwaha 			unsigned int slot,
47144937214SPrabhakar Kushwaha 			unsigned int *addr)
47244937214SPrabhakar Kushwaha {
4733049a583SPriyanka Jain #ifndef CONFIG_TARGET_LS2081ARDB
474d1418c15SPriyanka Jain #ifdef CONFIG_FSL_QIXIS
47544937214SPrabhakar Kushwaha 	u8 sw;
47644937214SPrabhakar Kushwaha 
47744937214SPrabhakar Kushwaha 	sw = QIXIS_READ(arch);
47844937214SPrabhakar Kushwaha 	if ((sw & 0xf) < 0x3) {
47944937214SPrabhakar Kushwaha 		if (ctrl_num == 1 && slot == 0)
48044937214SPrabhakar Kushwaha 			*addr = SPD_EEPROM_ADDRESS4;
48144937214SPrabhakar Kushwaha 		else if (ctrl_num == 1 && slot == 1)
48244937214SPrabhakar Kushwaha 			*addr = SPD_EEPROM_ADDRESS3;
48344937214SPrabhakar Kushwaha 	}
484d1418c15SPriyanka Jain #endif
4853049a583SPriyanka Jain #endif
48644937214SPrabhakar Kushwaha }
487