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 <command.h>
29#include <netdev.h>
30#ifdef CONFIG_PCI
31#include <pci.h>
32#include <asm/m8260_pci.h>
33#endif
34#include "tqm8272.h"
35
36#if 0
37#define deb_printf(fmt,arg...) \
38 printf ("TQM8272 %s %s: " fmt,__FILE__, __FUNCTION__, ##arg)
39#else
40#define deb_printf(fmt,arg...) \
41 do { } while (0)
42#endif
43
44#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
45unsigned long board_get_cpu_clk_f (void);
46#endif
47
48
49
50
51
52
53
54
55const iop_conf_t iop_conf_tab[4][32] = {
56
57
58 {
59 { 0, 0, 0, 1, 0, 0 },
60 { 0, 0, 0, 1, 0, 0 },
61 { 0, 0, 0, 1, 0, 0 },
62 { 0, 0, 0, 1, 0, 0 },
63 { 0, 0, 0, 1, 0, 0 },
64 { 0, 0, 0, 1, 0, 0 },
65 { 0, 0, 0, 1, 0, 0 },
66 { 0, 0, 0, 1, 0, 0 },
67 { 0, 0, 0, 1, 0, 0 },
68 { 0, 0, 0, 1, 0, 0 },
69 { 0, 0, 0, 1, 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 { 0, 0, 0, 1, 0, 0 },
75 { 0, 0, 0, 1, 0, 0 },
76 { 0, 0, 0, 1, 0, 0 },
77 { 0, 0, 0, 1, 0, 0 },
78 { 0, 0, 0, 1, 0, 0 },
79 { 0, 0, 0, 1, 0, 0 },
80 { 0, 0, 0, 1, 0, 0 },
81 { 1, 1, 0, 1, 0, 0 },
82 { 1, 1, 0, 0, 0, 0 },
83 { 0, 0, 0, 1, 0, 0 },
84 { 0, 0, 0, 1, 0, 0 },
85 { 0, 0, 0, 1, 0, 0 },
86 { 0, 0, 0, 1, 0, 0 },
87 { 0, 0, 0, 1, 0, 0 },
88 { 0, 0, 0, 1, 0, 0 },
89 { 0, 0, 0, 1, 0, 0 },
90 { 0, 0, 0, 1, 0, 0 }
91 },
92
93
94 {
95 { 1, 1, 0, 1, 0, 0 },
96 { 1, 1, 0, 0, 0, 0 },
97 { 1, 1, 1, 1, 0, 0 },
98 { 1, 1, 0, 0, 0, 0 },
99 { 1, 1, 0, 0, 0, 0 },
100 { 1, 1, 0, 0, 0, 0 },
101 { 1, 1, 0, 1, 0, 0 },
102 { 1, 1, 0, 1, 0, 0 },
103 { 1, 1, 0, 1, 0, 0 },
104 { 1, 1, 0, 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, 0, 0, 0 },
109 { 0, 0, 0, 0, 0, 0 },
110 { 0, 0, 0, 0, 0, 0 },
111 { 0, 0, 0, 0, 0, 0 },
112 { 0, 0, 0, 0, 0, 0 },
113 { 0, 0, 0, 0, 0, 0 },
114 { 0, 0, 0, 0, 0, 0 },
115 { 0, 0, 0, 0, 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 { 0, 0, 0, 0, 0, 0 },
121 { 0, 0, 0, 0, 0, 0 },
122 { 0, 0, 0, 0, 0, 0 },
123 { 0, 0, 0, 0, 0, 0 },
124 { 0, 0, 0, 0, 0, 0 },
125 { 0, 0, 0, 0, 0, 0 },
126 { 0, 0, 0, 0, 0, 0 }
127 },
128
129
130 {
131 { 0, 0, 0, 1, 0, 0 },
132 { 0, 0, 0, 0, 0, 0 },
133 { 1, 1, 1, 0, 0, 0 },
134 { 0, 0, 0, 1, 0, 0 },
135 { 0, 0, 0, 1, 0, 0 },
136 { 0, 0, 0, 1, 0, 0 },
137 { 0, 0, 0, 1, 0, 0 },
138 { 0, 0, 0, 1, 0, 0 },
139 { 0, 1, 0, 1, 0, 0 },
140 { 0, 1, 0, 0, 0, 0 },
141 { 1, 1, 0, 0, 0, 0 },
142 { 1, 1, 0, 0, 0, 0 },
143 { 1, 1, 0, 0, 0, 0 },
144 { 1, 1, 0, 0, 0, 0 },
145 { 1, 0, 0, 1, 0, 0 },
146 { 1, 0, 0, 0, 0, 0 },
147 { 0, 0, 0, 1, 0, 0 },
148 { 1, 1, 0, 0, 0, 0 },
149 { 0, 0, 0, 1, 0, 0 },
150 { 0, 0, 0, 1, 0, 0 },
151 { 0, 0, 0, 1, 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 { 0, 0, 0, 1, 0, 0 },
157 { 1, 1, 0, 1, 0, 0 },
158 { 1, 1, 0, 0, 0, 0 },
159 { 0, 0, 0, 1, 0, 0 },
160 { 0, 0, 0, 1, 0, 1 },
161 { 0, 0, 0, 1, 0, 0 },
162 { 0, 0, 0, 1, 0, 0 },
163 },
164
165
166 {
167 { 1, 1, 0, 0, 0, 0 },
168 { 1, 1, 1, 1, 0, 0 },
169 { 1, 1, 0, 1, 0, 0 },
170 { 0, 0, 0, 1, 0, 0 },
171 { 0, 0, 0, 1, 0, 0 },
172 { 0, 0, 0, 1, 0, 0 },
173 { 0, 0, 0, 1, 0, 0 },
174 { 0, 0, 0, 1, 0, 0 },
175 { 0, 0, 0, 1, 0, 0 },
176 { 0, 0, 0, 1, 0, 0 },
177 { 0, 0, 0, 1, 0, 0 },
178 { 0, 0, 0, 1, 0, 0 },
179 { 0, 0, 0, 1, 0, 0 },
180 { 0, 0, 0, 1, 0, 0 },
181 { 0, 1, 0, 0, 0, 0 },
182 { 0, 1, 0, 1, 0, 0 },
183#if defined(CONFIG_SOFT_I2C)
184 { 1, 0, 0, 1, 1, 1 },
185 { 1, 0, 0, 1, 1, 1 },
186#else
187#if defined(CONFIG_HARD_I2C)
188 { 1, 1, 1, 0, 1, 0 },
189 { 1, 1, 1, 0, 1, 0 },
190#else
191 { 0, 1, 1, 0, 1, 0 },
192 { 0, 1, 1, 0, 1, 0 },
193#endif
194#endif
195 { 0, 0, 0, 0, 0, 0 },
196 { 0, 0, 0, 0, 0, 0 },
197 { 0, 0, 0, 0, 0, 0 },
198 { 0, 0, 0, 0, 0, 0 },
199 { 1, 1, 0, 1, 0, 0 },
200 { 1, 1, 0, 0, 0, 0 },
201 { 0, 0, 0, 1, 0, 1 },
202 { 0, 0, 0, 1, 0, 1 },
203 { 0, 0, 0, 1, 0, 0 },
204 { 0, 0, 0, 1, 0, 1 },
205 { 0, 0, 0, 0, 0, 0 },
206 { 0, 0, 0, 0, 0, 0 },
207 { 0, 0, 0, 0, 0, 0 },
208 { 0, 0, 0, 0, 0, 0 }
209 }
210};
211
212
213static const uint upmTableSlow[] =
214{
215
216 0xffffee00, 0x00ffcc80, 0x00ffcf00, 0x00ffdc00,
217 0x00ffce80, 0x00ffcc00, 0x00ffee00, 0x3fffcc07,
218
219
220 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
221 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
222
223
224 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
225 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
226
227
228 0xffffee00, 0x00ffec80, 0x00ffef00, 0x00fffc80,
229 0x00fffe00, 0x00ffec00, 0x0fffef00, 0x3fffec05,
230
231
232 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
233 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
234 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
235 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
236
237
238 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
239 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
240 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
241
242
243 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
244};
245
246
247static const uint upmTableFast[] =
248{
249
250 0xffffee00, 0x00ffcc80, 0x00ffcd80, 0x00ffdc00,
251 0x00ffdc00, 0x00ffcf00, 0x00ffec00, 0x3fffcc07,
252
253
254 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
255 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
256
257
258 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
259 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
260
261
262 0xffffee00, 0x00ffec80, 0x00ffee80, 0x00fffc00,
263 0x00fffc00, 0x00ffec00, 0x0fffef00, 0x3fffec05,
264
265
266 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
267 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
268 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
269 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
270
271
272 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
273 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
274 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
275
276
277 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
278};
279
280
281
282
283
284
285int checkboard (void)
286{
287 char *p = (char *) HWIB_INFO_START_ADDR;
288
289 puts ("Board: ");
290 if (*((unsigned long *)p) == (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
291 puts (p);
292 } else {
293 puts ("No HWIB assuming TQM8272");
294 }
295 putc ('\n');
296
297 return 0;
298}
299
300
301#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
302static int get_cas_latency (void)
303{
304
305
306 int ret = 3;
307 int pos = 0;
308 char *p = (char *) CIB_INFO_START_ADDR;
309
310 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
311 if (*p < ' ' || *p > '~') {
312 return ret;
313 }
314 if (*p == '-') {
315 if ((p[1] == 't') && (p[2] == 's')) {
316 return (p[4] - '0');
317 }
318 }
319 p++;
320 pos++;
321 }
322 return ret;
323}
324#endif
325
326static ulong set_sdram_timing (volatile uint *sdmr_ptr, ulong sdmr, int col)
327{
328#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
329 int clk = board_get_cpu_clk_f ();
330 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
331 int busmode = (immr->im_siu_conf.sc_bcr & BCR_EBM ? 1 : 0);
332 int cas;
333
334 sdmr = sdmr & ~(PSDMR_RFRC_MSK | PSDMR_PRETOACT_MSK | PSDMR_WRC_MSK | \
335 PSDMR_BUFCMD);
336 if (busmode) {
337 switch (clk) {
338 case 66666666:
339 sdmr |= (PSDMR_RFRC_66MHZ_60X | \
340 PSDMR_PRETOACT_66MHZ_60X | \
341 PSDMR_WRC_66MHZ_60X | \
342 PSDMR_BUFCMD_66MHZ_60X);
343 break;
344 case 100000000:
345 sdmr |= (PSDMR_RFRC_100MHZ_60X | \
346 PSDMR_PRETOACT_100MHZ_60X | \
347 PSDMR_WRC_100MHZ_60X | \
348 PSDMR_BUFCMD_100MHZ_60X);
349 break;
350
351 }
352 } else {
353 switch (clk) {
354 case 66666666:
355 sdmr |= (PSDMR_RFRC_66MHZ_SINGLE | \
356 PSDMR_PRETOACT_66MHZ_SINGLE | \
357 PSDMR_WRC_66MHZ_SINGLE | \
358 PSDMR_BUFCMD_66MHZ_SINGLE);
359 break;
360 case 100000000:
361 sdmr |= (PSDMR_RFRC_100MHZ_SINGLE | \
362 PSDMR_PRETOACT_100MHZ_SINGLE | \
363 PSDMR_WRC_100MHZ_SINGLE | \
364 PSDMR_BUFCMD_100MHZ_SINGLE);
365 break;
366 case 133333333:
367 sdmr |= (PSDMR_RFRC_133MHZ_SINGLE | \
368 PSDMR_PRETOACT_133MHZ_SINGLE | \
369 PSDMR_WRC_133MHZ_SINGLE | \
370 PSDMR_BUFCMD_133MHZ_SINGLE);
371 break;
372 }
373 }
374 cas = get_cas_latency();
375 sdmr &=~ (PSDMR_CL_MSK | PSDMR_LDOTOPRE_MSK);
376 sdmr |= cas;
377 sdmr |= ((cas - 1) << 6);
378 return sdmr;
379#else
380 return sdmr;
381#endif
382}
383
384
385
386
387
388
389
390
391static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
392 ulong orx, volatile uchar * base, int col)
393{
394 volatile uchar c = 0xff;
395 volatile uint *sdmr_ptr;
396 volatile uint *orx_ptr;
397 ulong maxsize, size;
398 int i;
399
400
401
402
403
404
405 maxsize = (1 + (~orx | 0x7fff)) / 2;
406
407
408
409
410 sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
411 orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
412
413 *orx_ptr = orx;
414 sdmr = set_sdram_timing (sdmr_ptr, sdmr, col);
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
436 *base = c;
437
438 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
439 for (i = 0; i < 8; i++)
440 *base = c;
441
442 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
443 *(base + CONFIG_SYS_MRS_OFFS) = c;
444
445 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
446 *base = c;
447
448 size = get_ram_size((long *)base, maxsize);
449 *orx_ptr = orx | ~(size - 1);
450
451 return (size);
452}
453
454phys_size_t initdram (int board_type)
455{
456 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
457 volatile memctl8260_t *memctl = &immap->im_memctl;
458
459#ifndef CONFIG_SYS_RAMBOOT
460 long size8, size9;
461#endif
462 long psize;
463
464 psize = 16 * 1024 * 1024;
465
466 memctl->memc_psrt = CONFIG_SYS_PSRT;
467 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
468
469#ifndef CONFIG_SYS_RAMBOOT
470
471
472 size8 = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR1_8COL,
473 (uchar *) CONFIG_SYS_SDRAM_BASE, 8);
474 size9 = try_init (memctl, CONFIG_SYS_PSDMR_9COL, CONFIG_SYS_OR1_9COL,
475 (uchar *) CONFIG_SYS_SDRAM_BASE, 9);
476
477 if (size8 < size9) {
478 psize = size9;
479 printf ("(60x:9COL - %ld MB, ", psize >> 20);
480 } else {
481 psize = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR1_8COL,
482 (uchar *) CONFIG_SYS_SDRAM_BASE, 8);
483 printf ("(60x:8COL - %ld MB, ", psize >> 20);
484 }
485
486#endif
487
488 icache_enable ();
489
490 return (psize);
491}
492
493
494static inline int scanChar (char *p, int len, unsigned long *number)
495{
496 int akt = 0;
497
498 *number = 0;
499 while (akt < len) {
500 if ((*p >= '0') && (*p <= '9')) {
501 *number *= 10;
502 *number += *p - '0';
503 p += 1;
504 } else {
505 if (*p == '-') return akt;
506 return -1;
507 }
508 akt ++;
509 }
510 return akt;
511}
512
513static int dump_hwib(void)
514{
515 HWIB_INFO *hw = &hwinf;
516 char buf[64];
517 int i = getenv_f("serial#", buf, sizeof(buf));
518 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
519
520 if (i < 0)
521 buf[0] = '\0';
522
523 if (hw->OK) {
524 printf ("HWIB on %x\n", HWIB_INFO_START_ADDR);
525 printf ("serial : %s\n", buf);
526 printf ("ethaddr: %s\n", hw->ethaddr);
527 printf ("FLASH : %x nr:%d\n", hw->flash, hw->flash_nr);
528 printf ("RAM : %x cs:%d\n", hw->ram, hw->ram_cs);
529 printf ("CPU : %lu\n", hw->cpunr);
530 printf ("CAN : %d\n", hw->can);
531 if (hw->eeprom) printf ("EEprom : %x\n", hw->eeprom);
532 else printf ("No EEprom\n");
533 if (hw->nand) {
534 printf ("NAND : %x\n", hw->nand);
535 printf ("NAND CS: %d\n", hw->nand_cs);
536 } else { printf ("No NAND\n");}
537 printf ("Bus %s mode.\n", (hw->Bus ? "60x" : "Single PQII"));
538 printf (" real : %s\n", (immr->im_siu_conf.sc_bcr & BCR_EBM ? \
539 "60x" : "Single PQII"));
540 printf ("Option : %lx\n", hw->option);
541 printf ("%s Security Engine\n", (hw->SecEng ? "with" : "no"));
542 printf ("CPM Clk: %d\n", hw->cpmcl);
543 printf ("CPU Clk: %d\n", hw->cpucl);
544 printf ("Bus Clk: %d\n", hw->buscl);
545 if (hw->busclk_real_ok) {
546 printf (" real Clk: %d\n", hw->busclk_real);
547 }
548 printf ("CAS : %d\n", get_cas_latency());
549 } else {
550 printf("HWIB @%x not OK\n", HWIB_INFO_START_ADDR);
551 }
552 return 0;
553}
554
555static inline int search_real_busclk (int *clk)
556{
557 int part = 0, pos = 0;
558 char *p = (char *) CIB_INFO_START_ADDR;
559 int ok = 0;
560
561 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
562 if (*p < ' ' || *p > '~') {
563 return 0;
564 }
565 switch (part) {
566 default:
567 if (*p == '-') {
568 ++part;
569 }
570 break;
571 case 3:
572 if (*p == '-') {
573 ++part;
574 break;
575 }
576 if (*p == 'b') {
577 ok = 1;
578 p++;
579 break;
580 }
581 if (ok) {
582 switch (*p) {
583 case '6':
584 *clk = 66666666;
585 return 1;
586 break;
587 case '1':
588 if (p[1] == '3') {
589 *clk = 133333333;
590 } else {
591 *clk = 100000000;
592 }
593 return 1;
594 break;
595 }
596 }
597 break;
598 }
599 p++;
600 }
601 return 0;
602}
603
604int analyse_hwib (void)
605{
606 char *p = (char *) HWIB_INFO_START_ADDR;
607 int anz;
608 int part = 1, i = 0, pos = 0;
609 HWIB_INFO *hw = &hwinf;
610
611 deb_printf(" %s pointer: %p\n", __FUNCTION__, p);
612
613 if (*((unsigned long *)p) != (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
614 deb_printf("No HWIB\n");
615 return -1;
616 }
617 p += 3;
618 if (scanChar (p, 4, &hw->cpunr) < 0) {
619 deb_printf("No CPU\n");
620 return -2;
621 }
622 p +=4;
623
624 hw->flash = 0x200000 << (*p - 'A');
625 p++;
626 hw->flash_nr = *p - '0';
627 p++;
628
629 hw->ram = 0x2000000 << (*p - 'A');
630 p++;
631 if (*p == '2') {
632 hw->ram_cs = 2;
633 p++;
634 }
635
636 if (*p == 'A') hw->can = 1;
637 if (*p == 'B') hw->can = 2;
638 p +=1;
639 p +=1;
640 if (*p != '0') {
641 hw->eeprom = 0x1000 << (*p - 'A');
642 }
643 p++;
644
645 if ((*p < '0') || (*p > '9')) {
646
647 hw->nand = 0x8000000 << (*p - 'A');
648 p++;
649 hw->nand_cs = *p - '0';
650 p += 2;
651 }
652
653 anz = scanChar (p, 4, &hw->option);
654 if (anz < 0) {
655 deb_printf("No option\n");
656 return -3;
657 }
658 if (hw->option & 0x8) hw->Bus = 1;
659 p += anz;
660 if (*p != '-') {
661 deb_printf("No -\n");
662 return -4;
663 }
664 p++;
665
666 if (*p == 'E') {
667 hw->SecEng = 1;
668 p++;
669 }
670 switch (*p) {
671 case 'M': hw->cpucl = 266666666;
672 break;
673 case 'P': hw->cpucl = 300000000;
674 break;
675 case 'T': hw->cpucl = 400000000;
676 break;
677 default:
678 deb_printf("No CPU Clk: %c\n", *p);
679 return -5;
680 break;
681 }
682 p++;
683 switch (*p) {
684 case 'I': hw->cpmcl = 200000000;
685 break;
686 case 'M': hw->cpmcl = 300000000;
687 break;
688 default:
689 deb_printf("No CPM Clk\n");
690 return -6;
691 break;
692 }
693 p++;
694 switch (*p) {
695 case 'B': hw->buscl = 66666666;
696 break;
697 case 'E': hw->buscl = 100000000;
698 break;
699 case 'F': hw->buscl = 133333333;
700 break;
701 default:
702 deb_printf("No BUS Clk\n");
703 return -7;
704 break;
705 }
706 p++;
707
708 hw->OK = 1;
709
710 while ((*p != '\0') && (pos < CONFIG_SYS_HWINFO_SIZE)) {
711 if (*p < ' ' || *p > '~') {
712 return 0;
713 }
714 switch (part) {
715 default:
716 if (*p == ' ') {
717 ++part;
718 i = 0;
719 }
720 break;
721 case 3:
722 if (*p == ' ') {
723 ++part;
724 i = 0;
725 break;
726 }
727 hw->ethaddr[i++] = *p;
728 if ((i % 3) == 2)
729 hw->ethaddr[i++] = ':';
730 break;
731
732 }
733 p++;
734 }
735
736 hw->busclk_real_ok = search_real_busclk (&hw->busclk_real);
737 return 0;
738}
739
740#if defined(CONFIG_GET_CPU_STR_F)
741
742char get_cpu_str_f (char *buf)
743{
744 char *p = (char *) HWIB_INFO_START_ADDR;
745 int i = 0;
746
747 buf[i++] = 'M';
748 buf[i++] = 'P';
749 buf[i++] = 'C';
750 if (*((unsigned long *)p) == (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
751 buf[i++] = *&p[3];
752 buf[i++] = *&p[4];
753 buf[i++] = *&p[5];
754 buf[i++] = *&p[6];
755 } else {
756 buf[i++] = '8';
757 buf[i++] = '2';
758 buf[i++] = '7';
759 buf[i++] = 'x';
760 }
761 buf[i++] = 0;
762 return 0;
763}
764#endif
765
766#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
767
768unsigned long board_get_cpu_clk_f (void)
769{
770 char *p = (char *) HWIB_INFO_START_ADDR;
771 int i = 0;
772
773 if (*((unsigned long *)p) == (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
774 if (search_real_busclk (&i))
775 return i;
776 }
777 return CONFIG_8260_CLKIN;
778}
779#endif
780
781#if CONFIG_BOARD_EARLY_INIT_R
782
783static int can_test (unsigned long off)
784{
785 volatile unsigned char *base = (unsigned char *) (CONFIG_SYS_CAN_BASE + off);
786
787 *(base + 0x17) = 'T';
788 *(base + 0x18) = 'Q';
789 *(base + 0x19) = 'M';
790 if ((*(base + 0x17) != 'T') ||
791 (*(base + 0x18) != 'Q') ||
792 (*(base + 0x19) != 'M')) {
793 return 0;
794 }
795 return 1;
796}
797
798static int can_config_one (unsigned long off)
799{
800 volatile unsigned char *ctrl = (unsigned char *) (CONFIG_SYS_CAN_BASE + off);
801 volatile unsigned char *cpu_if = (unsigned char *) (CONFIG_SYS_CAN_BASE + off + 0x02);
802 volatile unsigned char *clkout = (unsigned char *) (CONFIG_SYS_CAN_BASE + off + 0x1f);
803 unsigned char temp;
804
805 *cpu_if = 0x45;
806 temp = *ctrl;
807 temp |= 0x40;
808 *ctrl = temp;
809 *clkout = 0x20;
810 temp = *ctrl;
811 temp &= ~0x40;
812 *ctrl = temp;
813 return 0;
814}
815
816static int can_config (void)
817{
818 int ret = 0;
819 can_config_one (0);
820 if (hwinf.can == 2) {
821 can_config_one (0x100);
822 }
823
824 ret += can_test (0);
825 ret += can_test (0x100);
826 return ret;
827}
828
829static int init_can (void)
830{
831 volatile immap_t * immr = (immap_t *)CONFIG_SYS_IMMR;
832 volatile memctl8260_t *memctl = &immr->im_memctl;
833 int count = 0;
834
835 if ((hwinf.OK) && (hwinf.can)) {
836 memctl->memc_or4 = CONFIG_SYS_CAN_OR;
837 memctl->memc_br4 = CONFIG_SYS_CAN_BR;
838
839 upmconfig (UPMC, (uint *) upmTableFast,
840 sizeof (upmTableFast) / sizeof (uint));
841 memctl->memc_mcmr = (MxMR_DSx_3_CYCL |
842 MxMR_GPL_x4DIS |
843 MxMR_RLFx_2X |
844 MxMR_WLFx_2X |
845 MxMR_OP_NORM);
846
847 count = can_config ();
848 printf ("CAN: %d @ %x\n", count, CONFIG_SYS_CAN_BASE);
849 if (hwinf.can != count) printf("!!! difference to HWIB\n");
850 } else {
851 printf ("CAN: No\n");
852 }
853 return 0;
854}
855
856int board_early_init_r(void)
857{
858 analyse_hwib ();
859 init_can ();
860 return 0;
861}
862#endif
863
864int do_hwib_dump (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
865{
866 dump_hwib ();
867 return 0;
868}
869
870U_BOOT_CMD(
871 hwib, 1, 1, do_hwib_dump,
872 "dump HWIB'",
873 ""
874);
875
876#ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
877static int get_flash_timing (void)
878{
879
880
881 int ret = 0x00000c84;
882 int pos = 0;
883 int nr = 0;
884 char *p = (char *) CIB_INFO_START_ADDR;
885
886 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
887 if (*p < ' ' || *p > '~') {
888 return ret;
889 }
890 if (*p == '-') {
891 if ((p[1] == 't') && (p[2] == 'f')) {
892 p += 6;
893 ret = 0;
894 while (nr < 8) {
895 if ((*p >= '0') && (*p <= '9')) {
896 ret *= 0x10;
897 ret += *p - '0';
898 p += 1;
899 nr ++;
900 } else if ((*p >= 'A') && (*p <= 'F')) {
901 ret *= 10;
902 ret += *p - '7';
903 p += 1;
904 nr ++;
905 } else {
906 if (nr < 8) return 0x00000c84;
907 return ret;
908 }
909 }
910 }
911 }
912 p++;
913 pos++;
914 }
915 return ret;
916}
917
918
919int update_flash_size (int flash_size)
920{
921 volatile immap_t * immr = (immap_t *)CONFIG_SYS_IMMR;
922 volatile memctl8260_t *memctl = &immr->im_memctl;
923 unsigned long reg;
924 unsigned long tim;
925
926
927 reg = memctl->memc_or0;
928 reg &= ~ORxU_AM_MSK;
929 reg |= MEG_TO_AM(flash_size >> 20);
930 tim = get_flash_timing ();
931 reg &= ~0xfff;
932 reg |= (tim & 0xfff);
933 memctl->memc_or0 = reg;
934 return 0;
935}
936#endif
937
938#ifdef CONFIG_PCI
939struct pci_controller hose;
940
941int board_early_init_f (void)
942{
943 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
944
945 immap->im_clkrst.car_sccr |= M826X_SCCR_PCI_MODE_EN;
946 return 0;
947}
948
949extern void pci_mpc8250_init(struct pci_controller *);
950
951void pci_init_board(void)
952{
953 pci_mpc8250_init(&hose);
954}
955#endif
956
957int board_eth_init(bd_t *bis)
958{
959 return pci_eth_init(bis);
960}
961