2 * Copyright 2011,2012 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <linux/compiler.h>
12 #include <asm/processor.h>
13 #include <asm/cache.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 extern void pci_of_setup(void *blob
, bd_t
*bd
);
25 DECLARE_GLOBAL_DATA_PTR
;
30 struct cpu_type
*cpu
= gd
->arch
.cpu
;
33 printf("Board: %sRDB, ", cpu
->name
);
34 printf("CPLD version: %d.%d ", CPLD_READ(cpld_ver
),
35 CPLD_READ(cpld_ver_sub
));
37 sw
= CPLD_READ(fbank_sel
);
38 printf("vBank: %d\n", sw
& 0x1);
41 * Display the actual SERDES reference clocks as configured by the
42 * dip switches on the board. Note that the SWx registers could
43 * technically be set to force the reference clocks to match the
44 * values that the SERDES expects (or vice versa). For now, however,
45 * we just display both values and hope the user notices when they
48 puts("SERDES Reference Clocks: ");
49 sw
= in_8(&CPLD_SW(2)) >> 2;
50 for (i
= 0; i
< 2; i
++) {
51 static const char * const freq
[][3] = {{"0", "100", "125"},
52 {"100", "156.25", "125"}
54 unsigned int clock
= (sw
>> (2 * i
)) & 3;
56 printf("Bank%u=%sMhz ", i
+1, freq
[i
][clock
]);
63 int board_early_init_f(void)
65 ccsr_gur_t
*gur
= (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR
);
67 /* board only uses the DDR_MCK0/1, so disable the DDR_MCK2/3 */
68 setbits_be32(&gur
->ddrclkdr
, 0x000f000f);
73 #define CPLD_LANE_A_SEL 0x1
74 #define CPLD_LANE_G_SEL 0x2
75 #define CPLD_LANE_C_SEL 0x4
76 #define CPLD_LANE_D_SEL 0x8
78 void board_config_lanes_mux(void)
80 ccsr_gur_t
*gur
= (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR
;
81 int srds_prtcl
= (in_be32(&gur
->rcwsr
[4]) &
82 FSL_CORENET_RCWSR4_SRDS_PRTCL
) >> 26;
93 mux
|= CPLD_LANE_C_SEL
| CPLD_LANE_D_SEL
;
96 mux
|= CPLD_LANE_A_SEL
;
99 mux
|= CPLD_LANE_G_SEL
;
104 mux
|= CPLD_LANE_G_SEL
| CPLD_LANE_C_SEL
| CPLD_LANE_D_SEL
;
107 mux
|= CPLD_LANE_G_SEL
| CPLD_LANE_A_SEL
;
110 printf("Fman:Unsupported SerDes Protocol 0x%02x\n", srds_prtcl
);
113 CPLD_WRITE(serdes_mux
, mux
);
116 int board_early_init_r(void)
118 const unsigned int flashbase
= CONFIG_SYS_FLASH_BASE
;
119 const u8 flash_esel
= find_tlb_idx((void *)flashbase
, 1);
122 * Remap Boot flash + PROMJET region to caching-inhibited
123 * so that flash can be erased properly.
126 /* Flush d-cache and invalidate i-cache of any FLASH data */
130 /* invalidate existing TLB entry for flash + promjet */
131 disable_tlb(flash_esel
);
133 set_tlb(1, flashbase
, CONFIG_SYS_FLASH_BASE_PHYS
,
134 MAS3_SX
|MAS3_SW
|MAS3_SR
, MAS2_I
|MAS2_G
,
135 0, flash_esel
, BOOKE_PAGESZ_256M
, 1);
139 board_config_lanes_mux();
144 unsigned long get_board_sys_clk(unsigned long dummy
)
146 u8 sysclk_conf
= CPLD_READ(sysclk_sw1
);
148 switch (sysclk_conf
& 0x7) {
151 case CPLD_SYSCLK_100
:
158 static const char *serdes_clock_to_string(u32 clock
)
161 case SRDS_PLLCR0_RFCK_SEL_100
:
163 case SRDS_PLLCR0_RFCK_SEL_125
:
165 case SRDS_PLLCR0_RFCK_SEL_156_25
:
172 #define NUM_SRDS_BANKS 2
174 int misc_init_r(void)
176 serdes_corenet_t
*regs
= (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR
;
177 u32 actual
[NUM_SRDS_BANKS
];
180 static const int freq
[][3] = {
181 {0, SRDS_PLLCR0_RFCK_SEL_100
, SRDS_PLLCR0_RFCK_SEL_125
},
182 {SRDS_PLLCR0_RFCK_SEL_100
, SRDS_PLLCR0_RFCK_SEL_156_25
,
183 SRDS_PLLCR0_RFCK_SEL_125
}
186 sw
= in_8(&CPLD_SW(2)) >> 2;
187 for (i
= 0; i
< NUM_SRDS_BANKS
; i
++) {
188 unsigned int clock
= (sw
>> (2 * i
)) & 3;
190 printf("Warning: SDREFCLK%u switch setting of '11' is "
191 "unsupported\n", i
+ 1);
194 if (i
== 0 && clock
== 0)
195 puts("Warning: SDREFCLK1 switch setting of"
196 "'00' is unsupported\n");
198 actual
[i
] = freq
[i
][clock
];
201 * PC board uses a different CPLD with PB board, this CPLD
202 * has cpld_ver_sub = 1, and pcba_ver = 5. But CPLD on PB
203 * board has cpld_ver_sub = 0, and pcba_ver = 4.
205 if ((i
== 1) && (CPLD_READ(cpld_ver_sub
) == 1) &&
206 (CPLD_READ(pcba_ver
) == 5)) {
207 /* PC board bank2 frequency */
208 actual
[i
] = freq
[i
-1][clock
];
212 for (i
= 0; i
< NUM_SRDS_BANKS
; i
++) {
213 u32 expected
= in_be32(®s
->bank
[i
].pllcr0
);
214 expected
&= SRDS_PLLCR0_RFCK_SEL_MASK
;
215 if (expected
!= actual
[i
]) {
216 printf("Warning: SERDES bank %u expects reference clock"
217 " %sMHz, but actual is %sMHz\n", i
+ 1,
218 serdes_clock_to_string(expected
),
219 serdes_clock_to_string(actual
[i
]));
226 void ft_board_setup(void *blob
, bd_t
*bd
)
231 ft_cpu_setup(blob
, bd
);
233 base
= getenv_bootm_low();
234 size
= getenv_bootm_size();
236 fdt_fixup_memory(blob
, (u64
)base
, (u64
)size
);
238 #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB)
239 fdt_fixup_dr_usb(blob
, bd
);
243 pci_of_setup(blob
, bd
);
246 fdt_fixup_liodn(blob
);
247 #ifdef CONFIG_SYS_DPAA_FMAN
248 fdt_fixup_fman_ethernet(blob
);