2 * Copyright 2015 Freescale Semiconductor
4 * SPDX-License-Identifier: GPL-2.0+
13 #include <fdt_support.h>
15 #include <fsl_debug_server.h>
16 #include <fsl-mc/fsl_mc.h>
17 #include <environment.h>
19 #include <asm/arch-fsl-lsch3/soc.h>
21 #include "../common/qixis.h"
22 #include "ls2085aqds_qixis.h"
24 DECLARE_GLOBAL_DATA_PTR;
26 unsigned long long get_qixis_addr(void)
28 unsigned long long addr;
30 if (gd->flags & GD_FLG_RELOC)
31 addr = QIXIS_BASE_PHYS;
33 addr = QIXIS_BASE_PHYS_EARLY;
36 * IFC address under 256MB is mapped to 0x30000000, any address above
37 * is mapped to 0x5_10000000 up to 4GB.
39 addr = addr > 0x10000000 ? addr + 0x500000000ULL : addr + 0x30000000;
48 static const char *const freq[] = {"100", "125", "156.25",
53 printf("Board: %s-QDS, ", buf);
55 sw = QIXIS_READ(arch);
56 printf("Board Arch: V%d, ", sw >> 4);
57 printf("Board version: %c, boot from ", (sw & 0xf) + 'A' - 1);
59 memset((u8 *)buf, 0x00, ARRAY_SIZE(buf));
61 sw = QIXIS_READ(brdcfg[0]);
62 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
65 printf("vBank: %d\n", sw);
73 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
75 printf("FPGA: v%d (%s), build %d",
76 (int)QIXIS_READ(scver), qixis_read_tag(buf),
77 (int)qixis_read_minor());
78 /* the timestamp string contains "\n" at the end */
79 printf(" on %s", qixis_read_time(buf));
82 * Display the actual SERDES reference clocks as configured by the
83 * dip switches on the board. Note that the SWx registers could
84 * technically be set to force the reference clocks to match the
85 * values that the SERDES expects (or vice versa). For now, however,
86 * we just display both values and hope the user notices when they
89 puts("SERDES1 Reference : ");
90 sw = QIXIS_READ(brdcfg[2]);
91 clock = (sw >> 6) & 3;
92 printf("Clock1 = %sMHz ", freq[clock]);
93 clock = (sw >> 4) & 3;
94 printf("Clock2 = %sMHz", freq[clock]);
96 puts("\nSERDES2 Reference : ");
97 clock = (sw >> 2) & 3;
98 printf("Clock1 = %sMHz ", freq[clock]);
99 clock = (sw >> 0) & 3;
100 printf("Clock2 = %sMHz\n", freq[clock]);
105 unsigned long get_board_sys_clk(void)
107 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
109 switch (sysclk_conf & 0x0F) {
110 case QIXIS_SYSCLK_83:
112 case QIXIS_SYSCLK_100:
114 case QIXIS_SYSCLK_125:
116 case QIXIS_SYSCLK_133:
118 case QIXIS_SYSCLK_150:
120 case QIXIS_SYSCLK_160:
122 case QIXIS_SYSCLK_166:
128 unsigned long get_board_ddr_clk(void)
130 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
132 switch ((ddrclk_conf & 0x30) >> 4) {
133 case QIXIS_DDRCLK_100:
135 case QIXIS_DDRCLK_125:
137 case QIXIS_DDRCLK_133:
143 int select_i2c_ch_pca9547(u8 ch)
147 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
149 puts("PCA: failed to select proper channel\n");
158 init_final_memctl_regs();
160 #ifdef CONFIG_ENV_IS_NOWHERE
161 gd->env_addr = (ulong)&default_environment[0];
163 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
168 int board_early_init_f(void)
170 fsl_lsch3_early_init_f();
174 void detail_board_ddr_info(void)
177 print_size(gd->bd->bi_dram[0].size + gd->bd->bi_dram[1].size, "");
179 if (gd->bd->bi_dram[2].size) {
181 print_size(gd->bd->bi_dram[2].size, "");
182 print_ddr_info(CONFIG_DP_DDR_CTRL);
188 gd->ram_size = initdram(0);
193 #if defined(CONFIG_ARCH_MISC_INIT)
194 int arch_misc_init(void)
196 #ifdef CONFIG_FSL_DEBUG_SERVER
204 unsigned long get_dram_size_to_hide(void)
206 unsigned long dram_to_hide = 0;
208 /* Carve the Debug Server private DRAM block from the end of DRAM */
209 #ifdef CONFIG_FSL_DEBUG_SERVER
210 dram_to_hide += debug_server_get_dram_block_size();
213 /* Carve the MC private DRAM block from the end of DRAM */
214 #ifdef CONFIG_FSL_MC_ENET
215 dram_to_hide += mc_get_dram_block_size();
218 return roundup(dram_to_hide, CONFIG_SYS_MEM_TOP_HIDE_MIN);
221 #ifdef CONFIG_FSL_MC_ENET
222 void fdt_fixup_board_enet(void *fdt)
226 offset = fdt_path_offset(fdt, "/fsl-mc");
229 offset = fdt_path_offset(fdt, "/fsl,dprc@0");
232 printf("%s: ERROR: fsl-mc node not found in device tree (error %d)\n",
237 if (get_mc_boot_status() == 0)
238 fdt_status_okay(fdt, offset);
240 fdt_status_fail(fdt, offset);
244 #ifdef CONFIG_OF_BOARD_SETUP
245 int ft_board_setup(void *blob, bd_t *bd)
247 u64 base[CONFIG_NR_DRAM_BANKS];
248 u64 size[CONFIG_NR_DRAM_BANKS];
250 ft_cpu_setup(blob, bd);
252 /* fixup DT for the two GPP DDR banks */
253 base[0] = gd->bd->bi_dram[0].start;
254 size[0] = gd->bd->bi_dram[0].size;
255 base[1] = gd->bd->bi_dram[1].start;
256 size[1] = gd->bd->bi_dram[1].size;
258 fdt_fixup_memory_banks(blob, base, size, 2);
260 #ifdef CONFIG_FSL_MC_ENET
261 fdt_fixup_board_enet(blob);
262 fsl_mc_ldpaa_exit(bd);
269 void qixis_dump_switch(void)
273 QIXIS_WRITE(cms[0], 0x00);
274 nr_of_cfgsw = QIXIS_READ(cms[1]);
276 puts("DIP switch settings dump:\n");
277 for (i = 1; i <= nr_of_cfgsw; i++) {
278 QIXIS_WRITE(cms[0], i);
279 printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1]));