2 * Copyright 2007 Wind River Systemes, Inc. <www.windriver.com>
3 * Copyright 2007 Embedded Specialties, Inc.
4 * Joe Hamman joe.hamman@embeddedspecialties.com
6 * Copyright 2004 Freescale Semiconductor.
8 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
10 * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
12 * See file CREDITS for list of people who contributed to this
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 #include <asm/processor.h>
35 #include <asm/immap_86xx.h>
36 #include <asm/fsl_pci.h>
37 #include <asm/fsl_ddr_sdram.h>
39 #include <fdt_support.h>
41 long int fixed_sdram (void);
43 int board_early_init_f (void)
50 puts ("Board: Wind River SBC8641D\n");
55 phys_size_t initdram (int board_type)
59 #if defined(CONFIG_SPD_EEPROM)
60 dram_size = fsl_ddr_sdram();
62 dram_size = fixed_sdram ();
65 #if defined(CONFIG_SYS_RAMBOOT)
74 #if defined(CONFIG_SYS_DRAM_TEST)
77 uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
78 uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
81 puts ("SDRAM test phase 1:\n");
82 for (p = pstart; p < pend; p++)
85 for (p = pstart; p < pend; p++) {
86 if (*p != 0xaaaaaaaa) {
87 printf ("SDRAM test fails at: %08x\n", (uint) p);
92 puts ("SDRAM test phase 2:\n");
93 for (p = pstart; p < pend; p++)
96 for (p = pstart; p < pend; p++) {
97 if (*p != 0x55555555) {
98 printf ("SDRAM test fails at: %08x\n", (uint) p);
103 puts ("SDRAM test passed.\n");
108 #if !defined(CONFIG_SPD_EEPROM)
110 * Fixed sdram init -- doesn't use serial presence detect.
112 long int fixed_sdram (void)
114 #if !defined(CONFIG_SYS_RAMBOOT)
115 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
116 volatile ccsr_ddr_t *ddr = &immap->im_ddr1;
118 ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
119 ddr->cs1_bnds = CONFIG_SYS_DDR_CS1_BNDS;
120 ddr->cs2_bnds = CONFIG_SYS_DDR_CS2_BNDS;
121 ddr->cs3_bnds = CONFIG_SYS_DDR_CS3_BNDS;
122 ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
123 ddr->cs1_config = CONFIG_SYS_DDR_CS1_CONFIG;
124 ddr->cs2_config = CONFIG_SYS_DDR_CS2_CONFIG;
125 ddr->cs3_config = CONFIG_SYS_DDR_CS3_CONFIG;
126 ddr->timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
127 ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
128 ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
129 ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
130 ddr->sdram_cfg = CONFIG_SYS_DDR_CFG_1A;
131 ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CFG_2;
132 ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1;
133 ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2;
134 ddr->sdram_mode_cntl = CONFIG_SYS_DDR_MODE_CTL;
135 ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
136 ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT;
137 ddr->sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL;
143 ddr->sdram_cfg = CONFIG_SYS_DDR_CFG_1B;
147 ddr = &immap->im_ddr2;
149 ddr->cs0_bnds = CONFIG_SYS_DDR2_CS0_BNDS;
150 ddr->cs1_bnds = CONFIG_SYS_DDR2_CS1_BNDS;
151 ddr->cs2_bnds = CONFIG_SYS_DDR2_CS2_BNDS;
152 ddr->cs3_bnds = CONFIG_SYS_DDR2_CS3_BNDS;
153 ddr->cs0_config = CONFIG_SYS_DDR2_CS0_CONFIG;
154 ddr->cs1_config = CONFIG_SYS_DDR2_CS1_CONFIG;
155 ddr->cs2_config = CONFIG_SYS_DDR2_CS2_CONFIG;
156 ddr->cs3_config = CONFIG_SYS_DDR2_CS3_CONFIG;
157 ddr->timing_cfg_3 = CONFIG_SYS_DDR2_EXT_REFRESH;
158 ddr->timing_cfg_0 = CONFIG_SYS_DDR2_TIMING_0;
159 ddr->timing_cfg_1 = CONFIG_SYS_DDR2_TIMING_1;
160 ddr->timing_cfg_2 = CONFIG_SYS_DDR2_TIMING_2;
161 ddr->sdram_cfg = CONFIG_SYS_DDR2_CFG_1A;
162 ddr->sdram_cfg_2 = CONFIG_SYS_DDR2_CFG_2;
163 ddr->sdram_mode = CONFIG_SYS_DDR2_MODE_1;
164 ddr->sdram_mode_2 = CONFIG_SYS_DDR2_MODE_2;
165 ddr->sdram_mode_cntl = CONFIG_SYS_DDR2_MODE_CTL;
166 ddr->sdram_interval = CONFIG_SYS_DDR2_INTERVAL;
167 ddr->sdram_data_init = CONFIG_SYS_DDR2_DATA_INIT;
168 ddr->sdram_clk_cntl = CONFIG_SYS_DDR2_CLK_CTRL;
174 ddr->sdram_cfg = CONFIG_SYS_DDR2_CFG_1B;
179 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
181 #endif /* !defined(CONFIG_SPD_EEPROM) */
183 #if defined(CONFIG_PCI)
185 * Initialize PCI Devices, report devices found.
188 #ifndef CONFIG_PCI_PNP
189 static struct pci_config_table pci_fsl86xxads_config_table[] = {
190 {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
191 PCI_IDSEL_NUMBER, PCI_ANY_ID,
192 pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
194 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER}},
199 static struct pci_controller pci1_hose = {
200 #ifndef CONFIG_PCI_PNP
201 config_table:pci_mpc86xxcts_config_table
204 #endif /* CONFIG_PCI */
207 static struct pci_controller pci2_hose;
208 #endif /* CONFIG_PCI2 */
210 int first_free_busno = 0;
212 void pci_init_board(void)
214 volatile immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR;
215 volatile ccsr_gur_t *gur = &immap->im_gur;
216 uint devdisr = gur->devdisr;
217 uint io_sel = (gur->pordevsr & MPC8641_PORDEVSR_IO_SEL)
218 >> MPC8641_PORDEVSR_IO_SEL_SHIFT;
222 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR;
223 struct pci_controller *hose = &pci1_hose;
224 struct pci_region *r = hose->regions;
226 uint host1_agent = (gur->porbmsr & MPC8641_PORBMSR_HA)
227 >> MPC8641_PORBMSR_HA_SHIFT;
228 uint pex1_agent = (host1_agent == 0) || (host1_agent == 1);
230 if ((io_sel == 2 || io_sel == 3 || io_sel == 5
231 || io_sel == 6 || io_sel == 7 || io_sel == 0xF)
232 && !(devdisr & MPC86xx_DEVDISR_PCIEX1)) {
233 debug("PCI-EXPRESS 1: %s \n", pex1_agent ? "Agent" : "Host");
234 debug("0x%08x=0x%08x ", &pci->pme_msg_det, pci->pme_msg_det);
235 if (pci->pme_msg_det) {
236 pci->pme_msg_det = 0xffffffff;
237 debug(" with errors. Clearing. Now 0x%08x",
242 /* outbound memory */
244 CONFIG_SYS_PCI1_MEM_BUS,
245 CONFIG_SYS_PCI1_MEM_PHYS,
246 CONFIG_SYS_PCI1_MEM_SIZE,
251 CONFIG_SYS_PCI1_IO_BUS,
252 CONFIG_SYS_PCI1_IO_PHYS,
253 CONFIG_SYS_PCI1_IO_SIZE,
256 hose->region_count = r - hose->regions;
258 hose->first_busno=first_free_busno;
260 fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
262 first_free_busno=hose->last_busno+1;
263 printf (" PCI-EXPRESS 1 on bus %02x - %02x\n",
264 hose->first_busno,hose->last_busno);
267 puts("PCI-EXPRESS 1: Disabled\n");
271 puts("PCI-EXPRESS1: Disabled\n");
272 #endif /* CONFIG_PCI1 */
276 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI2_ADDR;
277 struct pci_controller *hose = &pci2_hose;
278 struct pci_region *r = hose->regions;
280 /* outbound memory */
282 CONFIG_SYS_PCI2_MEM_BUS,
283 CONFIG_SYS_PCI2_MEM_PHYS,
284 CONFIG_SYS_PCI2_MEM_SIZE,
289 CONFIG_SYS_PCI2_IO_BUS,
290 CONFIG_SYS_PCI2_IO_PHYS,
291 CONFIG_SYS_PCI2_IO_SIZE,
294 hose->region_count = r - hose->regions;
296 hose->first_busno=first_free_busno;
298 fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
300 first_free_busno=hose->last_busno+1;
301 printf (" PCI-EXPRESS 2 on bus %02x - %02x\n",
302 hose->first_busno,hose->last_busno);
305 puts("PCI-EXPRESS 2: Disabled\n");
306 #endif /* CONFIG_PCI2 */
311 #if defined(CONFIG_OF_BOARD_SETUP)
312 void ft_board_setup (void *blob, bd_t *bd)
314 ft_cpu_setup(blob, bd);
317 ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
320 ft_fsl_pci_setup(blob, "pci1", &pci2_hose);
325 void sbc8641d_reset_board (void)
327 puts ("Resetting board....\n");
332 * Clock is fixed at 1GHz on this board. Used for CONFIG_SYS_CLK_FREQ
335 unsigned long get_board_sys_clk (ulong dummy)
373 void board_reset(void)
375 #ifdef CONFIG_SYS_RESET_ADDRESS
376 ulong addr = CONFIG_SYS_RESET_ADDRESS;
378 /* flush and disable I/D cache */
379 __asm__ __volatile__ ("mfspr 3, 1008" ::: "r3");
380 __asm__ __volatile__ ("ori 5, 5, 0xcc00" ::: "r5");
381 __asm__ __volatile__ ("ori 4, 3, 0xc00" ::: "r4");
382 __asm__ __volatile__ ("andc 5, 3, 5" ::: "r5");
383 __asm__ __volatile__ ("sync");
384 __asm__ __volatile__ ("mtspr 1008, 4");
385 __asm__ __volatile__ ("isync");
386 __asm__ __volatile__ ("sync");
387 __asm__ __volatile__ ("mtspr 1008, 5");
388 __asm__ __volatile__ ("isync");
389 __asm__ __volatile__ ("sync");
392 * SRR0 has system reset vector, SRR1 has default MSR value
393 * rfi restores MSR from SRR1 and sets the PC to the SRR0 value
395 __asm__ __volatile__ ("mtspr 26, %0" :: "r" (addr));
396 __asm__ __volatile__ ("li 4, (1 << 6)" ::: "r4");
397 __asm__ __volatile__ ("mtspr 27, 4");
398 __asm__ __volatile__ ("rfi");
403 extern void cpu_mp_lmb_reserve(struct lmb *lmb);
405 void board_lmb_reserve(struct lmb *lmb)
407 cpu_mp_lmb_reserve(lmb);