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
27
28
29
30
31#include <common.h>
32#include <ioports.h>
33#include <i2c.h>
34#include <mpc8260.h>
35#include <pci.h>
36
37
38
39
40
41
42
43
44
45
46
47
48
49#define CONFIG_PBI 0
50#define PESSIMISTIC_SDRAM 0
51#define EAMUX 0
52#define BUFCMD 0
53
54
55
56
57
58
59
60
61
62const iop_conf_t iop_conf_tab[4][32] = {
63
64
65 {
66 { 0, 1, 0, 1, 0, 0 },
67 { 0, 1, 0, 0, 0, 0 },
68 { 0, 1, 0, 1, 0, 0 },
69 { 0, 1, 0, 1, 0, 0 },
70 { 0, 1, 0, 0, 0, 0 },
71 { 0, 1, 0, 0, 0, 0 },
72 { 0, 1, 0, 1, 0, 0 },
73 { 0, 1, 0, 1, 0, 0 },
74 { 0, 1, 0, 1, 0, 0 },
75 { 0, 1, 0, 1, 0, 0 },
76 { 0, 1, 0, 1, 0, 0 },
77 { 0, 1, 0, 1, 0, 0 },
78 { 0, 1, 0, 1, 0, 0 },
79 { 0, 1, 0, 1, 0, 0 },
80 { 0, 1, 0, 0, 0, 0 },
81 { 0, 1, 0, 0, 0, 0 },
82 { 0, 1, 0, 0, 0, 0 },
83 { 0, 1, 0, 0, 0, 0 },
84 { 0, 1, 0, 0, 0, 0 },
85 { 0, 1, 0, 0, 0, 0 },
86 { 0, 1, 0, 0, 0, 0 },
87 { 0, 1, 0, 0, 0, 0 },
88 { 0, 1, 1, 1, 0, 0 },
89 { 0, 1, 1, 0, 0, 0 },
90 { 0, 0, 0, 1, 0, 0 },
91 { 1, 1, 1, 1, 0, 0 },
92 { 0, 0, 0, 1, 0, 0 },
93 { 0, 0, 0, 1, 0, 0 },
94 { 0, 0, 0, 1, 0, 0 },
95 { 0, 0, 0, 1, 0, 0 },
96 { 1, 0, 0, 0, 0, 0 },
97 { 0, 0, 0, 1, 0, 0 }
98 },
99
100
101 {
102 { 1, 1, 0, 1, 0, 0 },
103 { 1, 1, 0, 0, 0, 0 },
104 { 1, 1, 1, 1, 0, 0 },
105 { 1, 1, 0, 0, 0, 0 },
106 { 1, 1, 0, 0, 0, 0 },
107 { 1, 1, 0, 0, 0, 0 },
108 { 1, 1, 0, 1, 0, 0 },
109 { 1, 1, 0, 1, 0, 0 },
110 { 1, 1, 0, 1, 0, 0 },
111 { 1, 1, 0, 1, 0, 0 },
112 { 1, 1, 0, 0, 0, 0 },
113 { 1, 1, 0, 0, 0, 0 },
114 { 1, 1, 0, 0, 0, 0 },
115 { 1, 1, 0, 0, 0, 0 },
116 { 0, 1, 0, 0, 0, 0 },
117 { 0, 1, 0, 0, 0, 0 },
118 { 0, 1, 0, 1, 0, 0 },
119 { 0, 1, 0, 1, 0, 0 },
120 { 0, 1, 0, 0, 0, 0 },
121 { 0, 1, 0, 0, 0, 0 },
122 { 0, 1, 0, 0, 0, 0 },
123 { 0, 1, 0, 0, 0, 0 },
124 { 0, 1, 0, 0, 0, 0 },
125 { 0, 1, 0, 0, 0, 0 },
126 { 0, 1, 0, 1, 0, 0 },
127 { 0, 1, 0, 1, 0, 0 },
128 { 0, 1, 0, 1, 0, 0 },
129 { 0, 1, 0, 1, 0, 0 },
130 { 0, 0, 0, 0, 0, 0 },
131 { 0, 0, 0, 0, 0, 0 },
132 { 0, 0, 0, 0, 0, 0 },
133 { 0, 0, 0, 0, 0, 0 }
134 },
135
136
137 {
138 { 0, 0, 0, 1, 0, 0 },
139 { 0, 0, 0, 1, 0, 0 },
140 { 0, 1, 1, 0, 0, 0 },
141 { 0, 0, 0, 1, 0, 0 },
142 { 0, 0, 0, 1, 0, 0 },
143 { 0, 0, 0, 1, 0, 0 },
144 { 0, 0, 0, 1, 0, 0 },
145 { 0, 0, 0, 1, 0, 0 },
146 { 0, 1, 0, 1, 0, 0 },
147 { 0, 1, 0, 0, 0, 0 },
148 { 0, 1, 0, 0, 0, 0 },
149 { 0, 1, 0, 0, 0, 0 },
150 { 1, 1, 0, 0, 0, 0 },
151 { 1, 1, 0, 0, 0, 0 },
152 { 0, 0, 0, 1, 0, 0 },
153 { 0, 1, 0, 0, 0, 0 },
154 { 0, 0, 0, 1, 0, 0 },
155 { 0, 1, 0, 0, 0, 0 },
156 { 0, 0, 0, 1, 0, 0 },
157 { 0, 1, 0, 1, 0, 0 },
158 { 0, 0, 0, 1, 0, 0 },
159 { 1, 0, 0, 1, 0, 0 },
160 { 1, 0, 0, 0, 0, 0 },
161 { 0, 0, 0, 1, 0, 0 },
162 { 0, 0, 0, 1, 0, 0 },
163 { 0, 0, 0, 1, 0, 0 },
164 { 0, 0, 0, 1, 0, 0 },
165 { 0, 0, 0, 1, 0, 0 },
166 { 0, 0, 0, 1, 0, 0 },
167 { 0, 0, 0, 1, 0, 1 },
168 { 0, 0, 0, 1, 0, 0 },
169 { 0, 0, 0, 1, 0, 0 },
170 },
171
172
173 {
174 { 1, 1, 0, 0, 0, 0 },
175 { 1, 1, 1, 1, 0, 0 },
176 { 0, 1, 0, 1, 0, 0 },
177 { 0, 1, 0, 0, 0, 0 },
178 { 0, 1, 1, 1, 0, 0 },
179 { 0, 0, 0, 1, 0, 0 },
180 { 0, 0, 0, 1, 0, 0 },
181 { 0, 0, 0, 1, 0, 0 },
182 { 0, 0, 0, 1, 0, 0 },
183 { 0, 0, 0, 1, 0, 0 },
184 { 0, 0, 0, 1, 0, 0 },
185 { 0, 0, 0, 1, 0, 0 },
186 { 0, 0, 0, 1, 0, 0 },
187 { 0, 0, 0, 1, 0, 0 },
188 { 0, 1, 0, 0, 0, 0 },
189 { 0, 1, 0, 1, 0, 0 },
190 { 1, 1, 1, 0, 1, 0 },
191 { 1, 1, 1, 0, 1, 0 },
192 { 0, 0, 0, 0, 0, 0 },
193 { 0, 0, 0, 0, 0, 0 },
194 { 0, 0, 0, 0, 0, 0 },
195 { 0, 0, 0, 0, 0, 0 },
196 { 1, 1, 0, 1, 0, 0 },
197 { 1, 1, 0, 0, 0, 0 },
198 { 0, 0, 0, 1, 0, 1 },
199 { 0, 0, 0, 1, 0, 1 },
200 { 0, 0, 0, 1, 0, 1 },
201 { 0, 0, 0, 1, 0, 1 },
202 { 0, 0, 0, 0, 0, 0 },
203 { 0, 0, 0, 0, 0, 0 },
204 { 0, 0, 0, 0, 0, 0 },
205 { 0, 0, 0, 0, 0, 0 }
206 }
207};
208
209typedef struct bscr_ {
210 unsigned long bcsr0;
211 unsigned long bcsr1;
212 unsigned long bcsr2;
213 unsigned long bcsr3;
214 unsigned long bcsr4;
215 unsigned long bcsr5;
216 unsigned long bcsr6;
217 unsigned long bcsr7;
218} bcsr_t;
219
220typedef struct pci_ic_s {
221 unsigned long pci_int_stat;
222 unsigned long pci_int_mask;
223} pci_ic_t;
224
225void reset_phy(void)
226{
227 volatile bcsr_t *bcsr = (bcsr_t *)CONFIG_SYS_BCSR;
228
229
230 bcsr->bcsr1 &= ~FETH_RST;
231 bcsr->bcsr1 |= FETH_RST;
232}
233
234
235int board_early_init_f(void)
236{
237 volatile bcsr_t *bcsr = (bcsr_t *)CONFIG_SYS_BCSR;
238 volatile pci_ic_t *pci_ic = (pci_ic_t *)CONFIG_SYS_PCI_INT;
239
240 bcsr->bcsr1 = ~FETHIEN & ~RS232EN_1 & ~RS232EN_2;
241
242
243 pci_ic->pci_int_mask |= 0xfff00000;
244
245 return 0;
246}
247
248int checkboard(void)
249{
250 puts("Board: Motorola MPC8266ADS\n");
251 return 0;
252}
253
254phys_size_t initdram(int board_type)
255{
256
257 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
258 volatile memctl8260_t *memctl = &immap->im_memctl;
259 volatile uchar c = 0xff;
260 volatile uchar *ramaddr = (uchar *) (CONFIG_SYS_SDRAM_BASE + 0x8);
261 uint psdmr = CONFIG_SYS_PSDMR;
262 int i;
263
264 uint psrt = 0x21;
265 uint chipselects = 1;
266 uint sdram_size = CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
267 uint or = CONFIG_SYS_OR2_PRELIM;
268 uint data_width;
269 uint rows;
270 uint banks;
271 uint cols;
272 uint caslatency;
273 uint width;
274 uint rowst;
275 uint sdam;
276 uint bsma;
277 uint sda10;
278 u_char data;
279 u_char cksum;
280 int j;
281
282
283
284
285
286 data_width = rows = banks = cols = caslatency = 0;
287
288
289
290
291 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
292
293 i2c_read(SDRAM_SPD_ADDR, 0, 1, &data, 1);
294 cksum = data;
295 for (j = 1; j < 64; j++) {
296
297 i2c_read(SDRAM_SPD_ADDR, 0, 0, &data, 1);
298
299 if (j == 5)
300 chipselects = data & 0x0F;
301 else if (j == 6)
302 data_width = data;
303 else if (j == 7)
304 data_width |= data << 8;
305 else if (j == 3)
306 rows = data & 0x0F;
307 else if (j == 4)
308 cols = data & 0x0F;
309 else if (j == 12) {
310
311
312
313
314
315 switch (data & 0x7F) {
316 default:
317 case 0:
318 psrt = 0x21;
319 break;
320 case 1:
321 psrt = 0x07;
322 break;
323 case 2:
324 psrt = 0x0F;
325 break;
326 case 3:
327 psrt = 0x43;
328 break;
329 case 4:
330 psrt = 0x87;
331 break;
332 case 5:
333 psrt = 0xFF;
334 break;
335 }
336 } else if (j == 17)
337 banks = data;
338 else if (j == 18) {
339 caslatency = 3;
340#if (PESSIMISTIC_SDRAM)
341 if ((data & 0x04) != 0)
342 caslatency = 3;
343 else if ((data & 0x02) != 0)
344 caslatency = 2;
345 else if ((data & 0x01) != 0)
346 caslatency = 1;
347#else
348 if ((data & 0x01) != 0)
349 caslatency = 1;
350 else if ((data & 0x02) != 0)
351 caslatency = 2;
352 else if ((data & 0x04) != 0)
353 caslatency = 3;
354#endif
355 else {
356 printf("WARNING: Unknown CAS latency 0x%02X, using 3\n",
357 data);
358 }
359 } else if (j == 63) {
360 if (data != cksum) {
361 printf("WARNING: Configuration data checksum failure:"
362 " is 0x%02x, calculated 0x%02x\n",
363 data, cksum);
364 }
365 }
366 cksum += data;
367 }
368
369
370 if (caslatency < 2) {
371 printf("CL was %d, forcing to 2\n", caslatency);
372 caslatency = 2;
373 }
374 if (rows > 14) {
375 printf("This doesn't look good, rows = %d, should be <= 14\n",
376 rows);
377 rows = 14;
378 }
379 if (cols > 11) {
380 printf("This doesn't look good, columns = %d, should be <= 11\n",
381 cols);
382 cols = 11;
383 }
384
385 if ((data_width != 64) && (data_width != 72)) {
386 printf("WARNING: SDRAM width unsupported, is %d, expected 64 or 72.\n",
387 data_width);
388 }
389 width = 3;
390
391
392
393 if (banks == 2)
394 banks = 1;
395 else if (banks == 4)
396 banks = 2;
397 else if (banks == 8)
398 banks = 3;
399
400
401 sdram_size = 1 << (rows + cols + banks + width);
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425 if (cols > 10)
426 cols = 10;
427
428#if (CONFIG_PBI == 0)
429 rowst = ((32 - 6) - (rows + cols + width)) * 2;
430#else
431 rowst = 32 - (rows + banks + cols + width);
432#endif
433
434 or = ~(sdram_size - 1) |
435 ((banks - 1) << 13) |
436 (rowst << 9) |
437 ((rows - 9) << 6);
438
439
440
441
442
443
444
445
446
447
448
449
450
451#if (CONFIG_PBI == 0)
452 sdam = cols - 8;
453 bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
454 sda10 = sdam + 2;
455#else
456 sdam = cols + banks - 8;
457 bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
458 sda10 = sdam;
459#endif
460#if (PESSIMISTIC_SDRAM)
461 psdmr = (CONFIG_PBI | PSDMR_RFEN | PSDMR_RFRC_16_CLK |
462 PSDMR_PRETOACT_8W | PSDMR_ACTTORW_8W | PSDMR_WRC_4C |
463 PSDMR_EAMUX | PSDMR_BUFCMD) | caslatency |
464 ((caslatency - 1) << 6) |
465 (sdam << 24) | (bsma << 21) | (sda10 << 18);
466#else
467 psdmr = (CONFIG_PBI | PSDMR_RFEN | PSDMR_RFRC_7_CLK |
468 PSDMR_PRETOACT_3W |
469 PSDMR_ACTTORW_2W |
470 PSDMR_WRC_1C |
471 EAMUX | BUFCMD) | caslatency |
472 ((caslatency - 1) << 6) |
473 (sdam << 24) | (bsma << 21) | (sda10 << 18);
474#endif
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
526 memctl->memc_psrt = psrt;
527
528 memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
529 memctl->memc_or2 = or;
530
531 memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
532 *ramaddr = c;
533
534 memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
535 for (i = 0; i < 8; i++)
536 *ramaddr = c;
537
538 memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
539 *ramaddr = c;
540
541 memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
542 *ramaddr = c;
543
544
545
546
547
548 if (chipselects > 1) {
549 ramaddr += sdram_size;
550
551 memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM + sdram_size;
552 memctl->memc_or3 = or;
553
554 memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
555 *ramaddr = c;
556
557 memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
558 for (i = 0; i < 8; i++)
559 *ramaddr = c;
560
561 memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
562 *ramaddr = c;
563
564 memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
565 *ramaddr = c;
566 }
567
568
569 printf("SDRAM configuration read from SPD\n");
570 printf("\tSize per side = %dMB\n", sdram_size >> 20);
571 printf("\tOrganization: %d sides, %d banks, %d Columns, %d Rows, Data width = %d bits\n",
572 chipselects, 1 << (banks), cols, rows, data_width);
573 printf("\tRefresh rate = %d, CAS latency = %d", psrt, caslatency);
574#if (CONFIG_PBI == 0)
575 printf(", Using Bank Based Interleave\n");
576#else
577 printf(", Using Page Based Interleave\n");
578#endif
579 printf("\tTotal size: ");
580
581
582
583 if ((sdram_size * chipselects) == (16 * 1024 * 1024))
584 udelay(250000);
585
586 return sdram_size * chipselects;
587}
588
589#ifdef CONFIG_PCI
590struct pci_controller hose;
591
592extern void pci_mpc8250_init(struct pci_controller *);
593
594void pci_init_board(void)
595{
596 pci_mpc8250_init(&hose);
597}
598#endif
599