diff options
Diffstat (limited to 'arch/mips/sni/sniprom.c')
-rw-r--r-- | arch/mips/sni/sniprom.c | 172 |
1 files changed, 131 insertions, 41 deletions
diff --git a/arch/mips/sni/sniprom.c b/arch/mips/sni/sniprom.c index 1213d166f22e..643366eb854a 100644 --- a/arch/mips/sni/sniprom.c +++ b/arch/mips/sni/sniprom.c | |||
@@ -9,9 +9,12 @@ | |||
9 | * Copyright (C) 2005-2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de) | 9 | * Copyright (C) 2005-2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de) |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define DEBUG | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | 15 | #include <linux/init.h> |
14 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/console.h> | ||
15 | 18 | ||
16 | #include <asm/addrspace.h> | 19 | #include <asm/addrspace.h> |
17 | #include <asm/sni.h> | 20 | #include <asm/sni.h> |
@@ -31,14 +34,13 @@ | |||
31 | #define PROM_ENTRY(x) (PROM_VEC + (x)) | 34 | #define PROM_ENTRY(x) (PROM_VEC + (x)) |
32 | 35 | ||
33 | 36 | ||
34 | #undef DEBUG | ||
35 | #ifdef DEBUG | ||
36 | #define DBG_PRINTF(x...) prom_printf(x) | ||
37 | #else | ||
38 | #define DBG_PRINTF(x...) | ||
39 | #endif | ||
40 | |||
41 | static int *(*__prom_putchar)(int) = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR); | 37 | static int *(*__prom_putchar)(int) = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR); |
38 | |||
39 | void prom_putchar(char c) | ||
40 | { | ||
41 | __prom_putchar(c); | ||
42 | } | ||
43 | |||
42 | static char *(*__prom_getenv)(char *) = (char *(*)(char *))PROM_ENTRY(PROM_GETENV); | 44 | static char *(*__prom_getenv)(char *) = (char *(*)(char *))PROM_ENTRY(PROM_GETENV); |
43 | static void (*__prom_get_memconf)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF); | 45 | static void (*__prom_get_memconf)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF); |
44 | 46 | ||
@@ -47,26 +49,6 @@ char *prom_getenv (char *s) | |||
47 | return __prom_getenv(s); | 49 | return __prom_getenv(s); |
48 | } | 50 | } |
49 | 51 | ||
50 | void prom_printf(char *fmt, ...) | ||
51 | { | ||
52 | va_list args; | ||
53 | char ppbuf[1024]; | ||
54 | char *bptr; | ||
55 | |||
56 | va_start(args, fmt); | ||
57 | vsprintf(ppbuf, fmt, args); | ||
58 | |||
59 | bptr = ppbuf; | ||
60 | |||
61 | while (*bptr != 0) { | ||
62 | if (*bptr == '\n') | ||
63 | __prom_putchar('\r'); | ||
64 | |||
65 | __prom_putchar(*bptr++); | ||
66 | } | ||
67 | va_end(args); | ||
68 | } | ||
69 | |||
70 | void __init prom_free_prom_memory(void) | 52 | void __init prom_free_prom_memory(void) |
71 | { | 53 | { |
72 | } | 54 | } |
@@ -93,15 +75,15 @@ static void sni_idprom_dump(void) | |||
93 | { | 75 | { |
94 | int i; | 76 | int i; |
95 | 77 | ||
96 | prom_printf("SNI IDProm dump (first 128byte):\n"); | 78 | pr_debug("SNI IDProm dump:\n"); |
97 | for(i=0;i<128;i++) { | 79 | for (i = 0; i < 256; i++) { |
98 | if (i%16 == 0) | 80 | if (i%16 == 0) |
99 | prom_printf("%04x ", i); | 81 | pr_debug("%04x ", i); |
100 | 82 | ||
101 | prom_printf("%02x ", *(unsigned char *) (SNI_IDPROM_BASE+i)); | 83 | printk("%02x ", *(unsigned char *) (SNI_IDPROM_BASE + i)); |
102 | 84 | ||
103 | if (i%16 == 15) | 85 | if (i % 16 == 15) |
104 | prom_printf("\n"); | 86 | printk("\n"); |
105 | } | 87 | } |
106 | } | 88 | } |
107 | #endif | 89 | #endif |
@@ -118,34 +100,142 @@ static void sni_mem_init(void ) | |||
118 | } memconf[8]; | 100 | } memconf[8]; |
119 | 101 | ||
120 | /* MemSIZE from prom in 16MByte chunks */ | 102 | /* MemSIZE from prom in 16MByte chunks */ |
121 | memsize=*((unsigned char *) SNI_IDPROM_MEMSIZE) * 16; | 103 | memsize = *((unsigned char *) SNI_IDPROM_MEMSIZE) * 16; |
122 | 104 | ||
123 | DBG_PRINTF("IDProm memsize: %lu MByte\n", memsize); | 105 | pr_debug("IDProm memsize: %lu MByte\n", memsize); |
124 | 106 | ||
125 | /* get memory bank layout from prom */ | 107 | /* get memory bank layout from prom */ |
126 | __prom_get_memconf(&memconf); | 108 | __prom_get_memconf(&memconf); |
127 | 109 | ||
128 | DBG_PRINTF("prom_get_mem_conf memory configuration:\n"); | 110 | pr_debug("prom_get_mem_conf memory configuration:\n"); |
129 | for(i=0;i<8 && memconf[i].size;i++) { | 111 | for (i = 0;i < 8 && memconf[i].size; i++) { |
130 | prom_printf("Bank%d: %08x @ %08x\n", i, | 112 | if (sni_brd_type == SNI_BRD_PCI_TOWER || |
113 | sni_brd_type == SNI_BRD_PCI_TOWER_CPLUS) { | ||
114 | if (memconf[i].base >= 0x20000000 && | ||
115 | memconf[i].base < 0x30000000) { | ||
116 | memconf[i].base -= 0x20000000; | ||
117 | } | ||
118 | } | ||
119 | pr_debug("Bank%d: %08x @ %08x\n", i, | ||
131 | memconf[i].size, memconf[i].base); | 120 | memconf[i].size, memconf[i].base); |
132 | add_memory_region(memconf[i].base, memconf[i].size, BOOT_MEM_RAM); | 121 | add_memory_region(memconf[i].base, memconf[i].size, BOOT_MEM_RAM); |
133 | } | 122 | } |
134 | } | 123 | } |
135 | 124 | ||
125 | static void __init sni_console_setup(void) | ||
126 | { | ||
127 | char *ctype; | ||
128 | char *cdev; | ||
129 | char *baud; | ||
130 | int port; | ||
131 | static char options[8]; | ||
132 | |||
133 | cdev = prom_getenv ("console_dev"); | ||
134 | if (strncmp (cdev, "tty", 3) == 0) { | ||
135 | ctype = prom_getenv ("console"); | ||
136 | switch (*ctype) { | ||
137 | default: | ||
138 | case 'l': | ||
139 | port = 0; | ||
140 | baud = prom_getenv("lbaud"); | ||
141 | break; | ||
142 | case 'r': | ||
143 | port = 1; | ||
144 | baud = prom_getenv("rbaud"); | ||
145 | break; | ||
146 | } | ||
147 | if (baud) | ||
148 | strcpy(options, baud); | ||
149 | add_preferred_console("ttyS", port, baud ? options : NULL); | ||
150 | } | ||
151 | } | ||
152 | |||
136 | void __init prom_init(void) | 153 | void __init prom_init(void) |
137 | { | 154 | { |
138 | int argc = fw_arg0; | 155 | int argc = fw_arg0; |
139 | char **argv = (void *)fw_arg1; | 156 | char **argv = (void *)fw_arg1; |
140 | unsigned int sni_brd_type = *(unsigned char *) SNI_IDPROM_BRDTYPE; | ||
141 | int i; | 157 | int i; |
142 | 158 | int cputype; | |
143 | DBG_PRINTF("Found SNI brdtype %02x\n", sni_brd_type); | 159 | |
160 | sni_brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE; | ||
161 | cputype = *(unsigned char *)SNI_IDPROM_CPUTYPE; | ||
162 | switch (sni_brd_type) { | ||
163 | case SNI_BRD_TOWER_OASIC: | ||
164 | switch (cputype) { | ||
165 | case SNI_CPU_M8030: | ||
166 | systype = "RM400-330"; | ||
167 | break; | ||
168 | case SNI_CPU_M8031: | ||
169 | systype = "RM400-430"; | ||
170 | break; | ||
171 | case SNI_CPU_M8037: | ||
172 | systype = "RM400-530"; | ||
173 | break; | ||
174 | case SNI_CPU_M8034: | ||
175 | systype = "RM400-730"; | ||
176 | break; | ||
177 | default: | ||
178 | systype = "RM400-xxx"; | ||
179 | break; | ||
180 | } | ||
181 | break; | ||
182 | case SNI_BRD_MINITOWER: | ||
183 | switch (cputype) { | ||
184 | case SNI_CPU_M8021: | ||
185 | case SNI_CPU_M8043: | ||
186 | systype = "RM400-120"; | ||
187 | break; | ||
188 | case SNI_CPU_M8040: | ||
189 | systype = "RM400-220"; | ||
190 | break; | ||
191 | case SNI_CPU_M8053: | ||
192 | systype = "RM400-225"; | ||
193 | break; | ||
194 | case SNI_CPU_M8050: | ||
195 | systype = "RM400-420"; | ||
196 | break; | ||
197 | default: | ||
198 | systype = "RM400-xxx"; | ||
199 | break; | ||
200 | } | ||
201 | break; | ||
202 | case SNI_BRD_PCI_TOWER: | ||
203 | systype = "RM400-Cxx"; | ||
204 | break; | ||
205 | case SNI_BRD_RM200: | ||
206 | systype = "RM200-xxx"; | ||
207 | break; | ||
208 | case SNI_BRD_PCI_MTOWER: | ||
209 | systype = "RM300-Cxx"; | ||
210 | break; | ||
211 | case SNI_BRD_PCI_DESKTOP: | ||
212 | switch (read_c0_prid() & 0xff00) { | ||
213 | case PRID_IMP_R4600: | ||
214 | case PRID_IMP_R4700: | ||
215 | systype = "RM200-C20"; | ||
216 | break; | ||
217 | case PRID_IMP_R5000: | ||
218 | systype = "RM200-C40"; | ||
219 | break; | ||
220 | default: | ||
221 | systype = "RM200-Cxx"; | ||
222 | break; | ||
223 | } | ||
224 | break; | ||
225 | case SNI_BRD_PCI_TOWER_CPLUS: | ||
226 | systype = "RM400-Exx"; | ||
227 | break; | ||
228 | case SNI_BRD_PCI_MTOWER_CPLUS: | ||
229 | systype = "RM300-Exx"; | ||
230 | break; | ||
231 | } | ||
232 | pr_debug("Found SNI brdtype %02x name %s\n", sni_brd_type,systype); | ||
144 | 233 | ||
145 | #ifdef DEBUG | 234 | #ifdef DEBUG |
146 | sni_idprom_dump(); | 235 | sni_idprom_dump(); |
147 | #endif | 236 | #endif |
148 | sni_mem_init(); | 237 | sni_mem_init(); |
238 | sni_console_setup(); | ||
149 | 239 | ||
150 | /* copy prom cmdline parameters to kernel cmdline */ | 240 | /* copy prom cmdline parameters to kernel cmdline */ |
151 | for (i = 1; i < argc; i++) { | 241 | for (i = 1; i < argc; i++) { |