]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/bc3450/bc3450.c
2 * (C) Copyright 2003-2004
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
8 * (C) Copyright 2004-2005
9 * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
12 * Stefan Strobl, GERSYS GmbH, stefan.strobl@gersys.de
14 * See file CREDITS for list of people who contributed to this
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
38 #ifdef CONFIG_VIDEO_SM501
42 #if defined(CONFIG_MPC5200_DDR)
43 #include "mt46v16m16-75.h"
45 #include "mt48lc16m16a2-75.h"
48 #ifdef CONFIG_RTC_MPC5200
53 void ps2mult_early_init(void);
56 #ifndef CONFIG_SYS_RAMBOOT
57 static void sdram_start (int hi_addr
)
59 long hi_addr_bit
= hi_addr
? 0x01000000 : 0;
61 /* unlock mode register */
62 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000000 |
64 __asm__
volatile ("sync");
66 /* precharge all banks */
67 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000002 |
69 __asm__
volatile ("sync");
72 /* set mode register: extended mode */
73 *(vu_long
*)MPC5XXX_SDRAM_MODE
= SDRAM_EMODE
;
74 __asm__
volatile ("sync");
76 /* set mode register: reset DLL */
77 *(vu_long
*)MPC5XXX_SDRAM_MODE
= SDRAM_MODE
| 0x04000000;
78 __asm__
volatile ("sync");
81 /* precharge all banks */
82 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000002 |
84 __asm__
volatile ("sync");
87 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000004 |
89 __asm__
volatile ("sync");
91 /* set mode register */
92 *(vu_long
*)MPC5XXX_SDRAM_MODE
= SDRAM_MODE
;
93 __asm__
volatile ("sync");
95 /* normal operation */
96 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| hi_addr_bit
;
97 __asm__
volatile ("sync");
102 * ATTENTION: Although partially referenced initdram does NOT make real use
103 * use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
104 * is something else than 0x00000000.
107 phys_size_t
initdram (int board_type
)
111 #ifndef CONFIG_SYS_RAMBOOT
114 /* setup SDRAM chip selects */
115 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0x0000001c; /* 512MB at 0x0 */
116 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= 0x40000000; /* disabled */
117 __asm__
volatile ("sync");
119 /* setup config registers */
120 *(vu_long
*)MPC5XXX_SDRAM_CONFIG1
= SDRAM_CONFIG1
;
121 *(vu_long
*)MPC5XXX_SDRAM_CONFIG2
= SDRAM_CONFIG2
;
122 __asm__
volatile ("sync");
126 *(vu_long
*)MPC5XXX_CDM_PORCFG
= SDRAM_TAPDELAY
;
127 __asm__
volatile ("sync");
130 /* find RAM size using SDRAM CS0 only */
132 test1
= get_ram_size((long *)CONFIG_SYS_SDRAM_BASE
, 0x20000000);
134 test2
= get_ram_size((long *)CONFIG_SYS_SDRAM_BASE
, 0x20000000);
142 /* memory smaller than 1MB is impossible */
143 if (dramsize
< (1 << 20)) {
147 /* set SDRAM CS0 size according to the amount of RAM found */
149 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0x13 +
150 __builtin_ffs(dramsize
>> 20) - 1;
152 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0; /* disabled */
155 /* let SDRAM CS1 start right after CS0 */
156 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= dramsize
+ 0x0000001c; /* 512MB */
158 /* find RAM size using SDRAM CS1 only */
160 test1
= get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE
+ dramsize
), 0x20000000);
162 test2
= get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE
+ dramsize
), 0x20000000);
170 /* memory smaller than 1MB is impossible */
171 if (dramsize2
< (1 << 20)) {
175 /* set SDRAM CS1 size according to the amount of RAM found */
177 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= dramsize
178 | (0x13 + __builtin_ffs(dramsize2
>> 20) - 1);
180 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= dramsize
; /* disabled */
183 #else /* CONFIG_SYS_RAMBOOT */
185 /* retrieve size of memory connected to SDRAM CS0 */
186 dramsize
= *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
& 0xFF;
187 if (dramsize
>= 0x13) {
188 dramsize
= (1 << (dramsize
- 0x13)) << 20;
193 /* retrieve size of memory connected to SDRAM CS1 */
194 dramsize2
= *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
& 0xFF;
195 if (dramsize2
>= 0x13) {
196 dramsize2
= (1 << (dramsize2
- 0x13)) << 20;
201 #endif /* CONFIG_SYS_RAMBOOT */
206 int checkboard (void)
208 #if defined (CONFIG_TQM5200)
209 puts ("Board: TQM5200 (TQ-Components GmbH)\n");
212 #if defined (CONFIG_BC3450)
213 puts ("Dev: GERSYS BC3450\n");
219 void flash_preinit(void)
222 * Now, when we are in RAM, enable flash write
223 * access for detection process.
224 * Note that CS_BOOT cannot be cleared when
225 * executing in flash.
227 *(vu_long
*)MPC5XXX_BOOTCS_CFG
&= ~0x1; /* clear RO */
232 static struct pci_controller hose
;
234 extern void pci_mpc5xxx_init(struct pci_controller
*);
236 void pci_init_board(void)
238 pci_mpc5xxx_init(&hose
);
242 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
244 void init_ide_reset (void)
246 debug ("init_ide_reset\n");
248 /* Configure PSC1_4 as GPIO output for ATA reset */
249 *(vu_long
*) MPC5XXX_WU_GPIO_ENABLE
|= GPIO_PSC1_4
;
250 *(vu_long
*) MPC5XXX_WU_GPIO_DIR
|= GPIO_PSC1_4
;
253 void ide_set_reset (int idereset
)
255 debug ("ide_reset(%d)\n", idereset
);
258 *(vu_long
*) MPC5XXX_WU_GPIO_DATA_O
&= ~GPIO_PSC1_4
;
260 *(vu_long
*) MPC5XXX_WU_GPIO_DATA_O
|= GPIO_PSC1_4
;
267 * Reads GPIO pin PSC6_3. A keypress is reported, if PSC6_3 is low. If PSC6_3
268 * is left open, no keypress is detected.
270 int post_hotkeys_pressed(void)
272 struct mpc5xxx_gpio
*gpio
;
274 gpio
= (struct mpc5xxx_gpio
*) MPC5XXX_GPIO
;
277 * Configure PSC6_1 and PSC6_3 as GPIO. PSC6 then couldn't be used in
278 * CODEC or UART mode. Consumer IrDA should still be possible.
280 gpio
->port_config
&= ~(0x07000000);
281 gpio
->port_config
|= 0x03000000;
283 /* Enable GPIO for GPIO_IRDA_1 (IR_USB_CLK pin) = PSC6_3 */
284 gpio
->simple_gpioe
|= 0x20000000;
286 /* Configure GPIO_IRDA_1 as input */
287 gpio
->simple_ddr
&= ~(0x20000000);
289 return ((gpio
->simple_ival
& 0x20000000) ? 0 : 1);
293 #ifdef CONFIG_BOARD_EARLY_INIT_R
294 int board_early_init_r (void)
296 #ifdef CONFIG_RTC_MPC5200
299 /* set to Wed Dec 31 19:00:00 1969 */
300 t
.tm_sec
= t
.tm_min
= 0;
308 #endif /* CONFIG_RTC_MPC5200 */
310 #ifdef CONFIG_PS2MULT
311 ps2mult_early_init();
312 #endif /* CONFIG_PS2MULT */
315 #endif /* CONFIG_BOARD_EARLY_INIT_R */
318 int last_stage_init (void)
321 * auto scan for really existing devices and re-set chip select
328 * Check for SRAM and SRAM size
331 /* save original SRAM content */
332 save
= *(volatile u16
*)CONFIG_SYS_CS2_START
;
335 /* write test pattern to SRAM */
336 *(volatile u16
*)CONFIG_SYS_CS2_START
= 0xA5A5;
337 __asm__
volatile ("sync");
339 * Put a different pattern on the data lines: otherwise they may float
340 * long enough to read back what we wrote.
342 tmp
= *(volatile u16
*)CONFIG_SYS_FLASH_BASE
;
344 puts ("!! possible error in SRAM detection\n");
346 if (*(volatile u16
*)CONFIG_SYS_CS2_START
!= 0xA5A5) {
347 /* no SRAM at all, disable cs */
348 *(vu_long
*)MPC5XXX_ADDECR
&= ~(1 << 18);
349 *(vu_long
*)MPC5XXX_CS2_START
= 0x0000FFFF;
350 *(vu_long
*)MPC5XXX_CS2_STOP
= 0x0000FFFF;
352 __asm__
volatile ("sync");
353 } else if (*(volatile u16
*)(CONFIG_SYS_CS2_START
+ (1<<19)) == 0xA5A5) {
354 /* make sure that we access a mirrored address */
355 *(volatile u16
*)CONFIG_SYS_CS2_START
= 0x1111;
356 __asm__
volatile ("sync");
357 if (*(volatile u16
*)(CONFIG_SYS_CS2_START
+ (1<<19)) == 0x1111) {
358 /* SRAM size = 512 kByte */
359 *(vu_long
*)MPC5XXX_CS2_STOP
= STOP_REG(CONFIG_SYS_CS2_START
,
361 __asm__
volatile ("sync");
362 puts ("SRAM: 512 kB\n");
365 puts ("!! possible error in SRAM detection\n");
367 puts ("SRAM: 1 MB\n");
369 /* restore origianl SRAM content */
371 *(volatile u16
*)CONFIG_SYS_CS2_START
= save
;
372 __asm__
volatile ("sync");
376 * Check for Grafic Controller
379 /* save origianl FB content */
380 save
= *(volatile u16
*)CONFIG_SYS_CS1_START
;
383 /* write test pattern to FB memory */
384 *(volatile u16
*)CONFIG_SYS_CS1_START
= 0xA5A5;
385 __asm__
volatile ("sync");
387 * Put a different pattern on the data lines: otherwise they may float
388 * long enough to read back what we wrote.
390 tmp
= *(volatile u16
*)CONFIG_SYS_FLASH_BASE
;
392 puts ("!! possible error in grafic controller detection\n");
394 if (*(volatile u16
*)CONFIG_SYS_CS1_START
!= 0xA5A5) {
395 /* no grafic controller at all, disable cs */
396 *(vu_long
*)MPC5XXX_ADDECR
&= ~(1 << 17);
397 *(vu_long
*)MPC5XXX_CS1_START
= 0x0000FFFF;
398 *(vu_long
*)MPC5XXX_CS1_STOP
= 0x0000FFFF;
400 __asm__
volatile ("sync");
402 puts ("VGA: SMI501 (Voyager) with 8 MB\n");
404 /* restore origianl FB content */
406 *(volatile u16
*)CONFIG_SYS_CS1_START
= save
;
407 __asm__
volatile ("sync");
413 #ifdef CONFIG_VIDEO_SM501
415 #define DISPLAY_WIDTH 640
416 #define DISPLAY_HEIGHT 480
418 #ifdef CONFIG_VIDEO_SM501_8BPP
419 #error CONFIG_VIDEO_SM501_8BPP not supported.
420 #endif /* CONFIG_VIDEO_SM501_8BPP */
422 #ifdef CONFIG_VIDEO_SM501_16BPP
423 #error CONFIG_VIDEO_SM501_16BPP not supported.
424 #endif /* CONFIG_VIDEO_SM501_16BPP */
426 #ifdef CONFIG_VIDEO_SM501_32BPP
427 static const SMI_REGS init_regs
[] =
429 #if defined (CONFIG_BC3450_FP) && !defined (CONFIG_BC3450_CRT)
432 {0x00048, 0x00021807},
433 {0x0004C, 0x091a0a01},
435 {0x00040, 0x00021807},
436 {0x00044, 0x091a0a01},
438 {0x80000, 0x01013106},
439 {0x80004, 0xc428bb17},
440 {0x80000, 0x03013106},
441 {0x8000C, 0x00000000},
442 {0x80010, 0x0a000a00},
443 {0x80014, 0x02800000},
444 {0x80018, 0x01e00000},
445 {0x8001C, 0x00000000},
446 {0x80020, 0x01e00280},
447 {0x80024, 0x02fa027f},
448 {0x80028, 0x004a028b},
449 {0x8002C, 0x020c01df},
450 {0x80030, 0x000201e9},
451 {0x80200, 0x00010200},
452 {0x80000, 0x0f013106},
453 #elif defined (CONFIG_BC3450_CRT) && !defined (CONFIG_BC3450_FP)
456 {0x00048, 0x00021807},
457 {0x0004C, 0x10090a01},
459 {0x00040, 0x00021807},
460 {0x00044, 0x10090a01},
462 {0x80200, 0x00010000},
464 {0x80208, 0x0A000A00},
465 {0x8020C, 0x02fa027f},
466 {0x80210, 0x004a028b},
467 {0x80214, 0x020c01df},
468 {0x80218, 0x000201e9},
469 {0x80200, 0x00013306},
470 #else /* panel + CRT */
472 {0x00048, 0x00021807},
473 {0x0004C, 0x091a0a01},
475 {0x00040, 0x00021807},
476 {0x00044, 0x091a0a01},
478 {0x80000, 0x0f013106},
479 {0x80004, 0xc428bb17},
480 {0x8000C, 0x00000000},
481 {0x80010, 0x0a000a00},
482 {0x80014, 0x02800000},
483 {0x80018, 0x01e00000},
484 {0x8001C, 0x00000000},
485 {0x80020, 0x01e00280},
486 {0x80024, 0x02fa027f},
487 {0x80028, 0x004a028b},
488 {0x8002C, 0x020c01df},
489 {0x80030, 0x000201e9},
490 {0x80200, 0x00010000},
494 #endif /* CONFIG_VIDEO_SM501_32BPP */
496 #ifdef CONFIG_CONSOLE_EXTRA_INFO
498 * Return text to be printed besides the logo.
500 void video_get_info_str (int line_number
, char *info
)
502 if (line_number
== 1) {
503 #if defined (CONFIG_TQM5200)
504 strcpy (info
, " Board: TQM5200 (TQ-Components GmbH)");
506 #error No supported board selected
507 #endif /* CONFIG_TQM5200 */
509 #if defined (CONFIG_BC3450)
510 } else if (line_number
== 2) {
511 strcpy (info
, " Dev: GERSYS BC3450");
512 #endif /* CONFIG_BC3450 */
521 * Returns SM501 register base address. First thing called in the
522 * driver. Checks if SM501 is physically present.
524 unsigned int board_video_init (void)
530 * Check for Grafic Controller
533 /* save origianl FB content */
534 save
= *(volatile u16
*)CONFIG_SYS_CS1_START
;
537 /* write test pattern to FB memory */
538 *(volatile u16
*)CONFIG_SYS_CS1_START
= 0xA5A5;
539 __asm__
volatile ("sync");
541 * Put a different pattern on the data lines: otherwise they may float
542 * long enough to read back what we wrote.
544 tmp
= *(volatile u16
*)CONFIG_SYS_FLASH_BASE
;
546 puts ("!! possible error in grafic controller detection\n");
548 if (*(volatile u16
*)CONFIG_SYS_CS1_START
!= 0xA5A5) {
549 /* no grafic controller found */
553 ret
= SM501_MMIO_BASE
;
557 *(volatile u16
*)CONFIG_SYS_CS1_START
= save
;
558 __asm__
volatile ("sync");
564 * Returns SM501 framebuffer address
566 unsigned int board_video_get_fb (void)
568 return SM501_FB_BASE
;
572 * Called after initializing the SM501 and before clearing the screen.
574 void board_validate_screen (unsigned int base
)
579 * Return a pointer to the initialization sequence.
581 const SMI_REGS
*board_get_regs (void)
586 int board_get_width (void)
588 return DISPLAY_WIDTH
;
591 int board_get_height (void)
593 return DISPLAY_HEIGHT
;
596 #endif /* CONFIG_VIDEO_SM501 */
598 int board_eth_init(bd_t
*bis
)
600 cpu_eth_init(bis
); /* Built in FEC comes first */
601 return pci_eth_init(bis
);