2 * Copyright 2007 Freescale Semiconductor, Inc.
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/processor.h>
27 #include <asm/immap_85xx.h>
28 #include <asm/immap_fsl_pci.h>
30 #include <spd_sdram.h>
33 #include <fdt_support.h>
35 #include "../common/pixis.h"
37 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
38 extern void ddr_enable_ecc(unsigned int dram_size);
41 void sdram_init(void);
43 int board_early_init_f (void)
50 volatile ccsr_gur_t *gur = (void *)(CFG_MPC85xx_GUTS_ADDR);
51 volatile ccsr_lbc_t *lbc = (void *)(CFG_MPC85xx_LBC_ADDR);
52 volatile ccsr_local_ecm_t *ecm = (void *)(CFG_MPC85xx_ECM_ADDR);
54 if ((uint)&gur->porpllsr != 0xe00e0000) {
55 printf("immap size error %x\n",&gur->porpllsr);
57 printf ("Board: MPC8544DS\n");
59 lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
60 lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
61 ecm->eedr = 0xffffffff; /* Clear ecm errors */
62 ecm->eeer = 0xffffffff; /* Enable ecm errors */
68 initdram(int board_type)
72 puts("Initializing\n");
74 dram_size = spd_sdram();
76 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
78 * Initialize and enable DDR ECC.
80 ddr_enable_ecc(dram_size);
87 static struct pci_controller pci1_hose;
91 static struct pci_controller pcie1_hose;
95 static struct pci_controller pcie2_hose;
99 static struct pci_controller pcie3_hose;
102 int first_free_busno=0;
107 volatile ccsr_gur_t *gur = (void *)(CFG_MPC85xx_GUTS_ADDR);
108 uint devdisr = gur->devdisr;
109 uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
110 uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16;
112 debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n",
113 devdisr, io_sel, host_agent);
116 if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS))
117 printf (" eTSEC1 is in sgmii mode.\n");
118 if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
119 printf (" eTSEC3 is in sgmii mode.\n");
124 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CFG_PCIE3_ADDR;
125 extern void fsl_pci_init(struct pci_controller *hose);
126 struct pci_controller *hose = &pcie3_hose;
127 int pcie_ep = (host_agent == 1);
128 int pcie_configured = io_sel >= 1;
130 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
131 printf ("\n PCIE3 connected to ULI as %s (base address %x)",
132 pcie_ep ? "End Point" : "Root Complex",
134 if (pci->pme_msg_det) {
135 pci->pme_msg_det = 0xffffffff;
136 debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
141 pci_set_region(hose->regions + 0,
145 PCI_REGION_MEM | PCI_REGION_MEMORY);
147 /* outbound memory */
148 pci_set_region(hose->regions + 1,
155 pci_set_region(hose->regions + 2,
161 hose->region_count = 3;
162 #ifdef CFG_PCIE3_MEM_BASE2
163 /* outbound memory */
164 pci_set_region(hose->regions + 3,
169 hose->region_count++;
171 hose->first_busno=first_free_busno;
172 pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
176 first_free_busno=hose->last_busno+1;
177 printf (" PCIE3 on bus %02x - %02x\n",
178 hose->first_busno,hose->last_busno);
181 * Activate ULI1575 legacy chip by performing a fake
182 * memory access. Needed to make ULI RTC work.
184 in_be32((u32 *)CFG_PCIE3_MEM_BASE);
186 printf (" PCIE3: disabled\n");
191 gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */
196 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CFG_PCIE1_ADDR;
197 extern void fsl_pci_init(struct pci_controller *hose);
198 struct pci_controller *hose = &pcie1_hose;
199 int pcie_ep = (host_agent == 5);
200 int pcie_configured = io_sel & 6;
202 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
203 printf ("\n PCIE1 connected to Slot2 as %s (base address %x)",
204 pcie_ep ? "End Point" : "Root Complex",
206 if (pci->pme_msg_det) {
207 pci->pme_msg_det = 0xffffffff;
208 debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
213 pci_set_region(hose->regions + 0,
217 PCI_REGION_MEM | PCI_REGION_MEMORY);
219 /* outbound memory */
220 pci_set_region(hose->regions + 1,
227 pci_set_region(hose->regions + 2,
233 hose->region_count = 3;
234 #ifdef CFG_PCIE1_MEM_BASE2
235 /* outbound memory */
236 pci_set_region(hose->regions + 3,
241 hose->region_count++;
243 hose->first_busno=first_free_busno;
245 pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
249 first_free_busno=hose->last_busno+1;
250 printf(" PCIE1 on bus %02x - %02x\n",
251 hose->first_busno,hose->last_busno);
254 printf (" PCIE1: disabled\n");
259 gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */
264 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CFG_PCIE2_ADDR;
265 extern void fsl_pci_init(struct pci_controller *hose);
266 struct pci_controller *hose = &pcie2_hose;
267 int pcie_ep = (host_agent == 3);
268 int pcie_configured = io_sel & 4;
270 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
271 printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)",
272 pcie_ep ? "End Point" : "Root Complex",
274 if (pci->pme_msg_det) {
275 pci->pme_msg_det = 0xffffffff;
276 debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
281 pci_set_region(hose->regions + 0,
285 PCI_REGION_MEM | PCI_REGION_MEMORY);
287 /* outbound memory */
288 pci_set_region(hose->regions + 1,
295 pci_set_region(hose->regions + 2,
301 hose->region_count = 3;
302 #ifdef CFG_PCIE2_MEM_BASE2
303 /* outbound memory */
304 pci_set_region(hose->regions + 3,
309 hose->region_count++;
311 hose->first_busno=first_free_busno;
312 pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
315 first_free_busno=hose->last_busno+1;
316 printf (" PCIE2 on bus %02x - %02x\n",
317 hose->first_busno,hose->last_busno);
320 printf (" PCIE2: disabled\n");
325 gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */
331 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CFG_PCI1_ADDR;
332 extern void fsl_pci_init(struct pci_controller *hose);
333 struct pci_controller *hose = &pci1_hose;
335 uint pci_agent = (host_agent == 6);
336 uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */
338 uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */
339 uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */
342 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
343 printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n",
345 (pci_speed == 33333000) ? "33" :
346 (pci_speed == 66666000) ? "66" : "unknown",
347 pci_clk_sel ? "sync" : "async",
348 pci_agent ? "agent" : "host",
349 pci_arb ? "arbiter" : "external-arbiter",
354 pci_set_region(hose->regions + 0,
358 PCI_REGION_MEM | PCI_REGION_MEMORY);
360 /* outbound memory */
361 pci_set_region(hose->regions + 1,
368 pci_set_region(hose->regions + 2,
373 hose->region_count = 3;
374 #ifdef CFG_PCIE3_MEM_BASE2
375 /* outbound memory */
376 pci_set_region(hose->regions + 3,
381 hose->region_count++;
383 hose->first_busno=first_free_busno;
384 pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
387 first_free_busno=hose->last_busno+1;
388 printf ("PCI on bus %02x - %02x\n",
389 hose->first_busno,hose->last_busno);
391 printf (" PCI: disabled\n");
395 gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */
400 int last_stage_init(void)
407 get_board_sys_clk(ulong dummy)
409 u8 i, go_bit, rd_clks;
412 go_bit = in8(PIXIS_BASE + PIXIS_VCTL);
415 rd_clks = in8(PIXIS_BASE + PIXIS_VCFGEN0);
419 * Only if both go bit and the SCLK bit in VCFGEN0 are set
420 * should we be using the AUX register. Remember, we also set the
421 * GO bit to boot from the alternate bank on the on-board flash
426 i = in8(PIXIS_BASE + PIXIS_AUX);
428 i = in8(PIXIS_BASE + PIXIS_SPD);
430 i = in8(PIXIS_BASE + PIXIS_SPD);
465 #if defined(CONFIG_OF_BOARD_SETUP)
468 ft_board_setup(void *blob, bd_t *bd)
473 ft_cpu_setup(blob, bd);
475 node = fdt_path_offset(blob, "/aliases");
479 path = fdt_getprop(blob, node, "pci0", NULL);
481 tmp[1] = pci1_hose.last_busno - pci1_hose.first_busno;
482 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
486 path = fdt_getprop(blob, node, "pci1", NULL);
488 tmp[1] = pcie2_hose.last_busno - pcie2_hose.first_busno;
489 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
493 path = fdt_getprop(blob, node, "pci2", NULL);
495 tmp[1] = pcie1_hose.last_busno - pcie1_hose.first_busno;
496 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
500 path = fdt_getprop(blob, node, "pci3", NULL);
502 tmp[1] = pcie3_hose.last_busno - pcie3_hose.first_busno;
503 do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);