1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <config.h>
27#include <common.h>
28#include <mpc8xx.h>
29#include <pcmcia.h>
30
31#define _NOT_USED_ 0xFFFFFFFF
32
33
34
35#ifndef CONFIG_MPC885ADS
36
37#if defined(CONFIG_DRAM_50MHZ)
38
39static const uint dram_60ns[] =
40{ 0x8fffec24, 0x0fffec04, 0x0cffec04, 0x00ffec04,
41 0x00ffec00, 0x37ffec47, _NOT_USED_, _NOT_USED_,
42 0x8fffec24, 0x0fffec04, 0x08ffec04, 0x00ffec0c,
43 0x03ffec00, 0x00ffec44, 0x00ffcc08, 0x0cffcc44,
44 0x00ffec0c, 0x03ffec00, 0x00ffec44, 0x00ffcc00,
45 0x3fffc847, _NOT_USED_, _NOT_USED_, _NOT_USED_,
46 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x11bfcc47,
47 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
48 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x03afcc4c,
49 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c,
50 0x0cafcc00, 0x33bfcc4f, _NOT_USED_, _NOT_USED_,
51 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
52 0xc0ffcc84, 0x00ffcc04, 0x07ffcc04, 0x3fffcc06,
53 0xffffcc85, 0xffffcc05, _NOT_USED_, _NOT_USED_,
54 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
55 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
56
57static const uint dram_70ns[] =
58{ 0x8fffcc24, 0x0fffcc04, 0x0cffcc04, 0x00ffcc04,
59 0x00ffcc00, 0x37ffcc47, _NOT_USED_, _NOT_USED_,
60 0x8fffcc24, 0x0fffcc04, 0x0cffcc04, 0x00ffcc04,
61 0x00ffcc08, 0x0cffcc44, 0x00ffec0c, 0x03ffec00,
62 0x00ffec44, 0x00ffcc08, 0x0cffcc44, 0x00ffec04,
63 0x00ffec00, 0x3fffec47, _NOT_USED_, _NOT_USED_,
64 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x11bfcc47,
65 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
66 0x8fafcc24, 0x0fafcc04, 0x0cafcc00, 0x03afcc4c,
67 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c,
68 0x0cafcc00, 0x33bfcc4f, _NOT_USED_, _NOT_USED_,
69 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
70 0xe0ffcc84, 0x00ffcc04, 0x00ffcc04, 0x0fffcc04,
71 0x7fffcc06, 0xffffcc85, 0xffffcc05, _NOT_USED_,
72 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
73 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
74
75static const uint edo_60ns[] =
76{ 0x8ffbec24, 0x0ff3ec04, 0x0cf3ec04, 0x00f3ec04,
77 0x00f3ec00, 0x37f7ec47, _NOT_USED_, _NOT_USED_,
78 0x8fffec24, 0x0ffbec04, 0x0cf3ec04, 0x00f3ec0c,
79 0x0cf3ec00, 0x00f3ec4c, 0x0cf3ec00, 0x00f3ec4c,
80 0x0cf3ec00, 0x00f3ec44, 0x03f3ec00, 0x3ff7ec47,
81 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
82 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x11bfcc47,
83 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
84 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x03afcc4c,
85 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c,
86 0x0cafcc00, 0x33bfcc4f, _NOT_USED_, _NOT_USED_,
87 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
88 0xc0ffcc84, 0x00ffcc04, 0x07ffcc04, 0x3fffcc06,
89 0xffffcc85, 0xffffcc05, _NOT_USED_, _NOT_USED_,
90 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
91 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
92
93static const uint edo_70ns[] =
94{ 0x8ffbcc24, 0x0ff3cc04, 0x0cf3cc04, 0x00f3cc04,
95 0x00f3cc00, 0x37f7cc47, _NOT_USED_, _NOT_USED_,
96 0x8fffcc24, 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc0c,
97 0x03f3cc00, 0x00f3cc44, 0x00f3ec0c, 0x0cf3ec00,
98 0x00f3ec4c, 0x03f3ec00, 0x00f3ec44, 0x00f3cc00,
99 0x33f7cc47, _NOT_USED_, _NOT_USED_, _NOT_USED_,
100 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x11bfcc47,
101 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
102 0x8fffcc24, 0x0fefcc04, 0x0cafcc00, 0x03afcc4c,
103 0x0cafcc00, 0x03afcc4c, 0x0cafcc00, 0x03afcc4c,
104 0x0cafcc00, 0x33bfcc47, _NOT_USED_, _NOT_USED_,
105 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
106 0xe0ffcc84, 0x00ffcc04, 0x00ffcc04, 0x0fffcc04,
107 0x7fffcc04, 0xffffcc86, 0xffffcc05, _NOT_USED_,
108 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
109 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
110
111#elif defined(CONFIG_DRAM_25MHZ)
112
113
114
115static const uint dram_60ns[] =
116{ 0x0fffcc04, 0x08ffcc00, 0x33ffcc47, _NOT_USED_,
117 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
118 0x0fffcc24, 0x0fffcc04, 0x08ffcc00, 0x03ffcc4c,
119 0x08ffcc00, 0x03ffcc4c, 0x08ffcc00, 0x03ffcc4c,
120 0x08ffcc00, 0x33ffcc47, _NOT_USED_, _NOT_USED_,
121 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
122 0x0fafcc04, 0x08afcc00, 0x3fbfcc47, _NOT_USED_,
123 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
124 0x0fafcc04, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00,
125 0x01afcc4c, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00,
126 0x31bfcc43, _NOT_USED_, _NOT_USED_, _NOT_USED_,
127 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
128 0x80ffcc84, 0x13ffcc04, 0xffffcc87, 0xffffcc05,
129 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
130 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
131 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
132
133static const uint dram_70ns[] =
134{ 0x0fffec04, 0x08ffec04, 0x00ffec00, 0x3fffcc47,
135 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
136 0x0fffcc24, 0x0fffcc04, 0x08ffcc00, 0x03ffcc4c,
137 0x08ffcc00, 0x03ffcc4c, 0x08ffcc00, 0x03ffcc4c,
138 0x08ffcc00, 0x33ffcc47, _NOT_USED_, _NOT_USED_,
139 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
140 0x0fafcc04, 0x08afcc00, 0x3fbfcc47, _NOT_USED_,
141 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
142 0x0fafcc04, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00,
143 0x01afcc4c, 0x0cafcc00, 0x01afcc4c, 0x0cafcc00,
144 0x31bfcc43, _NOT_USED_, _NOT_USED_, _NOT_USED_,
145 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
146 0xc0ffcc84, 0x01ffcc04, 0x7fffcc86, 0xffffcc05,
147 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
148 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
149 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
150
151static const uint edo_60ns[] =
152{ 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc00, 0x33f7cc47,
153 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
154 0x0ffbcc04, 0x09f3cc0c, 0x09f3cc0c, 0x09f3cc0c,
155 0x08f3cc00, 0x3ff7cc47, _NOT_USED_, _NOT_USED_,
156 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
157 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
158 0x0fefcc04, 0x08afcc04, 0x00afcc00, 0x3fbfcc47,
159 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
160 0x0fefcc04, 0x08afcc00, 0x07afcc48, 0x08afcc48,
161 0x08afcc48, 0x39bfcc47, _NOT_USED_, _NOT_USED_,
162 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
163 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
164 0x80ffcc84, 0x13ffcc04, 0xffffcc87, 0xffffcc05,
165 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
166 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
167 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
168
169static const uint edo_70ns[] =
170{ 0x0ffbcc04, 0x0cf3cc04, 0x00f3cc00, 0x33f7cc47,
171 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
172 0x0ffbec04, 0x08f3ec04, 0x03f3ec48, 0x08f3cc00,
173 0x0ff3cc4c, 0x08f3cc00, 0x0ff3cc4c, 0x08f3cc00,
174 0x3ff7cc47, _NOT_USED_, _NOT_USED_, _NOT_USED_,
175 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
176 0x0fefcc04, 0x08afcc04, 0x00afcc00, 0x3fbfcc47,
177 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
178 0x0fefcc04, 0x08afcc00, 0x07afcc4c, 0x08afcc00,
179 0x07afcc4c, 0x08afcc00, 0x07afcc4c, 0x08afcc00,
180 0x37bfcc47, _NOT_USED_, _NOT_USED_, _NOT_USED_,
181 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
182 0xc0ffcc84, 0x01ffcc04, 0x7fffcc86, 0xffffcc05,
183 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
184 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
185 0x33ffcc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
186#else
187#error dram not correctly defined - use CONFIG_DRAM_25MHZ or CONFIG_DRAM_50MHZ
188#endif
189
190
191static int _draminit (uint base, uint noMbytes, uint edo, uint delay)
192{
193 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
194 volatile memctl8xx_t *memctl = &immap->im_memctl;
195
196
197
198 switch (delay) {
199 case 70:
200 if (edo) {
201 upmconfig (UPMA, (uint *) edo_70ns,
202 sizeof (edo_70ns) / sizeof (uint));
203 } else {
204 upmconfig (UPMA, (uint *) dram_70ns,
205 sizeof (dram_70ns) / sizeof (uint));
206 }
207
208 break;
209
210 case 60:
211 if (edo) {
212 upmconfig (UPMA, (uint *) edo_60ns,
213 sizeof (edo_60ns) / sizeof (uint));
214 } else {
215 upmconfig (UPMA, (uint *) dram_60ns,
216 sizeof (dram_60ns) / sizeof (uint));
217 }
218
219 break;
220
221 default:
222 return -1;
223 }
224
225 memctl->memc_mptpr = 0x0400;
226
227 switch (noMbytes) {
228 case 4:
229#ifdef CONFIG_ADS
230 memctl->memc_mamr = 0xc0a21114;
231#else
232 memctl->memc_mamr = 0x13a01114;
233#endif
234 memctl->memc_or2 = 0xffc00800;
235 break;
236
237 case 8:
238 memctl->memc_mamr = 0x13a01114;
239 memctl->memc_or3 = 0xffc00800;
240 memctl->memc_br3 = 0x00400081 + base;
241 memctl->memc_or2 = 0xffc00800;
242 break;
243
244 case 16:
245#ifdef CONFIG_ADS
246 memctl->memc_mamr = 0x60b21114;
247#else
248 memctl->memc_mamr = 0x13b01114;
249#endif
250 memctl->memc_or2 = 0xff000800;
251 break;
252
253 case 32:
254 memctl->memc_mamr = 0x13b01114;
255 memctl->memc_or3 = 0xff000800;
256 memctl->memc_br3 = 0x01000081 + base;
257 memctl->memc_or2 = 0xff000800;
258 break;
259
260 default:
261 return -1;
262 }
263
264 memctl->memc_br2 = 0x81 + base;
265
266 *((uint *) BCSR1) &= ~BCSR1_DRAM_EN;
267
268
269
270
271
272
273 if (noMbytes == 8)
274 if (get_ram_size ((long *) base, noMbytes << 19) != noMbytes << 19) {
275 *((uint *) BCSR1) |= BCSR1_DRAM_EN;
276 return -1;
277 }
278
279 return 0;
280}
281
282
283
284static void _dramdisable(void)
285{
286 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
287 volatile memctl8xx_t *memctl = &immap->im_memctl;
288
289 memctl->memc_br2 = 0x00000000;
290 memctl->memc_br3 = 0x00000000;
291
292
293}
294#endif
295
296
297
298#ifdef CONFIG_FADS
299
300#if defined(CONFIG_SDRAM_100MHZ)
301
302
303
304
305
306
307
308
309
310#ifdef SDRAM_ALT_INIT_SEQENCE
311# define SDRAM_MBMRVALUE0 0xc3802114
312#define SDRAM_MBMRVALUE1 SDRAM_MBMRVALUE0
313# define SDRAM_MCRVALUE0 0x80808111
314# define SDRAM_MCRVALUE1 SDRAM_MCRVALUE0
315#else
316# define SDRAM_MxMR_PTx 195
317# define UPM_MRS_ADDR 0x11
318# define UPM_REFRESH_ADDR 0x30
319#endif
320
321static const uint sdram_table[] =
322{
323
324 0xefebfc24, 0x1f07fc24, 0xeeaefc04, 0x11adfc04,
325 0xefbbbc00, 0x1ff77c45, _NOT_USED_, _NOT_USED_,
326
327
328 0xefebfc24, 0x1f07fc24, 0xeeaefc04, 0x10adfc04,
329 0xf0affc00, 0xf0affc00, 0xf1affc00, 0xefbbbc00,
330 0x1ff77c45,
331
332
333 0xeffbbc04, 0x1ff77c34, 0xefeabc34,
334 0x1fb57c35, _NOT_USED_, _NOT_USED_, _NOT_USED_,
335
336
337 0xefebfc24, 0x1f07fc24, 0xeeaebc00, 0x01b93c04,
338 0x1ff77c45, _NOT_USED_, _NOT_USED_, _NOT_USED_,
339
340
341 0xefebfc24, 0x1f07fc24, 0xeeaebc00, 0x10ad7c00,
342 0xf0affc00, 0xf0affc00, 0xe1bbbc04, 0x1ff77c45,
343 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
344 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
345
346
347 0xeffafc84, 0x1ff5fc04, 0xfffffc04, 0xfffffc04,
348 0xfffffc84, 0xfffffc07, _NOT_USED_, _NOT_USED_,
349 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
350
351
352 0xeffffc06, 0x1ffffc07, _NOT_USED_, _NOT_USED_ };
353
354#elif defined(CONFIG_SDRAM_50MHZ)
355
356
357
358
359
360
361#ifdef SDRAM_ALT_INIT_SEQENCE
362# define SDRAM_MBMRVALUE0 0x80802114
363# define SDRAM_MBMRVALUE1 0x80802118
364# define SDRAM_MCRVALUE0 0x80808105
365# define SDRAM_MCRVALUE1 0x80808130
366# define SDRAM_MPTRVALUE 0x400
367#define SDRAM_MARVALUE 0x88
368#else
369# define SDRAM_MxMR_PTx 128
370# define UPM_MRS_ADDR 0x5
371# define UPM_REFRESH_ADDR 0x30
372#endif
373
374static const uint sdram_table[] =
375{
376
377 0x1f07fc04, 0xeeaefc04, 0x11adfc04, 0xefbbbc00,
378 0x1ff77c47,
379
380
381 0x1ff77c34, 0xefeabc34, 0x1fb57c35,
382
383
384 0x1f07fc04, 0xeeaefc04, 0x10adfc04, 0xf0affc00,
385 0xf0affc00, 0xf1affc00, 0xefbbbc00, 0x1ff77c47,
386 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
387 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
388
389
390 0x1f27fc04, 0xeeaebc00, 0x01b93c04, 0x1ff77c47,
391 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
392
393
394 0x1f07fc04, 0xeeaebc00, 0x10ad7c00, 0xf0affc00,
395 0xf0affc00, 0xe1bbbc04, 0x1ff77c47, _NOT_USED_,
396 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
397 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
398
399
400 0x1ff5fc84, 0xfffffc04, 0xfffffc04, 0xfffffc04,
401 0xfffffc84, 0xfffffc07, _NOT_USED_, _NOT_USED_,
402 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
403
404
405 0x7ffffc07, _NOT_USED_, _NOT_USED_, _NOT_USED_ };
406
407
408#else
409#error SDRAM not correctly configured
410#endif
411
412
413
414
415
416
417#define SDRAM_OR4VALUE 0x00000a00
418#define SDRAM_BR4VALUE 0x000000c1
419
420
421#ifdef SDRAM_ALT_INIT_SEQENCE
422
423
424static int _initsdram(uint base, uint noMbytes)
425{
426 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
427 volatile memctl8xx_t *memctl = &immap->im_memctl;
428
429 upmconfig(UPMB, (uint *)sdram_table,sizeof(sdram_table)/sizeof(uint));
430
431 memctl->memc_mptpr = SDRAM_MPTPRVALUE;
432
433
434
435
436
437
438
439
440
441
442
443
444 memctl->memc_mbmr = SDRAM_MBMRVALUE0;
445 memctl->memc_mar = SDRAM_MARVALUE;
446
447 udelay(200);
448
449
450
451
452 memctl->memc_mcr = 0x80808111;
453
454 udelay(200);
455
456
457
458 memctl->memc_mcr = SDRAM_MCRVALUE0;
459
460
461 udelay(200);
462
463 memctl->memc_mbmr = SDRAM_MBMRVALUE1;
464 memctl->memc_mcr = SDRAM_MCRVALUE1;
465
466
467 udelay(200);
468
469 memctl->memc_mbmr = SDRAM_MBMRVALUE0;
470
471 memctl->memc_or4 = SDRAM_OR4VALUE | ~((noMbytes<<20)-1);
472 memctl->memc_br4 = SDRAM_BR4VALUE | base;
473
474 return 0;
475}
476
477
478#else
479
480
481
482# define MPTPR_2BK_4K MPTPR_PTP_DIV16
483# define MPTPR_1BK_4K MPTPR_PTP_DIV32
484
485
486# define MPTPR_2BK_8K MPTPR_PTP_DIV8
487# define MPTPR_1BK_8K MPTPR_PTP_DIV16
488
489
490
491
492
493
494# define SDRAM_MxMR_8COL ((SDRAM_MxMR_PTx << MBMR_PTB_SHIFT) | MBMR_PTBE | \
495 MBMR_AMB_TYPE_0 | MBMR_DSB_1_CYCL | MBMR_G0CLB_A11 | \
496 MBMR_RLFB_1X | MBMR_WLFB_1X | MBMR_TLFB_4X)
497
498# define SDRAM_MxMR_9COL ((SDRAM_MxMR_PTx << MBMR_PTB_SHIFT) | MBMR_PTAE | \
499 MBMR_AMB_TYPE_1 | MBMR_DSB_1_CYCL | MBMR_G0CLB_A10 | \
500 MBMR_RLFB_1X | MBMR_WLFB_1X | MBMR_TLFB_4X)
501
502static int _initsdram(uint base, uint noMbytes)
503{
504 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
505 volatile memctl8xx_t *memctl = &immap->im_memctl;
506
507 upmconfig(UPMB, (uint *)sdram_table,sizeof(sdram_table)/sizeof(uint));
508
509 memctl->memc_mptpr = MPTPR_2BK_4K;
510 memctl->memc_mbmr = SDRAM_MxMR_8COL & (~(MBMR_PTBE));
511
512
513 memctl->memc_or4 = SDRAM_OR4VALUE | ~((noMbytes<<20)-1);
514 memctl->memc_br4 = SDRAM_BR4VALUE | base;
515
516
517# ifdef UPM_NOP_ADDR
518
519 memctl->memc_mar = 0x00000000;
520 memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 |
521 MCR_MLCF(0) | UPM_NOP_ADDR;
522# endif
523
524
525 udelay(200);
526
527# ifdef UPM_PRECHARGE_ADDR
528
529 memctl->memc_mar = 0x00000000;
530 memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 |
531 MCR_MLCF(4) | UPM_PRECHARGE_ADDR;
532# endif
533
534
535 memctl->memc_mar = 0x00000000;
536 memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 |
537 MCR_MLCF(2) | UPM_REFRESH_ADDR;
538
539
540
541
542
543
544
545 memctl->memc_mar = 0x00000088;
546 memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 |
547 MCR_MLCF(1) | UPM_MRS_ADDR;
548
549# ifdef UPM_NOP_ADDR
550 memctl->memc_mar = 0x00000000;
551 memctl->memc_mcr = MCR_UPM_B | MCR_OP_RUN | MCR_MB_CS4 |
552 MCR_MLCF(0) | UPM_NOP_ADDR;
553# endif
554
555
556
557
558 memctl->memc_mbmr |= MBMR_PTBE;
559 return 0;
560}
561#endif
562
563
564
565static void _sdramdisable(void)
566{
567 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
568 volatile memctl8xx_t *memctl = &immap->im_memctl;
569
570 memctl->memc_br4 = 0x00000000;
571
572
573}
574
575
576
577static int initsdram(uint base, uint *noMbytes)
578{
579 uint m = CONFIG_SYS_SDRAM_SIZE>>20;
580
581
582 *((uint *)BCSR1) |= BCSR1_SDRAM_EN;
583
584 if(!_initsdram(base, m))
585 {
586 *noMbytes += m;
587 return 0;
588 }
589 else
590 {
591 *((uint *)BCSR1) &= ~BCSR1_SDRAM_EN;
592
593 _sdramdisable();
594
595 return -1;
596 }
597}
598
599#endif
600
601
602
603phys_size_t initdram (int board_type)
604{
605 uint sdramsz = 0;
606 uint m = 0;
607#ifndef CONFIG_MPC885ADS
608 uint base = 0;
609 uint k, s;
610#endif
611
612#ifdef CONFIG_FADS
613 if (!initsdram (0x00000000, &sdramsz)) {
614#ifndef CONFIG_MPC885ADS
615 base = sdramsz << 20;
616#endif
617 printf ("(%u MB SDRAM) ", sdramsz);
618 }
619#endif
620#ifndef CONFIG_MPC885ADS
621 k = (*((uint *) BCSR2) >> 23) & 0x0f;
622
623 switch (k & 0x3) {
624
625 case 0x00:
626 m = 4;
627 break;
628
629
630 case 0x01:
631 m = 32;
632 break;
633
634 case 0x02:
635 m = 16;
636 break;
637
638 case 0x03:
639 m = 8;
640 break;
641
642 }
643
644 switch (k >> 2) {
645 case 0x02:
646 k = 70;
647 break;
648
649 case 0x03:
650 k = 60;
651 break;
652
653 default:
654 printf ("unknown dramdelay (0x%x) - defaulting to 70 ns", k);
655 k = 70;
656 }
657
658#ifdef CONFIG_FADS
659
660 s = 0;
661#else
662 s = (*((uint *) BCSR2) >> 27) & 0x01;
663#endif
664
665 if (!_draminit (base, m, s, k)) {
666 printf ("%dM %dns %sDRAM: ", m, k, s ? "EDO " : "");
667 } else {
668 _dramdisable ();
669 m = 0;
670 }
671#endif
672 m += sdramsz;
673
674 return (m << 20);
675}
676
677
678
679int testdram (void)
680{
681
682 printf ("test: 16 MB - ok\n");
683
684 return (0);
685}
686
687
688
689
690
691
692
693#if defined(CONFIG_FADS) && defined(CONFIG_SYS_DAUGHTERBOARD)
694static void checkdboard(void)
695{
696
697 uint k = (*((uint *)BCSR3) >> 24) & 0x3f;
698
699 puts (" with db ");
700
701 switch(k) {
702 case 0x03 :
703 puts ("MPC823");
704 break;
705 case 0x20 :
706 puts ("MPC801");
707 break;
708 case 0x21 :
709 puts ("MPC850");
710 break;
711 case 0x22 :
712 puts ("MPC821, MPC860 / MPC860SAR / MPC860T");
713 break;
714 case 0x23 :
715 puts ("MPC860SAR");
716 break;
717 case 0x24 :
718 case 0x2A :
719 puts ("MPC860T");
720 break;
721 case 0x3F :
722 puts ("MPC850SAR");
723 break;
724 default : printf("0x%x", k);
725 }
726}
727#endif
728
729int checkboard (void)
730{
731#if defined(CONFIG_MPC86xADS)
732 puts ("Board: MPC86xADS\n");
733#elif defined(CONFIG_MPC885ADS)
734 puts ("Board: MPC885ADS\n");
735#else
736 uint r = (((*((uint *) BCSR3) >> 23) & 1) << 3)
737 | (((*((uint *) BCSR3) >> 19) & 1) << 2)
738 | (((*((uint *) BCSR3) >> 16) & 3));
739
740 puts ("Board: ");
741#if defined(CONFIG_FADS)
742 puts ("FADS");
743 checkdboard ();
744#else
745 puts ("ADS");
746#endif
747
748 puts (" rev ");
749
750 switch (r) {
751#if defined(CONFIG_ADS)
752 case 0x00:
753 puts ("ENG - this board sucks, check the errata, not supported\n");
754 return -1;
755 case 0x01:
756 puts ("PILOT - warning, read errata \n");
757 break;
758 case 0x02:
759 puts ("A - warning, read errata \n");
760 break;
761 case 0x03:
762 puts ("B\n");
763 break;
764#else
765 case 0x00:
766 puts ("ENG\n");
767 break;
768 case 0x01:
769 puts ("PILOT\n");
770 break;
771#endif
772 default:
773 printf ("unknown (0x%x)\n", r);
774 return -1;
775 }
776#endif
777
778 return 0;
779}
780
781
782
783#if defined(CONFIG_CMD_PCMCIA)
784
785#ifdef CONFIG_SYS_PCMCIA_MEM_ADDR
786volatile unsigned char *pcmcia_mem = (unsigned char*)CONFIG_SYS_PCMCIA_MEM_ADDR;
787#endif
788
789int pcmcia_init(void)
790{
791 volatile pcmconf8xx_t *pcmp;
792 uint v, slota = 0, slotb = 0;
793
794
795
796
797 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
798
799#if 0
800 pcmp->pcmc_pbr0 = CONFIG_SYS_PCMCIA_MEM_ADDR;
801 pcmp->pcmc_por0 = 0xc00ff05d;
802#endif
803
804
805 pcmp->pcmc_pgcra = 0;
806 pcmp->pcmc_pgcrb = 0;
807#ifdef CONFIG_PCMCIA_SLOT_A
808 pcmp->pcmc_pgcra = 0x40;
809#endif
810#ifdef CONFIG_PCMCIA_SLOT_B
811 pcmp->pcmc_pgcrb = 0x40;
812#endif
813
814
815 *((uint *)BCSR1) &= ~BCSR1_PCCEN;
816
817
818
819#ifdef CONFIG_PCMCIA_SLOT_A
820 slota = (pcmp->pcmc_pipr & 0x18000000) == 0 ;
821#endif
822#ifdef CONFIG_PCMCIA_SLOT_B
823 slotb = (pcmp->pcmc_pipr & 0x00001800) == 0 ;
824#endif
825
826 if (!(slota || slotb)) {
827 printf("No card present\n");
828 pcmp->pcmc_pgcra = 0;
829 pcmp->pcmc_pgcrb = 0;
830 return -1;
831 }
832 else
833 printf("Card present (");
834
835 v = 0;
836
837
838
839
840
841
842
843#if defined(CONFIG_MPC86x)
844 switch ((pcmp->pcmc_pipr >> 30) & 3)
845#elif defined(CONFIG_MPC823) || defined(CONFIG_MPC850)
846 switch ((pcmp->pcmc_pipr >> 14) & 3)
847#endif
848 {
849 case 0x03 :
850 printf("5V");
851 v = 5;
852 break;
853 case 0x01 :
854 printf("5V and 3V");
855#ifdef CONFIG_FADS
856 v = 3;
857#else
858 v = 5;
859#endif
860 break;
861 case 0x00 :
862 printf("5V, 3V and x.xV");
863#ifdef CONFIG_FADS
864 v = 3;
865#else
866 v = 5;
867#endif
868 break;
869 }
870
871 switch (v) {
872#ifdef CONFIG_FADS
873 case 3:
874 printf("; using 3V");
875
876
877
878 *((uint *)BCSR1) &= ~BCSR1_PCCVCC1;
879 *((uint *)BCSR1) |= BCSR1_PCCVCC0;
880 break;
881#endif
882 case 5:
883 printf("; using 5V");
884#ifdef CONFIG_ADS
885
886
887
888 *((uint *)BCSR1) &= ~BCSR1_PCCVCCON;
889#endif
890#ifdef CONFIG_FADS
891
892
893
894 *((uint *)BCSR1) &= ~BCSR1_PCCVCC0;
895 *((uint *)BCSR1) |= BCSR1_PCCVCC1;
896#endif
897 break;
898
899 default:
900 *((uint *)BCSR1) |= BCSR1_PCCEN;
901
902 printf("; unknown voltage");
903 return -1;
904 }
905 printf(")\n");
906
907
908 udelay(20);
909
910#ifdef CONFIG_PCMCIA_SLOT_A
911 pcmp->pcmc_pgcra = 0;
912#endif
913#ifdef CONFIG_PCMCIA_SLOT_B
914 pcmp->pcmc_pgcrb = 0;
915#endif
916
917
918
919#ifdef CONFIG_DISK_SPINUP_TIME
920 udelay(CONFIG_DISK_SPINUP_TIME);
921#endif
922
923 return 0;
924}
925
926#endif
927
928
929
930#ifdef CONFIG_SYS_PC_IDE_RESET
931
932void ide_set_reset(int on)
933{
934 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
935
936
937
938
939 if (on) {
940 immr->im_ioport.iop_pcdat &= ~(CONFIG_SYS_PC_IDE_RESET);
941 } else {
942 immr->im_ioport.iop_pcdat |= CONFIG_SYS_PC_IDE_RESET;
943 }
944
945
946 immr->im_ioport.iop_pcpar &= ~(CONFIG_SYS_PC_IDE_RESET);
947 immr->im_ioport.iop_pcso &= ~(CONFIG_SYS_PC_IDE_RESET);
948 immr->im_ioport.iop_pcdir |= CONFIG_SYS_PC_IDE_RESET;
949}
950
951#endif
952