2 * Copyright 2013 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
11 #include <linux/compiler.h>
13 #include <asm/processor.h>
14 #include <asm/cache.h>
15 #include <asm/immap_85xx.h>
16 #include <asm/fsl_law.h>
17 #include <asm/fsl_serdes.h>
18 #include <asm/fsl_portals.h>
19 #include <asm/fsl_liodn.h>
22 #include <asm/mpc85xx_gpio.h>
24 #include "../common/qixis.h"
26 #include "t1040qds_qixis.h"
28 DECLARE_GLOBAL_DATA_PTR;
34 struct cpu_type *cpu = gd->arch.cpu;
35 static const char *const freq[] = {"100", "125", "156.25", "161.13",
36 "122.88", "122.88", "122.88"};
39 printf("Board: %sQDS, ", cpu->name);
40 printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, ",
41 QIXIS_READ(id), QIXIS_READ(arch));
43 sw = QIXIS_READ(brdcfg[0]);
44 sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
47 printf("vBank: %d\n", sw);
55 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
57 printf("FPGA: v%d (%s), build %d",
58 (int)QIXIS_READ(scver), qixis_read_tag(buf),
59 (int)qixis_read_minor());
60 /* the timestamp string contains "\n" at the end */
61 printf(" on %s", qixis_read_time(buf));
64 * Display the actual SERDES reference clocks as configured by the
65 * dip switches on the board. Note that the SWx registers could
66 * technically be set to force the reference clocks to match the
67 * values that the SERDES expects (or vice versa). For now, however,
68 * we just display both values and hope the user notices when they
71 puts("SERDES Reference: ");
72 sw = QIXIS_READ(brdcfg[2]);
73 clock = (sw >> 6) & 3;
74 printf("Clock1=%sMHz ", freq[clock]);
75 clock = (sw >> 4) & 3;
76 printf("Clock2=%sMHz\n", freq[clock]);
81 int select_i2c_ch_pca9547(u8 ch)
85 ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
87 puts("PCA: failed to select proper channel\n");
94 static void qe_board_setup(void)
98 if (hwconfig("qe") && hwconfig("tdm")) {
99 brdcfg15 = QIXIS_READ(brdcfg[15]);
101 * TDMRiser uses QE-TDM
102 * Route QE_TDM signals to TDM Riser slot
104 QIXIS_WRITE(brdcfg[15], brdcfg15 | 7);
105 } else if (hwconfig("qe") && hwconfig("uart")) {
106 brdcfg15 = QIXIS_READ(brdcfg[15]);
107 brdcfg9 = QIXIS_READ(brdcfg[9]);
109 * Route QE_TDM signals to UCC
110 * ProfiBus controlled by UCC3
113 QIXIS_WRITE(brdcfg[15], brdcfg15 | 2);
114 QIXIS_WRITE(brdcfg[9], brdcfg9 | 4);
118 int board_early_init_r(void)
120 #ifdef CONFIG_SYS_FLASH_BASE
121 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
122 int flash_esel = find_tlb_idx((void *)flashbase, 1);
125 * Remap Boot flash + PROMJET region to caching-inhibited
126 * so that flash can be erased properly.
129 /* Flush d-cache and invalidate i-cache of any FLASH data */
133 if (flash_esel == -1) {
134 /* very unlikely unless something is messed up */
135 puts("Error: Could not find TLB for FLASH BASE\n");
136 flash_esel = 2; /* give our best effort to continue */
138 /* invalidate existing TLB entry for flash + promjet */
139 disable_tlb(flash_esel);
142 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
143 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
144 0, flash_esel, BOOKE_PAGESZ_256M, 1);
147 #ifdef CONFIG_SYS_DPAA_QBMAN
150 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
155 unsigned long get_board_sys_clk(void)
157 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
159 switch (sysclk_conf & 0x0F) {
160 case QIXIS_SYSCLK_64:
162 case QIXIS_SYSCLK_83:
164 case QIXIS_SYSCLK_100:
166 case QIXIS_SYSCLK_125:
168 case QIXIS_SYSCLK_133:
170 case QIXIS_SYSCLK_150:
172 case QIXIS_SYSCLK_160:
174 case QIXIS_SYSCLK_166:
180 unsigned long get_board_ddr_clk(void)
182 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
184 switch ((ddrclk_conf & 0x30) >> 4) {
185 case QIXIS_DDRCLK_100:
187 case QIXIS_DDRCLK_125:
189 case QIXIS_DDRCLK_133:
195 #define NUM_SRDS_BANKS 2
196 int misc_init_r(void)
199 serdes_corenet_t *srds_regs =
200 (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
201 u32 actual[NUM_SRDS_BANKS] = { 0 };
204 sw = QIXIS_READ(brdcfg[2]);
205 for (i = 0; i < NUM_SRDS_BANKS; i++) {
206 unsigned int clock = (sw >> (6 - 2 * i)) & 3;
209 actual[i] = SRDS_PLLCR0_RFCK_SEL_100;
212 actual[i] = SRDS_PLLCR0_RFCK_SEL_125;
215 actual[i] = SRDS_PLLCR0_RFCK_SEL_156_25;
221 for (i = 0; i < NUM_SRDS_BANKS; i++) {
222 u32 pllcr0 = srds_regs->bank[i].pllcr0;
223 u32 expected = pllcr0 & SRDS_PLLCR0_RFCK_SEL_MASK;
224 if (expected != actual[i]) {
225 printf("expects ref clk%d %sMHz, but actual is %sMHz\n",
226 i + 1, serdes_clock_to_string(expected),
227 serdes_clock_to_string(actual[i]));
236 void ft_board_setup(void *blob, bd_t *bd)
241 ft_cpu_setup(blob, bd);
243 base = getenv_bootm_low();
244 size = getenv_bootm_size();
246 fdt_fixup_memory(blob, (u64)base, (u64)size);
249 pci_of_setup(blob, bd);
252 fdt_fixup_liodn(blob);
254 #ifdef CONFIG_HAS_FSL_DR_USB
255 fdt_fixup_dr_usb(blob, bd);
258 #ifdef CONFIG_SYS_DPAA_FMAN
259 fdt_fixup_fman_ethernet(blob);
260 fdt_fixup_board_enet(blob);
264 void qixis_dump_switch(void)
268 QIXIS_WRITE(cms[0], 0x00);
269 nr_of_cfgsw = QIXIS_READ(cms[1]);
271 puts("DIP switch settings dump:\n");
272 for (i = 1; i <= nr_of_cfgsw; i++) {
273 QIXIS_WRITE(cms[0], i);
274 printf("SW%d = (0x%02x)\n", i, QIXIS_READ(cms[1]));
278 int board_need_mem_reset(void)
283 #ifdef CONFIG_DEEP_SLEEP
284 void board_mem_sleep_setup(void)
286 /* does not provide HW signals for power management */
287 QIXIS_WRITE(pwr_ctl[1], (QIXIS_READ(pwr_ctl[1]) & ~0x2));
288 /* Disable MCKE isolation */
289 gpio_set_value(2, 0);