blob: 121188d5ec4a3ee90660bf4c6c557001cd46afec [file] [log] [blame]
Mark.Zhana240a462006-05-06 17:04:20 +08001/*
2 * setup.c: Setup pointers to hardware dependent routines.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org)
9 * Copyright (C) 2006, Wind River System Inc. Rongkai.zhan <rongkai.zhan@windriver.com>
10 */
Mark.Zhana240a462006-05-06 17:04:20 +080011#include <linux/init.h>
12#include <linux/string.h>
13#include <linux/kernel.h>
14#include <linux/tty.h>
15#include <linux/serial.h>
16#include <linux/serial_core.h>
17#include <linux/pm.h>
18
19#include <asm/io.h>
20#include <asm/bootinfo.h>
21#include <asm/reboot.h>
22#include <asm/time.h>
23#include <asm/gt64120.h>
24
25unsigned long gt64120_base = KSEG1ADDR(0x14000000);
26
27#ifdef WRPPMC_EARLY_DEBUG
28
29static volatile unsigned char * wrppmc_led = \
30 (volatile unsigned char *)KSEG1ADDR(WRPPMC_LED_BASE);
31
32/*
33 * PPMC LED control register:
34 * -) bit[0] controls DS1 LED (1 - OFF, 0 - ON)
35 * -) bit[1] controls DS2 LED (1 - OFF, 0 - ON)
36 * -) bit[2] controls DS4 LED (1 - OFF, 0 - ON)
37 */
38void wrppmc_led_on(int mask)
39{
40 unsigned char value = *wrppmc_led;
41
42 value &= (0xF8 | mask);
43 *wrppmc_led = value;
44}
45
46/* If mask = 0, turn off all LEDs */
47void wrppmc_led_off(int mask)
48{
49 unsigned char value = *wrppmc_led;
50
51 value |= (0x7 & mask);
52 *wrppmc_led = value;
53}
54
55/*
56 * We assume that bootloader has initialized UART16550 correctly
57 */
58void __init wrppmc_early_putc(char ch)
59{
60 static volatile unsigned char *wrppmc_uart = \
61 (volatile unsigned char *)KSEG1ADDR(WRPPMC_UART16550_BASE);
62 unsigned char value;
63
64 /* Wait until Transmit-Holding-Register is empty */
65 while (1) {
66 value = *(wrppmc_uart + 5);
67 if (value & 0x20)
68 break;
69 }
70
71 *wrppmc_uart = ch;
72}
73
74void __init wrppmc_early_printk(const char *fmt, ...)
75{
76 static char pbuf[256] = {'\0', };
77 char *ch = pbuf;
78 va_list args;
79 unsigned int i;
80
81 memset(pbuf, 0, 256);
82 va_start(args, fmt);
83 i = vsprintf(pbuf, fmt, args);
84 va_end(args);
85
86 /* Print the string */
87 while (*ch != '\0') {
88 wrppmc_early_putc(*ch);
89 /* if print '\n', also print '\r' */
90 if (*ch++ == '\n')
91 wrppmc_early_putc('\r');
92 }
93}
94#endif /* WRPPMC_EARLY_DEBUG */
95
Atsushi Nemotoc44e8d52006-12-30 00:43:59 +090096void __init prom_free_prom_memory(void)
Mark.Zhana240a462006-05-06 17:04:20 +080097{
Mark.Zhana240a462006-05-06 17:04:20 +080098}
99
100#ifdef CONFIG_SERIAL_8250
101static void wrppmc_setup_serial(void)
102{
103 struct uart_port up;
104
105 memset(&up, 0x00, sizeof(struct uart_port));
106
107 /*
108 * A note about mapbase/membase
109 * -) mapbase is the physical address of the IO port.
110 * -) membase is an 'ioremapped' cookie.
111 */
112 up.line = 0;
113 up.type = PORT_16550;
114 up.iotype = UPIO_MEM;
115 up.mapbase = WRPPMC_UART16550_BASE;
116 up.membase = ioremap(up.mapbase, 8);
117 up.irq = WRPPMC_UART16550_IRQ;
118 up.uartclk = WRPPMC_UART16550_CLOCK;
119 up.flags = UPF_SKIP_TEST/* | UPF_BOOT_AUTOCONF */;
120 up.regshift = 0;
121
122 early_serial_setup(&up);
123}
124#endif
125
Mark.Zhan92478572006-06-20 18:15:02 +0800126void __init plat_mem_setup(void)
Mark.Zhana240a462006-05-06 17:04:20 +0800127{
128 extern void wrppmc_time_init(void);
Mark.Zhana240a462006-05-06 17:04:20 +0800129 extern void wrppmc_machine_restart(char *command);
130 extern void wrppmc_machine_halt(void);
131 extern void wrppmc_machine_power_off(void);
132
133 _machine_restart = wrppmc_machine_restart;
134 _machine_halt = wrppmc_machine_halt;
135 pm_power_off = wrppmc_machine_power_off;
136
137 /* Use MIPS Count/Compare Timer */
138 board_time_init = wrppmc_time_init;
Mark.Zhana240a462006-05-06 17:04:20 +0800139
140 /* This makes the operations of 'in/out[bwl]' to the
141 * physical address ( < KSEG0) can work via KSEG1
142 */
143 set_io_port_base(KSEG1);
144
145#ifdef CONFIG_SERIAL_8250
146 wrppmc_setup_serial();
147#endif
148}
149
150const char *get_system_type(void)
151{
152 return "Wind River PPMC (GT64120)";
153}
154
155/*
156 * Initializes basic routines and structures pointers, memory size (as
157 * given by the bios and saves the command line.
158 */
159void __init prom_init(void)
160{
161 mips_machgroup = MACH_GROUP_GALILEO;
162 mips_machtype = MACH_EV64120A;
163
164 add_memory_region(WRPPMC_SDRAM_SCS0_BASE, WRPPMC_SDRAM_SCS0_SIZE, BOOT_MEM_RAM);
165 add_memory_region(WRPPMC_BOOTROM_BASE, WRPPMC_BOOTROM_SIZE, BOOT_MEM_ROM_DATA);
166
167 wrppmc_early_printk("prom_init: GT64120 SDRAM Bank 0: 0x%x - 0x%08lx\n",
168 WRPPMC_SDRAM_SCS0_BASE, (WRPPMC_SDRAM_SCS0_BASE + WRPPMC_SDRAM_SCS0_SIZE));
169}