183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2550e3dc0SWang Huan /*
3550e3dc0SWang Huan * Copyright 2014 Freescale Semiconductor, Inc.
4550e3dc0SWang Huan */
5550e3dc0SWang Huan
6550e3dc0SWang Huan #include <common.h>
7550e3dc0SWang Huan #include <i2c.h>
8550e3dc0SWang Huan #include <asm/io.h>
9550e3dc0SWang Huan #include <asm/arch/immap_ls102xa.h>
10550e3dc0SWang Huan #include <asm/arch/clock.h>
11550e3dc0SWang Huan #include <asm/arch/fsl_serdes.h>
127ba02618SYao Yuan #include <asm/arch/ls102xa_soc.h>
1303c22449SZhuoyu Zhang #include <asm/arch/ls102xa_devdis.h>
14bca11bd7SYao Yuan #include <hwconfig.h>
15550e3dc0SWang Huan #include <mmc.h>
16435acd83SMingkai Hu #include <fsl_csu.h>
17550e3dc0SWang Huan #include <fsl_esdhc.h>
18550e3dc0SWang Huan #include <fsl_ifc.h>
194ba4a095SRuchika Gupta #include <fsl_sec.h>
2086949c2bSAlison Wang #include <spl.h>
2103c22449SZhuoyu Zhang #include <fsl_devdis.h>
22d0412885SAneesh Bansal #include <fsl_validate.h>
2302fb2761SShengzhou Liu #include <fsl_ddr.h>
2441ba57d0Stang yuantian #include "../common/sleep.h"
25550e3dc0SWang Huan #include "../common/qixis.h"
26550e3dc0SWang Huan #include "ls1021aqds_qixis.h"
2763e75fd7SZhao Qiang #ifdef CONFIG_U_QE
282459afb1SQianyu Gong #include <fsl_qe.h>
2963e75fd7SZhao Qiang #endif
30550e3dc0SWang Huan
31bca11bd7SYao Yuan #define PIN_MUX_SEL_CAN 0x03
32bca11bd7SYao Yuan #define PIN_MUX_SEL_IIC2 0xa0
33bca11bd7SYao Yuan #define PIN_MUX_SEL_RGMII 0x00
34bca11bd7SYao Yuan #define PIN_MUX_SEL_SAI 0x0c
35bca11bd7SYao Yuan #define PIN_MUX_SEL_SDHC 0x00
36bca11bd7SYao Yuan
37bca11bd7SYao Yuan #define SET_SDHC_MUX_SEL(reg, value) ((reg & 0x0f) | value)
38bca11bd7SYao Yuan #define SET_EC_MUX_SEL(reg, value) ((reg & 0xf0) | value)
39550e3dc0SWang Huan enum {
40bca11bd7SYao Yuan MUX_TYPE_CAN,
41bca11bd7SYao Yuan MUX_TYPE_IIC2,
42bca11bd7SYao Yuan MUX_TYPE_RGMII,
43bca11bd7SYao Yuan MUX_TYPE_SAI,
44bca11bd7SYao Yuan MUX_TYPE_SDHC,
45550e3dc0SWang Huan MUX_TYPE_SD_PCI4,
46550e3dc0SWang Huan MUX_TYPE_SD_PC_SA_SG_SG,
47550e3dc0SWang Huan MUX_TYPE_SD_PC_SA_PC_SG,
48550e3dc0SWang Huan MUX_TYPE_SD_PC_SG_SG,
49550e3dc0SWang Huan };
50550e3dc0SWang Huan
510f5e5579SAlison Wang enum {
520f5e5579SAlison Wang GE0_CLK125,
530f5e5579SAlison Wang GE2_CLK125,
540f5e5579SAlison Wang GE1_CLK125,
550f5e5579SAlison Wang };
560f5e5579SAlison Wang
checkboard(void)57550e3dc0SWang Huan int checkboard(void)
58550e3dc0SWang Huan {
5970097027SAlison Wang #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI)
60550e3dc0SWang Huan char buf[64];
61d612f0abSAlison Wang #endif
6286949c2bSAlison Wang #if !defined(CONFIG_SD_BOOT) && !defined(CONFIG_QSPI_BOOT)
63550e3dc0SWang Huan u8 sw;
6486949c2bSAlison Wang #endif
65550e3dc0SWang Huan
66550e3dc0SWang Huan puts("Board: LS1021AQDS\n");
67550e3dc0SWang Huan
6886949c2bSAlison Wang #ifdef CONFIG_SD_BOOT
6986949c2bSAlison Wang puts("SD\n");
7086949c2bSAlison Wang #elif CONFIG_QSPI_BOOT
7186949c2bSAlison Wang puts("QSPI\n");
7286949c2bSAlison Wang #else
73550e3dc0SWang Huan sw = QIXIS_READ(brdcfg[0]);
74550e3dc0SWang Huan sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
75550e3dc0SWang Huan
76550e3dc0SWang Huan if (sw < 0x8)
77550e3dc0SWang Huan printf("vBank: %d\n", sw);
78550e3dc0SWang Huan else if (sw == 0x8)
79550e3dc0SWang Huan puts("PromJet\n");
80550e3dc0SWang Huan else if (sw == 0x9)
81550e3dc0SWang Huan puts("NAND\n");
82550e3dc0SWang Huan else if (sw == 0x15)
83550e3dc0SWang Huan printf("IFCCard\n");
84550e3dc0SWang Huan else
85550e3dc0SWang Huan printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
8686949c2bSAlison Wang #endif
87550e3dc0SWang Huan
8870097027SAlison Wang #if !defined(CONFIG_QSPI_BOOT) && !defined(CONFIG_SD_BOOT_QSPI)
89550e3dc0SWang Huan printf("Sys ID:0x%02x, Sys Ver: 0x%02x\n",
90550e3dc0SWang Huan QIXIS_READ(id), QIXIS_READ(arch));
91550e3dc0SWang Huan
92550e3dc0SWang Huan printf("FPGA: v%d (%s), build %d\n",
93550e3dc0SWang Huan (int)QIXIS_READ(scver), qixis_read_tag(buf),
94550e3dc0SWang Huan (int)qixis_read_minor());
95d612f0abSAlison Wang #endif
96550e3dc0SWang Huan
97550e3dc0SWang Huan return 0;
98550e3dc0SWang Huan }
99550e3dc0SWang Huan
get_board_sys_clk(void)100550e3dc0SWang Huan unsigned long get_board_sys_clk(void)
101550e3dc0SWang Huan {
102550e3dc0SWang Huan u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
103550e3dc0SWang Huan
104550e3dc0SWang Huan switch (sysclk_conf & 0x0f) {
105550e3dc0SWang Huan case QIXIS_SYSCLK_64:
106550e3dc0SWang Huan return 64000000;
107550e3dc0SWang Huan case QIXIS_SYSCLK_83:
108550e3dc0SWang Huan return 83333333;
109550e3dc0SWang Huan case QIXIS_SYSCLK_100:
110550e3dc0SWang Huan return 100000000;
111550e3dc0SWang Huan case QIXIS_SYSCLK_125:
112550e3dc0SWang Huan return 125000000;
113550e3dc0SWang Huan case QIXIS_SYSCLK_133:
114550e3dc0SWang Huan return 133333333;
115550e3dc0SWang Huan case QIXIS_SYSCLK_150:
116550e3dc0SWang Huan return 150000000;
117550e3dc0SWang Huan case QIXIS_SYSCLK_160:
118550e3dc0SWang Huan return 160000000;
119550e3dc0SWang Huan case QIXIS_SYSCLK_166:
120550e3dc0SWang Huan return 166666666;
121550e3dc0SWang Huan }
122550e3dc0SWang Huan return 66666666;
123550e3dc0SWang Huan }
124550e3dc0SWang Huan
get_board_ddr_clk(void)125550e3dc0SWang Huan unsigned long get_board_ddr_clk(void)
126550e3dc0SWang Huan {
127550e3dc0SWang Huan u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
128550e3dc0SWang Huan
129550e3dc0SWang Huan switch ((ddrclk_conf & 0x30) >> 4) {
130550e3dc0SWang Huan case QIXIS_DDRCLK_100:
131550e3dc0SWang Huan return 100000000;
132550e3dc0SWang Huan case QIXIS_DDRCLK_125:
133550e3dc0SWang Huan return 125000000;
134550e3dc0SWang Huan case QIXIS_DDRCLK_133:
135550e3dc0SWang Huan return 133333333;
136550e3dc0SWang Huan }
137550e3dc0SWang Huan return 66666666;
138550e3dc0SWang Huan }
139550e3dc0SWang Huan
select_i2c_ch_pca9547(u8 ch)140afff1379SChenhui Zhao int select_i2c_ch_pca9547(u8 ch)
141afff1379SChenhui Zhao {
142afff1379SChenhui Zhao int ret;
143afff1379SChenhui Zhao
144afff1379SChenhui Zhao ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
145afff1379SChenhui Zhao if (ret) {
146afff1379SChenhui Zhao puts("PCA: failed to select proper channel\n");
147afff1379SChenhui Zhao return ret;
148afff1379SChenhui Zhao }
149afff1379SChenhui Zhao
150afff1379SChenhui Zhao return 0;
151afff1379SChenhui Zhao }
152afff1379SChenhui Zhao
dram_init(void)153550e3dc0SWang Huan int dram_init(void)
154550e3dc0SWang Huan {
155afff1379SChenhui Zhao /*
156afff1379SChenhui Zhao * When resuming from deep sleep, the I2C channel may not be
157afff1379SChenhui Zhao * in the default channel. So, switch to the default channel
158afff1379SChenhui Zhao * before accessing DDR SPD.
159afff1379SChenhui Zhao */
160afff1379SChenhui Zhao select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
1613eace37eSSimon Glass return fsl_initdram();
162550e3dc0SWang Huan }
163550e3dc0SWang Huan
164550e3dc0SWang Huan #ifdef CONFIG_FSL_ESDHC
165550e3dc0SWang Huan struct fsl_esdhc_cfg esdhc_cfg[1] = {
166550e3dc0SWang Huan {CONFIG_SYS_FSL_ESDHC_ADDR},
167550e3dc0SWang Huan };
168550e3dc0SWang Huan
board_mmc_init(bd_t * bis)169550e3dc0SWang Huan int board_mmc_init(bd_t *bis)
170550e3dc0SWang Huan {
171550e3dc0SWang Huan esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
172550e3dc0SWang Huan
173550e3dc0SWang Huan return fsl_esdhc_initialize(bis, &esdhc_cfg[0]);
174550e3dc0SWang Huan }
175550e3dc0SWang Huan #endif
176550e3dc0SWang Huan
board_early_init_f(void)177550e3dc0SWang Huan int board_early_init_f(void)
178550e3dc0SWang Huan {
179550e3dc0SWang Huan struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
180550e3dc0SWang Huan
181550e3dc0SWang Huan #ifdef CONFIG_TSEC_ENET
182ebe4c1e6SClaudiu Manoil /* clear BD & FR bits for BE BD's and frame data */
183ebe4c1e6SClaudiu Manoil clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR);
184550e3dc0SWang Huan #endif
185550e3dc0SWang Huan
186550e3dc0SWang Huan #ifdef CONFIG_FSL_IFC
187550e3dc0SWang Huan init_early_memctl_regs();
188550e3dc0SWang Huan #endif
189550e3dc0SWang Huan
1907ba02618SYao Yuan arch_soc_init();
191550e3dc0SWang Huan
19241ba57d0Stang yuantian #if defined(CONFIG_DEEP_SLEEP)
19341ba57d0Stang yuantian if (is_warm_boot())
19441ba57d0Stang yuantian fsl_dp_disable_console();
19541ba57d0Stang yuantian #endif
19641ba57d0Stang yuantian
197550e3dc0SWang Huan return 0;
198550e3dc0SWang Huan }
199550e3dc0SWang Huan
20086949c2bSAlison Wang #ifdef CONFIG_SPL_BUILD
board_init_f(ulong dummy)20186949c2bSAlison Wang void board_init_f(ulong dummy)
20286949c2bSAlison Wang {
2038ab967b6SAlison Wang #ifdef CONFIG_NAND_BOOT
2048ab967b6SAlison Wang struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
2058ab967b6SAlison Wang u32 porsr1, pinctl;
2068ab967b6SAlison Wang
2078ab967b6SAlison Wang /*
2088ab967b6SAlison Wang * There is LS1 SoC issue where NOR, FPGA are inaccessible during
2098ab967b6SAlison Wang * NAND boot because IFC signals > IFC_AD7 are not enabled.
2108ab967b6SAlison Wang * This workaround changes RCW source to make all signals enabled.
2118ab967b6SAlison Wang */
2128ab967b6SAlison Wang porsr1 = in_be32(&gur->porsr1);
2138ab967b6SAlison Wang pinctl = ((porsr1 & ~(DCFG_CCSR_PORSR1_RCW_MASK)) |
2148ab967b6SAlison Wang DCFG_CCSR_PORSR1_RCW_SRC_I2C);
2158ab967b6SAlison Wang out_be32((unsigned int *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1),
2168ab967b6SAlison Wang pinctl);
2178ab967b6SAlison Wang #endif
2188ab967b6SAlison Wang
21986949c2bSAlison Wang /* Clear the BSS */
22086949c2bSAlison Wang memset(__bss_start, 0, __bss_end - __bss_start);
22186949c2bSAlison Wang
22286949c2bSAlison Wang #ifdef CONFIG_FSL_IFC
22386949c2bSAlison Wang init_early_memctl_regs();
22486949c2bSAlison Wang #endif
22586949c2bSAlison Wang
22686949c2bSAlison Wang get_clocks();
22786949c2bSAlison Wang
22841ba57d0Stang yuantian #if defined(CONFIG_DEEP_SLEEP)
22941ba57d0Stang yuantian if (is_warm_boot())
23041ba57d0Stang yuantian fsl_dp_disable_console();
23141ba57d0Stang yuantian #endif
23241ba57d0Stang yuantian
23386949c2bSAlison Wang preloader_console_init();
23486949c2bSAlison Wang
23586949c2bSAlison Wang #ifdef CONFIG_SPL_I2C_SUPPORT
23686949c2bSAlison Wang i2c_init_all();
23786949c2bSAlison Wang #endif
238036f3f33SAlison Wang
239*f668c520SAlison Wang timer_init();
24086949c2bSAlison Wang dram_init();
24186949c2bSAlison Wang
2428f0c7cbbSAlison Wang /* Allow OCRAM access permission as R/W */
243435acd83SMingkai Hu #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
244435acd83SMingkai Hu enable_layerscape_ns_access();
2458f0c7cbbSAlison Wang #endif
2468f0c7cbbSAlison Wang
24786949c2bSAlison Wang board_init_r(NULL, 0);
24886949c2bSAlison Wang }
24986949c2bSAlison Wang #endif
25086949c2bSAlison Wang
config_etseccm_source(int etsec_gtx_125_mux)2510f5e5579SAlison Wang void config_etseccm_source(int etsec_gtx_125_mux)
2520f5e5579SAlison Wang {
2530f5e5579SAlison Wang struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
2540f5e5579SAlison Wang
2550f5e5579SAlison Wang switch (etsec_gtx_125_mux) {
2560f5e5579SAlison Wang case GE0_CLK125:
2570f5e5579SAlison Wang out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE0_CLK125);
2580f5e5579SAlison Wang debug("etseccm set to GE0_CLK125\n");
2590f5e5579SAlison Wang break;
2600f5e5579SAlison Wang
2610f5e5579SAlison Wang case GE2_CLK125:
2620f5e5579SAlison Wang out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125);
2630f5e5579SAlison Wang debug("etseccm set to GE2_CLK125\n");
2640f5e5579SAlison Wang break;
2650f5e5579SAlison Wang
2660f5e5579SAlison Wang case GE1_CLK125:
2670f5e5579SAlison Wang out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE1_CLK125);
2680f5e5579SAlison Wang debug("etseccm set to GE1_CLK125\n");
2690f5e5579SAlison Wang break;
2700f5e5579SAlison Wang
2710f5e5579SAlison Wang default:
2720f5e5579SAlison Wang printf("Error! trying to set etseccm to invalid value\n");
2730f5e5579SAlison Wang break;
2740f5e5579SAlison Wang }
2750f5e5579SAlison Wang }
2760f5e5579SAlison Wang
config_board_mux(int ctrl_type)277550e3dc0SWang Huan int config_board_mux(int ctrl_type)
278550e3dc0SWang Huan {
279bca11bd7SYao Yuan u8 reg12, reg14;
280550e3dc0SWang Huan
281550e3dc0SWang Huan reg12 = QIXIS_READ(brdcfg[12]);
282bca11bd7SYao Yuan reg14 = QIXIS_READ(brdcfg[14]);
283550e3dc0SWang Huan
284550e3dc0SWang Huan switch (ctrl_type) {
285bca11bd7SYao Yuan case MUX_TYPE_CAN:
2860f5e5579SAlison Wang config_etseccm_source(GE2_CLK125);
287bca11bd7SYao Yuan reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_CAN);
288bca11bd7SYao Yuan break;
289bca11bd7SYao Yuan case MUX_TYPE_IIC2:
290bca11bd7SYao Yuan reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_IIC2);
291bca11bd7SYao Yuan break;
292bca11bd7SYao Yuan case MUX_TYPE_RGMII:
293bca11bd7SYao Yuan reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_RGMII);
294bca11bd7SYao Yuan break;
295bca11bd7SYao Yuan case MUX_TYPE_SAI:
2960f5e5579SAlison Wang config_etseccm_source(GE2_CLK125);
297bca11bd7SYao Yuan reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_SAI);
298bca11bd7SYao Yuan break;
299bca11bd7SYao Yuan case MUX_TYPE_SDHC:
300bca11bd7SYao Yuan reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_SDHC);
301bca11bd7SYao Yuan break;
302550e3dc0SWang Huan case MUX_TYPE_SD_PCI4:
303550e3dc0SWang Huan reg12 = 0x38;
304550e3dc0SWang Huan break;
305550e3dc0SWang Huan case MUX_TYPE_SD_PC_SA_SG_SG:
306550e3dc0SWang Huan reg12 = 0x01;
307550e3dc0SWang Huan break;
308550e3dc0SWang Huan case MUX_TYPE_SD_PC_SA_PC_SG:
309550e3dc0SWang Huan reg12 = 0x01;
310550e3dc0SWang Huan break;
311550e3dc0SWang Huan case MUX_TYPE_SD_PC_SG_SG:
312550e3dc0SWang Huan reg12 = 0x21;
313550e3dc0SWang Huan break;
314550e3dc0SWang Huan default:
315550e3dc0SWang Huan printf("Wrong mux interface type\n");
316550e3dc0SWang Huan return -1;
317550e3dc0SWang Huan }
318550e3dc0SWang Huan
319550e3dc0SWang Huan QIXIS_WRITE(brdcfg[12], reg12);
320bca11bd7SYao Yuan QIXIS_WRITE(brdcfg[14], reg14);
321550e3dc0SWang Huan
322550e3dc0SWang Huan return 0;
323550e3dc0SWang Huan }
324550e3dc0SWang Huan
config_serdes_mux(void)325550e3dc0SWang Huan int config_serdes_mux(void)
326550e3dc0SWang Huan {
327550e3dc0SWang Huan struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_FSL_GUTS_ADDR;
328550e3dc0SWang Huan u32 cfg;
329550e3dc0SWang Huan
330550e3dc0SWang Huan cfg = in_be32(&gur->rcwsr[4]) & RCWSR4_SRDS1_PRTCL_MASK;
331550e3dc0SWang Huan cfg >>= RCWSR4_SRDS1_PRTCL_SHIFT;
332550e3dc0SWang Huan
333550e3dc0SWang Huan switch (cfg) {
334550e3dc0SWang Huan case 0x0:
335550e3dc0SWang Huan config_board_mux(MUX_TYPE_SD_PCI4);
336550e3dc0SWang Huan break;
337550e3dc0SWang Huan case 0x30:
338550e3dc0SWang Huan config_board_mux(MUX_TYPE_SD_PC_SA_SG_SG);
339550e3dc0SWang Huan break;
340550e3dc0SWang Huan case 0x60:
341550e3dc0SWang Huan config_board_mux(MUX_TYPE_SD_PC_SG_SG);
342550e3dc0SWang Huan break;
343550e3dc0SWang Huan case 0x70:
344550e3dc0SWang Huan config_board_mux(MUX_TYPE_SD_PC_SA_PC_SG);
345550e3dc0SWang Huan break;
346550e3dc0SWang Huan default:
347550e3dc0SWang Huan printf("SRDS1 prtcl:0x%x\n", cfg);
348550e3dc0SWang Huan break;
349550e3dc0SWang Huan }
350550e3dc0SWang Huan
351550e3dc0SWang Huan return 0;
352550e3dc0SWang Huan }
353550e3dc0SWang Huan
3544632ad77Stang yuantian #ifdef CONFIG_BOARD_LATE_INIT
board_late_init(void)3554632ad77Stang yuantian int board_late_init(void)
3564632ad77Stang yuantian {
357d0412885SAneesh Bansal #ifdef CONFIG_CHAIN_OF_TRUST
358d0412885SAneesh Bansal fsl_setenv_chain_of_trust();
359d0412885SAneesh Bansal #endif
3604632ad77Stang yuantian
3614632ad77Stang yuantian return 0;
3624632ad77Stang yuantian }
3634632ad77Stang yuantian #endif
3644632ad77Stang yuantian
misc_init_r(void)3654ba4a095SRuchika Gupta int misc_init_r(void)
3664ba4a095SRuchika Gupta {
367bca11bd7SYao Yuan int conflict_flag;
368bca11bd7SYao Yuan
369bca11bd7SYao Yuan /* some signals can not enable simultaneous*/
370bca11bd7SYao Yuan conflict_flag = 0;
371bca11bd7SYao Yuan if (hwconfig("sdhc"))
372bca11bd7SYao Yuan conflict_flag++;
373bca11bd7SYao Yuan if (hwconfig("iic2"))
374bca11bd7SYao Yuan conflict_flag++;
375bca11bd7SYao Yuan if (conflict_flag > 1) {
376bca11bd7SYao Yuan printf("WARNING: pin conflict !\n");
377bca11bd7SYao Yuan return 0;
378bca11bd7SYao Yuan }
379bca11bd7SYao Yuan
380bca11bd7SYao Yuan conflict_flag = 0;
381bca11bd7SYao Yuan if (hwconfig("rgmii"))
382bca11bd7SYao Yuan conflict_flag++;
383bca11bd7SYao Yuan if (hwconfig("can"))
384bca11bd7SYao Yuan conflict_flag++;
385bca11bd7SYao Yuan if (hwconfig("sai"))
386bca11bd7SYao Yuan conflict_flag++;
387bca11bd7SYao Yuan if (conflict_flag > 1) {
388bca11bd7SYao Yuan printf("WARNING: pin conflict !\n");
389bca11bd7SYao Yuan return 0;
390bca11bd7SYao Yuan }
391bca11bd7SYao Yuan
392bca11bd7SYao Yuan if (hwconfig("can"))
393bca11bd7SYao Yuan config_board_mux(MUX_TYPE_CAN);
394bca11bd7SYao Yuan else if (hwconfig("rgmii"))
395bca11bd7SYao Yuan config_board_mux(MUX_TYPE_RGMII);
396bca11bd7SYao Yuan else if (hwconfig("sai"))
397bca11bd7SYao Yuan config_board_mux(MUX_TYPE_SAI);
398bca11bd7SYao Yuan
399bca11bd7SYao Yuan if (hwconfig("iic2"))
400bca11bd7SYao Yuan config_board_mux(MUX_TYPE_IIC2);
401bca11bd7SYao Yuan else if (hwconfig("sdhc"))
402bca11bd7SYao Yuan config_board_mux(MUX_TYPE_SDHC);
403bca11bd7SYao Yuan
40403c22449SZhuoyu Zhang #ifdef CONFIG_FSL_DEVICE_DISABLE
40503c22449SZhuoyu Zhang device_disable(devdis_tbl, ARRAY_SIZE(devdis_tbl));
40603c22449SZhuoyu Zhang #endif
4074ba4a095SRuchika Gupta #ifdef CONFIG_FSL_CAAM
4084ba4a095SRuchika Gupta return sec_init();
4094ba4a095SRuchika Gupta #endif
410bca11bd7SYao Yuan return 0;
4114ba4a095SRuchika Gupta }
4124ba4a095SRuchika Gupta
board_init(void)413550e3dc0SWang Huan int board_init(void)
414550e3dc0SWang Huan {
415b392a6d4SHou Zhiqiang #ifdef CONFIG_SYS_FSL_ERRATUM_A010315
416b392a6d4SHou Zhiqiang erratum_a010315();
417b392a6d4SHou Zhiqiang #endif
41802fb2761SShengzhou Liu #ifdef CONFIG_SYS_FSL_ERRATUM_A009942
41902fb2761SShengzhou Liu erratum_a009942_check_cpo();
42002fb2761SShengzhou Liu #endif
421550e3dc0SWang Huan
422550e3dc0SWang Huan select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
423550e3dc0SWang Huan
424550e3dc0SWang Huan #ifndef CONFIG_SYS_FSL_NO_SERDES
425550e3dc0SWang Huan fsl_serdes_init();
426550e3dc0SWang Huan config_serdes_mux();
427550e3dc0SWang Huan #endif
42863e75fd7SZhao Qiang
429a08b1921SAlison Wang ls102xa_smmu_stream_id_init();
430660673afSXiubo Li
43163e75fd7SZhao Qiang #ifdef CONFIG_U_QE
43263e75fd7SZhao Qiang u_qe_init();
43363e75fd7SZhao Qiang #endif
43463e75fd7SZhao Qiang
435550e3dc0SWang Huan return 0;
436550e3dc0SWang Huan }
437550e3dc0SWang Huan
43841ba57d0Stang yuantian #if defined(CONFIG_DEEP_SLEEP)
board_sleep_prepare(void)43941ba57d0Stang yuantian void board_sleep_prepare(void)
44041ba57d0Stang yuantian {
441435acd83SMingkai Hu #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
442435acd83SMingkai Hu enable_layerscape_ns_access();
44341ba57d0Stang yuantian #endif
44441ba57d0Stang yuantian }
44541ba57d0Stang yuantian #endif
44641ba57d0Stang yuantian
ft_board_setup(void * blob,bd_t * bd)447e895a4b0SSimon Glass int ft_board_setup(void *blob, bd_t *bd)
448550e3dc0SWang Huan {
449550e3dc0SWang Huan ft_cpu_setup(blob, bd);
450e895a4b0SSimon Glass
451d42bd345SMinghuan Lian #ifdef CONFIG_PCI
452d42bd345SMinghuan Lian ft_pci_setup(blob, bd);
453da419027SMinghuan Lian #endif
454da419027SMinghuan Lian
455e895a4b0SSimon Glass return 0;
456550e3dc0SWang Huan }
457550e3dc0SWang Huan
flash_read8(void * addr)458550e3dc0SWang Huan u8 flash_read8(void *addr)
459550e3dc0SWang Huan {
460550e3dc0SWang Huan return __raw_readb(addr + 1);
461550e3dc0SWang Huan }
462550e3dc0SWang Huan
flash_write16(u16 val,void * addr)463550e3dc0SWang Huan void flash_write16(u16 val, void *addr)
464550e3dc0SWang Huan {
465550e3dc0SWang Huan u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
466550e3dc0SWang Huan
467550e3dc0SWang Huan __raw_writew(shftval, addr);
468550e3dc0SWang Huan }
469550e3dc0SWang Huan
flash_read16(void * addr)470550e3dc0SWang Huan u16 flash_read16(void *addr)
471550e3dc0SWang Huan {
472550e3dc0SWang Huan u16 val = __raw_readw(addr);
473550e3dc0SWang Huan
474550e3dc0SWang Huan return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00);
475550e3dc0SWang Huan }
476