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)
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/string.h>
15 #include <linux/console.h>
17 #include <asm/addrspace.h>
19 #include <asm/mipsprom.h>
20 #include <asm/bootinfo.h>
22 /* special SNI prom calls */
24 * This does not exist in all proms - SINIX compares
25 * the prom env variable "version" against "2.0008"
26 * or greater. If lesser it tries to probe interesting
29 #define PROM_GET_MEMCONF 58
31 #define PROM_VEC (u64 *)CKSEG1ADDR(0x1fc00000)
32 #define PROM_ENTRY(x) (PROM_VEC + (x))
37 #define DBG_PRINTF(x...) prom_printf(x)
39 #define DBG_PRINTF(x...)
42 static int *(*__prom_putchar)(int) = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR);
43 static char *(*__prom_getenv)(char *) = (char *(*)(char *))PROM_ENTRY(PROM_GETENV);
44 static void (*__prom_get_memconf)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF);
46 char *prom_getenv (char *s)
48 return __prom_getenv(s);
51 void prom_printf(char *fmt, ...)
58 vsprintf(ppbuf, fmt, args);
66 __prom_putchar(*bptr++);
71 void __init prom_free_prom_memory(void)
76 * /proc/cpuinfo system type
79 static const char *systype = "Unknown";
80 const char *get_system_type(void)
85 #define SNI_IDPROM_BASE 0xbff00000
86 #define SNI_IDPROM_MEMSIZE (SNI_IDPROM_BASE+0x28) /* Memsize in 16MB quantities */
87 #define SNI_IDPROM_BRDTYPE (SNI_IDPROM_BASE+0x29) /* Board Type */
88 #define SNI_IDPROM_CPUTYPE (SNI_IDPROM_BASE+0x30) /* CPU Type */
90 #define SNI_IDPROM_SIZE 0x1000
93 static void sni_idprom_dump(void)
97 prom_printf("SNI IDProm dump:\n");
98 for (i = 0; i < 256; i++) {
100 prom_printf("%04x ", i);
102 prom_printf("%02x ", *(unsigned char *) (SNI_IDPROM_BASE + i));
110 static void sni_mem_init(void )
121 /* MemSIZE from prom in 16MByte chunks */
122 memsize = *((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
124 DBG_PRINTF("IDProm memsize: %lu MByte\n", memsize);
126 /* get memory bank layout from prom */
127 __prom_get_memconf(&memconf);
129 DBG_PRINTF("prom_get_mem_conf memory configuration:\n");
130 for (i = 0;i < 8 && memconf[i].size; i++) {
131 if (sni_brd_type == SNI_BRD_PCI_TOWER ||
132 sni_brd_type == SNI_BRD_PCI_TOWER_CPLUS) {
133 if (memconf[i].base >= 0x20000000 &&
134 memconf[i].base < 0x30000000) {
135 memconf[i].base -= 0x20000000;
138 DBG_PRINTF("Bank%d: %08x @ %08x\n", i,
139 memconf[i].size, memconf[i].base);
140 add_memory_region(memconf[i].base, memconf[i].size, BOOT_MEM_RAM);
144 static void __init sni_console_setup(void)
150 static char options[8];
152 cdev = prom_getenv ("console_dev");
153 if (strncmp (cdev, "tty", 3) == 0) {
154 ctype = prom_getenv ("console");
159 baud = prom_getenv("lbaud");
163 baud = prom_getenv("rbaud");
167 strcpy(options, baud);
168 add_preferred_console("ttyS", port, baud ? options : NULL);
172 void __init prom_init(void)
175 char **argv = (void *)fw_arg1;
179 sni_brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE;
180 cputype = *(unsigned char *)SNI_IDPROM_CPUTYPE;
181 switch (sni_brd_type) {
182 case SNI_BRD_TOWER_OASIC:
185 systype = "RM400-330";
188 systype = "RM400-430";
191 systype = "RM400-530";
194 systype = "RM400-730";
197 systype = "RM400-xxx";
201 case SNI_BRD_MINITOWER:
205 systype = "RM400-120";
208 systype = "RM400-220";
211 systype = "RM400-225";
214 systype = "RM400-420";
217 systype = "RM400-xxx";
221 case SNI_BRD_PCI_TOWER:
222 systype = "RM400-Cxx";
225 systype = "RM200-xxx";
227 case SNI_BRD_PCI_MTOWER:
228 systype = "RM300-Cxx";
230 case SNI_BRD_PCI_DESKTOP:
231 switch (read_c0_prid() & 0xff00) {
234 systype = "RM200-C20";
237 systype = "RM200-C40";
240 systype = "RM200-Cxx";
244 case SNI_BRD_PCI_TOWER_CPLUS:
245 systype = "RM400-Exx";
247 case SNI_BRD_PCI_MTOWER_CPLUS:
248 systype = "RM300-Exx";
251 DBG_PRINTF("Found SNI brdtype %02x name %s\n", sni_brd_type,systype);
259 /* copy prom cmdline parameters to kernel cmdline */
260 for (i = 1; i < argc; i++) {
261 strcat(arcs_cmdline, argv[i]);
263 strcat(arcs_cmdline, " ");