blob: 612f17eab1aa27d59cd5e39db120bf5a3a93a606 [file] [log] [blame]
Wang Huan550e3dc2014-09-05 13:52:44 +08001/*
2 * Copyright 2014 Freescale Semiconductor, Inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <i2c.h>
9#include <asm/io.h>
10#include <asm/arch/immap_ls102xa.h>
11#include <asm/arch/clock.h>
12#include <asm/arch/fsl_serdes.h>
Xiubo Li660673a2014-11-21 17:40:59 +080013#include <asm/arch/ls102xa_stream_id.h>
Zhuoyu Zhang03c22442015-08-17 18:55:12 +080014#include <asm/arch/ls102xa_devdis.h>
Yao Yuanbca11bd2014-11-26 14:54:33 +080015#include <hwconfig.h>
Wang Huan550e3dc2014-09-05 13:52:44 +080016#include <mmc.h>
Mingkai Hu435acd82015-10-26 19:47:41 +080017#include <fsl_csu.h>
Wang Huan550e3dc2014-09-05 13:52:44 +080018#include <fsl_esdhc.h>
19#include <fsl_ifc.h>
Ruchika Gupta4ba4a092014-10-15 11:39:06 +053020#include <fsl_sec.h>
Alison Wang86949c22014-12-03 15:00:47 +080021#include <spl.h>
Zhuoyu Zhang03c22442015-08-17 18:55:12 +080022#include <fsl_devdis.h>
Wang Huan550e3dc2014-09-05 13:52:44 +080023
tang yuantian41ba57d2014-12-17 12:58:05 +080024#include "../common/sleep.h"
Wang Huan550e3dc2014-09-05 13:52:44 +080025#include "../common/qixis.h"
26#include "ls1021aqds_qixis.h"
Zhao Qiang63e75fd2014-09-26 16:25:32 +080027#ifdef CONFIG_U_QE
28#include "../../../drivers/qe/qe.h"
29#endif
Wang Huan550e3dc2014-09-05 13:52:44 +080030
Yao Yuanbca11bd2014-11-26 14:54:33 +080031#define PIN_MUX_SEL_CAN 0x03
32#define PIN_MUX_SEL_IIC2 0xa0
33#define PIN_MUX_SEL_RGMII 0x00
34#define PIN_MUX_SEL_SAI 0x0c
35#define PIN_MUX_SEL_SDHC 0x00
36
37#define SET_SDHC_MUX_SEL(reg, value) ((reg & 0x0f) | value)
38#define SET_EC_MUX_SEL(reg, value) ((reg & 0xf0) | value)
Wang Huan550e3dc2014-09-05 13:52:44 +080039DECLARE_GLOBAL_DATA_PTR;
40
41enum {
Yao Yuanbca11bd2014-11-26 14:54:33 +080042 MUX_TYPE_CAN,
43 MUX_TYPE_IIC2,
44 MUX_TYPE_RGMII,
45 MUX_TYPE_SAI,
46 MUX_TYPE_SDHC,
Wang Huan550e3dc2014-09-05 13:52:44 +080047 MUX_TYPE_SD_PCI4,
48 MUX_TYPE_SD_PC_SA_SG_SG,
49 MUX_TYPE_SD_PC_SA_PC_SG,
50 MUX_TYPE_SD_PC_SG_SG,
51};
52
Alison Wang0f5e5572014-12-09 17:38:23 +080053enum {
54 GE0_CLK125,
55 GE2_CLK125,
56 GE1_CLK125,
57};
58
Wang Huan550e3dc2014-09-05 13:52:44 +080059int checkboard(void)
60{
Alison Wangd612f0a2014-12-09 17:38:02 +080061#ifndef CONFIG_QSPI_BOOT
Wang Huan550e3dc2014-09-05 13:52:44 +080062 char buf[64];
Alison Wangd612f0a2014-12-09 17:38:02 +080063#endif
Alison Wang86949c22014-12-03 15:00:47 +080064#if !defined(CONFIG_SD_BOOT) && !defined(CONFIG_QSPI_BOOT)
Wang Huan550e3dc2014-09-05 13:52:44 +080065 u8 sw;
Alison Wang86949c22014-12-03 15:00:47 +080066#endif
Wang Huan550e3dc2014-09-05 13:52:44 +080067
68 puts("Board: LS1021AQDS\n");
69
Alison Wang86949c22014-12-03 15:00:47 +080070#ifdef CONFIG_SD_BOOT
71 puts("SD\n");
72#elif CONFIG_QSPI_BOOT
73 puts("QSPI\n");
74#else
Wang Huan550e3dc2014-09-05 13:52:44 +080075 sw = QIXIS_READ(brdcfg[0]);
76 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
77
78 if (sw < 0x8)
79 printf("vBank: %d\n", sw);
80 else if (sw == 0x8)
81 puts("PromJet\n");
82 else if (sw == 0x9)
83 puts("NAND\n");
84 else if (sw == 0x15)
85 printf("IFCCard\n");
86 else
87 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
Alison Wang86949c22014-12-03 15:00:47 +080088#endif
Wang Huan550e3dc2014-09-05 13:52:44 +080089
Alison Wangd612f0a2014-12-09 17:38:02 +080090#ifndef CONFIG_QSPI_BOOT
Wang Huan550e3dc2014-09-05 13:52:44 +080091 printf("Sys ID:0x%02x, Sys Ver: 0x%02x\n",
92 QIXIS_READ(id), QIXIS_READ(arch));
93
94 printf("FPGA: v%d (%s), build %d\n",
95 (int)QIXIS_READ(scver), qixis_read_tag(buf),
96 (int)qixis_read_minor());
Alison Wangd612f0a2014-12-09 17:38:02 +080097#endif
Wang Huan550e3dc2014-09-05 13:52:44 +080098
99 return 0;
100}
101
102unsigned long get_board_sys_clk(void)
103{
104 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
105
106 switch (sysclk_conf & 0x0f) {
107 case QIXIS_SYSCLK_64:
108 return 64000000;
109 case QIXIS_SYSCLK_83:
110 return 83333333;
111 case QIXIS_SYSCLK_100:
112 return 100000000;
113 case QIXIS_SYSCLK_125:
114 return 125000000;
115 case QIXIS_SYSCLK_133:
116 return 133333333;
117 case QIXIS_SYSCLK_150:
118 return 150000000;
119 case QIXIS_SYSCLK_160:
120 return 160000000;
121 case QIXIS_SYSCLK_166:
122 return 166666666;
123 }
124 return 66666666;
125}
126
127unsigned long get_board_ddr_clk(void)
128{
129 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
130
131 switch ((ddrclk_conf & 0x30) >> 4) {
132 case QIXIS_DDRCLK_100:
133 return 100000000;
134 case QIXIS_DDRCLK_125:
135 return 125000000;
136 case QIXIS_DDRCLK_133:
137 return 133333333;
138 }
139 return 66666666;
140}
141
Alison Wang036f3f32015-03-12 11:31:44 +0800142unsigned int get_soc_major_rev(void)
143{
144 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
145 unsigned int svr, major;
146
147 svr = in_be32(&gur->svr);
148 major = SVR_MAJ(svr);
149
150 return major;
151}
152
Chenhui Zhaoafff1372014-11-06 10:51:59 +0800153int select_i2c_ch_pca9547(u8 ch)
154{
155 int ret;
156
157 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
158 if (ret) {
159 puts("PCA: failed to select proper channel\n");
160 return ret;
161 }
162
163 return 0;
164}
165
Wang Huan550e3dc2014-09-05 13:52:44 +0800166int dram_init(void)
167{
Chenhui Zhaoafff1372014-11-06 10:51:59 +0800168 /*
169 * When resuming from deep sleep, the I2C channel may not be
170 * in the default channel. So, switch to the default channel
171 * before accessing DDR SPD.
172 */
173 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
Wang Huan550e3dc2014-09-05 13:52:44 +0800174 gd->ram_size = initdram(0);
175
176 return 0;
177}
178
179#ifdef CONFIG_FSL_ESDHC
180struct fsl_esdhc_cfg esdhc_cfg[1] = {
181 {CONFIG_SYS_FSL_ESDHC_ADDR},
182};
183
184int board_mmc_init(bd_t *bis)
185{
186 esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
187
188 return fsl_esdhc_initialize(bis, &esdhc_cfg[0]);
189}
190#endif
191
Wang Huan550e3dc2014-09-05 13:52:44 +0800192int board_early_init_f(void)
193{
194 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
195 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
Alison Wang036f3f32015-03-12 11:31:44 +0800196 unsigned int major;
Wang Huan550e3dc2014-09-05 13:52:44 +0800197
198#ifdef CONFIG_TSEC_ENET
Claudiu Manoilebe4c1e2015-08-12 13:29:14 +0300199 /* clear BD & FR bits for BE BD's and frame data */
200 clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR);
Wang Huan550e3dc2014-09-05 13:52:44 +0800201#endif
202
203#ifdef CONFIG_FSL_IFC
204 init_early_memctl_regs();
205#endif
206
Alison Wangd612f0a2014-12-09 17:38:02 +0800207#ifdef CONFIG_FSL_QSPI
208 out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
209#endif
210
Xiubo Lidd048322014-12-16 14:50:33 +0800211#ifdef CONFIG_FSL_DCU_FB
212 out_be32(&scfg->pixclkcr, SCFG_PIXCLKCR_PXCKEN);
213#endif
214
Alison Wang88c857d2015-06-09 16:07:49 +0800215 /* Configure Little endian for SAI, ASRC and SPDIF */
216 out_be32(&scfg->endiancr, SCFG_ENDIANCR_LE);
217
Alison Wang7df50fd2015-01-15 17:29:29 +0800218 /*
219 * Enable snoop requests and DVM message requests for
220 * Slave insterface S4 (A7 core cluster)
221 */
222 out_le32(&cci->slave[4].snoop_ctrl,
223 CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
224
Alison Wang036f3f32015-03-12 11:31:44 +0800225 major = get_soc_major_rev();
226 if (major == SOC_MAJOR_VER_1_0) {
227 /*
228 * Set CCI-400 Slave interface S1, S2 Shareable Override
229 * Register All transactions are treated as non-shareable
230 */
231 out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
232 out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
Alison Wang7df50fd2015-01-15 17:29:29 +0800233
Alison Wang036f3f32015-03-12 11:31:44 +0800234 /* Workaround for the issue that DDR could not respond to
235 * barrier transaction which is generated by executing DSB/ISB
236 * instruction. Set CCI-400 control override register to
237 * terminate the barrier transaction. After DDR is initialized,
238 * allow barrier transaction to DDR again */
239 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
240 }
Wang Huan550e3dc2014-09-05 13:52:44 +0800241
tang yuantian41ba57d2014-12-17 12:58:05 +0800242#if defined(CONFIG_DEEP_SLEEP)
243 if (is_warm_boot())
244 fsl_dp_disable_console();
245#endif
246
Wang Huan550e3dc2014-09-05 13:52:44 +0800247 return 0;
248}
249
Alison Wang86949c22014-12-03 15:00:47 +0800250#ifdef CONFIG_SPL_BUILD
251void board_init_f(ulong dummy)
252{
253 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
Alison Wang036f3f32015-03-12 11:31:44 +0800254 unsigned int major;
Alison Wang86949c22014-12-03 15:00:47 +0800255
Alison Wang8ab967b2014-12-09 17:38:14 +0800256#ifdef CONFIG_NAND_BOOT
257 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
258 u32 porsr1, pinctl;
259
260 /*
261 * There is LS1 SoC issue where NOR, FPGA are inaccessible during
262 * NAND boot because IFC signals > IFC_AD7 are not enabled.
263 * This workaround changes RCW source to make all signals enabled.
264 */
265 porsr1 = in_be32(&gur->porsr1);
266 pinctl = ((porsr1 & ~(DCFG_CCSR_PORSR1_RCW_MASK)) |
267 DCFG_CCSR_PORSR1_RCW_SRC_I2C);
268 out_be32((unsigned int *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1),
269 pinctl);
270#endif
271
Alison Wang86949c22014-12-03 15:00:47 +0800272 /* Clear the BSS */
273 memset(__bss_start, 0, __bss_end - __bss_start);
274
275#ifdef CONFIG_FSL_IFC
276 init_early_memctl_regs();
277#endif
278
279 get_clocks();
280
tang yuantian41ba57d2014-12-17 12:58:05 +0800281#if defined(CONFIG_DEEP_SLEEP)
282 if (is_warm_boot())
283 fsl_dp_disable_console();
284#endif
285
Alison Wang86949c22014-12-03 15:00:47 +0800286 preloader_console_init();
287
288#ifdef CONFIG_SPL_I2C_SUPPORT
289 i2c_init_all();
290#endif
Alison Wang036f3f32015-03-12 11:31:44 +0800291
292 major = get_soc_major_rev();
293 if (major == SOC_MAJOR_VER_1_0)
294 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
Alison Wang86949c22014-12-03 15:00:47 +0800295
296 dram_init();
297
Alison Wang8f0c7cb2015-07-09 10:50:07 +0800298 /* Allow OCRAM access permission as R/W */
Mingkai Hu435acd82015-10-26 19:47:41 +0800299#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
300 enable_layerscape_ns_access();
Alison Wang8f0c7cb2015-07-09 10:50:07 +0800301#endif
302
Alison Wang86949c22014-12-03 15:00:47 +0800303 board_init_r(NULL, 0);
304}
305#endif
306
Alison Wang0f5e5572014-12-09 17:38:23 +0800307void config_etseccm_source(int etsec_gtx_125_mux)
308{
309 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
310
311 switch (etsec_gtx_125_mux) {
312 case GE0_CLK125:
313 out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE0_CLK125);
314 debug("etseccm set to GE0_CLK125\n");
315 break;
316
317 case GE2_CLK125:
318 out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125);
319 debug("etseccm set to GE2_CLK125\n");
320 break;
321
322 case GE1_CLK125:
323 out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE1_CLK125);
324 debug("etseccm set to GE1_CLK125\n");
325 break;
326
327 default:
328 printf("Error! trying to set etseccm to invalid value\n");
329 break;
330 }
331}
332
Wang Huan550e3dc2014-09-05 13:52:44 +0800333int config_board_mux(int ctrl_type)
334{
Yao Yuanbca11bd2014-11-26 14:54:33 +0800335 u8 reg12, reg14;
Wang Huan550e3dc2014-09-05 13:52:44 +0800336
337 reg12 = QIXIS_READ(brdcfg[12]);
Yao Yuanbca11bd2014-11-26 14:54:33 +0800338 reg14 = QIXIS_READ(brdcfg[14]);
Wang Huan550e3dc2014-09-05 13:52:44 +0800339
340 switch (ctrl_type) {
Yao Yuanbca11bd2014-11-26 14:54:33 +0800341 case MUX_TYPE_CAN:
Alison Wang0f5e5572014-12-09 17:38:23 +0800342 config_etseccm_source(GE2_CLK125);
Yao Yuanbca11bd2014-11-26 14:54:33 +0800343 reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_CAN);
344 break;
345 case MUX_TYPE_IIC2:
346 reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_IIC2);
347 break;
348 case MUX_TYPE_RGMII:
349 reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_RGMII);
350 break;
351 case MUX_TYPE_SAI:
Alison Wang0f5e5572014-12-09 17:38:23 +0800352 config_etseccm_source(GE2_CLK125);
Yao Yuanbca11bd2014-11-26 14:54:33 +0800353 reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_SAI);
354 break;
355 case MUX_TYPE_SDHC:
356 reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_SDHC);
357 break;
Wang Huan550e3dc2014-09-05 13:52:44 +0800358 case MUX_TYPE_SD_PCI4:
359 reg12 = 0x38;
360 break;
361 case MUX_TYPE_SD_PC_SA_SG_SG:
362 reg12 = 0x01;
363 break;
364 case MUX_TYPE_SD_PC_SA_PC_SG:
365 reg12 = 0x01;
366 break;
367 case MUX_TYPE_SD_PC_SG_SG:
368 reg12 = 0x21;
369 break;
370 default:
371 printf("Wrong mux interface type\n");
372 return -1;
373 }
374
375 QIXIS_WRITE(brdcfg[12], reg12);
Yao Yuanbca11bd2014-11-26 14:54:33 +0800376 QIXIS_WRITE(brdcfg[14], reg14);
Wang Huan550e3dc2014-09-05 13:52:44 +0800377
378 return 0;
379}
380
381int config_serdes_mux(void)
382{
383 struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_FSL_GUTS_ADDR;
384 u32 cfg;
385
386 cfg = in_be32(&gur->rcwsr[4]) & RCWSR4_SRDS1_PRTCL_MASK;
387 cfg >>= RCWSR4_SRDS1_PRTCL_SHIFT;
388
389 switch (cfg) {
390 case 0x0:
391 config_board_mux(MUX_TYPE_SD_PCI4);
392 break;
393 case 0x30:
394 config_board_mux(MUX_TYPE_SD_PC_SA_SG_SG);
395 break;
396 case 0x60:
397 config_board_mux(MUX_TYPE_SD_PC_SG_SG);
398 break;
399 case 0x70:
400 config_board_mux(MUX_TYPE_SD_PC_SA_PC_SG);
401 break;
402 default:
403 printf("SRDS1 prtcl:0x%x\n", cfg);
404 break;
405 }
406
407 return 0;
408}
409
Ruchika Gupta4ba4a092014-10-15 11:39:06 +0530410int misc_init_r(void)
411{
Yao Yuanbca11bd2014-11-26 14:54:33 +0800412 int conflict_flag;
413
414 /* some signals can not enable simultaneous*/
415 conflict_flag = 0;
416 if (hwconfig("sdhc"))
417 conflict_flag++;
418 if (hwconfig("iic2"))
419 conflict_flag++;
420 if (conflict_flag > 1) {
421 printf("WARNING: pin conflict !\n");
422 return 0;
423 }
424
425 conflict_flag = 0;
426 if (hwconfig("rgmii"))
427 conflict_flag++;
428 if (hwconfig("can"))
429 conflict_flag++;
430 if (hwconfig("sai"))
431 conflict_flag++;
432 if (conflict_flag > 1) {
433 printf("WARNING: pin conflict !\n");
434 return 0;
435 }
436
437 if (hwconfig("can"))
438 config_board_mux(MUX_TYPE_CAN);
439 else if (hwconfig("rgmii"))
440 config_board_mux(MUX_TYPE_RGMII);
441 else if (hwconfig("sai"))
442 config_board_mux(MUX_TYPE_SAI);
443
444 if (hwconfig("iic2"))
445 config_board_mux(MUX_TYPE_IIC2);
446 else if (hwconfig("sdhc"))
447 config_board_mux(MUX_TYPE_SDHC);
448
Zhuoyu Zhang03c22442015-08-17 18:55:12 +0800449#ifdef CONFIG_FSL_DEVICE_DISABLE
450 device_disable(devdis_tbl, ARRAY_SIZE(devdis_tbl));
451#endif
Ruchika Gupta4ba4a092014-10-15 11:39:06 +0530452#ifdef CONFIG_FSL_CAAM
453 return sec_init();
454#endif
Yao Yuanbca11bd2014-11-26 14:54:33 +0800455 return 0;
Ruchika Gupta4ba4a092014-10-15 11:39:06 +0530456}
Ruchika Gupta4ba4a092014-10-15 11:39:06 +0530457
Alison Wang81335742015-01-16 17:21:34 +0800458struct liodn_id_table sec_liodn_tbl[] = {
459 SET_SEC_JR_LIODN_ENTRY(0, 0x10, 0x10),
460 SET_SEC_JR_LIODN_ENTRY(1, 0x10, 0x10),
461 SET_SEC_JR_LIODN_ENTRY(2, 0x10, 0x10),
462 SET_SEC_JR_LIODN_ENTRY(3, 0x10, 0x10),
463 SET_SEC_RTIC_LIODN_ENTRY(a, 0x10),
464 SET_SEC_RTIC_LIODN_ENTRY(b, 0x10),
465 SET_SEC_RTIC_LIODN_ENTRY(c, 0x10),
466 SET_SEC_RTIC_LIODN_ENTRY(d, 0x10),
467 SET_SEC_DECO_LIODN_ENTRY(0, 0x10, 0x10),
468 SET_SEC_DECO_LIODN_ENTRY(1, 0x10, 0x10),
469 SET_SEC_DECO_LIODN_ENTRY(2, 0x10, 0x10),
470 SET_SEC_DECO_LIODN_ENTRY(3, 0x10, 0x10),
471 SET_SEC_DECO_LIODN_ENTRY(4, 0x10, 0x10),
472 SET_SEC_DECO_LIODN_ENTRY(5, 0x10, 0x10),
473 SET_SEC_DECO_LIODN_ENTRY(6, 0x10, 0x10),
474 SET_SEC_DECO_LIODN_ENTRY(7, 0x10, 0x10),
475};
476
Xiubo Li660673a2014-11-21 17:40:59 +0800477struct smmu_stream_id dev_stream_id[] = {
478 { 0x100, 0x01, "ETSEC MAC1" },
479 { 0x104, 0x02, "ETSEC MAC2" },
480 { 0x108, 0x03, "ETSEC MAC3" },
481 { 0x10c, 0x04, "PEX1" },
482 { 0x110, 0x05, "PEX2" },
483 { 0x114, 0x06, "qDMA" },
484 { 0x118, 0x07, "SATA" },
485 { 0x11c, 0x08, "USB3" },
486 { 0x120, 0x09, "QE" },
487 { 0x124, 0x0a, "eSDHC" },
488 { 0x128, 0x0b, "eMA" },
489 { 0x14c, 0x0c, "2D-ACE" },
490 { 0x150, 0x0d, "USB2" },
491 { 0x18c, 0x0e, "DEBUG" },
492};
493
Wang Huan550e3dc2014-09-05 13:52:44 +0800494int board_init(void)
495{
496 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
Alison Wang036f3f32015-03-12 11:31:44 +0800497 unsigned int major;
Wang Huan550e3dc2014-09-05 13:52:44 +0800498
Alison Wang036f3f32015-03-12 11:31:44 +0800499 major = get_soc_major_rev();
500 if (major == SOC_MAJOR_VER_1_0) {
501 /* Set CCI-400 control override register to
502 * enable barrier transaction */
503 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
504 }
Wang Huan550e3dc2014-09-05 13:52:44 +0800505
506 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
507
508#ifndef CONFIG_SYS_FSL_NO_SERDES
509 fsl_serdes_init();
510 config_serdes_mux();
511#endif
Zhao Qiang63e75fd2014-09-26 16:25:32 +0800512
Alison Wang81335742015-01-16 17:21:34 +0800513 ls1021x_config_caam_stream_id(sec_liodn_tbl,
514 ARRAY_SIZE(sec_liodn_tbl));
Xiubo Li660673a2014-11-21 17:40:59 +0800515 ls102xa_config_smmu_stream_id(dev_stream_id,
516 ARRAY_SIZE(dev_stream_id));
517
Mingkai Hu435acd82015-10-26 19:47:41 +0800518#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
519 enable_layerscape_ns_access();
Xiubo Lie87f3b32014-11-21 17:40:58 +0800520#endif
521
Zhao Qiang63e75fd2014-09-26 16:25:32 +0800522#ifdef CONFIG_U_QE
523 u_qe_init();
524#endif
525
Wang Huan550e3dc2014-09-05 13:52:44 +0800526 return 0;
527}
528
tang yuantian41ba57d2014-12-17 12:58:05 +0800529#if defined(CONFIG_DEEP_SLEEP)
530void board_sleep_prepare(void)
531{
532 struct ccsr_cci400 __iomem *cci = (void *)CONFIG_SYS_CCI400_ADDR;
Alison Wang036f3f32015-03-12 11:31:44 +0800533 unsigned int major;
tang yuantian41ba57d2014-12-17 12:58:05 +0800534
Alison Wang036f3f32015-03-12 11:31:44 +0800535 major = get_soc_major_rev();
536 if (major == SOC_MAJOR_VER_1_0) {
537 /* Set CCI-400 control override register to
538 * enable barrier transaction */
539 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
540 }
541
tang yuantian41ba57d2014-12-17 12:58:05 +0800542
Mingkai Hu435acd82015-10-26 19:47:41 +0800543#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
544 enable_layerscape_ns_access();
tang yuantian41ba57d2014-12-17 12:58:05 +0800545#endif
546}
547#endif
548
Simon Glasse895a4b2014-10-23 18:58:47 -0600549int ft_board_setup(void *blob, bd_t *bd)
Wang Huan550e3dc2014-09-05 13:52:44 +0800550{
551 ft_cpu_setup(blob, bd);
Simon Glasse895a4b2014-10-23 18:58:47 -0600552
Minghuan Liand42bd342015-03-12 10:58:48 +0800553#ifdef CONFIG_PCI
554 ft_pci_setup(blob, bd);
Minghuan Lianda419022014-10-31 13:43:44 +0800555#endif
556
Simon Glasse895a4b2014-10-23 18:58:47 -0600557 return 0;
Wang Huan550e3dc2014-09-05 13:52:44 +0800558}
559
560u8 flash_read8(void *addr)
561{
562 return __raw_readb(addr + 1);
563}
564
565void flash_write16(u16 val, void *addr)
566{
567 u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
568
569 __raw_writew(shftval, addr);
570}
571
572u16 flash_read16(void *addr)
573{
574 u16 val = __raw_readw(addr);
575
576 return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00);
577}