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