1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <common.h>
18#include <mpc5xxx.h>
19#include <pci.h>
20#include <netdev.h>
21
22#ifdef CONFIG_VIDEO_SM501
23#include <sm501.h>
24#endif
25
26#if defined(CONFIG_MPC5200_DDR)
27#include "mt46v16m16-75.h"
28#else
29#include "mt48lc16m16a2-75.h"
30#endif
31
32#ifdef CONFIG_RTC_MPC5200
33#include <rtc.h>
34#endif
35
36#ifdef CONFIG_PS2MULT
37void ps2mult_early_init(void);
38#endif
39
40#ifndef CONFIG_SYS_RAMBOOT
41static void sdram_start (int hi_addr)
42{
43 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
44
45
46 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
47 hi_addr_bit;
48 __asm__ volatile ("sync");
49
50
51 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
52 hi_addr_bit;
53 __asm__ volatile ("sync");
54
55#if SDRAM_DDR
56
57 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
58 __asm__ volatile ("sync");
59
60
61 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
62 __asm__ volatile ("sync");
63#endif
64
65
66 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
67 hi_addr_bit;
68 __asm__ volatile ("sync");
69
70
71 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
72 hi_addr_bit;
73 __asm__ volatile ("sync");
74
75
76 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
77 __asm__ volatile ("sync");
78
79
80 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
81 __asm__ volatile ("sync");
82}
83#endif
84
85
86
87
88
89
90
91phys_size_t initdram (int board_type)
92{
93 ulong dramsize = 0;
94 ulong dramsize2 = 0;
95#ifndef CONFIG_SYS_RAMBOOT
96 ulong test1, test2;
97
98
99 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001c;
100 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x40000000;
101 __asm__ volatile ("sync");
102
103
104 *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
105 *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
106 __asm__ volatile ("sync");
107
108#if SDRAM_DDR
109
110 *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
111 __asm__ volatile ("sync");
112#endif
113
114
115 sdram_start(0);
116 test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
117 sdram_start(1);
118 test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
119 if (test1 > test2) {
120 sdram_start(0);
121 dramsize = test1;
122 } else {
123 dramsize = test2;
124 }
125
126
127 if (dramsize < (1 << 20)) {
128 dramsize = 0;
129 }
130
131
132 if (dramsize > 0) {
133 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
134 __builtin_ffs(dramsize >> 20) - 1;
135 } else {
136 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0;
137 }
138
139
140 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001c;
141
142
143 sdram_start(0);
144 test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
145 sdram_start(1);
146 test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
147 if (test1 > test2) {
148 sdram_start(0);
149 dramsize2 = test1;
150 } else {
151 dramsize2 = test2;
152 }
153
154
155 if (dramsize2 < (1 << 20)) {
156 dramsize2 = 0;
157 }
158
159
160 if (dramsize2 > 0) {
161 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
162 | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
163 } else {
164 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize;
165 }
166
167#else
168
169
170 dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
171 if (dramsize >= 0x13) {
172 dramsize = (1 << (dramsize - 0x13)) << 20;
173 } else {
174 dramsize = 0;
175 }
176
177
178 dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
179 if (dramsize2 >= 0x13) {
180 dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
181 } else {
182 dramsize2 = 0;
183 }
184
185#endif
186
187 return dramsize;
188}
189
190int checkboard (void)
191{
192#if defined (CONFIG_TQM5200)
193 puts ("Board: TQM5200 (TQ-Components GmbH)\n");
194#endif
195
196#if defined (CONFIG_BC3450)
197 puts ("Dev: GERSYS BC3450\n");
198#endif
199
200 return 0;
201}
202
203void flash_preinit(void)
204{
205
206
207
208
209
210
211 *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1;
212}
213
214
215#ifdef CONFIG_PCI
216static struct pci_controller hose;
217
218extern void pci_mpc5xxx_init(struct pci_controller *);
219
220void pci_init_board(void)
221{
222 pci_mpc5xxx_init(&hose);
223}
224#endif
225
226#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
227
228void init_ide_reset (void)
229{
230 debug ("init_ide_reset\n");
231
232
233 *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
234 *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
235}
236
237void ide_set_reset (int idereset)
238{
239 debug ("ide_reset(%d)\n", idereset);
240
241 if (idereset) {
242 *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4;
243 } else {
244 *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
245 }
246}
247#endif
248
249#ifdef CONFIG_POST
250
251
252
253
254int post_hotkeys_pressed(void)
255{
256 struct mpc5xxx_gpio *gpio;
257
258 gpio = (struct mpc5xxx_gpio*) MPC5XXX_GPIO;
259
260
261
262
263
264 gpio->port_config &= ~(0x07000000);
265 gpio->port_config |= 0x03000000;
266
267
268 gpio->simple_gpioe |= 0x20000000;
269
270
271 gpio->simple_ddr &= ~(0x20000000);
272
273 return ((gpio->simple_ival & 0x20000000) ? 0 : 1);
274}
275#endif
276
277#ifdef CONFIG_BOARD_EARLY_INIT_R
278int board_early_init_r (void)
279{
280#ifdef CONFIG_RTC_MPC5200
281 struct rtc_time t;
282
283
284 t.tm_sec = t.tm_min = 0;
285 t.tm_hour = 19;
286 t.tm_mday = 31;
287 t.tm_mon = 12;
288 t.tm_year = 1969;
289 t.tm_wday = 3;
290
291 rtc_set(&t);
292#endif
293
294#ifdef CONFIG_PS2MULT
295 ps2mult_early_init();
296#endif
297 return (0);
298}
299#endif
300
301
302int last_stage_init (void)
303{
304
305
306
307
308 u16 save, tmp;
309 int restore;
310
311
312
313
314
315
316 save = *(volatile u16 *)CONFIG_SYS_CS2_START;
317 restore = 1;
318
319
320 *(volatile u16 *)CONFIG_SYS_CS2_START = 0xA5A5;
321 __asm__ volatile ("sync");
322
323
324
325
326 tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE;
327 if (tmp == 0xA5A5)
328 puts ("!! possible error in SRAM detection\n");
329
330 if (*(volatile u16 *)CONFIG_SYS_CS2_START != 0xA5A5) {
331
332 *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 18);
333 *(vu_long *)MPC5XXX_CS2_START = 0x0000FFFF;
334 *(vu_long *)MPC5XXX_CS2_STOP = 0x0000FFFF;
335 restore = 0;
336 __asm__ volatile ("sync");
337 } else if (*(volatile u16 *)(CONFIG_SYS_CS2_START + (1<<19)) == 0xA5A5) {
338
339 *(volatile u16 *)CONFIG_SYS_CS2_START = 0x1111;
340 __asm__ volatile ("sync");
341 if (*(volatile u16 *)(CONFIG_SYS_CS2_START + (1<<19)) == 0x1111) {
342
343 *(vu_long *)MPC5XXX_CS2_STOP = STOP_REG(CONFIG_SYS_CS2_START,
344 0x80000);
345 __asm__ volatile ("sync");
346 puts ("SRAM: 512 kB\n");
347 }
348 else
349 puts ("!! possible error in SRAM detection\n");
350 } else {
351 puts ("SRAM: 1 MB\n");
352 }
353
354 if (restore) {
355 *(volatile u16 *)CONFIG_SYS_CS2_START = save;
356 __asm__ volatile ("sync");
357 }
358
359
360
361
362
363
364 save = *(volatile u16 *)CONFIG_SYS_CS1_START;
365 restore = 1;
366
367
368 *(volatile u16 *)CONFIG_SYS_CS1_START = 0xA5A5;
369 __asm__ volatile ("sync");
370
371
372
373
374 tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE;
375 if (tmp == 0xA5A5)
376 puts ("!! possible error in grafic controller detection\n");
377
378 if (*(volatile u16 *)CONFIG_SYS_CS1_START != 0xA5A5) {
379
380 *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 17);
381 *(vu_long *)MPC5XXX_CS1_START = 0x0000FFFF;
382 *(vu_long *)MPC5XXX_CS1_STOP = 0x0000FFFF;
383 restore = 0;
384 __asm__ volatile ("sync");
385 } else {
386 puts ("VGA: SMI501 (Voyager) with 8 MB\n");
387 }
388
389 if (restore) {
390 *(volatile u16 *)CONFIG_SYS_CS1_START = save;
391 __asm__ volatile ("sync");
392 }
393
394 return 0;
395}
396
397#ifdef CONFIG_VIDEO_SM501
398
399#define DISPLAY_WIDTH 640
400#define DISPLAY_HEIGHT 480
401
402#ifdef CONFIG_VIDEO_SM501_8BPP
403#error CONFIG_VIDEO_SM501_8BPP not supported.
404#endif
405
406#ifdef CONFIG_VIDEO_SM501_16BPP
407#error CONFIG_VIDEO_SM501_16BPP not supported.
408#endif
409
410#ifdef CONFIG_VIDEO_SM501_32BPP
411static const SMI_REGS init_regs [] =
412{
413#if defined (CONFIG_BC3450_FP) && !defined (CONFIG_BC3450_CRT)
414
415 {0x00004, 0x0},
416 {0x00048, 0x00021807},
417 {0x0004C, 0x091a0a01},
418 {0x00054, 0x1},
419 {0x00040, 0x00021807},
420 {0x00044, 0x091a0a01},
421 {0x00054, 0x0},
422 {0x80000, 0x01013106},
423 {0x80004, 0xc428bb17},
424 {0x80000, 0x03013106},
425 {0x8000C, 0x00000000},
426 {0x80010, 0x0a000a00},
427 {0x80014, 0x02800000},
428 {0x80018, 0x01e00000},
429 {0x8001C, 0x00000000},
430 {0x80020, 0x01e00280},
431 {0x80024, 0x02fa027f},
432 {0x80028, 0x004a028b},
433 {0x8002C, 0x020c01df},
434 {0x80030, 0x000201e9},
435 {0x80200, 0x00010200},
436 {0x80000, 0x0f013106},
437#elif defined (CONFIG_BC3450_CRT) && !defined (CONFIG_BC3450_FP)
438
439 {0x00004, 0x0},
440 {0x00048, 0x00021807},
441 {0x0004C, 0x10090a01},
442 {0x00054, 0x1},
443 {0x00040, 0x00021807},
444 {0x00044, 0x10090a01},
445 {0x00054, 0x0},
446 {0x80200, 0x00010000},
447 {0x80204, 0x0},
448 {0x80208, 0x0A000A00},
449 {0x8020C, 0x02fa027f},
450 {0x80210, 0x004a028b},
451 {0x80214, 0x020c01df},
452 {0x80218, 0x000201e9},
453 {0x80200, 0x00013306},
454#else
455 {0x00004, 0x0},
456 {0x00048, 0x00021807},
457 {0x0004C, 0x091a0a01},
458 {0x00054, 0x1},
459 {0x00040, 0x00021807},
460 {0x00044, 0x091a0a01},
461 {0x00054, 0x0},
462 {0x80000, 0x0f013106},
463 {0x80004, 0xc428bb17},
464 {0x8000C, 0x00000000},
465 {0x80010, 0x0a000a00},
466 {0x80014, 0x02800000},
467 {0x80018, 0x01e00000},
468 {0x8001C, 0x00000000},
469 {0x80020, 0x01e00280},
470 {0x80024, 0x02fa027f},
471 {0x80028, 0x004a028b},
472 {0x8002C, 0x020c01df},
473 {0x80030, 0x000201e9},
474 {0x80200, 0x00010000},
475#endif
476 {0, 0}
477};
478#endif
479
480#ifdef CONFIG_CONSOLE_EXTRA_INFO
481
482
483
484void video_get_info_str (int line_number, char *info)
485{
486 if (line_number == 1) {
487#if defined (CONFIG_TQM5200)
488 strcpy (info, " Board: TQM5200 (TQ-Components GmbH)");
489#else
490#error No supported board selected
491#endif
492
493#if defined (CONFIG_BC3450)
494 } else if (line_number == 2) {
495 strcpy (info, " Dev: GERSYS BC3450");
496#endif
497 }
498 else {
499 info [0] = '\0';
500 }
501}
502#endif
503
504
505
506
507
508unsigned int board_video_init (void)
509{
510 u16 save, tmp;
511 int restore, ret;
512
513
514
515
516
517
518 save = *(volatile u16 *)CONFIG_SYS_CS1_START;
519 restore = 1;
520
521
522 *(volatile u16 *)CONFIG_SYS_CS1_START = 0xA5A5;
523 __asm__ volatile ("sync");
524
525
526
527
528 tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE;
529 if (tmp == 0xA5A5)
530 puts ("!! possible error in grafic controller detection\n");
531
532 if (*(volatile u16 *)CONFIG_SYS_CS1_START != 0xA5A5) {
533
534 restore = 0;
535 ret = 0;
536 } else {
537 ret = SM501_MMIO_BASE;
538 }
539
540 if (restore) {
541 *(volatile u16 *)CONFIG_SYS_CS1_START = save;
542 __asm__ volatile ("sync");
543 }
544 return ret;
545}
546
547
548
549
550unsigned int board_video_get_fb (void)
551{
552 return SM501_FB_BASE;
553}
554
555
556
557
558void board_validate_screen (unsigned int base)
559{
560}
561
562
563
564
565const SMI_REGS *board_get_regs (void)
566{
567 return init_regs;
568}
569
570int board_get_width (void)
571{
572 return DISPLAY_WIDTH;
573}
574
575int board_get_height (void)
576{
577 return DISPLAY_HEIGHT;
578}
579
580#endif
581
582int board_eth_init(bd_t *bis)
583{
584 cpu_eth_init(bis);
585 return pci_eth_init(bis);
586}
587