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 "../common/qixis.h"
24 #include "t1040qds_qixis.h"
26 DECLARE_GLOBAL_DATA_PTR
;
32 struct cpu_type
*cpu
= gd
->arch
.cpu
;
33 static const char *const freq
[] = {"100", "125", "156.25", "161.13",
34 "122.88", "122.88", "122.88"};
37 printf("Board: %sQDS, ", cpu
->name
);
38 printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, ",
39 QIXIS_READ(id
), QIXIS_READ(arch
));
41 sw
= QIXIS_READ(brdcfg
[0]);
42 sw
= (sw
& QIXIS_LBMAP_MASK
) >> QIXIS_LBMAP_SHIFT
;
45 printf("vBank: %d\n", sw
);
53 printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH
);
55 printf("FPGA: v%d (%s), build %d",
56 (int)QIXIS_READ(scver
), qixis_read_tag(buf
),
57 (int)qixis_read_minor());
58 /* the timestamp string contains "\n" at the end */
59 printf(" on %s", qixis_read_time(buf
));
62 * Display the actual SERDES reference clocks as configured by the
63 * dip switches on the board. Note that the SWx registers could
64 * technically be set to force the reference clocks to match the
65 * values that the SERDES expects (or vice versa). For now, however,
66 * we just display both values and hope the user notices when they
69 puts("SERDES Reference: ");
70 sw
= QIXIS_READ(brdcfg
[2]);
71 clock
= (sw
>> 6) & 3;
72 printf("Clock1=%sMHz ", freq
[clock
]);
73 clock
= (sw
>> 4) & 3;
74 printf("Clock2=%sMHz\n", freq
[clock
]);
79 int select_i2c_ch_pca9547(u8 ch
)
83 ret
= i2c_write(I2C_MUX_PCA_ADDR_PRI
, 0, 1, &ch
, 1);
85 puts("PCA: failed to select proper channel\n");
92 int board_early_init_r(void)
94 #ifdef CONFIG_SYS_FLASH_BASE
95 const unsigned int flashbase
= CONFIG_SYS_FLASH_BASE
;
96 const u8 flash_esel
= find_tlb_idx((void *)flashbase
, 1);
99 * Remap Boot flash + PROMJET region to caching-inhibited
100 * so that flash can be erased properly.
103 /* Flush d-cache and invalidate i-cache of any FLASH data */
107 /* invalidate existing TLB entry for flash + promjet */
108 disable_tlb(flash_esel
);
110 set_tlb(1, flashbase
, CONFIG_SYS_FLASH_BASE_PHYS
,
111 MAS3_SX
|MAS3_SW
|MAS3_SR
, MAS2_I
|MAS2_G
,
112 0, flash_esel
, BOOKE_PAGESZ_256M
, 1);
115 #ifdef CONFIG_SYS_DPAA_QBMAN
118 select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT
);
123 unsigned long get_board_sys_clk(void)
125 u8 sysclk_conf
= QIXIS_READ(brdcfg
[1]);
127 switch (sysclk_conf
& 0x0F) {
128 case QIXIS_SYSCLK_64
:
130 case QIXIS_SYSCLK_83
:
132 case QIXIS_SYSCLK_100
:
134 case QIXIS_SYSCLK_125
:
136 case QIXIS_SYSCLK_133
:
138 case QIXIS_SYSCLK_150
:
140 case QIXIS_SYSCLK_160
:
142 case QIXIS_SYSCLK_166
:
148 unsigned long get_board_ddr_clk(void)
150 u8 ddrclk_conf
= QIXIS_READ(brdcfg
[1]);
152 switch ((ddrclk_conf
& 0x30) >> 4) {
153 case QIXIS_DDRCLK_100
:
155 case QIXIS_DDRCLK_125
:
157 case QIXIS_DDRCLK_133
:
163 static const char *serdes_clock_to_string(u32 clock
)
166 case SRDS_PLLCR0_RFCK_SEL_100
:
168 case SRDS_PLLCR0_RFCK_SEL_125
:
170 case SRDS_PLLCR0_RFCK_SEL_156_25
:
173 return "Unknown frequency";
177 #define NUM_SRDS_BANKS 2
178 int misc_init_r(void)
181 serdes_corenet_t
*srds_regs
=
182 (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR
;
183 u32 actual
[NUM_SRDS_BANKS
] = { 0 };
186 sw
= QIXIS_READ(brdcfg
[2]);
187 for (i
= 0; i
< NUM_SRDS_BANKS
; i
++) {
188 unsigned int clock
= (sw
>> (6 - 2 * i
)) & 3;
191 actual
[i
] = SRDS_PLLCR0_RFCK_SEL_100
;
194 actual
[i
] = SRDS_PLLCR0_RFCK_SEL_125
;
197 actual
[i
] = SRDS_PLLCR0_RFCK_SEL_156_25
;
203 for (i
= 0; i
< NUM_SRDS_BANKS
; i
++) {
204 u32 pllcr0
= srds_regs
->bank
[i
].pllcr0
;
205 u32 expected
= pllcr0
& SRDS_PLLCR0_RFCK_SEL_MASK
;
206 if (expected
!= actual
[i
]) {
207 printf("expects ref clk%d %sMHz, but actual is %sMHz\n",
208 i
+ 1, serdes_clock_to_string(expected
),
209 serdes_clock_to_string(actual
[i
]));
216 void ft_board_setup(void *blob
, bd_t
*bd
)
221 ft_cpu_setup(blob
, bd
);
223 base
= getenv_bootm_low();
224 size
= getenv_bootm_size();
226 fdt_fixup_memory(blob
, (u64
)base
, (u64
)size
);
229 pci_of_setup(blob
, bd
);
232 fdt_fixup_liodn(blob
);
234 #ifdef CONFIG_HAS_FSL_DR_USB
235 fdt_fixup_dr_usb(blob
, bd
);
238 #ifdef CONFIG_SYS_DPAA_FMAN
239 fdt_fixup_fman_ethernet(blob
);
243 void qixis_dump_switch(void)
247 QIXIS_WRITE(cms
[0], 0x00);
248 nr_of_cfgsw
= QIXIS_READ(cms
[1]);
250 puts("DIP switch settings dump:\n");
251 for (i
= 1; i
<= nr_of_cfgsw
; i
++) {
252 QIXIS_WRITE(cms
[0], i
);
253 printf("SW%d = (0x%02x)\n", i
, QIXIS_READ(cms
[1]));