2 * Copyright 2009-2013 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
11 #include <linux/compiler.h>
13 #include <asm/processor.h>
14 #include <asm/immap_85xx.h>
15 #include <asm/fsl_law.h>
16 #include <asm/fsl_serdes.h>
17 #include <asm/fsl_portals.h>
18 #include <asm/fsl_liodn.h>
21 #include "../common/qixis.h"
22 #include "../common/vsc3316_3308.h"
24 #include "t2080qds_qixis.h"
26 DECLARE_GLOBAL_DATA_PTR;
32 struct cpu_type *cpu = gd->arch.cpu;
33 static const char *freq[4] = {
34 "100.00MHZ(from 8T49N222A)", "125.00MHz",
35 "156.25MHZ", "100.00MHz"
38 printf("Board: %sQDS, ", cpu->name);
39 sw = QIXIS_READ(arch);
40 printf("Sys ID: 0x%02x, Board Arch: V%d, ", QIXIS_READ(id), sw >> 4);
41 printf("Board Version: %c, boot from ", (sw & 0xf) + 'A' - 1);
43 sw = QIXIS_READ(brdcfg[0]);
44 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
47 printf("vBank%d\n", sw);
53 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
55 printf("FPGA: v%d (%s), build %d", (int)QIXIS_READ(scver),
56 qixis_read_tag(buf), (int)qixis_read_minor());
57 /* the timestamp string contains "\n" at the end */
58 printf(" on %s", qixis_read_time(buf));
60 puts("SERDES Reference Clocks:\n");
61 sw = QIXIS_READ(brdcfg[2]);
62 printf("SD1_CLK1=%s, SD1_CLK2=%s\n", freq[sw >> 6],
63 freq[(sw >> 4) & 0x3]);
64 printf("SD2_CLK1=%s, SD2_CLK2=%s\n", freq[(sw & 0xf) >> 2],
70 int select_i2c_ch_pca9547(u8 ch)
74 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
76 puts("PCA: failed to select proper channel\n");
83 int brd_mux_lane_to_slot(void)
85 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
86 u32 srds_prtcl_s1, srds_prtcl_s2;
88 srds_prtcl_s1 = in_be32(&gur->rcwsr[4]) &
89 FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
90 srds_prtcl_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
91 srds_prtcl_s2 = in_be32(&gur->rcwsr[4]) &
92 FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
93 srds_prtcl_s2 >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
95 switch (srds_prtcl_s1) {
97 /* SerDes1 is not enabled */
103 /* SD1(A:D) => SLOT3 SGMII
104 * SD1(G:H) => SLOT1 SGMII
106 QIXIS_WRITE(brdcfg[12], 0x58);
109 /* SD1(A:D) => SLOT3 XAUI
110 * SD1(E) => SLOT1 PCIe4
111 * SD1(F:H) => SLOT2 SGMII
113 QIXIS_WRITE(brdcfg[12], 0x15);
117 /* SD1(A:D) => XFI cage
118 * SD1(E:H) => SLOT1 PCIe4
120 QIXIS_WRITE(brdcfg[12], 0xfe);
123 /* SD1(A:D) => XFI cage
124 * SD1(E) => SLOT1 PCIe4
125 * SD1(F:H) => SLOT2 SGMII
127 QIXIS_WRITE(brdcfg[12], 0xf1);
131 /* SD1(A:B) => XFI cage
132 * SD1(C:D) => SLOT3 SGMII
133 * SD1(E:H) => SLOT1 PCIe4
135 QIXIS_WRITE(brdcfg[12], 0xda);
138 printf("WARNING: unsupported for SerDes1 Protocol %d\n",
143 switch (srds_prtcl_s2) {
145 /* SerDes2 is not enabled */
149 /* SD2(A:H) => SLOT4 PCIe1 */
150 QIXIS_WRITE(brdcfg[13], 0x20);
155 * SD2(A:D) => SLOT4 PCIe1
156 * SD2(E:F) => SLOT5 PCIe2
157 * SD2(G:H) => SATA1,SATA2
159 QIXIS_WRITE(brdcfg[13], 0xb0);
163 * SD2(A:D) => SLOT4 PCIe1
164 * SD2(E:F) => SLOT5 Aurora
165 * SD2(G:H) => SATA1,SATA2
167 QIXIS_WRITE(brdcfg[13], 0x70);
171 * SD2(A:D) => SLOT4 PCIe1
172 * SD2(E:H) => SLOT5 PCIe2
174 QIXIS_WRITE(brdcfg[13], 0xa0);
180 * SD2(A:D) => SLOT4 SRIO2
181 * SD2(E:H) => SLOT5 SRIO1
183 QIXIS_WRITE(brdcfg[13], 0x50);
186 printf("WARNING: unsupported for SerDes2 Protocol %d\n",
193 int board_early_init_r(void)
195 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
196 const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
199 * Remap Boot flash + PROMJET region to caching-inhibited
200 * so that flash can be erased properly.
203 /* Flush d-cache and invalidate i-cache of any FLASH data */
207 /* invalidate existing TLB entry for flash + promjet */
208 disable_tlb(flash_esel);
210 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
211 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
212 0, flash_esel, BOOKE_PAGESZ_256M, 1);
215 #ifdef CONFIG_SYS_DPAA_QBMAN
219 /* Disable remote I2C connection to qixis fpga */
220 QIXIS_WRITE(brdcfg[5], QIXIS_READ(brdcfg[5]) & ~BRDCFG5_IRE);
222 brd_mux_lane_to_slot();
223 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
228 unsigned long get_board_sys_clk(void)
230 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
231 #ifdef CONFIG_FSL_QIXIS_CLOCK_MEASUREMENT
232 /* use accurate clock measurement */
233 int freq = QIXIS_READ(clk_freq[0]) << 8 | QIXIS_READ(clk_freq[1]);
234 int base = QIXIS_READ(clk_base[0]) << 8 | QIXIS_READ(clk_base[1]);
239 debug("SYS Clock measurement is: %d\n", val);
242 printf("Warning: SYS clock measurement is invalid, ");
243 printf("using value from brdcfg1.\n");
247 switch (sysclk_conf & 0x0F) {
248 case QIXIS_SYSCLK_83:
250 case QIXIS_SYSCLK_100:
252 case QIXIS_SYSCLK_125:
254 case QIXIS_SYSCLK_133:
256 case QIXIS_SYSCLK_150:
258 case QIXIS_SYSCLK_160:
260 case QIXIS_SYSCLK_166:
266 unsigned long get_board_ddr_clk(void)
268 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
269 #ifdef CONFIG_FSL_QIXIS_CLOCK_MEASUREMENT
270 /* use accurate clock measurement */
271 int freq = QIXIS_READ(clk_freq[2]) << 8 | QIXIS_READ(clk_freq[3]);
272 int base = QIXIS_READ(clk_base[0]) << 8 | QIXIS_READ(clk_base[1]);
277 debug("DDR Clock measurement is: %d\n", val);
280 printf("Warning: DDR clock measurement is invalid, ");
281 printf("using value from brdcfg1.\n");
285 switch ((ddrclk_conf & 0x30) >> 4) {
286 case QIXIS_DDRCLK_100:
288 case QIXIS_DDRCLK_125:
290 case QIXIS_DDRCLK_133:
296 int misc_init_r(void)
301 void ft_board_setup(void *blob, bd_t *bd)
306 ft_cpu_setup(blob, bd);
308 base = getenv_bootm_low();
309 size = getenv_bootm_size();
311 fdt_fixup_memory(blob, (u64)base, (u64)size);
314 pci_of_setup(blob, bd);
317 fdt_fixup_liodn(blob);
318 fdt_fixup_dr_usb(blob, bd);
320 #ifdef CONFIG_SYS_DPAA_FMAN
321 fdt_fixup_fman_ethernet(blob);
322 fdt_fixup_board_enet(blob);