2 * Copyright 2004 Freescale Semiconductor.
3 * Jeff Brown (jeffrey@freescale.com)
4 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
6 * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 #include <asm/processor.h>
30 #include <asm/immap_86xx.h>
33 #if defined(CONFIG_OF_FLAT_TREE)
35 extern void ft_cpu_setup(void *blob, bd_t *bd);
38 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
39 extern void ddr_enable_ecc(unsigned int dram_size);
42 extern long int spd_sdram(void);
44 void local_bus_init(void);
45 void sdram_init(void);
46 long int fixed_sdram(void);
49 int board_early_init_f (void)
56 puts("Board: MPC8641HPCN\n");
60 /* Sri: Note that at this point we will only test on PCI1
63 volatile immap_t *immap = (immap_t *) CFG_CCSRBAR;
64 volatile ccsr_gur_t *gur = &immap->im_gur;
65 volatile ccsr_pex_t *pex1 = &immap->im_pex1;
67 uint devdisr = gur->devdisr;
68 uint io_sel = (gur->pordevsr & MPC86xx_PORDEVSR_IO_SEL) >> 16;
69 uint host1_agent = (gur->porbmsr & MPC86xx_PORBMSR_HA) >> 17;
70 uint pex1_agent = (host1_agent == 0) || (host1_agent == 1);
73 if ((io_sel==2 || io_sel==3 || io_sel==5 || io_sel==6 || io_sel==7 || io_sel==0xF ) && !(devdisr & MPC86xx_DEVDISR_PCIEX1)){
74 debug ("PCI-EXPRESS 1: %s \n",
75 pex1_agent ? "Agent" : "Host");
76 debug("0x%08x=0x%08x ", &pex1->pme_msg_det,pex1->pme_msg_det);
77 if (pex1->pme_msg_det) {
78 pex1->pme_msg_det = 0xffffffff;
79 debug (" with errors. Clearing. Now 0x%08x",pex1->pme_msg_det);
83 printf ("PCI-EXPRESS 1: Disabled\n");
87 printf("PCI-EXPRESS1: Disabled\n");
91 * Initialize local bus.
100 initdram(int board_type)
103 extern long spd_sdram (void);
105 #if defined(CONFIG_SPD_EEPROM)
106 dram_size = spd_sdram ();
108 dram_size = fixed_sdram ();
111 #if defined(CFG_RAMBOOT)
116 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
118 * Initialize and enable DDR ECC.
120 ddr_enable_ecc(dram_size);
124 * Initialize SDRAM. Currently HPCN doesn't have
125 * SDRAM but we'll leave this here for now
126 * in case someone changes their mind
128 #if !defined(CONFIG_MPC8641HPCN)
138 * Initialize Local Bus
144 volatile immap_t *immap = (immap_t *)CFG_IMMR;
145 volatile ccsr_lbc_t *lbc = &immap->im_lbc;
153 * Fix Local Bus clock glitch when DLL is enabled.
155 * If localbus freq is < 66Mhz, DLL bypass mode must be used.
156 * If localbus freq is > 133Mhz, DLL can be safely enabled.
157 * Between 66 and 133, the DLL is enabled with an override workaround.
160 get_sys_info(&sysinfo);
161 clkdiv = lbc->lcrr & 0x0f;
162 lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
165 #if defined(CFG_DRAM_TEST)
168 uint *pstart = (uint *) CFG_MEMTEST_START;
169 uint *pend = (uint *) CFG_MEMTEST_END;
172 printf("SDRAM test phase 1:\n");
173 for (p = pstart; p < pend; p++)
176 for (p = pstart; p < pend; p++) {
177 if (*p != 0xaaaaaaaa) {
178 printf ("SDRAM test fails at: %08x\n", (uint) p);
183 printf("SDRAM test phase 2:\n");
184 for (p = pstart; p < pend; p++)
187 for (p = pstart; p < pend; p++) {
188 if (*p != 0x55555555) {
189 printf ("SDRAM test fails at: %08x\n", (uint) p);
194 printf("SDRAM test passed.\n");
200 #if !defined(CONFIG_SPD_EEPROM)
201 /*************************************************************************
202 * fixed sdram init -- doesn't use serial presence detect.
203 ************************************************************************/
204 long int fixed_sdram (void)
206 #if !defined(CFG_RAMBOOT)
207 volatile immap_t *immap = (immap_t *)CFG_IMMR;
208 volatile ccsr_ddr_t *ddr= &immap->im_ddr1;
210 ddr->cs0_bnds = CFG_DDR_CS0_BNDS;
211 ddr->cs0_config = CFG_DDR_CS0_CONFIG;
212 ddr->ext_refrec = CFG_DDR_EXT_REFRESH;
213 ddr->timing_cfg_0 = CFG_DDR_TIMING_0;
214 ddr->timing_cfg_1 = CFG_DDR_TIMING_1;
215 ddr->timing_cfg_2 = CFG_DDR_TIMING_2;
216 ddr->sdram_mode_1 = CFG_DDR_MODE_1;
217 ddr->sdram_mode_2 = CFG_DDR_MODE_2;
218 ddr->sdram_interval = CFG_DDR_INTERVAL;
219 ddr->sdram_data_init = CFG_DDR_DATA_INIT;
220 ddr->sdram_clk_cntl = CFG_DDR_CLK_CTRL;
221 ddr->sdram_ocd_cntl = CFG_DDR_OCD_CTRL;
222 ddr->sdram_ocd_status = CFG_DDR_OCD_STATUS;
224 #if defined (CONFIG_DDR_ECC)
225 ddr->err_disable = 0x0000008D;
226 ddr->err_sbe = 0x00ff0000;
232 #if defined (CONFIG_DDR_ECC)
233 /* Enable ECC checking */
234 ddr->sdram_cfg_1 = (CFG_DDR_CONTROL | 0x20000000);
236 ddr->sdram_cfg_1 = CFG_DDR_CONTROL;
237 ddr->sdram_cfg_2 = CFG_DDR_CONTROL2;
243 return CFG_SDRAM_SIZE * 1024 * 1024;
245 #endif /* !defined(CONFIG_SPD_EEPROM) */
248 #if defined(CONFIG_PCI)
250 * Initialize PCI Devices, report devices found.
253 #ifndef CONFIG_PCI_PNP
254 static struct pci_config_table pci_fsl86xxads_config_table[] = {
255 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
256 PCI_IDSEL_NUMBER, PCI_ANY_ID,
257 pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
259 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
266 static struct pci_controller hose = {
267 #ifndef CONFIG_PCI_PNP
268 config_table: pci_mpc86xxcts_config_table,
272 #endif /* CONFIG_PCI */
279 extern void pci_mpc86xx_init(struct pci_controller *hose);
281 pci_mpc86xx_init(&hose);
282 #endif /* CONFIG_PCI */
285 #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
287 ft_board_setup(void *blob, bd_t *bd)
292 ft_cpu_setup(blob, bd);
294 p = ft_get_prop(blob, "/memory/reg", &len);
296 *p++ = cpu_to_be32(bd->bi_memstart);
297 *p = cpu_to_be32(bd->bi_memsize);
304 after_reloc(ulong dest_addr)
306 DECLARE_GLOBAL_DATA_PTR;
308 /* now, jump to the main U-Boot board init code */
309 board_init_r ((gd_t *)gd, dest_addr);