blob: 2b3de4499b16cf86e689c71e0e74bc7b25286b2c [file] [log] [blame]
Wolfgang Grandeggerc7487e92009-02-11 18:38:26 +01001
Stefan Roese09554022005-11-30 13:06:40 +01002/*
3 * (C) Copyright 2005
4 * Stefan Roese, DENX Software Engineering, sr@denx.de.
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
Stefan Roese09554022005-11-30 13:06:40 +010025#include <common.h>
26#include <asm/processor.h>
27#include <asm/immap_85xx.h>
28#include <asm/processor.h>
29#include <asm/mmu.h>
Stefan Roese09554022005-11-30 13:06:40 +010030
31struct sdram_conf_s {
32 unsigned long size;
33 unsigned long reg;
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020034#ifdef CONFIG_TQM8548
35 unsigned long refresh;
36#endif /* CONFIG_TQM8548 */
Stefan Roese09554022005-11-30 13:06:40 +010037};
38
39typedef struct sdram_conf_s sdram_conf_t;
40
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020041#ifdef CONFIG_TQM8548
Wolfgang Grandegger57181dd2009-02-11 18:38:24 +010042#ifdef CONFIG_TQM8548_AG
43sdram_conf_t ddr_cs_conf[] = {
44 {(1024 << 20), 0x80044202, 0x0002D000}, /* 1024MB, 14x10(4) */
45 { (512 << 20), 0x80044102, 0x0001A000}, /* 512MB, 13x10(4) */
46 { (256 << 20), 0x80040102, 0x00014000}, /* 256MB, 13x10(4) */
47 { (128 << 20), 0x80040101, 0x0000C000}, /* 128MB, 13x9(4) */
48};
49#else /* !CONFIG_TQM8548_AG */
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020050sdram_conf_t ddr_cs_conf[] = {
51 {(512 << 20), 0x80044102, 0x0001A000}, /* 512MB, 13x10(4) */
52 {(256 << 20), 0x80040102, 0x00014000}, /* 256MB, 13x10(4) */
53 {(128 << 20), 0x80040101, 0x0000C000}, /* 128MB, 13x9(4) */
54};
Wolfgang Grandegger57181dd2009-02-11 18:38:24 +010055#endif /* CONFIG_TQM8548_AG */
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020056#else /* !CONFIG_TQM8548 */
Stefan Roese09554022005-11-30 13:06:40 +010057sdram_conf_t ddr_cs_conf[] = {
58 {(512 << 20), 0x80000202}, /* 512MB, 14x10(4) */
59 {(256 << 20), 0x80000102}, /* 256MB, 13x10(4) */
60 {(128 << 20), 0x80000101}, /* 128MB, 13x9(4) */
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +020061 {( 64 << 20), 0x80000001}, /* 64MB, 12x9(4) */
Stefan Roese09554022005-11-30 13:06:40 +010062};
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020063#endif /* CONFIG_TQM8548 */
Stefan Roese09554022005-11-30 13:06:40 +010064
65#define N_DDR_CS_CONF (sizeof(ddr_cs_conf) / sizeof(ddr_cs_conf[0]))
66
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +020067int cas_latency (void);
Stefan Roese09554022005-11-30 13:06:40 +010068
69/*
70 * Autodetect onboard DDR SDRAM on 85xx platforms
71 *
72 * NOTE: Some of the hardcoded values are hardware dependant,
73 * so this should be extended for other future boards
74 * using this routine!
75 */
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +020076long int sdram_setup (int casl)
Stefan Roese09554022005-11-30 13:06:40 +010077{
78 int i;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020079 volatile ccsr_ddr_t *ddr = (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020080#ifdef CONFIG_TQM8548
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020081 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Wolfgang Grandeggerc7487e92009-02-11 18:38:26 +010082 volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020083#else /* !CONFIG_TQM8548 */
Stefan Roese09554022005-11-30 13:06:40 +010084 unsigned long cfg_ddr_timing1;
85 unsigned long cfg_ddr_mode;
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020086#endif /* CONFIG_TQM8548 */
Stefan Roese09554022005-11-30 13:06:40 +010087
88 /*
89 * Disable memory controller.
90 */
91 ddr->cs0_config = 0;
92 ddr->sdram_cfg = 0;
93
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020094#ifdef CONFIG_TQM8548
Wolfgang Grandegger89ad1852009-02-11 18:38:23 +010095 /* Timing and refresh settings for DDR2-533 and below */
96
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +020097 ddr->cs0_bnds = (ddr_cs_conf[0].size - 1) >> 24;
98 ddr->cs0_config = ddr_cs_conf[0].reg;
Wolfgang Grandegger89ad1852009-02-11 18:38:23 +010099 ddr->timing_cfg_3 = 0x00020000;
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200100
101 /* TIMING CFG 1, 533MHz
102 * PRETOACT: 4 Clocks
103 * ACTTOPRE: 12 Clocks
104 * ACTTORW: 4 Clocks
105 * CASLAT: 4 Clocks
Wolfgang Grandegger89ad1852009-02-11 18:38:23 +0100106 * REFREC: EXT_REFREC:REFREC 53 Clocks
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200107 * WRREC: 4 Clocks
108 * ACTTOACT: 3 Clocks
109 * WRTORD: 2 Clocks
110 */
Wolfgang Grandegger89ad1852009-02-11 18:38:23 +0100111 ddr->timing_cfg_1 = 0x4C47D432;
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200112
113 /* TIMING CFG 2, 533MHz
114 * ADD_LAT: 3 Clocks
115 * CPO: READLAT + 1
116 * WR_LAT: 3 Clocks
117 * RD_TO_PRE: 2 Clocks
118 * WR_DATA_DELAY: 1/2 Clock
Wolfgang Grandegger89ad1852009-02-11 18:38:23 +0100119 * CKE_PLS: 3 Clock
120 * FOUR_ACT: 14 Clocks
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200121 */
Wolfgang Grandegger89ad1852009-02-11 18:38:23 +0100122 ddr->timing_cfg_2 = 0x331848CE;
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200123
124 /* DDR SDRAM Mode, 533MHz
125 * MRS: Extended Mode Register
126 * OUT: Outputs enabled
127 * RDQS: no
128 * DQS: enabled
129 * OCD: default state
130 * RTT: 75 Ohms
131 * Posted CAS: 3 Clocks
132 * ODS: reduced strength
133 * DLL: enabled
134 * MR: Mode Register
135 * PD: fast exit
136 * WR: 4 Clocks
137 * DLL: no DLL reset
138 * TM: normal
139 * CAS latency: 4 Clocks
140 * BT: sequential
141 * Burst length: 4
142 */
143 ddr->sdram_mode = 0x439E0642;
144
145 /* DDR SDRAM Interval, 533MHz
146 * REFINT: 1040 Clocks
147 * BSTOPRE: 256
148 */
149 ddr->sdram_interval = (1040 << 16) | 0x100;
150
151 /*
Wolfgang Grandeggerc7487e92009-02-11 18:38:26 +0100152 * Workaround for erratum DDR19 according to MPC8548 Device Errata
153 * document, Rev. 1: DDR IO receiver must be set to an acceptable
154 * bias point by modifying a hidden register.
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200155 */
Wolfgang Grandeggerc7487e92009-02-11 18:38:26 +0100156 if (SVR_REV (get_svr ()) < 0x21)
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200157 gur->ddrioovcr = 0x90000000; /* enable, VSEL 1.8V */
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200158
159 /* DDR SDRAM CFG 2
160 * FRC_SR: normal mode
161 * SR_IE: no self-refresh interrupt
162 * DLL_RST_DIS: don't care, leave at reset value
163 * DQS_CFG: differential DQS signals
164 * ODT_CFG: assert ODT to internal IOs only during reads to DRAM
165 * LVWx_CFG: don't care, leave at reset value
166 * NUM_PR: 1 refresh will be issued at a time
167 * DM_CFG: don't care, leave at reset value
168 * D_INIT: no data initialization
169 */
170 ddr->sdram_cfg_2 = 0x04401000;
171
172 /* DDR SDRAM MODE 2
173 * MRS: Extended Mode Register 2
174 */
175 ddr->sdram_mode_2 = 0x8000C000;
176
177 /* DDR SDRAM CLK CNTL
178 * CLK_ADJUST: 1/2 Clock 0x02000000
179 * CLK_ADJUST: 5/8 Clock 0x02800000
180 */
181 ddr->sdram_clk_cntl = 0x02800000;
182
183 /* wait for clock stabilization */
184 asm ("sync;isync;msync");
Wolfgang Grandeggerc7487e92009-02-11 18:38:26 +0100185 udelay (1000);
186
187#if defined(CONFIG_TQM8548_AG) || defined(CONFIG_TQM8548_BE)
188 /*
189 * Workaround for erratum DDR20 according to MPC8548 Device Errata
190 * document, Rev. 1: "CKE signal may not function correctly after
191 * assertion of HRESET"
192 */
193
194 /* 1. Configure DDR register as is done in normal DDR configuration.
195 * Do not set DDR_SDRAM_CFG[MEM_EN].
196 *
197 * 2. Set reserved bit EEBACR[3] at offset 0x1000
198 */
199 ecm->eebacr |= 0x10000000;
200
201 /*
202 * 3. Before DDR_SDRAM_CFG[MEM_EN] is set, write DDR_SDRAM_CFG_2[D_INIT]
203 *
204 * DDR_SDRAM_CFG_2:
205 * FRC_SR: normal mode
206 * SR_IE: no self-refresh interrupt
207 * DLL_RST_DIS: don't care, leave at reset value
208 * DQS_CFG: differential DQS signals
209 * ODT_CFG: assert ODT to internal IOs only during reads to DRAM
210 * LVWx_CFG: don't care, leave at reset value
211 * NUM_PR: 1 refresh will be issued at a time
212 * DM_CFG: don't care, leave at reset value
213 * D_INIT: enable data initialization
214 */
215 ddr->sdram_cfg_2 |= 0x00000010;
216
217 /*
218 * 4. Before DDR_SDRAM_CFG[MEM_EN] set, write D3[21] to disable data
219 * training
220 */
221 ddr->debug_3 |= 0x00000400;
222
223 /*
224 * 5. Wait 200 micro-seconds
225 */
226 udelay (200);
227
228 /*
229 * 6. Set DDR_SDRAM_CFG[MEM_EN]
230 *
231 * BTW, initialize DDR_SDRAM_CFG:
232 * MEM_EN: enabled
233 * SREN: don't care, leave at reset value
234 * ECC_EN: no error report
235 * RD_EN: no registered DIMMs
236 * SDRAM_TYPE: DDR2
237 * DYN_PWR: no power management
238 * 32_BE: don't care, leave at reset value
239 * 8_BE: 4 beat burst
240 * NCAP: don't care, leave at reset value
241 * 2T_EN: 1T Timing
242 * BA_INTLV_CTL: no interleaving
243 * x32_EN: x16 organization
244 * PCHB8: MA[10] for auto-precharge
245 * HSE: half strength for single and 2-layer stacks
246 * (full strength for 3- and 4-layer stacks not
247 * yet considered)
248 * MEM_HALT: no halt
249 * BI: automatic initialization
250 */
251 ddr->sdram_cfg = 0x83000008;
252
253 /*
254 * 7. Poll DDR_SDRAM_CFG_2[D_INIT] until it is cleared by hardware
255 */
256 asm ("sync;isync;msync");
257 while (ddr->sdram_cfg_2 & 0x00000010)
258 asm ("eieio");
259
260 /*
261 * 8. Clear D3[21] to re-enable data training
262 */
263 ddr->debug_3 &= ~0x00000400;
264
265 /*
266 * 9. Set D2(21) to force data training to run
267 */
268 ddr->debug_2 |= 0x00000400;
269
270 /*
271 * 10. Poll on D2[21] until it is cleared by hardware
272 */
273 asm ("sync;isync;msync");
274 while (ddr->debug_2 & 0x00000400)
275 asm ("eieio");
276
277 /*
278 * 11. Clear reserved bit EEBACR[3] at offset 0x1000
279 */
280 ecm->eebacr &= ~0x10000000;
281
282#else /* !(CONFIG_TQM8548_AG || CONFIG_TQM8548_BE) */
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200283
284 /* DDR SDRAM CLK CNTL
285 * MEM_EN: enabled
286 * SREN: don't care, leave at reset value
287 * ECC_EN: no error report
288 * RD_EN: no register DIMMs
289 * SDRAM_TYPE: DDR2
290 * DYN_PWR: no power management
291 * 32_BE: don't care, leave at reset value
292 * 8_BE: 4 beat burst
293 * NCAP: don't care, leave at reset value
294 * 2T_EN: 1T Timing
295 * BA_INTLV_CTL: no interleaving
296 * x32_EN: x16 organization
297 * PCHB8: MA[10] for auto-precharge
298 * HSE: half strength for single and 2-layer stacks
299 * (full strength for 3- and 4-layer stacks no yet considered)
300 * MEM_HALT: no halt
301 * BI: automatic initialization
302 */
303 ddr->sdram_cfg = 0x83000008;
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200304
Wolfgang Grandeggerc7487e92009-02-11 18:38:26 +0100305#endif /* CONFIG_TQM8548_AG || CONFIG_TQM8548_BE */
306
307 asm ("sync; isync; msync");
308 udelay (1000);
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200309#else /* !CONFIG_TQM8548 */
Stefan Roese09554022005-11-30 13:06:40 +0100310 switch (casl) {
311 case 20:
312 cfg_ddr_timing1 = 0x47405331 | (3 << 16);
313 cfg_ddr_mode = 0x40020002 | (2 << 4);
314 break;
315
316 case 25:
317 cfg_ddr_timing1 = 0x47405331 | (4 << 16);
318 cfg_ddr_mode = 0x40020002 | (6 << 4);
319 break;
320
321 case 30:
322 default:
323 cfg_ddr_timing1 = 0x47405331 | (5 << 16);
324 cfg_ddr_mode = 0x40020002 | (3 << 4);
325 break;
326 }
327
328 ddr->cs0_bnds = (ddr_cs_conf[0].size - 1) >> 24;
329 ddr->cs0_config = ddr_cs_conf[0].reg;
330 ddr->timing_cfg_1 = cfg_ddr_timing1;
331 ddr->timing_cfg_2 = 0x00000800; /* P9-45,may need tuning */
332 ddr->sdram_mode = cfg_ddr_mode;
333 ddr->sdram_interval = 0x05160100; /* autocharge,no open page */
334 ddr->err_disable = 0x0000000D;
335
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200336 asm ("sync; isync; msync");
337 udelay (1000);
Stefan Roese09554022005-11-30 13:06:40 +0100338
339 ddr->sdram_cfg = 0xc2000000; /* unbuffered,no DYN_PWR */
340 asm ("sync; isync; msync");
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200341 udelay (1000);
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200342#endif /* CONFIG_TQM8548 */
Stefan Roese09554022005-11-30 13:06:40 +0100343
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200344 for (i = 0; i < N_DDR_CS_CONF; i++) {
Stefan Roese09554022005-11-30 13:06:40 +0100345 ddr->cs0_config = ddr_cs_conf[i].reg;
346
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200347 if (get_ram_size (0, ddr_cs_conf[i].size) ==
348 ddr_cs_conf[i].size) {
Stefan Roese09554022005-11-30 13:06:40 +0100349 /*
Wolfgang Grandegger6d571542008-06-05 13:12:04 +0200350 * size detected -> set Chip Select Bounds Register
Stefan Roese09554022005-11-30 13:06:40 +0100351 */
Wolfgang Grandegger6d571542008-06-05 13:12:04 +0200352 ddr->cs0_bnds = (ddr_cs_conf[i].size - 1) >> 24;
353
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200354 break;
Stefan Roese09554022005-11-30 13:06:40 +0100355 }
356 }
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200357
358#ifdef CONFIG_TQM8548
359 if (i < N_DDR_CS_CONF) {
360 /* Adjust refresh rate for DDR2 */
361
362 ddr->timing_cfg_3 = ddr_cs_conf[i].refresh & 0x00070000;
363
364 ddr->timing_cfg_1 = (ddr->timing_cfg_1 & 0xFFFF0FFF) |
365 (ddr_cs_conf[i].refresh & 0x0000F000);
366
367 return ddr_cs_conf[i].size;
368 }
369#endif /* CONFIG_TQM8548 */
Stefan Roese09554022005-11-30 13:06:40 +0100370
Wolfgang Grandegger328c6ec2008-06-05 13:12:07 +0200371 /* return size if detected, else return 0 */
372 return (i < N_DDR_CS_CONF) ? ddr_cs_conf[i].size : 0;
Stefan Roese09554022005-11-30 13:06:40 +0100373}
374
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200375void board_add_ram_info (int use_default)
Stefan Roese09554022005-11-30 13:06:40 +0100376{
377 int casl;
378
379 if (use_default)
380 casl = CONFIG_DDR_DEFAULT_CL;
381 else
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200382 casl = cas_latency ();
Stefan Roese09554022005-11-30 13:06:40 +0100383
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200384 puts (" (CL=");
Stefan Roese09554022005-11-30 13:06:40 +0100385 switch (casl) {
386 case 20:
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200387 puts ("2)");
Stefan Roese09554022005-11-30 13:06:40 +0100388 break;
389
390 case 25:
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200391 puts ("2.5)");
Stefan Roese09554022005-11-30 13:06:40 +0100392 break;
393
394 case 30:
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200395 puts ("3)");
Stefan Roese09554022005-11-30 13:06:40 +0100396 break;
397 }
398}
399
Becky Brucebd99ae72008-06-09 16:03:40 -0500400phys_size_t initdram (int board_type)
Stefan Roese09554022005-11-30 13:06:40 +0100401{
402 long dram_size = 0;
403 int casl;
404
405#if defined(CONFIG_DDR_DLL)
406 /*
407 * This DLL-Override only used on TQM8540 and TQM8560
408 */
409 {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200410 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200411 int i, x;
Stefan Roese09554022005-11-30 13:06:40 +0100412
413 x = 10;
414
415 /*
416 * Work around to stabilize DDR DLL
417 */
418 gur->ddrdllcr = 0x81000000;
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200419 asm ("sync; isync; msync");
Stefan Roese09554022005-11-30 13:06:40 +0100420 udelay (200);
421 while (gur->ddrdllcr != 0x81000100) {
422 gur->devdisr = gur->devdisr | 0x00010000;
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200423 asm ("sync; isync; msync");
424 for (i = 0; i < x; i++)
Stefan Roese09554022005-11-30 13:06:40 +0100425 ;
426 gur->devdisr = gur->devdisr & 0xfff7ffff;
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200427 asm ("sync; isync; msync");
Stefan Roese09554022005-11-30 13:06:40 +0100428 x++;
429 }
430 }
431#endif
432
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200433 casl = cas_latency ();
434 dram_size = sdram_setup (casl);
Stefan Roese09554022005-11-30 13:06:40 +0100435 if ((dram_size == 0) && (casl != CONFIG_DDR_DEFAULT_CL)) {
436 /*
437 * Try again with default CAS latency
438 */
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200439 puts ("Problem with CAS lantency");
440 board_add_ram_info (1);
441 puts (", using default CL!\n");
Stefan Roese09554022005-11-30 13:06:40 +0100442 casl = CONFIG_DDR_DEFAULT_CL;
Wolfgang Grandegger9039ce12008-06-05 13:12:00 +0200443 dram_size = sdram_setup (casl);
444 puts (" ");
Stefan Roese09554022005-11-30 13:06:40 +0100445 }
446
447 return dram_size;
448}
449
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200450#if defined(CONFIG_SYS_DRAM_TEST)
Stefan Roese09554022005-11-30 13:06:40 +0100451int testdram (void)
452{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200453 uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
454 uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
Stefan Roese09554022005-11-30 13:06:40 +0100455 uint *p;
456
457 printf ("SDRAM test phase 1:\n");
458 for (p = pstart; p < pend; p++)
459 *p = 0xaaaaaaaa;
460
461 for (p = pstart; p < pend; p++) {
462 if (*p != 0xaaaaaaaa) {
463 printf ("SDRAM test fails at: %08x\n", (uint) p);
464 return 1;
465 }
466 }
467
468 printf ("SDRAM test phase 2:\n");
469 for (p = pstart; p < pend; p++)
470 *p = 0x55555555;
471
472 for (p = pstart; p < pend; p++) {
473 if (*p != 0x55555555) {
474 printf ("SDRAM test fails at: %08x\n", (uint) p);
475 return 1;
476 }
477 }
478
479 printf ("SDRAM test passed.\n");
480 return 0;
481}
482#endif