2 * (C) Copyright 2002,2003, Motorola Inc.
3 * Xianghua Xiao, (X.Xiao@motorola.com)
5 * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/processor.h>
30 #include <asm/immap_85xx.h>
31 #include <asm/fsl_ddr_sdram.h>
32 #include <spd_sdram.h>
34 long int fixed_sdram (void);
36 int board_pre_init (void)
38 #if defined(CONFIG_PCI)
39 volatile ccsr_pcix_t
*pci
= (void *)(CONFIG_SYS_MPC85xx_PCIX_ADDR
);
41 pci
->peer
&= 0xffffffdf; /* disable master abort */
50 get_sys_info (&sysinfo
);
52 printf ("Board: Freescale MPC8540EVAL Board\n");
53 printf ("\tCPU: %lu MHz\n", sysinfo
.freqProcessor
/ 1000000);
54 printf ("\tCCB: %lu MHz\n", sysinfo
.freqSystemBus
/ 1000000);
55 printf ("\tDDR: %lu MHz\n", sysinfo
.freqSystemBus
/ 2000000);
56 if((CONFIG_SYS_LBC_LCRR
& 0x0f) == 2 || (CONFIG_SYS_LBC_LCRR
& 0x0f) == 4 \
57 || (CONFIG_SYS_LBC_LCRR
& 0x0f) == 8) {
58 printf ("\tLBC: %lu MHz\n",
59 sysinfo
.freqSystemBus
/ 1000000/(CONFIG_SYS_LBC_LCRR
& 0x0f));
61 printf("\tLBC: unknown\n");
63 printf("L1 D-cache 32KB, L1 I-cache 32KB enabled.\n");
67 phys_size_t
initdram (int board_type
)
71 #if !defined(CONFIG_RAM_AS_FLASH)
72 volatile ccsr_lbc_t
*lbc
= (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR
);
76 #if !defined(CONFIG_RAM_AS_FLASH) || defined(CONFIG_DDR_DLL)
77 volatile ccsr_gur_t
*gur
= (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR
);
80 #if defined(CONFIG_DDR_DLL)
83 /* Work around to stabilize DDR DLL */
84 temp_ddrdll
= gur
->ddrdllcr
;
85 gur
->ddrdllcr
= ((temp_ddrdll
& 0xff) << 16) | 0x80000000;
86 asm("sync;isync;msync");
89 #if defined(CONFIG_SPD_EEPROM)
90 dram_size
= fsl_ddr_sdram();
91 dram_size
= setup_ddr_tlbs(dram_size
/ 0x100000);
92 dram_size
*= 0x100000;
94 dram_size
= fixed_sdram ();
97 #if defined(CONFIG_SYS_RAMBOOT)
101 #if !defined(CONFIG_RAM_AS_FLASH) /* LocalBus is not emulating flash */
102 get_sys_info(&sysinfo
);
103 /* if localbus freq is less than 66Mhz,we use bypass mode,otherwise use DLL */
104 if(sysinfo
.freqSystemBus
/(CONFIG_SYS_LBC_LCRR
& 0x0f) < 66000000) {
105 lbc
->lcrr
= (CONFIG_SYS_LBC_LCRR
& 0x0fffffff)| 0x80000000;
107 lbc
->lcrr
= CONFIG_SYS_LBC_LCRR
& 0x7fffffff;
109 temp_lbcdll
= gur
->lbcdllcr
;
110 gur
->lbcdllcr
= ((temp_lbcdll
& 0xff) << 16 ) | 0x80000000;
111 asm("sync;isync;msync");
113 lbc
->or2
= CONFIG_SYS_OR2_PRELIM
; /* 64MB SDRAM */
114 lbc
->br2
= CONFIG_SYS_BR2_PRELIM
;
115 lbc
->lbcr
= CONFIG_SYS_LBC_LBCR
;
116 lbc
->lsdmr
= CONFIG_SYS_LBC_LSDMR_1
;
118 * (ulong
*)0 = 0x000000ff;
119 lbc
->lsdmr
= CONFIG_SYS_LBC_LSDMR_2
;
121 * (ulong
*)0 = 0x000000ff;
122 lbc
->lsdmr
= CONFIG_SYS_LBC_LSDMR_3
;
124 * (ulong
*)0 = 0x000000ff;
125 lbc
->lsdmr
= CONFIG_SYS_LBC_LSDMR_4
;
127 * (ulong
*)0 = 0x000000ff;
128 lbc
->lsdmr
= CONFIG_SYS_LBC_LSDMR_5
;
130 lbc
->lsrt
= CONFIG_SYS_LBC_LSRT
;
132 lbc
->mrtpr
= CONFIG_SYS_LBC_MRTPR
;
136 #if defined(CONFIG_DDR_ECC)
138 /* Initialize all of memory for ECC, then
142 volatile ccsr_ddr_t
*ddr
= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR
);
144 for (*p
= 0; p
< (uint
*)(8 * 1024); p
++) {
145 if (((unsigned int)p
& 0x1f) == 0) { dcbz(p
); }
146 *p
= (unsigned int)0xdeadbeef;
147 if (((unsigned int)p
& 0x1c) == 0x1c) { dcbf(p
); }
151 dma_xfer((uint
*)0x2000,0x2000,(uint
*)0);
153 dma_xfer((uint
*)0x4000,0x4000,(uint
*)0);
155 dma_xfer((uint
*)0x8000,0x8000,(uint
*)0);
157 dma_xfer((uint
*)0x10000,0x10000,(uint
*)0);
159 dma_xfer((uint
*)0x20000,0x20000,(uint
*)0);
161 dma_xfer((uint
*)0x40000,0x40000,(uint
*)0);
163 dma_xfer((uint
*)0x80000,0x80000,(uint
*)0);
165 dma_xfer((uint
*)0x100000,0x100000,(uint
*)0);
167 dma_xfer((uint
*)0x200000,0x200000,(uint
*)0);
169 dma_xfer((uint
*)0x400000,0x400000,(uint
*)0);
171 for (i
= 1; i
< dram_size
/ 0x800000; i
++) {
172 dma_xfer((uint
*)(0x800000*i
),0x800000,(uint
*)0);
175 /* Enable errors for ECC */
176 ddr
->err_disable
= 0x00000000;
177 asm("sync;isync;msync");
184 #if defined(CONFIG_SYS_DRAM_TEST)
187 uint
*pstart
= (uint
*) CONFIG_SYS_MEMTEST_START
;
188 uint
*pend
= (uint
*) CONFIG_SYS_MEMTEST_END
;
191 printf("SDRAM test phase 1:\n");
192 for (p
= pstart
; p
< pend
; p
++)
195 for (p
= pstart
; p
< pend
; p
++) {
196 if (*p
!= 0xaaaaaaaa) {
197 printf ("SDRAM test fails at: %08x\n", (uint
) p
);
202 printf("SDRAM test phase 2:\n");
203 for (p
= pstart
; p
< pend
; p
++)
206 for (p
= pstart
; p
< pend
; p
++) {
207 if (*p
!= 0x55555555) {
208 printf ("SDRAM test fails at: %08x\n", (uint
) p
);
213 printf("SDRAM test passed.\n");
218 #if !defined(CONFIG_SPD_EEPROM)
219 /*************************************************************************
220 * fixed sdram init -- doesn't use serial presence detect.
221 ************************************************************************/
222 long int fixed_sdram (void)
224 #ifndef CONFIG_SYS_RAMBOOT
225 volatile ccsr_ddr_t
*ddr
= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR
);
227 ddr
->cs0_bnds
= CONFIG_SYS_DDR_CS0_BNDS
;
228 ddr
->cs0_config
= CONFIG_SYS_DDR_CS0_CONFIG
;
229 ddr
->timing_cfg_1
= CONFIG_SYS_DDR_TIMING_1
;
230 ddr
->timing_cfg_2
= CONFIG_SYS_DDR_TIMING_2
;
231 ddr
->sdram_mode
= CONFIG_SYS_DDR_MODE
;
232 ddr
->sdram_interval
= CONFIG_SYS_DDR_INTERVAL
;
233 #if defined (CONFIG_DDR_ECC)
234 ddr
->err_disable
= 0x0000000D;
235 ddr
->err_sbe
= 0x00ff0000;
237 asm("sync;isync;msync");
239 #if defined (CONFIG_DDR_ECC)
240 /* Enable ECC checking */
241 ddr
->sdram_cfg
= (CONFIG_SYS_DDR_CONTROL
| 0x20000000);
243 ddr
->sdram_cfg
= CONFIG_SYS_DDR_CONTROL
;
245 asm("sync; isync; msync");
248 return (CONFIG_SYS_SDRAM_SIZE
* 1024 * 1024);
250 #endif /* !defined(CONFIG_SPD_EEPROM) */
252 int board_eth_init(bd_t
*bis
)
255 * This board either has PCI NICs or uses the CPU's TSECs
256 * pci_eth_init() will return 0 if no NICs found, so in that case
257 * returning -1 will force cpu_eth_init() to be called.
259 int num
= pci_eth_init(bis
);
260 return (num
<= 0 ? -1 : num
);