1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2007,2009 Wind River Systems, Inc. <www.windriver.com>
5 * Copyright 2007 Embedded Specialties, Inc.
7 * Copyright 2004, 2007 Freescale Semiconductor.
9 * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
17 #include <asm/processor.h>
18 #include <asm/immap_85xx.h>
19 #include <asm/fsl_pci.h>
20 #include <fsl_ddr_sdram.h>
21 #include <asm/fsl_serdes.h>
22 #include <spd_sdram.h>
26 #include <linux/delay.h>
27 #include <linux/libfdt.h>
28 #include <fdt_support.h>
30 void local_bus_init(void);
32 int board_early_init_f (void)
39 volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
40 volatile u_char *rev= (void *)CONFIG_SYS_BD_REV;
42 printf ("Board: Wind River SBC8548 Rev. 0x%01x\n",
46 * Initialize local bus.
50 out_be32(&ecm->eedr, 0xffffffff); /* clear ecm errors */
51 out_be32(&ecm->eeer, 0xffffffff); /* enable ecm errors */
56 * Initialize Local Bus
61 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
62 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
64 uint clkdiv, lbc_mhz, lcrr = CONFIG_SYS_LBC_LCRR;
67 get_sys_info(&sysinfo);
69 lbc_mhz = sysinfo.freq_localbus / 1000000;
70 clkdiv = sysinfo.freq_systembus / sysinfo.freq_localbus;
72 debug("LCRR=0x%x, CD=%d, MHz=%d\n", lcrr, clkdiv, lbc_mhz);
74 out_be32(&gur->lbiuiplldcr1, 0x00078080);
76 out_be32(&gur->lbiuiplldcr0, 0x7c0f1bf0);
77 } else if (clkdiv == 8) {
78 out_be32(&gur->lbiuiplldcr0, 0x6c0f1bf0);
79 } else if (clkdiv == 4) {
80 out_be32(&gur->lbiuiplldcr0, 0x5c0f1bf0);
84 * Local Bus Clock > 83.3 MHz. According to timing
85 * specifications set LCRR[EADC] to 2 delay cycles.
93 * According to MPC8548ERMAD Rev. 1.3, 13.3.1.16, 13-30
94 * disable PLL bypass for Local Bus Clock > 83 MHz.
97 lcrr &= (~LCRR_DBYP); /* DLL Enabled */
100 lcrr |= LCRR_DBYP; /* DLL Bypass */
102 out_be32(&lbc->lcrr, lcrr);
103 asm("sync;isync;msync");
106 * According to MPC8548ERMAD Rev.1.3 read back LCRR
107 * and terminate with isync
109 lcrr = in_be32(&lbc->lcrr);
112 /* let DLL stabilize */
115 out_be32(&lbc->ltesr, 0xffffffff); /* Clear LBC error IRQs */
116 out_be32(&lbc->lteir, 0xffffffff); /* Enable LBC error IRQs */
120 * Initialize SDRAM memory on the Local Bus.
122 void lbc_sdram_init(void)
124 #if defined(CONFIG_SYS_LBC_SDRAM_SIZE)
127 const unsigned long size = CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024;
128 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
129 uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE;
130 uint *sdram_addr2 = (uint *)(CONFIG_SYS_LBC_SDRAM_BASE + size/2);
134 print_size(size, "\n");
137 * Setup SDRAM Base and Option Registers
139 set_lbc_or(3, CONFIG_SYS_OR3_PRELIM);
140 set_lbc_br(3, CONFIG_SYS_BR3_PRELIM);
141 set_lbc_or(4, CONFIG_SYS_OR4_PRELIM);
142 set_lbc_br(4, CONFIG_SYS_BR4_PRELIM);
144 out_be32(&lbc->lbcr, CONFIG_SYS_LBC_LBCR);
147 out_be32(&lbc->lsrt, CONFIG_SYS_LBC_LSRT);
148 out_be32(&lbc->mrtpr, CONFIG_SYS_LBC_MRTPR);
152 * Issue PRECHARGE ALL command.
154 out_be32(&lbc->lsdmr, CONFIG_SYS_LBC_LSDMR_PCHALL);
157 ppcDcbf((unsigned long) sdram_addr);
159 ppcDcbf((unsigned long) sdram_addr2);
163 * Issue 8 AUTO REFRESH commands.
165 for (idx = 0; idx < 8; idx++) {
166 out_be32(&lbc->lsdmr, CONFIG_SYS_LBC_LSDMR_ARFRSH);
169 ppcDcbf((unsigned long) sdram_addr);
171 ppcDcbf((unsigned long) sdram_addr2);
176 * Issue 8 MODE-set command.
178 out_be32(&lbc->lsdmr, CONFIG_SYS_LBC_LSDMR_MRW);
181 ppcDcbf((unsigned long) sdram_addr);
183 ppcDcbf((unsigned long) sdram_addr2);
187 * Issue RFEN command.
189 out_be32(&lbc->lsdmr, CONFIG_SYS_LBC_LSDMR_RFEN);
192 ppcDcbf((unsigned long) sdram_addr);
194 ppcDcbf((unsigned long) sdram_addr2);
195 udelay(200); /* Overkill. Must wait > 200 bus cycles */
197 #endif /* enable SDRAM init */
200 #if defined(CONFIG_SYS_DRAM_TEST)
204 uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
205 uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
208 printf("Testing DRAM from 0x%08x to 0x%08x\n",
209 CONFIG_SYS_MEMTEST_START,
210 CONFIG_SYS_MEMTEST_END);
212 printf("DRAM test phase 1:\n");
213 for (p = pstart; p < pend; p++)
216 for (p = pstart; p < pend; p++) {
217 if (*p != 0xaaaaaaaa) {
218 printf ("DRAM test fails at: %08x\n", (uint) p);
223 printf("DRAM test phase 2:\n");
224 for (p = pstart; p < pend; p++)
227 for (p = pstart; p < pend; p++) {
228 if (*p != 0x55555555) {
229 printf ("DRAM test fails at: %08x\n", (uint) p);
234 printf("DRAM test passed.\n");
240 static struct pci_controller pci1_hose;
241 #endif /* CONFIG_PCI1 */
247 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
248 int first_free_busno = 0;
251 struct fsl_pci_info pci_info;
252 u32 devdisr = in_be32(&gur->devdisr);
253 u32 pordevsr = in_be32(&gur->pordevsr);
254 u32 porpllsr = in_be32(&gur->porpllsr);
256 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
257 uint pci_32 = pordevsr & MPC85xx_PORDEVSR_PCI1_PCI32;
258 uint pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
259 uint pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
260 uint pci_speed = CONFIG_SYS_CLK_FREQ; /* get_clock_freq() */
262 printf("PCI: Host, %d bit, %s MHz, %s, %s\n",
264 (pci_speed == 33000000) ? "33" :
265 (pci_speed == 66000000) ? "66" : "unknown",
266 pci_clk_sel ? "sync" : "async",
267 pci_arb ? "arbiter" : "external-arbiter");
269 SET_STD_PCI_INFO(pci_info, 1);
270 set_next_law(pci_info.mem_phys,
271 law_size_bits(pci_info.mem_size), pci_info.law);
272 set_next_law(pci_info.io_phys,
273 law_size_bits(pci_info.io_size), pci_info.law);
275 first_free_busno = fsl_pci_init_port(&pci_info,
276 &pci1_hose, first_free_busno);
278 printf("PCI: disabled\n");
283 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
286 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI2); /* disable PCI2 */
288 fsl_pcie_init_board(first_free_busno);
292 int board_eth_init(bd_t *bis)
294 tsec_standard_init(bis);
296 return 0; /* otherwise cpu_eth_init gets run */
299 int last_stage_init(void)
304 #if defined(CONFIG_OF_BOARD_SETUP)
305 int ft_board_setup(void *blob, bd_t *bd)
307 ft_cpu_setup(blob, bd);
309 #ifdef CONFIG_FSL_PCI_INIT