2 * Big Endian PROM code for SNI RM machines
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
8 * Copyright (C) 2005-2006 Florian Lohoff (flo@rfc822.org)
9 * Copyright (C) 2005-2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/string.h>
17 #include <linux/console.h>
19 #include <asm/addrspace.h>
21 #include <asm/mipsprom.h>
22 #include <asm/mipsregs.h>
23 #include <asm/bootinfo.h>
25 /* special SNI prom calls */
27 * This does not exist in all proms - SINIX compares
28 * the prom env variable "version" against "2.0008"
29 * or greater. If lesser it tries to probe interesting
32 #define PROM_GET_MEMCONF 58
34 #define PROM_VEC (u64 *)CKSEG1ADDR(0x1fc00000)
35 #define PROM_ENTRY(x) (PROM_VEC + (x))
38 static int *(*__prom_putchar
)(int) = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR
);
40 void prom_putchar(char c
)
45 static char *(*__prom_getenv
)(char *) = (char *(*)(char *))PROM_ENTRY(PROM_GETENV
);
46 static void (*__prom_get_memconf
)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF
);
48 char *prom_getenv(char *s
)
50 return __prom_getenv(s
);
53 void __init
prom_free_prom_memory(void)
58 * /proc/cpuinfo system type
61 static const char *systype
= "Unknown";
62 const char *get_system_type(void)
67 #define SNI_IDPROM_BASE 0xbff00000
68 #define SNI_IDPROM_MEMSIZE (SNI_IDPROM_BASE+0x28) /* Memsize in 16MB quantities */
69 #define SNI_IDPROM_BRDTYPE (SNI_IDPROM_BASE+0x29) /* Board Type */
70 #define SNI_IDPROM_CPUTYPE (SNI_IDPROM_BASE+0x30) /* CPU Type */
72 #define SNI_IDPROM_SIZE 0x1000
75 static void __init
sni_idprom_dump(void)
79 pr_debug("SNI IDProm dump:\n");
80 for (i
= 0; i
< 256; i
++) {
84 printk("%02x ", *(unsigned char *) (SNI_IDPROM_BASE
+ i
));
92 static void __init
sni_mem_init(void )
103 /* MemSIZE from prom in 16MByte chunks */
104 memsize
= *((unsigned char *) SNI_IDPROM_MEMSIZE
) * 16;
106 pr_debug("IDProm memsize: %lu MByte\n", memsize
);
108 /* get memory bank layout from prom */
109 __prom_get_memconf(&memconf
);
111 pr_debug("prom_get_mem_conf memory configuration:\n");
112 for (i
= 0;i
< 8 && memconf
[i
].size
; i
++) {
113 if (sni_brd_type
== SNI_BRD_PCI_TOWER
||
114 sni_brd_type
== SNI_BRD_PCI_TOWER_CPLUS
) {
115 if (memconf
[i
].base
>= 0x20000000 &&
116 memconf
[i
].base
< 0x30000000) {
117 memconf
[i
].base
-= 0x20000000;
120 pr_debug("Bank%d: %08x @ %08x\n", i
,
121 memconf
[i
].size
, memconf
[i
].base
);
122 add_memory_region(memconf
[i
].base
, memconf
[i
].size
, BOOT_MEM_RAM
);
126 static void __init
sni_console_setup(void)
132 static char options
[8];
134 cdev
= prom_getenv("console_dev");
135 if (strncmp (cdev
, "tty", 3) == 0) {
136 ctype
= prom_getenv("console");
141 baud
= prom_getenv("lbaud");
145 baud
= prom_getenv("rbaud");
149 strcpy(options
, baud
);
150 if (strncmp (cdev
, "tty552", 6) == 0)
151 add_preferred_console("ttyS", port
, baud
? options
: NULL
);
153 add_preferred_console("ttySC", port
, baud
? options
: NULL
);
157 void __init
prom_init(void)
160 char **argv
= (void *)fw_arg1
;
164 sni_brd_type
= *(unsigned char *)SNI_IDPROM_BRDTYPE
;
165 cputype
= *(unsigned char *)SNI_IDPROM_CPUTYPE
;
166 switch (sni_brd_type
) {
167 case SNI_BRD_TOWER_OASIC
:
170 systype
= "RM400-330";
173 systype
= "RM400-430";
176 systype
= "RM400-530";
179 systype
= "RM400-730";
182 systype
= "RM400-xxx";
186 case SNI_BRD_MINITOWER
:
190 systype
= "RM400-120";
193 systype
= "RM400-220";
196 systype
= "RM400-225";
199 systype
= "RM400-420";
202 systype
= "RM400-xxx";
206 case SNI_BRD_PCI_TOWER
:
207 systype
= "RM400-Cxx";
210 systype
= "RM200-xxx";
212 case SNI_BRD_PCI_MTOWER
:
213 systype
= "RM300-Cxx";
215 case SNI_BRD_PCI_DESKTOP
:
216 switch (read_c0_prid() & 0xff00) {
219 systype
= "RM200-C20";
222 systype
= "RM200-C40";
225 systype
= "RM200-Cxx";
229 case SNI_BRD_PCI_TOWER_CPLUS
:
230 systype
= "RM400-Exx";
232 case SNI_BRD_PCI_MTOWER_CPLUS
:
233 systype
= "RM300-Exx";
236 pr_debug("Found SNI brdtype %02x name %s\n", sni_brd_type
, systype
);
244 /* copy prom cmdline parameters to kernel cmdline */
245 for (i
= 1; i
< argc
; i
++) {
246 strcat(arcs_cmdline
, argv
[i
]);
248 strcat(arcs_cmdline
, " ");