blob: d889ad50fd04d83d88197234c9fc70f6d0ac35bd [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>
tang yuantian4632ad72015-10-16 16:06:05 +080015#include <asm/arch/ls102xa_sata.h>
Yao Yuanbca11bd2014-11-26 14:54:33 +080016#include <hwconfig.h>
Wang Huan550e3dc2014-09-05 13:52:44 +080017#include <mmc.h>
Mingkai Hu435acd82015-10-26 19:47:41 +080018#include <fsl_csu.h>
Wang Huan550e3dc2014-09-05 13:52:44 +080019#include <fsl_esdhc.h>
20#include <fsl_ifc.h>
Ruchika Gupta4ba4a092014-10-15 11:39:06 +053021#include <fsl_sec.h>
Alison Wang86949c22014-12-03 15:00:47 +080022#include <spl.h>
Zhuoyu Zhang03c22442015-08-17 18:55:12 +080023#include <fsl_devdis.h>
Wang Huan550e3dc2014-09-05 13:52:44 +080024
tang yuantian41ba57d2014-12-17 12:58:05 +080025#include "../common/sleep.h"
Wang Huan550e3dc2014-09-05 13:52:44 +080026#include "../common/qixis.h"
27#include "ls1021aqds_qixis.h"
Zhao Qiang63e75fd2014-09-26 16:25:32 +080028#ifdef CONFIG_U_QE
29#include "../../../drivers/qe/qe.h"
30#endif
Wang Huan550e3dc2014-09-05 13:52:44 +080031
Yao Yuanbca11bd2014-11-26 14:54:33 +080032#define PIN_MUX_SEL_CAN 0x03
33#define PIN_MUX_SEL_IIC2 0xa0
34#define PIN_MUX_SEL_RGMII 0x00
35#define PIN_MUX_SEL_SAI 0x0c
36#define PIN_MUX_SEL_SDHC 0x00
37
38#define SET_SDHC_MUX_SEL(reg, value) ((reg & 0x0f) | value)
39#define SET_EC_MUX_SEL(reg, value) ((reg & 0xf0) | value)
Wang Huan550e3dc2014-09-05 13:52:44 +080040DECLARE_GLOBAL_DATA_PTR;
41
42enum {
Yao Yuanbca11bd2014-11-26 14:54:33 +080043 MUX_TYPE_CAN,
44 MUX_TYPE_IIC2,
45 MUX_TYPE_RGMII,
46 MUX_TYPE_SAI,
47 MUX_TYPE_SDHC,
Wang Huan550e3dc2014-09-05 13:52:44 +080048 MUX_TYPE_SD_PCI4,
49 MUX_TYPE_SD_PC_SA_SG_SG,
50 MUX_TYPE_SD_PC_SA_PC_SG,
51 MUX_TYPE_SD_PC_SG_SG,
52};
53
Alison Wang0f5e5572014-12-09 17:38:23 +080054enum {
55 GE0_CLK125,
56 GE2_CLK125,
57 GE1_CLK125,
58};
59
Wang Huan550e3dc2014-09-05 13:52:44 +080060int checkboard(void)
61{
Alison Wangd612f0a2014-12-09 17:38:02 +080062#ifndef CONFIG_QSPI_BOOT
Wang Huan550e3dc2014-09-05 13:52:44 +080063 char buf[64];
Alison Wangd612f0a2014-12-09 17:38:02 +080064#endif
Alison Wang86949c22014-12-03 15:00:47 +080065#if !defined(CONFIG_SD_BOOT) && !defined(CONFIG_QSPI_BOOT)
Wang Huan550e3dc2014-09-05 13:52:44 +080066 u8 sw;
Alison Wang86949c22014-12-03 15:00:47 +080067#endif
Wang Huan550e3dc2014-09-05 13:52:44 +080068
69 puts("Board: LS1021AQDS\n");
70
Alison Wang86949c22014-12-03 15:00:47 +080071#ifdef CONFIG_SD_BOOT
72 puts("SD\n");
73#elif CONFIG_QSPI_BOOT
74 puts("QSPI\n");
75#else
Wang Huan550e3dc2014-09-05 13:52:44 +080076 sw = QIXIS_READ(brdcfg[0]);
77 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
78
79 if (sw < 0x8)
80 printf("vBank: %d\n", sw);
81 else if (sw == 0x8)
82 puts("PromJet\n");
83 else if (sw == 0x9)
84 puts("NAND\n");
85 else if (sw == 0x15)
86 printf("IFCCard\n");
87 else
88 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
Alison Wang86949c22014-12-03 15:00:47 +080089#endif
Wang Huan550e3dc2014-09-05 13:52:44 +080090
Alison Wangd612f0a2014-12-09 17:38:02 +080091#ifndef CONFIG_QSPI_BOOT
Wang Huan550e3dc2014-09-05 13:52:44 +080092 printf("Sys ID:0x%02x, Sys Ver: 0x%02x\n",
93 QIXIS_READ(id), QIXIS_READ(arch));
94
95 printf("FPGA: v%d (%s), build %d\n",
96 (int)QIXIS_READ(scver), qixis_read_tag(buf),
97 (int)qixis_read_minor());
Alison Wangd612f0a2014-12-09 17:38:02 +080098#endif
Wang Huan550e3dc2014-09-05 13:52:44 +080099
100 return 0;
101}
102
103unsigned long get_board_sys_clk(void)
104{
105 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
106
107 switch (sysclk_conf & 0x0f) {
108 case QIXIS_SYSCLK_64:
109 return 64000000;
110 case QIXIS_SYSCLK_83:
111 return 83333333;
112 case QIXIS_SYSCLK_100:
113 return 100000000;
114 case QIXIS_SYSCLK_125:
115 return 125000000;
116 case QIXIS_SYSCLK_133:
117 return 133333333;
118 case QIXIS_SYSCLK_150:
119 return 150000000;
120 case QIXIS_SYSCLK_160:
121 return 160000000;
122 case QIXIS_SYSCLK_166:
123 return 166666666;
124 }
125 return 66666666;
126}
127
128unsigned long get_board_ddr_clk(void)
129{
130 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
131
132 switch ((ddrclk_conf & 0x30) >> 4) {
133 case QIXIS_DDRCLK_100:
134 return 100000000;
135 case QIXIS_DDRCLK_125:
136 return 125000000;
137 case QIXIS_DDRCLK_133:
138 return 133333333;
139 }
140 return 66666666;
141}
142
Alison Wang036f3f32015-03-12 11:31:44 +0800143unsigned int get_soc_major_rev(void)
144{
145 struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
146 unsigned int svr, major;
147
148 svr = in_be32(&gur->svr);
149 major = SVR_MAJ(svr);
150
151 return major;
152}
153
Chenhui Zhaoafff1372014-11-06 10:51:59 +0800154int select_i2c_ch_pca9547(u8 ch)
155{
156 int ret;
157
158 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
159 if (ret) {
160 puts("PCA: failed to select proper channel\n");
161 return ret;
162 }
163
164 return 0;
165}
166
Wang Huan550e3dc2014-09-05 13:52:44 +0800167int dram_init(void)
168{
Chenhui Zhaoafff1372014-11-06 10:51:59 +0800169 /*
170 * When resuming from deep sleep, the I2C channel may not be
171 * in the default channel. So, switch to the default channel
172 * before accessing DDR SPD.
173 */
174 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
Wang Huan550e3dc2014-09-05 13:52:44 +0800175 gd->ram_size = initdram(0);
176
177 return 0;
178}
179
180#ifdef CONFIG_FSL_ESDHC
181struct fsl_esdhc_cfg esdhc_cfg[1] = {
182 {CONFIG_SYS_FSL_ESDHC_ADDR},
183};
184
185int board_mmc_init(bd_t *bis)
186{
187 esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
188
189 return fsl_esdhc_initialize(bis, &esdhc_cfg[0]);
190}
191#endif
192
Wang Huan550e3dc2014-09-05 13:52:44 +0800193int board_early_init_f(void)
194{
195 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
196 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
Alison Wang036f3f32015-03-12 11:31:44 +0800197 unsigned int major;
Wang Huan550e3dc2014-09-05 13:52:44 +0800198
199#ifdef CONFIG_TSEC_ENET
Claudiu Manoilebe4c1e2015-08-12 13:29:14 +0300200 /* clear BD & FR bits for BE BD's and frame data */
201 clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR);
Wang Huan550e3dc2014-09-05 13:52:44 +0800202#endif
203
204#ifdef CONFIG_FSL_IFC
205 init_early_memctl_regs();
206#endif
207
Alison Wangd612f0a2014-12-09 17:38:02 +0800208#ifdef CONFIG_FSL_QSPI
209 out_be32(&scfg->qspi_cfg, SCFG_QSPI_CLKSEL);
210#endif
211
Xiubo Lidd048322014-12-16 14:50:33 +0800212#ifdef CONFIG_FSL_DCU_FB
213 out_be32(&scfg->pixclkcr, SCFG_PIXCLKCR_PXCKEN);
214#endif
215
Alison Wang88c857d2015-06-09 16:07:49 +0800216 /* Configure Little endian for SAI, ASRC and SPDIF */
217 out_be32(&scfg->endiancr, SCFG_ENDIANCR_LE);
218
Alison Wang7df50fd2015-01-15 17:29:29 +0800219 /*
220 * Enable snoop requests and DVM message requests for
221 * Slave insterface S4 (A7 core cluster)
222 */
223 out_le32(&cci->slave[4].snoop_ctrl,
224 CCI400_DVM_MESSAGE_REQ_EN | CCI400_SNOOP_REQ_EN);
225
Alison Wang036f3f32015-03-12 11:31:44 +0800226 major = get_soc_major_rev();
227 if (major == SOC_MAJOR_VER_1_0) {
228 /*
229 * Set CCI-400 Slave interface S1, S2 Shareable Override
230 * Register All transactions are treated as non-shareable
231 */
232 out_le32(&cci->slave[1].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
233 out_le32(&cci->slave[2].sha_ord, CCI400_SHAORD_NON_SHAREABLE);
Alison Wang7df50fd2015-01-15 17:29:29 +0800234
Alison Wang036f3f32015-03-12 11:31:44 +0800235 /* Workaround for the issue that DDR could not respond to
236 * barrier transaction which is generated by executing DSB/ISB
237 * instruction. Set CCI-400 control override register to
238 * terminate the barrier transaction. After DDR is initialized,
239 * allow barrier transaction to DDR again */
240 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
241 }
Wang Huan550e3dc2014-09-05 13:52:44 +0800242
tang yuantian41ba57d2014-12-17 12:58:05 +0800243#if defined(CONFIG_DEEP_SLEEP)
244 if (is_warm_boot())
245 fsl_dp_disable_console();
246#endif
247
Wang Huan550e3dc2014-09-05 13:52:44 +0800248 return 0;
249}
250
Alison Wang86949c22014-12-03 15:00:47 +0800251#ifdef CONFIG_SPL_BUILD
252void board_init_f(ulong dummy)
253{
254 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
Alison Wang036f3f32015-03-12 11:31:44 +0800255 unsigned int major;
Alison Wang86949c22014-12-03 15:00:47 +0800256
Alison Wang8ab967b2014-12-09 17:38:14 +0800257#ifdef CONFIG_NAND_BOOT
258 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
259 u32 porsr1, pinctl;
260
261 /*
262 * There is LS1 SoC issue where NOR, FPGA are inaccessible during
263 * NAND boot because IFC signals > IFC_AD7 are not enabled.
264 * This workaround changes RCW source to make all signals enabled.
265 */
266 porsr1 = in_be32(&gur->porsr1);
267 pinctl = ((porsr1 & ~(DCFG_CCSR_PORSR1_RCW_MASK)) |
268 DCFG_CCSR_PORSR1_RCW_SRC_I2C);
269 out_be32((unsigned int *)(CONFIG_SYS_DCSR_DCFG_ADDR + DCFG_DCSR_PORCR1),
270 pinctl);
271#endif
272
Alison Wang86949c22014-12-03 15:00:47 +0800273 /* Clear the BSS */
274 memset(__bss_start, 0, __bss_end - __bss_start);
275
276#ifdef CONFIG_FSL_IFC
277 init_early_memctl_regs();
278#endif
279
280 get_clocks();
281
tang yuantian41ba57d2014-12-17 12:58:05 +0800282#if defined(CONFIG_DEEP_SLEEP)
283 if (is_warm_boot())
284 fsl_dp_disable_console();
285#endif
286
Alison Wang86949c22014-12-03 15:00:47 +0800287 preloader_console_init();
288
289#ifdef CONFIG_SPL_I2C_SUPPORT
290 i2c_init_all();
291#endif
Alison Wang036f3f32015-03-12 11:31:44 +0800292
293 major = get_soc_major_rev();
294 if (major == SOC_MAJOR_VER_1_0)
295 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_TERM_BARRIER);
Alison Wang86949c22014-12-03 15:00:47 +0800296
297 dram_init();
298
Alison Wang8f0c7cb2015-07-09 10:50:07 +0800299 /* Allow OCRAM access permission as R/W */
Mingkai Hu435acd82015-10-26 19:47:41 +0800300#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
301 enable_layerscape_ns_access();
Alison Wang8f0c7cb2015-07-09 10:50:07 +0800302#endif
303
Alison Wang86949c22014-12-03 15:00:47 +0800304 board_init_r(NULL, 0);
305}
306#endif
307
Alison Wang0f5e5572014-12-09 17:38:23 +0800308void config_etseccm_source(int etsec_gtx_125_mux)
309{
310 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
311
312 switch (etsec_gtx_125_mux) {
313 case GE0_CLK125:
314 out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE0_CLK125);
315 debug("etseccm set to GE0_CLK125\n");
316 break;
317
318 case GE2_CLK125:
319 out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125);
320 debug("etseccm set to GE2_CLK125\n");
321 break;
322
323 case GE1_CLK125:
324 out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE1_CLK125);
325 debug("etseccm set to GE1_CLK125\n");
326 break;
327
328 default:
329 printf("Error! trying to set etseccm to invalid value\n");
330 break;
331 }
332}
333
Wang Huan550e3dc2014-09-05 13:52:44 +0800334int config_board_mux(int ctrl_type)
335{
Yao Yuanbca11bd2014-11-26 14:54:33 +0800336 u8 reg12, reg14;
Wang Huan550e3dc2014-09-05 13:52:44 +0800337
338 reg12 = QIXIS_READ(brdcfg[12]);
Yao Yuanbca11bd2014-11-26 14:54:33 +0800339 reg14 = QIXIS_READ(brdcfg[14]);
Wang Huan550e3dc2014-09-05 13:52:44 +0800340
341 switch (ctrl_type) {
Yao Yuanbca11bd2014-11-26 14:54:33 +0800342 case MUX_TYPE_CAN:
Alison Wang0f5e5572014-12-09 17:38:23 +0800343 config_etseccm_source(GE2_CLK125);
Yao Yuanbca11bd2014-11-26 14:54:33 +0800344 reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_CAN);
345 break;
346 case MUX_TYPE_IIC2:
347 reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_IIC2);
348 break;
349 case MUX_TYPE_RGMII:
350 reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_RGMII);
351 break;
352 case MUX_TYPE_SAI:
Alison Wang0f5e5572014-12-09 17:38:23 +0800353 config_etseccm_source(GE2_CLK125);
Yao Yuanbca11bd2014-11-26 14:54:33 +0800354 reg14 = SET_EC_MUX_SEL(reg14, PIN_MUX_SEL_SAI);
355 break;
356 case MUX_TYPE_SDHC:
357 reg14 = SET_SDHC_MUX_SEL(reg14, PIN_MUX_SEL_SDHC);
358 break;
Wang Huan550e3dc2014-09-05 13:52:44 +0800359 case MUX_TYPE_SD_PCI4:
360 reg12 = 0x38;
361 break;
362 case MUX_TYPE_SD_PC_SA_SG_SG:
363 reg12 = 0x01;
364 break;
365 case MUX_TYPE_SD_PC_SA_PC_SG:
366 reg12 = 0x01;
367 break;
368 case MUX_TYPE_SD_PC_SG_SG:
369 reg12 = 0x21;
370 break;
371 default:
372 printf("Wrong mux interface type\n");
373 return -1;
374 }
375
376 QIXIS_WRITE(brdcfg[12], reg12);
Yao Yuanbca11bd2014-11-26 14:54:33 +0800377 QIXIS_WRITE(brdcfg[14], reg14);
Wang Huan550e3dc2014-09-05 13:52:44 +0800378
379 return 0;
380}
381
382int config_serdes_mux(void)
383{
384 struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_FSL_GUTS_ADDR;
385 u32 cfg;
386
387 cfg = in_be32(&gur->rcwsr[4]) & RCWSR4_SRDS1_PRTCL_MASK;
388 cfg >>= RCWSR4_SRDS1_PRTCL_SHIFT;
389
390 switch (cfg) {
391 case 0x0:
392 config_board_mux(MUX_TYPE_SD_PCI4);
393 break;
394 case 0x30:
395 config_board_mux(MUX_TYPE_SD_PC_SA_SG_SG);
396 break;
397 case 0x60:
398 config_board_mux(MUX_TYPE_SD_PC_SG_SG);
399 break;
400 case 0x70:
401 config_board_mux(MUX_TYPE_SD_PC_SA_PC_SG);
402 break;
403 default:
404 printf("SRDS1 prtcl:0x%x\n", cfg);
405 break;
406 }
407
408 return 0;
409}
410
tang yuantian4632ad72015-10-16 16:06:05 +0800411#ifdef CONFIG_BOARD_LATE_INIT
412int board_late_init(void)
413{
414#ifdef CONFIG_SCSI_AHCI_PLAT
415 ls1021a_sata_init();
416#endif
417
418 return 0;
419}
420#endif
421
Ruchika Gupta4ba4a092014-10-15 11:39:06 +0530422int misc_init_r(void)
423{
Yao Yuanbca11bd2014-11-26 14:54:33 +0800424 int conflict_flag;
425
426 /* some signals can not enable simultaneous*/
427 conflict_flag = 0;
428 if (hwconfig("sdhc"))
429 conflict_flag++;
430 if (hwconfig("iic2"))
431 conflict_flag++;
432 if (conflict_flag > 1) {
433 printf("WARNING: pin conflict !\n");
434 return 0;
435 }
436
437 conflict_flag = 0;
438 if (hwconfig("rgmii"))
439 conflict_flag++;
440 if (hwconfig("can"))
441 conflict_flag++;
442 if (hwconfig("sai"))
443 conflict_flag++;
444 if (conflict_flag > 1) {
445 printf("WARNING: pin conflict !\n");
446 return 0;
447 }
448
449 if (hwconfig("can"))
450 config_board_mux(MUX_TYPE_CAN);
451 else if (hwconfig("rgmii"))
452 config_board_mux(MUX_TYPE_RGMII);
453 else if (hwconfig("sai"))
454 config_board_mux(MUX_TYPE_SAI);
455
456 if (hwconfig("iic2"))
457 config_board_mux(MUX_TYPE_IIC2);
458 else if (hwconfig("sdhc"))
459 config_board_mux(MUX_TYPE_SDHC);
460
Zhuoyu Zhang03c22442015-08-17 18:55:12 +0800461#ifdef CONFIG_FSL_DEVICE_DISABLE
462 device_disable(devdis_tbl, ARRAY_SIZE(devdis_tbl));
463#endif
Ruchika Gupta4ba4a092014-10-15 11:39:06 +0530464#ifdef CONFIG_FSL_CAAM
465 return sec_init();
466#endif
Yao Yuanbca11bd2014-11-26 14:54:33 +0800467 return 0;
Ruchika Gupta4ba4a092014-10-15 11:39:06 +0530468}
Ruchika Gupta4ba4a092014-10-15 11:39:06 +0530469
Alison Wang81335742015-01-16 17:21:34 +0800470struct liodn_id_table sec_liodn_tbl[] = {
471 SET_SEC_JR_LIODN_ENTRY(0, 0x10, 0x10),
472 SET_SEC_JR_LIODN_ENTRY(1, 0x10, 0x10),
473 SET_SEC_JR_LIODN_ENTRY(2, 0x10, 0x10),
474 SET_SEC_JR_LIODN_ENTRY(3, 0x10, 0x10),
475 SET_SEC_RTIC_LIODN_ENTRY(a, 0x10),
476 SET_SEC_RTIC_LIODN_ENTRY(b, 0x10),
477 SET_SEC_RTIC_LIODN_ENTRY(c, 0x10),
478 SET_SEC_RTIC_LIODN_ENTRY(d, 0x10),
479 SET_SEC_DECO_LIODN_ENTRY(0, 0x10, 0x10),
480 SET_SEC_DECO_LIODN_ENTRY(1, 0x10, 0x10),
481 SET_SEC_DECO_LIODN_ENTRY(2, 0x10, 0x10),
482 SET_SEC_DECO_LIODN_ENTRY(3, 0x10, 0x10),
483 SET_SEC_DECO_LIODN_ENTRY(4, 0x10, 0x10),
484 SET_SEC_DECO_LIODN_ENTRY(5, 0x10, 0x10),
485 SET_SEC_DECO_LIODN_ENTRY(6, 0x10, 0x10),
486 SET_SEC_DECO_LIODN_ENTRY(7, 0x10, 0x10),
487};
488
Xiubo Li660673a2014-11-21 17:40:59 +0800489struct smmu_stream_id dev_stream_id[] = {
490 { 0x100, 0x01, "ETSEC MAC1" },
491 { 0x104, 0x02, "ETSEC MAC2" },
492 { 0x108, 0x03, "ETSEC MAC3" },
493 { 0x10c, 0x04, "PEX1" },
494 { 0x110, 0x05, "PEX2" },
495 { 0x114, 0x06, "qDMA" },
496 { 0x118, 0x07, "SATA" },
497 { 0x11c, 0x08, "USB3" },
498 { 0x120, 0x09, "QE" },
499 { 0x124, 0x0a, "eSDHC" },
500 { 0x128, 0x0b, "eMA" },
501 { 0x14c, 0x0c, "2D-ACE" },
502 { 0x150, 0x0d, "USB2" },
503 { 0x18c, 0x0e, "DEBUG" },
504};
505
Wang Huan550e3dc2014-09-05 13:52:44 +0800506int board_init(void)
507{
508 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)CONFIG_SYS_CCI400_ADDR;
Alison Wang036f3f32015-03-12 11:31:44 +0800509 unsigned int major;
Wang Huan550e3dc2014-09-05 13:52:44 +0800510
Alison Wang036f3f32015-03-12 11:31:44 +0800511 major = get_soc_major_rev();
512 if (major == SOC_MAJOR_VER_1_0) {
513 /* Set CCI-400 control override register to
514 * enable barrier transaction */
515 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
516 }
Wang Huan550e3dc2014-09-05 13:52:44 +0800517
518 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
519
520#ifndef CONFIG_SYS_FSL_NO_SERDES
521 fsl_serdes_init();
522 config_serdes_mux();
523#endif
Zhao Qiang63e75fd2014-09-26 16:25:32 +0800524
Alison Wang81335742015-01-16 17:21:34 +0800525 ls1021x_config_caam_stream_id(sec_liodn_tbl,
526 ARRAY_SIZE(sec_liodn_tbl));
Xiubo Li660673a2014-11-21 17:40:59 +0800527 ls102xa_config_smmu_stream_id(dev_stream_id,
528 ARRAY_SIZE(dev_stream_id));
529
Mingkai Hu435acd82015-10-26 19:47:41 +0800530#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
531 enable_layerscape_ns_access();
Xiubo Lie87f3b32014-11-21 17:40:58 +0800532#endif
533
Zhao Qiang63e75fd2014-09-26 16:25:32 +0800534#ifdef CONFIG_U_QE
535 u_qe_init();
536#endif
537
Wang Huan550e3dc2014-09-05 13:52:44 +0800538 return 0;
539}
540
tang yuantian41ba57d2014-12-17 12:58:05 +0800541#if defined(CONFIG_DEEP_SLEEP)
542void board_sleep_prepare(void)
543{
544 struct ccsr_cci400 __iomem *cci = (void *)CONFIG_SYS_CCI400_ADDR;
Alison Wang036f3f32015-03-12 11:31:44 +0800545 unsigned int major;
tang yuantian41ba57d2014-12-17 12:58:05 +0800546
Alison Wang036f3f32015-03-12 11:31:44 +0800547 major = get_soc_major_rev();
548 if (major == SOC_MAJOR_VER_1_0) {
549 /* Set CCI-400 control override register to
550 * enable barrier transaction */
551 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
552 }
553
tang yuantian41ba57d2014-12-17 12:58:05 +0800554
Mingkai Hu435acd82015-10-26 19:47:41 +0800555#ifdef CONFIG_LAYERSCAPE_NS_ACCESS
556 enable_layerscape_ns_access();
tang yuantian41ba57d2014-12-17 12:58:05 +0800557#endif
558}
559#endif
560
Simon Glasse895a4b2014-10-23 18:58:47 -0600561int ft_board_setup(void *blob, bd_t *bd)
Wang Huan550e3dc2014-09-05 13:52:44 +0800562{
563 ft_cpu_setup(blob, bd);
Simon Glasse895a4b2014-10-23 18:58:47 -0600564
Minghuan Liand42bd342015-03-12 10:58:48 +0800565#ifdef CONFIG_PCI
566 ft_pci_setup(blob, bd);
Minghuan Lianda419022014-10-31 13:43:44 +0800567#endif
568
Simon Glasse895a4b2014-10-23 18:58:47 -0600569 return 0;
Wang Huan550e3dc2014-09-05 13:52:44 +0800570}
571
572u8 flash_read8(void *addr)
573{
574 return __raw_readb(addr + 1);
575}
576
577void flash_write16(u16 val, void *addr)
578{
579 u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
580
581 __raw_writew(shftval, addr);
582}
583
584u16 flash_read16(void *addr)
585{
586 u16 val = __raw_readw(addr);
587
588 return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00);
589}