blob: bdd95296417cd0aa95760cad2485c1c6abd1a112 [file] [log] [blame]
Prabhakar Kushwaha55432502016-06-03 18:41:34 +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 <fdt_support.h>
10#include <asm/io.h>
11#include <asm/arch/clock.h>
12#include <asm/arch/fsl_serdes.h>
13#include <asm/arch/fdt.h>
14#include <asm/arch/soc.h>
15#include <ahci.h>
16#include <hwconfig.h>
17#include <mmc.h>
18#include <scsi.h>
19#include <fm_eth.h>
Prabhakar Kushwaha55432502016-06-03 18:41:34 +053020#include <fsl_esdhc.h>
21#include <fsl_mmdc.h>
22#include <spl.h>
23#include <netdev.h>
24
25#include "../common/qixis.h"
26#include "ls1012aqds_qixis.h"
27
28DECLARE_GLOBAL_DATA_PTR;
29
Prabhakar Kushwaha55432502016-06-03 18:41:34 +053030int checkboard(void)
31{
32 char buf[64];
33 u8 sw;
34
35 sw = QIXIS_READ(arch);
36 printf("Board Arch: V%d, ", sw >> 4);
37 printf("Board version: %c, boot from ", (sw & 0xf) + 'A' - 1);
38
39 sw = QIXIS_READ(brdcfg[QIXIS_LBMAP_BRDCFG_REG]);
40
41 if (sw & QIXIS_LBMAP_ALTBANK)
42 printf("flash: 2\n");
43 else
44 printf("flash: 1\n");
45
46 printf("FPGA: v%d (%s), build %d",
47 (int)QIXIS_READ(scver), qixis_read_tag(buf),
48 (int)qixis_read_minor());
49
50 /* the timestamp string contains "\n" at the end */
51 printf(" on %s", qixis_read_time(buf));
52 return 0;
53}
54
Prabhakar Kushwaha55432502016-06-03 18:41:34 +053055int dram_init(void)
56{
York Sunc1e979b2016-09-26 08:09:25 -070057 static const struct fsl_mmdc_info mparam = {
58 0x05180000, /* mdctl */
59 0x00030035, /* mdpdc */
60 0x12554000, /* mdotc */
61 0xbabf7954, /* mdcfg0 */
62 0xdb328f64, /* mdcfg1 */
63 0x01ff00db, /* mdcfg2 */
64 0x00001680, /* mdmisc */
65 0x0f3c8000, /* mdref */
66 0x00002000, /* mdrwd */
67 0x00bf1023, /* mdor */
68 0x0000003f, /* mdasp */
69 0x0000022a, /* mpodtctrl */
70 0xa1390003, /* mpzqhwctrl */
71 };
72
73 mmdc_init(&mparam);
Prabhakar Kushwaha55432502016-06-03 18:41:34 +053074
75 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
76
77 return 0;
78}
79
80int board_early_init_f(void)
81{
82 fsl_lsch2_early_init_f();
83
84 return 0;
85}
86
87#ifdef CONFIG_MISC_INIT_R
88int misc_init_r(void)
89{
90 u8 mux_sdhc_cd = 0x80;
91
92 i2c_set_bus_num(0);
93
94 i2c_write(CONFIG_SYS_I2C_FPGA_ADDR, 0x5a, 1, &mux_sdhc_cd, 1);
95 return 0;
96}
97#endif
98
99int board_init(void)
100{
101 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)
102 CONFIG_SYS_CCI400_ADDR;
103
104 /* Set CCI-400 control override register to enable barrier
105 * transaction */
106 out_le32(&cci->ctrl_ord,
107 CCI400_CTRLORD_EN_BARRIER);
108
Hou Zhiqiang4b23ca82016-08-02 19:03:27 +0800109#ifdef CONFIG_SYS_FSL_ERRATUM_A010315
110 erratum_a010315();
111#endif
112
Prabhakar Kushwaha55432502016-06-03 18:41:34 +0530113#ifdef CONFIG_ENV_IS_NOWHERE
114 gd->env_addr = (ulong)&default_environment[0];
115#endif
116 return 0;
117}
118
119int board_eth_init(bd_t *bis)
120{
121 return pci_eth_init(bis);
122}
123
Yangbo Lu4bb1aee2017-01-17 10:43:55 +0800124int esdhc_status_fixup(void *blob, const char *compat)
125{
126 char esdhc0_path[] = "/soc/esdhc@1560000";
127 char esdhc1_path[] = "/soc/esdhc@1580000";
128 u8 card_id;
129
130 do_fixup_by_path(blob, esdhc0_path, "status", "okay",
131 sizeof("okay"), 1);
132
133 /*
134 * The Presence Detect 2 register detects the installation
135 * of cards in various PCI Express or SGMII slots.
136 *
137 * STAT_PRS2[7:5]: Specifies the type of card installed in the
138 * SDHC2 Adapter slot. 0b111 indicates no adapter is installed.
139 */
140 card_id = (QIXIS_READ(present2) & 0xe0) >> 5;
141
142 /* If no adapter is installed in SDHC2, disable SDHC2 */
143 if (card_id == 0x7)
144 do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
145 sizeof("disabled"), 1);
146 else
147 do_fixup_by_path(blob, esdhc1_path, "status", "okay",
148 sizeof("okay"), 1);
149 return 0;
150}
151
Prabhakar Kushwaha55432502016-06-03 18:41:34 +0530152#ifdef CONFIG_OF_BOARD_SETUP
153int ft_board_setup(void *blob, bd_t *bd)
154{
155 arch_fixup_fdt(blob);
156
157 ft_cpu_setup(blob, bd);
158
159 return 0;
160}
161#endif
Prabhakar Kushwaha1fb2f112017-01-30 17:05:22 +0530162
163void dram_init_banksize(void)
164{
165 /*
166 * gd->arch.secure_ram tracks the location of secure memory.
167 * It was set as if the memory starts from 0.
168 * The address needs to add the offset of its bank.
169 */
170 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
171 if (gd->ram_size > CONFIG_SYS_DDR_BLOCK1_SIZE) {
172 gd->bd->bi_dram[0].size = CONFIG_SYS_DDR_BLOCK1_SIZE;
173 gd->bd->bi_dram[1].start = CONFIG_SYS_DDR_BLOCK2_BASE;
174 gd->bd->bi_dram[1].size = gd->ram_size -
175 CONFIG_SYS_DDR_BLOCK1_SIZE;
176#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
177 gd->arch.secure_ram = gd->bd->bi_dram[1].start +
178 gd->arch.secure_ram -
179 CONFIG_SYS_DDR_BLOCK1_SIZE;
180 gd->arch.secure_ram |= MEM_RESERVE_SECURE_MAINTAINED;
181#endif
182 } else {
183 gd->bd->bi_dram[0].size = gd->ram_size;
184#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
185 gd->arch.secure_ram = gd->bd->bi_dram[0].start +
186 gd->arch.secure_ram;
187 gd->arch.secure_ram |= MEM_RESERVE_SECURE_MAINTAINED;
188#endif
189 }
190}