blob: a0f6b97a9590305fa4680c884e9f68473cbe6d35 [file] [log] [blame]
wdenk42d1f032003-10-15 23:53:47 +00001/*
wdenk97d80fc2004-06-09 00:34:46 +00002 * Copyright 2004 Freescale Semiconductor.
wdenk42d1f032003-10-15 23:53:47 +00003 * (C) Copyright 2003,Motorola Inc.
4 * Xianghua Xiao, (X.Xiao@motorola.com)
5 *
6 * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
7 *
8 * See file CREDITS for list of people who contributed to this
9 * project.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA
25 */
26
27
wdenk42d1f032003-10-15 23:53:47 +000028#include <common.h>
29#include <asm/processor.h>
30#include <asm/immap_85xx.h>
31#include <ioports.h>
32#include <spd.h>
33#include <miiphy.h>
34
wdenk0ac6f8b2004-07-09 23:27:13 +000035#if defined(CONFIG_DDR_ECC)
36extern void ddr_enable_ecc(unsigned int dram_size);
37#endif
38
39extern long int spd_sdram(void);
40
41void sdram_init(void);
42long int fixed_sdram(void);
43
wdenk42d1f032003-10-15 23:53:47 +000044
45/*
46 * I/O Port configuration table
47 *
48 * if conf is 1, then that port pin will be configured at boot time
49 * according to the five values podr/pdir/ppar/psor/pdat for that entry
50 */
51
52const iop_conf_t iop_conf_tab[4][32] = {
53
54 /* Port A configuration */
55 { /* conf ppar psor pdir podr pdat */
56 /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
57 /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
58 /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
59 /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
60 /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
61 /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
62 /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
63 /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
64 /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
65 /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
66 /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
67 /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
68 /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
69 /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
70 /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
71 /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
72 /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
73 /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
74 /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
75 /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
76 /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
77 /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
78 /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */
79 /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */
80 /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
81 /* PA6 */ { 0, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */
82 /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
83 /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
84 /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
85 /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
86 /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
87 /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
88 },
89
90 /* Port B configuration */
91 { /* conf ppar psor pdir podr pdat */
92 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
93 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
94 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
95 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
96 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
97 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
98 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
99 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
100 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
101 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
102 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
103 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
104 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
105 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
106 /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
107 /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
108 /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
109 /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
110 /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
111 /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
112 /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
113 /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
114 /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
115 /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
116 /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
117 /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
118 /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
119 /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
120 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
121 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
122 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
123 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
124 },
125
126 /* Port C */
127 { /* conf ppar psor pdir podr pdat */
128 /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
129 /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
130 /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
131 /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
132 /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */
133 /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
134 /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
135 /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
136 /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
137 /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
138 /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
139 /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
140 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */
141 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */
142 /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
143 /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */
144 /* PC15 */ { 1, 1, 0, 0, 0, 0 }, /* PC15 */
145 /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
146 /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
147 /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */
148 /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */
149 /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FETHMDC */
150 /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* FETHMDIO */
151 /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
152 /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
153 /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
154 /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
155 /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
156 /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
157 /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
158 /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
159 /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
160 },
161
162 /* Port D */
163 { /* conf ppar psor pdir podr pdat */
164 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
165 /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
166 /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
167 /* PD28 */ { 0, 1, 0, 0, 0, 0 }, /* PD28 */
168 /* PD27 */ { 0, 1, 1, 1, 0, 0 }, /* PD27 */
169 /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
170 /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
171 /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
172 /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
173 /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
174 /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
175 /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
176 /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
177 /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
178 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
179 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
180 /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
181 /* PD14 */ { 0, 0, 0, 1, 0, 0 }, /* LED */
182 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
183 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
184 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
185 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
186 /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
187 /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
188 /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
189 /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
190 /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
191 /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
192 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
193 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
194 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
195 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
196 }
197};
198
wdenk0ac6f8b2004-07-09 23:27:13 +0000199
200/*
201 * MPC8560ADS Board Status & Control Registers
202 */
203typedef struct bcsr_ {
wdenk42d1f032003-10-15 23:53:47 +0000204 volatile unsigned char bcsr0;
205 volatile unsigned char bcsr1;
206 volatile unsigned char bcsr2;
207 volatile unsigned char bcsr3;
208 volatile unsigned char bcsr4;
209 volatile unsigned char bcsr5;
210} bcsr_t;
211
wdenkc837dcb2004-01-20 23:12:12 +0000212int board_early_init_f (void)
wdenk42d1f032003-10-15 23:53:47 +0000213{
214#if defined(CONFIG_PCI)
wdenk0ac6f8b2004-07-09 23:27:13 +0000215 volatile immap_t *immr = (immap_t *) CFG_IMMR;
216 volatile ccsr_pcix_t *pci = &immr->im_pcix;
wdenk42d1f032003-10-15 23:53:47 +0000217
wdenk0ac6f8b2004-07-09 23:27:13 +0000218 pci->peer &= 0xffffffdf; /* disable master abort */
wdenk42d1f032003-10-15 23:53:47 +0000219#endif
wdenk0ac6f8b2004-07-09 23:27:13 +0000220
wdenk42d1f032003-10-15 23:53:47 +0000221 return 0;
222}
223
224void reset_phy (void)
225{
226#if defined(CONFIG_ETHER_ON_FCC) /* avoid compile warnings for now */
227 volatile bcsr_t *bcsr = (bcsr_t *) CFG_BCSR;
228#endif
229 /* reset Giga bit Ethernet port if needed here */
230
231 /* reset the CPM FEC port */
232#if (CONFIG_ETHER_INDEX == 2)
233 bcsr->bcsr2 &= ~FETH2_RST;
234 udelay(2);
235 bcsr->bcsr2 |= FETH2_RST;
236 udelay(1000);
237#elif (CONFIG_ETHER_INDEX == 3)
238 bcsr->bcsr3 &= ~FETH3_RST;
239 udelay(2);
240 bcsr->bcsr3 |= FETH3_RST;
241 udelay(1000);
242#endif
243#if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
244 miiphy_reset(0x0); /* reset PHY */
245 miiphy_write(0, PHY_MIPSCR, 0xf028); /* change PHY address to 0x02 */
246 miiphy_write(0x02, PHY_BMCR, PHY_BMCR_AUTON | PHY_BMCR_RST_NEG);
247#endif /* CONFIG_MII */
248}
249
250int checkboard (void)
251{
wdenk97d80fc2004-06-09 00:34:46 +0000252 puts("Board: ADS\n");
wdenk0ac6f8b2004-07-09 23:27:13 +0000253
254#ifdef CONFIG_PCI
255 printf(" PCI1: 32 bit, %d MHz (compiled)\n",
256 CONFIG_SYS_CLK_FREQ / 1000000);
257#else
258 printf(" PCI1: disabled\n");
259#endif
wdenk97d80fc2004-06-09 00:34:46 +0000260 return 0;
wdenk42d1f032003-10-15 23:53:47 +0000261}
262
263
wdenk0ac6f8b2004-07-09 23:27:13 +0000264long int
265initdram(int board_type)
wdenk42d1f032003-10-15 23:53:47 +0000266{
267 long dram_size = 0;
268 extern long spd_sdram (void);
269 volatile immap_t *immap = (immap_t *)CFG_IMMR;
wdenk0ac6f8b2004-07-09 23:27:13 +0000270
271 puts("Initializing\n");
wdenk97d80fc2004-06-09 00:34:46 +0000272
wdenk42d1f032003-10-15 23:53:47 +0000273#if defined(CONFIG_DDR_DLL)
wdenk0ac6f8b2004-07-09 23:27:13 +0000274 {
275 volatile ccsr_gur_t *gur= &immap->im_gur;
276 uint temp_ddrdll = 0;
wdenk42d1f032003-10-15 23:53:47 +0000277
wdenk0ac6f8b2004-07-09 23:27:13 +0000278 /*
279 * Work around to stabilize DDR DLL
280 */
281 temp_ddrdll = gur->ddrdllcr;
282 gur->ddrdllcr = ((temp_ddrdll & 0xff) << 16) | 0x80000000;
283 asm("sync;isync;msync");
284 }
wdenk42d1f032003-10-15 23:53:47 +0000285#endif
286
287#if defined(CONFIG_SPD_EEPROM)
288 dram_size = spd_sdram ();
289#else
290 dram_size = fixed_sdram ();
291#endif
292
wdenk0ac6f8b2004-07-09 23:27:13 +0000293#if defined(CONFIG_DDR_ECC)
294 /*
295 * Initialize and enable DDR ECC.
296 */
297 ddr_enable_ecc(dram_size);
298#endif
299
300 /*
301 * Initialize SDRAM.
302 */
303 sdram_init();
304
305 puts(" DDR: ");
306 return dram_size;
307}
308
309
310/*
311 * Initialize SDRAM memory on the Local Bus.
312 */
313
314void sdram_init (void)
315{
316#if !defined(CONFIG_RAM_AS_FLASH)
317 sys_info_t sysinfo;
318 volatile immap_t *immap = (immap_t *) CFG_IMMR;
319 volatile ccsr_lbc_t *lbc = &immap->im_lbc;
320 uint *sdram_addr = (uint *) CFG_LBC_SDRAM_BASE;
321
322 puts (" SDRAM: ");
323 print_size (CFG_LBC_SDRAM_SIZE * 1024 * 1024, "\n");
324
325 /*
326 * LocalBus SDRAM is not emulating flash.
327 */
328
329 /*
330 * Fix Local Bus clock glitch. Errata LBC11.
331 *
332 * If localbus freq is less than 66Mhz, use bypass mode,
333 * otherwise use DLL.
334 * lcrr is the local-bus clock ratio register.
335 */
336 get_sys_info (&sysinfo);
337 if (sysinfo.freqSystemBus / (CFG_LBC_LCRR & 0x0f) < 66000000) {
338 lbc->lcrr = (CFG_LBC_LCRR & 0x0fffffff) | 0x80000000;
339
wdenk42d1f032003-10-15 23:53:47 +0000340 } else {
wdenk0ac6f8b2004-07-09 23:27:13 +0000341 /*
342 * On REV1 boards, need to change CLKDIV before enable DLL.
343 * Default CLKDIV is 8, change it to 4 temporarily.
344 */
345 volatile ccsr_gur_t *gur = &immap->im_gur;
346 uint pvr = get_pvr ();
347 uint temp_lbcdll = 0;
wdenk97d80fc2004-06-09 00:34:46 +0000348
349 if (pvr == PVR_85xx_REV1) {
wdenk0ac6f8b2004-07-09 23:27:13 +0000350 lbc->lcrr = 0x10000004;
wdenk97d80fc2004-06-09 00:34:46 +0000351 }
wdenk0ac6f8b2004-07-09 23:27:13 +0000352
353 /* FIXME: jdl Should lcrr have 0x8000000 OR'ed in here too? */
wdenk42d1f032003-10-15 23:53:47 +0000354 lbc->lcrr = CFG_LBC_LCRR & 0x7fffffff;
wdenk0ac6f8b2004-07-09 23:27:13 +0000355 udelay (200);
wdenk42d1f032003-10-15 23:53:47 +0000356 temp_lbcdll = gur->lbcdllcr;
wdenk0ac6f8b2004-07-09 23:27:13 +0000357 gur->lbcdllcr = ((temp_lbcdll & 0xff) << 16) | 0x80000000;
358 asm ("sync;isync;msync");
wdenk42d1f032003-10-15 23:53:47 +0000359 }
wdenk0ac6f8b2004-07-09 23:27:13 +0000360
361 /*
362 * Setup SDRAM Base and Option Registers
363 */
364 lbc->or2 = CFG_OR2_PRELIM;
wdenk42d1f032003-10-15 23:53:47 +0000365 lbc->br2 = CFG_BR2_PRELIM;
366 lbc->lbcr = CFG_LBC_LBCR;
wdenk0ac6f8b2004-07-09 23:27:13 +0000367 asm ("msync");
368
wdenk42d1f032003-10-15 23:53:47 +0000369 lbc->lsrt = CFG_LBC_LSRT;
wdenk42d1f032003-10-15 23:53:47 +0000370 lbc->mrtpr = CFG_LBC_MRTPR;
wdenk0ac6f8b2004-07-09 23:27:13 +0000371 asm ("sync");
372
373 /*
374 * Configure the SDRAM controller.
375 */
376 lbc->lsdmr = CFG_LBC_LSDMR_1;
377 asm ("sync");
378 *sdram_addr = 0xff;
379 ppcDcbf ((unsigned long) sdram_addr);
380 udelay (100);
381
382 lbc->lsdmr = CFG_LBC_LSDMR_2;
383 asm ("sync");
384 *sdram_addr = 0xff;
385 ppcDcbf ((unsigned long) sdram_addr);
386 udelay (100);
387
388 lbc->lsdmr = CFG_LBC_LSDMR_3;
389 asm ("sync");
390 *sdram_addr = 0xff;
391 ppcDcbf ((unsigned long) sdram_addr);
392 udelay (100);
393
394 lbc->lsdmr = CFG_LBC_LSDMR_4;
395 asm ("sync");
396 *sdram_addr = 0xff;
397 ppcDcbf ((unsigned long) sdram_addr);
398 udelay (100);
399
400 lbc->lsdmr = CFG_LBC_LSDMR_5;
401 asm ("sync");
402 *sdram_addr = 0xff;
403 ppcDcbf ((unsigned long) sdram_addr);
404 udelay (100);
405
wdenk42d1f032003-10-15 23:53:47 +0000406#endif
wdenk42d1f032003-10-15 23:53:47 +0000407}
408
409
410#if defined(CFG_DRAM_TEST)
411int testdram (void)
412{
413 uint *pstart = (uint *) CFG_MEMTEST_START;
414 uint *pend = (uint *) CFG_MEMTEST_END;
415 uint *p;
416
417 printf("SDRAM test phase 1:\n");
418 for (p = pstart; p < pend; p++)
419 *p = 0xaaaaaaaa;
420
421 for (p = pstart; p < pend; p++) {
422 if (*p != 0xaaaaaaaa) {
423 printf ("SDRAM test fails at: %08x\n", (uint) p);
424 return 1;
425 }
426 }
427
428 printf("SDRAM test phase 2:\n");
429 for (p = pstart; p < pend; p++)
430 *p = 0x55555555;
431
432 for (p = pstart; p < pend; p++) {
433 if (*p != 0x55555555) {
434 printf ("SDRAM test fails at: %08x\n", (uint) p);
435 return 1;
436 }
437 }
438
439 printf("SDRAM test passed.\n");
440 return 0;
441}
442#endif
443
wdenk0ac6f8b2004-07-09 23:27:13 +0000444
wdenk42d1f032003-10-15 23:53:47 +0000445#if !defined(CONFIG_SPD_EEPROM)
446/*************************************************************************
447 * fixed sdram init -- doesn't use serial presence detect.
448 ************************************************************************/
449long int fixed_sdram (void)
450{
451 #ifndef CFG_RAMBOOT
452 volatile immap_t *immap = (immap_t *)CFG_IMMR;
453 volatile ccsr_ddr_t *ddr= &immap->im_ddr;
454
455 ddr->cs0_bnds = CFG_DDR_CS0_BNDS;
456 ddr->cs0_config = CFG_DDR_CS0_CONFIG;
457 ddr->timing_cfg_1 = CFG_DDR_TIMING_1;
458 ddr->timing_cfg_2 = CFG_DDR_TIMING_2;
459 ddr->sdram_mode = CFG_DDR_MODE;
460 ddr->sdram_interval = CFG_DDR_INTERVAL;
461 #if defined (CONFIG_DDR_ECC)
462 ddr->err_disable = 0x0000000D;
463 ddr->err_sbe = 0x00ff0000;
464 #endif
465 asm("sync;isync;msync");
466 udelay(500);
467 #if defined (CONFIG_DDR_ECC)
468 /* Enable ECC checking */
469 ddr->sdram_cfg = (CFG_DDR_CONTROL | 0x20000000);
470 #else
471 ddr->sdram_cfg = CFG_DDR_CONTROL;
472 #endif
473 asm("sync; isync; msync");
474 udelay(500);
475 #endif
wdenk0ac6f8b2004-07-09 23:27:13 +0000476 return CFG_SDRAM_SIZE * 1024 * 1024;
wdenk42d1f032003-10-15 23:53:47 +0000477}
478#endif /* !defined(CONFIG_SPD_EEPROM) */