blob: 2f1d63742ac3ec4254a459e9fc31ffc1119ad492 [file] [log] [blame]
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +05301/*
2 * Copyright 2016 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/clock.h>
11#include <asm/arch/fsl_serdes.h>
Prabhakar Kushwaha5b404be2017-01-30 17:05:35 +053012#ifdef CONFIG_FSL_LS_PPA
13#include <asm/arch/ppa.h>
14#endif
York Sun4961eaf2017-03-06 09:02:34 -080015#include <asm/arch/mmu.h>
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053016#include <asm/arch/soc.h>
17#include <hwconfig.h>
18#include <ahci.h>
19#include <mmc.h>
20#include <scsi.h>
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053021#include <fsl_esdhc.h>
22#include <environment.h>
23#include <fsl_mmdc.h>
24#include <netdev.h>
Vinitha Pillai-B5722311d14bf2017-03-23 13:48:20 +053025#include <fsl_sec.h>
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053026
27DECLARE_GLOBAL_DATA_PTR;
28
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053029int checkboard(void)
30{
31 u8 in1;
32
33 puts("Board: LS1012ARDB ");
34
35 /* Initialize i2c early for Serial flash bank information */
36 i2c_set_bus_num(0);
37
Yangbo Lu481fb012017-12-08 15:35:35 +080038 if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_1, 1, &in1, 1) < 0) {
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053039 printf("Error reading i2c boot information!\n");
40 return 0; /* Don't want to hang() on this error */
41 }
42
43 puts("Version");
Yangbo Lu481fb012017-12-08 15:35:35 +080044 if ((in1 & SW_REV_MASK) == SW_REV_A)
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053045 puts(": RevA");
Yangbo Lu481fb012017-12-08 15:35:35 +080046 else if ((in1 & SW_REV_MASK) == SW_REV_B)
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053047 puts(": RevB");
48 else
49 puts(": unknown");
50
51 printf(", boot from QSPI");
Yangbo Lu481fb012017-12-08 15:35:35 +080052 if ((in1 & SW_BOOT_MASK) == SW_BOOT_EMU)
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053053 puts(": emu\n");
Yangbo Lu481fb012017-12-08 15:35:35 +080054 else if ((in1 & SW_BOOT_MASK) == SW_BOOT_BANK1)
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053055 puts(": bank1\n");
Yangbo Lu481fb012017-12-08 15:35:35 +080056 else if ((in1 & SW_BOOT_MASK) == SW_BOOT_BANK2)
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053057 puts(": bank2\n");
58 else
59 puts("unknown\n");
60
61 return 0;
62}
63
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053064int dram_init(void)
65{
York Sun1fdcc8d2016-09-26 08:09:25 -070066 static const struct fsl_mmdc_info mparam = {
67 0x05180000, /* mdctl */
68 0x00030035, /* mdpdc */
69 0x12554000, /* mdotc */
70 0xbabf7954, /* mdcfg0 */
71 0xdb328f64, /* mdcfg1 */
72 0x01ff00db, /* mdcfg2 */
73 0x00001680, /* mdmisc */
74 0x0f3c8000, /* mdref */
75 0x00002000, /* mdrwd */
76 0x00bf1023, /* mdor */
77 0x0000003f, /* mdasp */
78 0x0000022a, /* mpodtctrl */
79 0xa1390003, /* mpzqhwctrl */
80 };
81
82 mmdc_init(&mparam);
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053083
84 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
York Sun4961eaf2017-03-06 09:02:34 -080085#if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
86 /* This will break-before-make MMU for DDR */
87 update_early_mmu_table();
88#endif
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +053089
90 return 0;
91}
92
93int board_eth_init(bd_t *bis)
94{
95 return pci_eth_init(bis);
96}
97
98int board_early_init_f(void)
99{
100 fsl_lsch2_early_init_f();
101
102 return 0;
103}
104
105int board_init(void)
106{
Ashish Kumar63b23162017-08-11 11:09:14 +0530107 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
108 CONFIG_SYS_CCI400_OFFSET);
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +0530109 /*
110 * Set CCI-400 control override register to enable barrier
111 * transaction
112 */
113 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
114
Hou Zhiqiangb392a6d2016-08-02 19:03:27 +0800115#ifdef CONFIG_SYS_FSL_ERRATUM_A010315
116 erratum_a010315();
117#endif
118
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +0530119#ifdef CONFIG_ENV_IS_NOWHERE
120 gd->env_addr = (ulong)&default_environment[0];
121#endif
122
Vinitha Pillai-B5722311d14bf2017-03-23 13:48:20 +0530123#ifdef CONFIG_FSL_CAAM
124 sec_init();
125#endif
126
Prabhakar Kushwaha5b404be2017-01-30 17:05:35 +0530127#ifdef CONFIG_FSL_LS_PPA
128 ppa_init();
129#endif
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +0530130 return 0;
131}
132
Yangbo Lu5e4a6db2017-01-17 10:43:56 +0800133int esdhc_status_fixup(void *blob, const char *compat)
134{
135 char esdhc0_path[] = "/soc/esdhc@1560000";
136 char esdhc1_path[] = "/soc/esdhc@1580000";
137 u8 io = 0;
138 u8 mux_sdhc2;
139
140 do_fixup_by_path(blob, esdhc0_path, "status", "okay",
141 sizeof("okay"), 1);
142
143 i2c_set_bus_num(0);
144
145 /*
146 * The I2C IO-expander for mux select is used to control the muxing
147 * of various onboard interfaces.
148 *
149 * IO1[3:2] indicates SDHC2 interface demultiplexer select lines.
150 * 00 - SDIO wifi
151 * 01 - GPIO (to Arduino)
152 * 10 - eMMC Memory
153 * 11 - SPI
154 */
Yangbo Lu481fb012017-12-08 15:35:35 +0800155 if (i2c_read(I2C_MUX_IO_ADDR, I2C_MUX_IO_0, 1, &io, 1) < 0) {
Yangbo Lu5e4a6db2017-01-17 10:43:56 +0800156 printf("Error reading i2c boot information!\n");
157 return 0; /* Don't want to hang() on this error */
158 }
159
160 mux_sdhc2 = (io & 0x0c) >> 2;
161 /* Enable SDHC2 only when use SDIO wifi and eMMC */
162 if (mux_sdhc2 == 2 || mux_sdhc2 == 0)
163 do_fixup_by_path(blob, esdhc1_path, "status", "okay",
164 sizeof("okay"), 1);
165 else
166 do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
167 sizeof("disabled"), 1);
168 return 0;
169}
170
Prabhakar Kushwaha3b6e3892016-06-03 18:41:35 +0530171int ft_board_setup(void *blob, bd_t *bd)
172{
173 arch_fixup_fdt(blob);
174
175 ft_cpu_setup(blob, bd);
176
177 return 0;
178}