2 * Copyright 2016 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <fdt_support.h>
10 #include <fsl_ddr_sdram.h>
12 #include <asm/arch/clock.h>
13 #include <asm/arch/fsl_serdes.h>
14 #include <asm/arch/fdt.h>
15 #include <asm/arch/mmu.h>
16 #include <asm/arch/soc.h>
23 #include <fsl_esdhc.h>
27 #include "../common/vid.h"
28 #include "../common/qixis.h"
29 #include "ls1046aqds_qixis.h"
31 DECLARE_GLOBAL_DATA_PTR;
40 #ifndef CONFIG_SD_BOOT
44 puts("Board: LS1046AQDS, boot from ");
49 sw = QIXIS_READ(brdcfg[0]);
50 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
53 printf("vBank: %d\n", sw);
61 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
64 printf("Sys ID: 0x%02x, Sys Ver: 0x%02x\n",
65 QIXIS_READ(id), QIXIS_READ(arch));
67 printf("FPGA: v%d (%s), build %d\n",
68 (int)QIXIS_READ(scver), qixis_read_tag(buf),
69 (int)qixis_read_minor());
74 bool if_board_diff_clk(void)
76 u8 diff_conf = QIXIS_READ(brdcfg[11]);
78 return diff_conf & 0x40;
81 unsigned long get_board_sys_clk(void)
83 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
85 switch (sysclk_conf & 0x0f) {
90 case QIXIS_SYSCLK_100:
92 case QIXIS_SYSCLK_125:
94 case QIXIS_SYSCLK_133:
96 case QIXIS_SYSCLK_150:
98 case QIXIS_SYSCLK_160:
100 case QIXIS_SYSCLK_166:
107 unsigned long get_board_ddr_clk(void)
109 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
111 if (if_board_diff_clk())
112 return get_board_sys_clk();
113 switch ((ddrclk_conf & 0x30) >> 4) {
114 case QIXIS_DDRCLK_100:
116 case QIXIS_DDRCLK_125:
118 case QIXIS_DDRCLK_133:
126 u32 get_lpuart_clk(void)
132 int select_i2c_ch_pca9547(u8 ch)
136 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
138 puts("PCA: failed to select proper channel\n");
148 * When resuming from deep sleep, the I2C channel may not be
149 * in the default channel. So, switch to the default channel
150 * before accessing DDR SPD.
152 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
154 #if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
155 /* This will break-before-make MMU for DDR */
156 update_early_mmu_table();
162 int i2c_multiplexer_select_vid_channel(u8 channel)
164 return select_i2c_ch_pca9547(channel);
167 int board_early_init_f(void)
169 #ifdef CONFIG_HAS_FSL_XHCI_USB
170 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
177 #ifdef CONFIG_SYS_I2C_EARLY_INIT
180 fsl_lsch2_early_init_f();
182 #ifdef CONFIG_HAS_FSL_XHCI_USB
183 out_be32(&scfg->rcwpmuxcr0, 0x3333);
184 out_be32(&scfg->usbdrvvbus_selcr, SCFG_USBDRVVBUS_SELCR_USB1);
185 usb_pwrfault = (SCFG_USBPWRFAULT_DEDICATED <<
186 SCFG_USBPWRFAULT_USB3_SHIFT) |
187 (SCFG_USBPWRFAULT_DEDICATED <<
188 SCFG_USBPWRFAULT_USB2_SHIFT) |
189 (SCFG_USBPWRFAULT_SHARED <<
190 SCFG_USBPWRFAULT_USB1_SHIFT);
191 out_be32(&scfg->usbpwrfault_selcr, usb_pwrfault);
195 /* We use lpuart0 as system console */
196 uart = QIXIS_READ(brdcfg[14]);
197 uart &= ~CFG_UART_MUX_MASK;
198 uart |= CFG_LPUART_EN << CFG_UART_MUX_SHIFT;
199 QIXIS_WRITE(brdcfg[14], uart);
205 #ifdef CONFIG_FSL_DEEP_SLEEP
206 /* determine if it is a warm boot */
207 bool is_warm_boot(void)
209 #define DCFG_CCSR_CRSTSR_WDRFR (1 << 3)
210 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
212 if (in_be32(&gur->crstsr) & DCFG_CCSR_CRSTSR_WDRFR)
219 int config_board_mux(int ctrl_type)
223 reg14 = QIXIS_READ(brdcfg[14]);
227 reg14 = (reg14 & (~0x6)) | 0x2;
230 puts("Unsupported mux interface type\n");
234 QIXIS_WRITE(brdcfg[14], reg14);
239 int config_serdes_mux(void)
244 #ifdef CONFIG_MISC_INIT_R
245 int misc_init_r(void)
247 if (hwconfig("gpio"))
248 config_board_mux(MUX_TYPE_GPIO);
256 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
258 #ifdef CONFIG_SYS_FSL_SERDES
262 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
263 enable_layerscape_ns_access();
267 printf("Warning: Adjusting core voltage failed.\n");
272 #ifdef CONFIG_OF_BOARD_SETUP
273 int ft_board_setup(void *blob, bd_t *bd)
275 u64 base[CONFIG_NR_DRAM_BANKS];
276 u64 size[CONFIG_NR_DRAM_BANKS];
279 /* fixup DT for the two DDR banks */
280 base[0] = gd->bd->bi_dram[0].start;
281 size[0] = gd->bd->bi_dram[0].size;
282 base[1] = gd->bd->bi_dram[1].start;
283 size[1] = gd->bd->bi_dram[1].size;
285 fdt_fixup_memory_banks(blob, base, size, 2);
286 ft_cpu_setup(blob, bd);
288 #ifdef CONFIG_SYS_DPAA_FMAN
289 fdt_fixup_fman_ethernet(blob);
290 fdt_fixup_board_enet(blob);
293 reg = QIXIS_READ(brdcfg[0]);
294 reg = (reg & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
296 /* Disable IFC if QSPI is enabled */
298 do_fixup_by_compat(blob, "fsl,ifc",
299 "status", "disabled", 8 + 1, 1);
305 u8 flash_read8(void *addr)
307 return __raw_readb(addr + 1);
310 void flash_write16(u16 val, void *addr)
312 u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
314 __raw_writew(shftval, addr);
317 u16 flash_read16(void *addr)
319 u16 val = __raw_readw(addr);
321 return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00);