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>
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 extern long int spd_sdram(void);
43 void sdram_init(void);
45 int board_early_init_f (void)
52 volatile immap_t
*immap
= (immap_t
*) CFG_CCSRBAR
;
53 volatile ccsr_gur_t
*gur
= (void *)(CFG_MPC85xx_GUTS_ADDR
);
54 volatile ccsr_lbc_t
*lbc
= &immap
->im_lbc
;
55 volatile ccsr_local_ecm_t
*ecm
= &immap
->im_local_ecm
;
57 if ((uint
)&gur
->porpllsr
!= 0xe00e0000) {
58 printf("immap size error %x\n",&gur
->porpllsr
);
60 printf ("Board: MPC8544DS\n");
62 lbc
->ltesr
= 0xffffffff; /* Clear LBC error interrupts */
63 lbc
->lteir
= 0xffffffff; /* Enable LBC error interrupts */
64 ecm
->eedr
= 0xffffffff; /* Clear ecm errors */
65 ecm
->eeer
= 0xffffffff; /* Enable ecm errors */
71 initdram(int board_type
)
75 puts("Initializing\n");
77 dram_size
= spd_sdram();
79 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
81 * Initialize and enable DDR ECC.
83 ddr_enable_ecc(dram_size
);
89 #if defined(CFG_DRAM_TEST)
93 uint
*pstart
= (uint
*) CFG_MEMTEST_START
;
94 uint
*pend
= (uint
*) CFG_MEMTEST_END
;
97 printf("Testing DRAM from 0x%08x to 0x%08x\n",
101 printf("DRAM test phase 1:\n");
102 for (p
= pstart
; p
< pend
; p
++)
105 for (p
= pstart
; p
< pend
; p
++) {
106 if (*p
!= 0xaaaaaaaa) {
107 printf ("DRAM test fails at: %08x\n", (uint
) p
);
112 printf("DRAM test phase 2:\n");
113 for (p
= pstart
; p
< pend
; p
++)
116 for (p
= pstart
; p
< pend
; p
++) {
117 if (*p
!= 0x55555555) {
118 printf ("DRAM test fails at: %08x\n", (uint
) p
);
123 printf("DRAM test passed.\n");
129 static struct pci_controller pci1_hose
;
133 static struct pci_controller pcie1_hose
;
137 static struct pci_controller pcie2_hose
;
141 static struct pci_controller pcie3_hose
;
144 int first_free_busno
=0;
149 volatile ccsr_gur_t
*gur
= (void *)(CFG_MPC85xx_GUTS_ADDR
);
150 uint devdisr
= gur
->devdisr
;
151 uint io_sel
= (gur
->pordevsr
& MPC85xx_PORDEVSR_IO_SEL
) >> 19;
152 uint host_agent
= (gur
->porbmsr
& MPC85xx_PORBMSR_HA
) >> 16;
154 debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n",
155 devdisr
, io_sel
, host_agent
);
158 if (!(gur
->pordevsr
& MPC85xx_PORDEVSR_SGMII1_DIS
))
159 printf (" eTSEC1 is in sgmii mode.\n");
160 if (!(gur
->pordevsr
& MPC85xx_PORDEVSR_SGMII3_DIS
))
161 printf (" eTSEC3 is in sgmii mode.\n");
166 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCIE3_ADDR
;
167 extern void fsl_pci_init(struct pci_controller
*hose
);
168 struct pci_controller
*hose
= &pcie3_hose
;
169 int pcie_ep
= (host_agent
== 3);
170 int pcie_configured
= io_sel
>= 1;
172 if (pcie_configured
&& !(devdisr
& MPC85xx_DEVDISR_PCIE
)){
173 printf ("\n PCIE3 connected to ULI as %s (base address %x)",
174 pcie_ep
? "End Point" : "Root Complex",
176 if (pci
->pme_msg_det
) {
177 pci
->pme_msg_det
= 0xffffffff;
178 debug (" with errors. Clearing. Now 0x%08x",pci
->pme_msg_det
);
183 pci_set_region(hose
->regions
+ 0,
187 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
189 /* outbound memory */
190 pci_set_region(hose
->regions
+ 1,
197 pci_set_region(hose
->regions
+ 2,
203 hose
->region_count
= 3;
204 #ifdef CFG_PCIE3_MEM_BASE2
205 /* outbound memory */
206 pci_set_region(hose
->regions
+ 3,
211 hose
->region_count
++;
213 hose
->first_busno
=first_free_busno
;
214 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
, (int) &pci
->cfg_data
);
218 first_free_busno
=hose
->last_busno
+1;
219 printf (" PCIE3 on bus %02x - %02x\n",
220 hose
->first_busno
,hose
->last_busno
);
223 * Activate ULI1575 legacy chip by performing a fake
224 * memory access. Needed to make ULI RTC work.
226 in_be32((u32
*)CFG_PCIE3_MEM_BASE
);
228 printf (" PCIE3: disabled\n");
233 gur
->devdisr
|= MPC85xx_DEVDISR_PCIE3
; /* disable */
238 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCIE1_ADDR
;
239 extern void fsl_pci_init(struct pci_controller
*hose
);
240 struct pci_controller
*hose
= &pcie1_hose
;
241 int pcie_ep
= (host_agent
== 5);
242 int pcie_configured
= io_sel
& 6;
244 if (pcie_configured
&& !(devdisr
& MPC85xx_DEVDISR_PCIE
)){
245 printf ("\n PCIE1 connected to Slot2 as %s (base address %x)",
246 pcie_ep
? "End Point" : "Root Complex",
248 if (pci
->pme_msg_det
) {
249 pci
->pme_msg_det
= 0xffffffff;
250 debug (" with errors. Clearing. Now 0x%08x",pci
->pme_msg_det
);
255 pci_set_region(hose
->regions
+ 0,
259 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
261 /* outbound memory */
262 pci_set_region(hose
->regions
+ 1,
269 pci_set_region(hose
->regions
+ 2,
275 hose
->region_count
= 3;
276 #ifdef CFG_PCIE1_MEM_BASE2
277 /* outbound memory */
278 pci_set_region(hose
->regions
+ 3,
283 hose
->region_count
++;
285 hose
->first_busno
=first_free_busno
;
287 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
, (int) &pci
->cfg_data
);
291 first_free_busno
=hose
->last_busno
+1;
292 printf(" PCIE1 on bus %02x - %02x\n",
293 hose
->first_busno
,hose
->last_busno
);
296 printf (" PCIE1: disabled\n");
301 gur
->devdisr
|= MPC85xx_DEVDISR_PCIE
; /* disable */
306 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCIE2_ADDR
;
307 extern void fsl_pci_init(struct pci_controller
*hose
);
308 struct pci_controller
*hose
= &pcie2_hose
;
309 int pcie_ep
= (host_agent
== 3);
310 int pcie_configured
= io_sel
& 4;
312 if (pcie_configured
&& !(devdisr
& MPC85xx_DEVDISR_PCIE
)){
313 printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)",
314 pcie_ep
? "End Point" : "Root Complex",
316 if (pci
->pme_msg_det
) {
317 pci
->pme_msg_det
= 0xffffffff;
318 debug (" with errors. Clearing. Now 0x%08x",pci
->pme_msg_det
);
323 pci_set_region(hose
->regions
+ 0,
327 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
329 /* outbound memory */
330 pci_set_region(hose
->regions
+ 1,
337 pci_set_region(hose
->regions
+ 2,
343 hose
->region_count
= 3;
344 #ifdef CFG_PCIE2_MEM_BASE2
345 /* outbound memory */
346 pci_set_region(hose
->regions
+ 3,
351 hose
->region_count
++;
353 hose
->first_busno
=first_free_busno
;
354 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
, (int) &pci
->cfg_data
);
357 first_free_busno
=hose
->last_busno
+1;
358 printf (" PCIE2 on bus %02x - %02x\n",
359 hose
->first_busno
,hose
->last_busno
);
362 printf (" PCIE2: disabled\n");
367 gur
->devdisr
|= MPC85xx_DEVDISR_PCIE2
; /* disable */
373 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCI1_ADDR
;
374 extern void fsl_pci_init(struct pci_controller
*hose
);
375 struct pci_controller
*hose
= &pci1_hose
;
377 uint pci_agent
= (host_agent
== 6);
378 uint pci_speed
= 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */
380 uint pci_arb
= gur
->pordevsr
& MPC85xx_PORDEVSR_PCI1_ARB
; /* PORDEVSR[14] */
381 uint pci_clk_sel
= gur
->porpllsr
& MPC85xx_PORDEVSR_PCI1_SPD
; /* PORPLLSR[16] */
384 if (!(devdisr
& MPC85xx_DEVDISR_PCI1
)) {
385 printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n",
387 (pci_speed
== 33333000) ? "33" :
388 (pci_speed
== 66666000) ? "66" : "unknown",
389 pci_clk_sel
? "sync" : "async",
390 pci_agent
? "agent" : "host",
391 pci_arb
? "arbiter" : "external-arbiter",
396 pci_set_region(hose
->regions
+ 0,
400 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
402 /* outbound memory */
403 pci_set_region(hose
->regions
+ 1,
410 pci_set_region(hose
->regions
+ 2,
415 hose
->region_count
= 3;
416 #ifdef CFG_PCIE3_MEM_BASE2
417 /* outbound memory */
418 pci_set_region(hose
->regions
+ 3,
423 hose
->region_count
++;
425 hose
->first_busno
=first_free_busno
;
426 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
, (int) &pci
->cfg_data
);
429 first_free_busno
=hose
->last_busno
+1;
430 printf ("PCI on bus %02x - %02x\n",
431 hose
->first_busno
,hose
->last_busno
);
433 printf (" PCI: disabled\n");
437 gur
->devdisr
|= MPC85xx_DEVDISR_PCI1
; /* disable */
442 int last_stage_init(void)
449 get_board_sys_clk(ulong dummy
)
451 u8 i
, go_bit
, rd_clks
;
454 go_bit
= in8(PIXIS_BASE
+ PIXIS_VCTL
);
457 rd_clks
= in8(PIXIS_BASE
+ PIXIS_VCFGEN0
);
461 * Only if both go bit and the SCLK bit in VCFGEN0 are set
462 * should we be using the AUX register. Remember, we also set the
463 * GO bit to boot from the alternate bank on the on-board flash
468 i
= in8(PIXIS_BASE
+ PIXIS_AUX
);
470 i
= in8(PIXIS_BASE
+ PIXIS_SPD
);
472 i
= in8(PIXIS_BASE
+ PIXIS_SPD
);
507 #if defined(CONFIG_OF_BOARD_SETUP)
510 ft_board_setup(void *blob
, bd_t
*bd
)
515 ft_cpu_setup(blob
, bd
);
517 node
= fdt_path_offset(blob
, "/aliases");
521 path
= fdt_getprop(blob
, node
, "pci0", NULL
);
523 tmp
[1] = pci1_hose
.last_busno
- pci1_hose
.first_busno
;
524 do_fixup_by_path(blob
, path
, "bus-range", &tmp
, 8, 1);
528 path
= fdt_getprop(blob
, node
, "pci1", NULL
);
530 tmp
[1] = pcie2_hose
.last_busno
- pcie2_hose
.first_busno
;
531 do_fixup_by_path(blob
, path
, "bus-range", &tmp
, 8, 1);
535 path
= fdt_getprop(blob
, node
, "pci2", NULL
);
537 tmp
[1] = pcie1_hose
.last_busno
- pcie1_hose
.first_busno
;
538 do_fixup_by_path(blob
, path
, "bus-range", &tmp
, 8, 1);
542 path
= fdt_getprop(blob
, node
, "pci3", NULL
);
544 tmp
[1] = pcie3_hose
.last_busno
- pcie3_hose
.first_busno
;
545 do_fixup_by_path(blob
, path
, "bus-range", &tmp
, 8, 1);