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_86xx.h>
28 #include <asm/immap_fsl_pci.h>
33 #if defined(CONFIG_OF_FLAT_TREE)
35 extern void ft_cpu_setup(void *blob
, bd_t
*bd
);
38 #include "../common/pixis.h"
40 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
41 extern void ddr_enable_ecc(unsigned int dram_size
);
44 #if defined(CONFIG_SPD_EEPROM)
45 #include "spd_sdram.h"
48 void sdram_init(void);
49 long int fixed_sdram(void);
51 /* called before any console output */
52 int board_early_init_f(void)
54 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
55 volatile ccsr_gur_t
*gur
= &immap
->im_gur
;
57 gur
->gpiocr
|= 0x888a5500; /* DIU16, IR1, UART0, UART2 */
64 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
65 volatile ccsr_lbc_t
*memctl
= &immap
->im_lbc
;
66 volatile ccsr_local_mcm_t
*mcm
= &immap
->im_local_mcm
;
68 puts("Board: MPC8610HPCD\n");
70 mcm
->abcr
|= 0x00010000; /* 0 */
71 mcm
->hpmr3
= 0x80000008; /* 4c */
83 initdram(int board_type
)
87 #if defined(CONFIG_SPD_EEPROM)
88 dram_size
= spd_sdram();
90 dram_size
= fixed_sdram();
93 #if defined(CFG_RAMBOOT)
98 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
100 * Initialize and enable DDR ECC.
102 ddr_enable_ecc(dram_size
);
110 #if defined(CFG_DRAM_TEST)
114 uint
*pstart
= (uint
*) CFG_MEMTEST_START
;
115 uint
*pend
= (uint
*) CFG_MEMTEST_END
;
118 puts("SDRAM test phase 1:\n");
119 for (p
= pstart
; p
< pend
; p
++)
122 for (p
= pstart
; p
< pend
; p
++) {
123 if (*p
!= 0xaaaaaaaa) {
124 printf("SDRAM test fails at: %08x\n", (uint
) p
);
129 puts("SDRAM test phase 2:\n");
130 for (p
= pstart
; p
< pend
; p
++)
133 for (p
= pstart
; p
< pend
; p
++) {
134 if (*p
!= 0x55555555) {
135 printf("SDRAM test fails at: %08x\n", (uint
) p
);
140 puts("SDRAM test passed.\n");
146 #if !defined(CONFIG_SPD_EEPROM)
148 * Fixed sdram init -- doesn't use serial presence detect.
151 long int fixed_sdram(void)
153 #if !defined(CFG_RAMBOOT)
154 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
155 volatile ccsr_ddr_t
*ddr
= &immap
->im_ddr1
;
158 ddr
->cs0_bnds
= 0x0000001f;
159 ddr
->cs0_config
= 0x80010202;
161 ddr
->ext_refrec
= 0x00000000;
162 ddr
->timing_cfg_0
= 0x00260802;
163 ddr
->timing_cfg_1
= 0x3935d322;
164 ddr
->timing_cfg_2
= 0x14904cc8;
165 ddr
->sdram_mode_1
= 0x00480432;
166 ddr
->sdram_mode_2
= 0x00000000;
167 ddr
->sdram_interval
= 0x06180fff; /* 0x06180100; */
168 ddr
->sdram_data_init
= 0xDEADBEEF;
169 ddr
->sdram_clk_cntl
= 0x03800000;
170 ddr
->sdram_cfg_2
= 0x04400010;
172 #if defined(CONFIG_DDR_ECC)
173 ddr
->err_int_en
= 0x0000000d;
174 ddr
->err_disable
= 0x00000000;
175 ddr
->err_sbe
= 0x00010000;
181 ddr
->sdram_cfg_1
= 0xc3000000; /* 0xe3008000;*/
184 #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
186 debug("DDR - 1st controller: memory initializing\n");
188 * Poll until memory is initialized.
189 * 512 Meg at 400 might hit this 200 times or so.
191 while ((ddr
->sdram_cfg_2
& (d_init
<< 4)) != 0)
194 debug("DDR: memory initialized\n\n");
199 return 512 * 1024 * 1024;
201 return CFG_SDRAM_SIZE
* 1024 * 1024;
206 #if defined(CONFIG_PCI)
208 * Initialize PCI Devices, report devices found.
211 #ifndef CONFIG_PCI_PNP
212 static struct pci_config_table pci_fsl86xxads_config_table
[] = {
213 {PCI_ANY_ID
, PCI_ANY_ID
, PCI_ANY_ID
, PCI_ANY_ID
,
214 PCI_IDSEL_NUMBER
, PCI_ANY_ID
,
215 pci_cfgfunc_config_device
, {PCI_ENET0_IOADDR
,
217 PCI_COMMAND_MEMORY
| PCI_COMMAND_MASTER
} },
223 static struct pci_controller pci1_hose
= {
224 #ifndef CONFIG_PCI_PNP
225 config_table
:pci_mpc86xxcts_config_table
228 #endif /* CONFIG_PCI */
231 static struct pci_controller pcie1_hose
;
235 static struct pci_controller pcie2_hose
;
238 int first_free_busno
= 0;
240 void pci_init_board(void)
242 volatile immap_t
*immap
= (immap_t
*) CFG_CCSRBAR
;
243 volatile ccsr_gur_t
*gur
= &immap
->im_gur
;
244 uint devdisr
= gur
->devdisr
;
245 uint io_sel
= (gur
->pordevsr
& MPC85xx_PORDEVSR_IO_SEL
) >> 19;
246 uint host_agent
= (gur
->porbmsr
& MPC85xx_PORBMSR_HA
) >> 16;
248 printf( " pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n",
249 devdisr
, io_sel
, host_agent
);
254 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCIE1_ADDR
;
255 extern void fsl_pci_init(struct pci_controller
*hose
);
256 struct pci_controller
*hose
= &pcie1_hose
;
257 int pcie_configured
= (io_sel
== 1) || (io_sel
== 4);
258 int pcie_ep
= (host_agent
== 0) || (host_agent
== 2) ||
261 if (pcie_configured
&& !(devdisr
& MPC86xx_DEVDISR_PCIE1
)) {
262 printf(" PCIe 1 connected to Uli as %s (base address %x)\n",
263 pcie_ep
? "End Point" : "Root Complex",
265 if (pci
->pme_msg_det
)
266 pci
->pme_msg_det
= 0xffffffff;
269 pci_set_region(hose
->regions
+ 0,
273 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
275 /* outbound memory */
276 pci_set_region(hose
->regions
+ 1,
283 pci_set_region(hose
->regions
+ 2,
289 hose
->region_count
= 3;
291 hose
->first_busno
= first_free_busno
;
292 pci_setup_indirect(hose
, (int)&pci
->cfg_addr
,
293 (int)&pci
->cfg_data
);
297 first_free_busno
= hose
->last_busno
+ 1;
298 printf(" PCI-Express 1 on bus %02x - %02x\n",
299 hose
->first_busno
, hose
->last_busno
);
302 puts(" PCI-Express 1: Disabled\n");
305 puts("PCI-Express 1: Disabled\n");
306 #endif /* CONFIG_PCIE1 */
311 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCIE2_ADDR
;
312 extern void fsl_pci_init(struct pci_controller
*hose
);
313 struct pci_controller
*hose
= &pcie2_hose
;
315 int pcie_configured
= (io_sel
== 0) || (io_sel
== 4);
316 int pcie_ep
= (host_agent
== 0) || (host_agent
== 1) ||
319 if (pcie_configured
&& !(devdisr
& MPC86xx_DEVDISR_PCIE2
)) {
320 printf(" PCI-Express 2 connected to slot as %s" \
321 " (base address %x)\n",
322 pcie_ep
? "End Point" : "Root Complex",
324 if (pci
->pme_msg_det
)
325 pci
->pme_msg_det
= 0xffffffff;
328 pci_set_region(hose
->regions
+ 0,
332 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
334 /* outbound memory */
335 pci_set_region(hose
->regions
+ 1,
342 pci_set_region(hose
->regions
+ 2,
348 hose
->region_count
= 3;
350 hose
->first_busno
= first_free_busno
;
351 pci_setup_indirect(hose
, (int)&pci
->cfg_addr
,
352 (int)&pci
->cfg_data
);
356 first_free_busno
= hose
->last_busno
+ 1;
357 printf(" PCI-Express 2 on bus %02x - %02x\n",
358 hose
->first_busno
, hose
->last_busno
);
360 puts(" PCI-Express 2: Disabled\n");
363 puts("PCI-Express 2: Disabled\n");
364 #endif /* CONFIG_PCIE2 */
369 volatile ccsr_fsl_pci_t
*pci
= (ccsr_fsl_pci_t
*) CFG_PCI1_ADDR
;
370 extern void fsl_pci_init(struct pci_controller
*hose
);
371 struct pci_controller
*hose
= &pci1_hose
;
372 int pci_agent
= (host_agent
>= 4) && (host_agent
<= 6);
374 if ( !(devdisr
& MPC86xx_DEVDISR_PCI1
)) {
375 printf(" PCI connected to PCI slots as %s" \
376 " (base address %x)\n",
377 pci_agent
? "Agent" : "Host",
381 pci_set_region(hose
->regions
+ 0,
385 PCI_REGION_MEM
| PCI_REGION_MEMORY
);
387 /* outbound memory */
388 pci_set_region(hose
->regions
+ 1,
395 pci_set_region(hose
->regions
+ 2,
401 hose
->region_count
= 3;
403 hose
->first_busno
= first_free_busno
;
404 pci_setup_indirect(hose
, (int) &pci
->cfg_addr
,
405 (int) &pci
->cfg_data
);
409 first_free_busno
= hose
->last_busno
+ 1;
410 printf(" PCI on bus %02x - %02x\n",
411 hose
->first_busno
, hose
->last_busno
);
415 puts(" PCI: Disabled\n");
417 #endif /* CONFIG_PCI1 */
420 #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
422 ft_board_setup(void *blob
, bd_t
*bd
)
427 ft_cpu_setup(blob
, bd
);
429 p
= ft_get_prop(blob
, "/memory/reg", &len
);
431 *p
++ = cpu_to_be32(bd
->bi_memstart
);
432 *p
= cpu_to_be32(bd
->bi_memsize
);
436 p
= (u32
*)ft_get_prop(blob
, "/" OF_SOC
"/pci@8000/bus-range", &len
);
439 p
[1] = pci1_hose
.last_busno
- pci1_hose
.first_busno
;
440 debug("pci@8000 first_busno=%d last_busno=%d\n",p
[0],p
[1]);
444 p
= (u32
*)ft_get_prop(blob
, "/" OF_SOC
"/pcie@a000/bus-range", &len
);
447 p
[1] = pcie1_hose
.last_busno
- pcie1_hose
.first_busno
;
448 debug("pcie@9000 first_busno=%d last_busno=%d\n",p
[0],p
[1]);
452 p
= (u32
*)ft_get_prop(blob
, "/" OF_SOC
"/pcie@9000/bus-range", &len
);
455 p
[1] = pcie2_hose
.last_busno
- pcie2_hose
.first_busno
;
456 debug("pcie@9000 first_busno=%d last_busno=%d\n",p
[0],p
[1]);
465 * Reads the FPGA on board for CONFIG_SYS_CLK_FREQ
469 get_board_sys_clk(ulong dummy
)
471 u8 i
, go_bit
, rd_clks
;
475 a
= PIXIS_BASE
+ PIXIS_SPD
;