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);
45 volatile ccsr_gur_t
*gur
= (void *)(CFG_MPC85xx_GUTS_ADDR
);
46 volatile ccsr_lbc_t
*lbc
= (void *)(CFG_MPC85xx_LBC_ADDR
);
47 volatile ccsr_local_ecm_t
*ecm
= (void *)(CFG_MPC85xx_ECM_ADDR
);
49 if ((uint
)&gur
->porpllsr
!= 0xe00e0000) {
50 printf("immap size error %x\n",&gur
->porpllsr
);
52 printf ("Board: MPC8544DS\n");
54 lbc
->ltesr
= 0xffffffff; /* Clear LBC error interrupts */
55 lbc
->lteir
= 0xffffffff; /* Enable LBC error interrupts */
56 ecm
->eedr
= 0xffffffff; /* Clear ecm errors */
57 ecm
->eeer
= 0xffffffff; /* Enable ecm errors */
63 initdram(int board_type
)
67 puts("Initializing\n");
69 dram_size
= spd_sdram();
71 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
73 * Initialize and enable DDR ECC.
75 ddr_enable_ecc(dram_size
);
82 static struct pci_controller pci1_hose
;
86 static struct pci_controller pcie1_hose
;
90 static struct pci_controller pcie2_hose
;
94 static struct pci_controller pcie3_hose
;
97 int first_free_busno
=0;
102 volatile ccsr_gur_t
*gur
= (void *)(CFG_MPC85xx_GUTS_ADDR
);
103 uint devdisr
= gur
->devdisr
;
104 uint io_sel
= (gur
->pordevsr
& MPC85xx_PORDEVSR_IO_SEL
) >> 19;
105 uint host_agent
= (gur
->porbmsr
& MPC85xx_PORBMSR_HA
) >> 16;
107 debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n",
108 devdisr
, io_sel
, host_agent
);
111 if (!(gur
->pordevsr
& MPC85xx_PORDEVSR_SGMII1_DIS
))
112 printf (" eTSEC1 is in sgmii mode.\n");
113 if (!(gur
->pordevsr
& MPC85xx_PORDEVSR_SGMII3_DIS
))
114 printf (" eTSEC3 is in sgmii mode.\n");
119 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCIE3_ADDR
;
120 extern void fsl_pci_init(struct pci_controller
*hose
);
121 struct pci_controller
*hose
= &pcie3_hose
;
122 int pcie_ep
= (host_agent
== 1);
123 int pcie_configured
= io_sel
>= 1;
125 if (pcie_configured
&& !(devdisr
& MPC85xx_DEVDISR_PCIE
)){
126 printf ("\n PCIE3 connected to ULI as %s (base address %x)",
127 pcie_ep
? "End Point" : "Root Complex",
129 if (pci
->pme_msg_det
) {
130 pci
->pme_msg_det
= 0xffffffff;
131 debug (" with errors. Clearing. Now 0x%08x",pci
->pme_msg_det
);
136 pci_set_region(hose
->regions
+ 0,
140 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
142 /* outbound memory */
143 pci_set_region(hose
->regions
+ 1,
150 pci_set_region(hose
->regions
+ 2,
156 hose
->region_count
= 3;
157 #ifdef CFG_PCIE3_MEM_BASE2
158 /* outbound memory */
159 pci_set_region(hose
->regions
+ 3,
164 hose
->region_count
++;
166 hose
->first_busno
=first_free_busno
;
167 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
, (int) &pci
->cfg_data
);
171 first_free_busno
=hose
->last_busno
+1;
172 printf (" PCIE3 on bus %02x - %02x\n",
173 hose
->first_busno
,hose
->last_busno
);
176 * Activate ULI1575 legacy chip by performing a fake
177 * memory access. Needed to make ULI RTC work.
179 in_be32((u32
*)CFG_PCIE3_MEM_BASE
);
181 printf (" PCIE3: disabled\n");
186 gur
->devdisr
|= MPC85xx_DEVDISR_PCIE3
; /* disable */
191 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCIE1_ADDR
;
192 extern void fsl_pci_init(struct pci_controller
*hose
);
193 struct pci_controller
*hose
= &pcie1_hose
;
194 int pcie_ep
= (host_agent
== 5);
195 int pcie_configured
= io_sel
& 6;
197 if (pcie_configured
&& !(devdisr
& MPC85xx_DEVDISR_PCIE
)){
198 printf ("\n PCIE1 connected to Slot2 as %s (base address %x)",
199 pcie_ep
? "End Point" : "Root Complex",
201 if (pci
->pme_msg_det
) {
202 pci
->pme_msg_det
= 0xffffffff;
203 debug (" with errors. Clearing. Now 0x%08x",pci
->pme_msg_det
);
208 pci_set_region(hose
->regions
+ 0,
212 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
214 /* outbound memory */
215 pci_set_region(hose
->regions
+ 1,
222 pci_set_region(hose
->regions
+ 2,
228 hose
->region_count
= 3;
229 #ifdef CFG_PCIE1_MEM_BASE2
230 /* outbound memory */
231 pci_set_region(hose
->regions
+ 3,
236 hose
->region_count
++;
238 hose
->first_busno
=first_free_busno
;
240 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
, (int) &pci
->cfg_data
);
244 first_free_busno
=hose
->last_busno
+1;
245 printf(" PCIE1 on bus %02x - %02x\n",
246 hose
->first_busno
,hose
->last_busno
);
249 printf (" PCIE1: disabled\n");
254 gur
->devdisr
|= MPC85xx_DEVDISR_PCIE
; /* disable */
259 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCIE2_ADDR
;
260 extern void fsl_pci_init(struct pci_controller
*hose
);
261 struct pci_controller
*hose
= &pcie2_hose
;
262 int pcie_ep
= (host_agent
== 3);
263 int pcie_configured
= io_sel
& 4;
265 if (pcie_configured
&& !(devdisr
& MPC85xx_DEVDISR_PCIE
)){
266 printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)",
267 pcie_ep
? "End Point" : "Root Complex",
269 if (pci
->pme_msg_det
) {
270 pci
->pme_msg_det
= 0xffffffff;
271 debug (" with errors. Clearing. Now 0x%08x",pci
->pme_msg_det
);
276 pci_set_region(hose
->regions
+ 0,
280 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
282 /* outbound memory */
283 pci_set_region(hose
->regions
+ 1,
290 pci_set_region(hose
->regions
+ 2,
296 hose
->region_count
= 3;
297 #ifdef CFG_PCIE2_MEM_BASE2
298 /* outbound memory */
299 pci_set_region(hose
->regions
+ 3,
304 hose
->region_count
++;
306 hose
->first_busno
=first_free_busno
;
307 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
, (int) &pci
->cfg_data
);
310 first_free_busno
=hose
->last_busno
+1;
311 printf (" PCIE2 on bus %02x - %02x\n",
312 hose
->first_busno
,hose
->last_busno
);
315 printf (" PCIE2: disabled\n");
320 gur
->devdisr
|= MPC85xx_DEVDISR_PCIE2
; /* disable */
326 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCI1_ADDR
;
327 extern void fsl_pci_init(struct pci_controller
*hose
);
328 struct pci_controller
*hose
= &pci1_hose
;
330 uint pci_agent
= (host_agent
== 6);
331 uint pci_speed
= 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */
333 uint pci_arb
= gur
->pordevsr
& MPC85xx_PORDEVSR_PCI1_ARB
; /* PORDEVSR[14] */
334 uint pci_clk_sel
= gur
->porpllsr
& MPC85xx_PORDEVSR_PCI1_SPD
; /* PORPLLSR[16] */
337 if (!(devdisr
& MPC85xx_DEVDISR_PCI1
)) {
338 printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n",
340 (pci_speed
== 33333000) ? "33" :
341 (pci_speed
== 66666000) ? "66" : "unknown",
342 pci_clk_sel
? "sync" : "async",
343 pci_agent
? "agent" : "host",
344 pci_arb
? "arbiter" : "external-arbiter",
349 pci_set_region(hose
->regions
+ 0,
353 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
355 /* outbound memory */
356 pci_set_region(hose
->regions
+ 1,
363 pci_set_region(hose
->regions
+ 2,
368 hose
->region_count
= 3;
369 #ifdef CFG_PCIE3_MEM_BASE2
370 /* outbound memory */
371 pci_set_region(hose
->regions
+ 3,
376 hose
->region_count
++;
378 hose
->first_busno
=first_free_busno
;
379 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
, (int) &pci
->cfg_data
);
382 first_free_busno
=hose
->last_busno
+1;
383 printf ("PCI on bus %02x - %02x\n",
384 hose
->first_busno
,hose
->last_busno
);
386 printf (" PCI: disabled\n");
390 gur
->devdisr
|= MPC85xx_DEVDISR_PCI1
; /* disable */
395 int last_stage_init(void)
402 get_board_sys_clk(ulong dummy
)
404 u8 i
, go_bit
, rd_clks
;
407 go_bit
= in8(PIXIS_BASE
+ PIXIS_VCTL
);
410 rd_clks
= in8(PIXIS_BASE
+ PIXIS_VCFGEN0
);
414 * Only if both go bit and the SCLK bit in VCFGEN0 are set
415 * should we be using the AUX register. Remember, we also set the
416 * GO bit to boot from the alternate bank on the on-board flash
421 i
= in8(PIXIS_BASE
+ PIXIS_AUX
);
423 i
= in8(PIXIS_BASE
+ PIXIS_SPD
);
425 i
= in8(PIXIS_BASE
+ PIXIS_SPD
);
460 #if defined(CONFIG_OF_BOARD_SETUP)
463 ft_board_setup(void *blob
, bd_t
*bd
)
468 ft_cpu_setup(blob
, bd
);
470 node
= fdt_path_offset(blob
, "/aliases");
474 path
= fdt_getprop(blob
, node
, "pci0", NULL
);
476 tmp
[1] = pci1_hose
.last_busno
- pci1_hose
.first_busno
;
477 do_fixup_by_path(blob
, path
, "bus-range", &tmp
, 8, 1);
481 path
= fdt_getprop(blob
, node
, "pci1", NULL
);
483 tmp
[1] = pcie2_hose
.last_busno
- pcie2_hose
.first_busno
;
484 do_fixup_by_path(blob
, path
, "bus-range", &tmp
, 8, 1);
488 path
= fdt_getprop(blob
, node
, "pci2", NULL
);
490 tmp
[1] = pcie1_hose
.last_busno
- pcie1_hose
.first_busno
;
491 do_fixup_by_path(blob
, path
, "bus-range", &tmp
, 8, 1);
495 path
= fdt_getprop(blob
, node
, "pci3", NULL
);
497 tmp
[1] = pcie3_hose
.last_busno
- pcie3_hose
.first_busno
;
498 do_fixup_by_path(blob
, path
, "bus-range", &tmp
, 8, 1);