1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <ioports.h>
26#include <mpc8260.h>
27
28#include "scm.h"
29
30DECLARE_GLOBAL_DATA_PTR;
31
32static void config_scoh_cs(void);
33extern int fpga_init(void);
34
35#if 0
36#define DEBUGF(fmt,args...) printf (fmt ,##args)
37#else
38#define DEBUGF(fmt,args...)
39#endif
40
41
42
43
44
45
46
47
48const iop_conf_t iop_conf_tab[4][32] = {
49
50
51 {
52 { 1, 1, 1, 0, 0, 0 },
53 { 1, 1, 1, 0, 0, 0 },
54 { 1, 1, 1, 1, 0, 0 },
55 { 1, 1, 1, 1, 0, 0 },
56 { 1, 1, 1, 0, 0, 0 },
57 { 1, 1, 1, 0, 0, 0 },
58 { 0, 0, 0, 1, 0, 0 },
59 { 0, 0, 0, 1, 0, 0 },
60 { 0, 0, 0, 1, 0, 0 },
61 { 0, 0, 0, 1, 0, 0 },
62 { 1, 1, 0, 1, 0, 0 },
63 { 1, 1, 0, 1, 0, 0 },
64 { 1, 1, 0, 1, 0, 0 },
65 { 1, 1, 0, 1, 0, 0 },
66 { 1, 1, 0, 0, 0, 0 },
67 { 1, 1, 0, 0, 0, 0 },
68 { 1, 1, 0, 0, 0, 0 },
69 { 1, 1, 0, 0, 0, 0 },
70 { 0, 0, 0, 1, 0, 0 },
71 { 0, 0, 0, 1, 0, 0 },
72 { 0, 0, 0, 1, 0, 0 },
73 { 0, 0, 0, 1, 0, 0 },
74 { 1, 1, 1, 1, 0, 0 },
75 { 1, 1, 1, 0, 0, 0 },
76 { 1, 1, 1, 0, 0, 0 },
77 { 1, 1, 1, 0, 0, 0 },
78 { 1, 0, 0, 0, 0, 0 },
79 { 1, 0, 0, 0, 0, 0 },
80 { 1, 1, 0, 0, 0, 0 },
81 { 1, 1, 0, 0, 0, 0 },
82 { 0, 0, 0, 1, 0, 0 },
83 { 1, 0, 0, 0, 0, 0 }
84 },
85
86
87 {
88 { 1, 0, 0, 1, 0, 0 },
89 { 1, 0, 0, 1, 0, 0 },
90 { 1, 0, 0, 1, 0, 0 },
91 { 1, 0, 0, 1, 0, 0 },
92 { 0, 1, 0, 0, 0, 0 },
93 { 0, 1, 0, 0, 0, 0 },
94 { 1, 0, 0, 1, 0, 0 },
95 { 1, 0, 0, 1, 0, 0 },
96 { 1, 1, 1, 0, 0, 0 },
97 { 1, 1, 1, 0, 0, 0 },
98 { 1, 1, 1, 0, 0, 0 },
99 { 1, 1, 1, 0, 0, 0 },
100 { 1, 0, 0, 0, 0, 0 },
101 { 0, 1, 0, 0, 0, 0 },
102 { 1, 1, 0, 0, 0, 0 },
103 { 1, 1, 0, 0, 0, 0 },
104 { 1, 1, 0, 1, 0, 0 },
105 { 1, 1, 0, 1, 0, 0 },
106 { 1, 1, 0, 0, 0, 0 },
107 { 1, 1, 0, 0, 0, 0 },
108 { 1, 1, 0, 0, 0, 0 },
109 { 1, 1, 0, 0, 0, 0 },
110 { 1, 1, 0, 0, 0, 0 },
111 { 1, 1, 0, 0, 0, 0 },
112 { 1, 1, 0, 1, 0, 0 },
113 { 1, 1, 0, 1, 0, 0 },
114 { 1, 1, 0, 1, 0, 0 },
115 { 1, 1, 0, 1, 0, 0 },
116 { 0, 0, 0, 0, 0, 0 },
117 { 0, 0, 0, 0, 0, 0 },
118 { 0, 0, 0, 0, 0, 0 },
119 { 0, 0, 0, 0, 0, 0 }
120 },
121
122
123 {
124 { 1, 1, 0, 0, 0, 0 },
125 { 1, 1, 0, 0, 0, 0 },
126 { 1, 1, 0, 0, 0, 0 },
127 { 1, 1, 0, 0, 0, 0 },
128 { 1, 1, 0, 0, 0, 0 },
129 { 1, 1, 0, 0, 0, 0 },
130 { 0, 0, 0, 1, 0, 0 },
131 { 0, 0, 0, 1, 0, 0 },
132 { 0, 1, 0, 1, 0, 0 },
133 { 0, 1, 0, 0, 0, 0 },
134 { 1, 1, 0, 0, 0, 0 },
135 { 1, 1, 0, 0, 0, 0 },
136 { 0, 1, 0, 0, 0, 0 },
137 { 0, 1, 0, 0, 0, 0 },
138 { 1, 1, 0, 0, 0, 0 },
139 { 1, 1, 0, 0, 0, 0 },
140 { 0, 0, 0, 1, 0, 0 },
141 { 0, 1, 0, 0, 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, 1, 0, 0, 0 },
147 { 0, 0, 0, 0, 0, 0 },
148 { 0, 0, 0, 0, 0, 0 },
149 { 0, 0, 0, 0, 0, 0 },
150 { 0, 0, 0, 0, 0, 0 },
151 { 0, 0, 0, 0, 0, 0 },
152 { 0, 0, 0, 1, 0, 0 },
153 { 0, 0, 0, 1, 0, 0 },
154 { 0, 0, 0, 1, 0, 0 },
155 { 0, 0, 0, 1, 0, 0 },
156 },
157
158
159 {
160 { 1, 1, 0, 0, 0, 0 },
161 { 1, 1, 1, 1, 0, 0 },
162 { 0, 0, 0, 0, 0, 0 },
163 { 0, 0, 0, 1, 0, 0 },
164 { 0, 0, 0, 0, 0, 0 },
165 { 0, 0, 0, 1, 0, 0 },
166 { 0, 0, 0, 1, 0, 0 },
167 { 0, 0, 0, 1, 0, 0 },
168 { 0, 0, 0, 1, 0, 0 },
169 { 1, 1, 1, 0, 0, 0 },
170 { 1, 1, 1, 0, 0, 0 },
171 { 1, 1, 1, 0, 0, 0 },
172 { 1, 1, 1, 0, 0, 0 },
173 { 1, 1, 1, 0, 0, 0 },
174 { 1, 1, 1, 0, 0, 0 },
175 { 1, 1, 1, 0, 0, 0 },
176#if defined(CONFIG_SOFT_I2C)
177 { 1, 0, 0, 1, 1, 1 },
178 { 1, 0, 0, 1, 1, 1 },
179#else
180#if defined(CONFIG_HARD_I2C)
181 { 1, 1, 1, 0, 1, 0 },
182 { 1, 1, 1, 0, 1, 0 },
183#else
184 { 0, 1, 1, 0, 1, 0 },
185 { 0, 1, 1, 0, 1, 0 },
186#endif
187#endif
188 { 1, 1, 1, 0, 0, 0 },
189 { 1, 1, 1, 0, 0, 0 },
190 { 1, 1, 1, 0, 0, 0 },
191 { 1, 1, 1, 0, 0, 0 },
192 { 1, 1, 0, 1, 0, 0 },
193 { 1, 1, 0, 0, 0, 0 },
194 { 0, 0, 0, 1, 0, 1 },
195 { 0, 0, 0, 1, 0, 1 },
196 { 0, 0, 0, 1, 0, 0 },
197 { 0, 0, 0, 1, 0, 0 },
198 { 0, 0, 0, 0, 0, 0 },
199 { 0, 0, 0, 0, 0, 0 },
200 { 0, 0, 0, 0, 0, 0 },
201 { 0, 0, 0, 0, 0, 0 }
202 }
203};
204
205
206
207
208
209int checkboard (void)
210{
211 char str[64];
212 int i = getenv_r ("serial#", str, sizeof (str));
213
214 puts ("Board: ");
215
216 if (!i || strncmp (str, "TQM8260", 7)) {
217 puts ("### No HW ID - assuming TQM8260\n");
218 return (0);
219 }
220
221 puts (str);
222 putc ('\n');
223
224 return 0;
225}
226
227
228
229
230
231
232
233
234
235
236static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
237 ulong orx, volatile uchar * base)
238{
239 volatile uchar c = 0xff;
240 volatile uint *sdmr_ptr;
241 volatile uint *orx_ptr;
242 ulong maxsize, size;
243 int i;
244
245
246
247
248
249
250 maxsize = (1 + (~orx | 0x7fff)) / 2;
251
252
253
254
255 sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
256 orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
257
258 *orx_ptr = orx;
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
281 *base = c;
282
283 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
284 for (i = 0; i < 8; i++)
285 *base = c;
286
287 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
288 *(base + CONFIG_SYS_MRS_OFFS) = c;
289
290 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
291 *base = c;
292
293 size = get_ram_size((long *)base, maxsize);
294
295 *orx_ptr = orx | ~(size - 1);
296
297 return (size);
298}
299
300
301
302
303int power_on_reset (void)
304{
305
306 return gd->reset_status & RSR_CSRS ? 0 : 1;
307}
308
309phys_size_t initdram (int board_type)
310{
311 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
312 volatile memctl8260_t *memctl = &immap->im_memctl;
313
314#ifndef CONFIG_SYS_RAMBOOT
315 long size8, size9;
316#endif
317 long psize, lsize;
318
319 psize = 16 * 1024 * 1024;
320 lsize = 0;
321
322 memctl->memc_psrt = CONFIG_SYS_PSRT;
323 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
324
325#if 0
326#define prt_br_or(brX,orX) do { \
327 ulong start = memctl->memc_ ## brX & 0xFFFF8000; \
328 ulong sizem = ~memctl->memc_ ## orX | 0x00007FFF; \
329 printf ("\n" \
330 #brX " 0x%08x " #orX " 0x%08x " \
331 "==> 0x%08lx ... 0x%08lx = %ld MB\n", \
332 memctl->memc_ ## brX, memctl->memc_ ## orX, \
333 start, start+sizem, (sizem+1)>>20); \
334 } while (0)
335 prt_br_or (br0, or0);
336 prt_br_or (br1, or1);
337 prt_br_or (br2, or2);
338 prt_br_or (br3, or3);
339#endif
340
341#ifndef CONFIG_SYS_RAMBOOT
342
343
344 size8 = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR1_8COL,
345 (uchar *) CONFIG_SYS_SDRAM_BASE);
346 size9 = try_init (memctl, CONFIG_SYS_PSDMR_9COL, CONFIG_SYS_OR1_9COL,
347 (uchar *) CONFIG_SYS_SDRAM_BASE);
348
349 if (size8 < size9) {
350 psize = size9;
351 printf ("(60x:9COL - %ld MB, ", psize >> 20);
352 } else {
353 psize = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR1_8COL,
354 (uchar *) CONFIG_SYS_SDRAM_BASE);
355 printf ("(60x:8COL - %ld MB, ", psize >> 20);
356 }
357
358
359
360#ifdef CONFIG_SYS_INIT_LOCAL_SDRAM
361 memctl->memc_lsrt = CONFIG_SYS_LSRT;
362 size8 = try_init (memctl, CONFIG_SYS_LSDMR_8COL, CONFIG_SYS_OR2_8COL,
363 (uchar *) SDRAM_BASE2_PRELIM);
364 size9 = try_init (memctl, CONFIG_SYS_LSDMR_9COL, CONFIG_SYS_OR2_9COL,
365 (uchar *) SDRAM_BASE2_PRELIM);
366
367 if (size8 < size9) {
368 lsize = size9;
369 printf ("Local:9COL - %ld MB) using ", lsize >> 20);
370 } else {
371 lsize = try_init (memctl, CONFIG_SYS_LSDMR_8COL, CONFIG_SYS_OR2_8COL,
372 (uchar *) SDRAM_BASE2_PRELIM);
373 printf ("Local:8COL - %ld MB) using ", lsize >> 20);
374 }
375
376#if 0
377
378
379
380 memctl->memc_br2 = (CONFIG_SYS_BR2_PRELIM & ~BRx_BA_MSK) |
381 (CONFIG_SYS_SDRAM_BASE + psize);
382#endif
383#endif
384#endif
385
386 icache_enable ();
387
388 config_scoh_cs ();
389
390 return (psize);
391}
392
393
394
395static void config_scoh_cs (void)
396{
397 volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
398 volatile memctl8260_t *memctl = &immr->im_memctl;
399 volatile can_reg_t *can = (volatile can_reg_t *) CONFIG_SYS_CAN0_BASE;
400 volatile uint tmp, i;
401
402
403 memctl->memc_or3 = CONFIG_SYS_CAN0_OR3;
404 memctl->memc_br3 = CONFIG_SYS_CAN0_BR3;
405
406 memctl->memc_or4 = CONFIG_SYS_CAN1_OR4;
407 memctl->memc_br4 = CONFIG_SYS_CAN1_BR4;
408
409
410 memctl->memc_mamr = 0x00 | MxMR_OP_WARR | MxMR_GPL_x4DIS;
411
412
413 memctl->memc_mdr = 0xcffeec00;
414 udelay (1);
415
416
417
418 tmp = can->cpu_interface;
419
420 memctl->memc_mdr = 0x0ffcec00;
421 udelay (1);
422 tmp = can->cpu_interface;
423
424 memctl->memc_mdr = 0x0ffcec00;
425 udelay (1);
426 tmp = can->cpu_interface;
427
428 memctl->memc_mdr = 0x0ffcec00;
429 udelay (1);
430 tmp = can->cpu_interface;
431
432 memctl->memc_mdr = 0x0ffcec00;
433 udelay (1);
434 tmp = can->cpu_interface;
435
436 memctl->memc_mdr = 0x0ffcfc00;
437 udelay (1);
438 tmp = can->cpu_interface;
439
440 memctl->memc_mdr = 0x0ffcfc00;
441 udelay (1);
442 tmp = can->cpu_interface;
443
444 memctl->memc_mdr = 0xfffdec07;
445 udelay (1);
446 tmp = can->cpu_interface;
447
448
449
450 memctl->memc_mamr = 0x18 | MxMR_OP_WARR | MxMR_GPL_x4DIS;
451
452
453 memctl->memc_mdr = 0xfcffec00;
454 udelay (1);
455 tmp = can->cpu_interface;
456
457 memctl->memc_mdr = 0x00ffec00;
458 udelay (1);
459 tmp = can->cpu_interface;
460
461 memctl->memc_mdr = 0x00ffec00;
462 udelay (1);
463 tmp = can->cpu_interface;
464
465 memctl->memc_mdr = 0x00ffec00;
466 udelay (1);
467 tmp = can->cpu_interface;
468
469 memctl->memc_mdr = 0x00ffec00;
470 udelay (1);
471 tmp = can->cpu_interface;
472
473 memctl->memc_mdr = 0x00fffc00;
474 udelay (1);
475 tmp = can->cpu_interface;
476
477 memctl->memc_mdr = 0x00fffc00;
478 udelay (1);
479 tmp = can->cpu_interface;
480
481 memctl->memc_mdr = 0x30ffec07;
482 udelay (1);
483 tmp = can->cpu_interface;
484
485
486 memctl->memc_mamr = MxMR_GPL_x4DIS;
487
488
489
490 memctl->memc_or5 = CONFIG_SYS_EXTPROM_OR5;
491 memctl->memc_br5 = CONFIG_SYS_EXTPROM_BR5;
492
493 memctl->memc_or6 = CONFIG_SYS_EXTPROM_OR6;
494 memctl->memc_br6 = CONFIG_SYS_EXTPROM_BR6;
495
496
497 memctl->memc_or7 = CONFIG_SYS_FIOX_OR7;
498 memctl->memc_br7 = CONFIG_SYS_FIOX_BR7;
499
500
501 memctl->memc_or8 = CONFIG_SYS_FDOHM_OR8;
502 memctl->memc_br8 = CONFIG_SYS_FDOHM_BR8;
503
504 DEBUGF ("OR0 %08x BR0 %08x\n", memctl->memc_or0, memctl->memc_br0);
505 DEBUGF ("OR1 %08x BR1 %08x\n", memctl->memc_or1, memctl->memc_br1);
506 DEBUGF ("OR2 %08x BR2 %08x\n", memctl->memc_or2, memctl->memc_br2);
507 DEBUGF ("OR3 %08x BR3 %08x\n", memctl->memc_or3, memctl->memc_br3);
508 DEBUGF ("OR4 %08x BR4 %08x\n", memctl->memc_or4, memctl->memc_br4);
509 DEBUGF ("OR5 %08x BR5 %08x\n", memctl->memc_or5, memctl->memc_br5);
510 DEBUGF ("OR6 %08x BR6 %08x\n", memctl->memc_or6, memctl->memc_br6);
511 DEBUGF ("OR7 %08x BR7 %08x\n", memctl->memc_or7, memctl->memc_br7);
512 DEBUGF ("OR8 %08x BR8 %08x\n", memctl->memc_or8, memctl->memc_br8);
513
514 DEBUGF ("UPMA addr 0x0\n");
515 memctl->memc_mamr = 0x00 | MxMR_OP_RARR | MxMR_GPL_x4DIS;
516 for (i = 0; i < 0x8; i++) {
517 tmp = can->cpu_interface;
518 udelay (1);
519 DEBUGF (" %08x ", memctl->memc_mdr);
520 }
521 DEBUGF ("\nUPMA addr 0x18\n");
522 memctl->memc_mamr = 0x18 | MxMR_OP_RARR | MxMR_GPL_x4DIS;
523 for (i = 0; i < 0x8; i++) {
524 tmp = can->cpu_interface;
525 udelay (1);
526 DEBUGF (" %08x ", memctl->memc_mdr);
527 }
528 DEBUGF ("\n");
529 memctl->memc_mamr = MxMR_GPL_x4DIS;
530}
531
532
533
534int misc_init_r (void)
535{
536 fpga_init ();
537 return (0);
538}
539
540
541