Merge git://git.infradead.org/battery-2.6
[pandora-kernel.git] / arch / mips / sni / sniprom.c
index 6a44bbf..eff4b89 100644 (file)
@@ -9,6 +9,8 @@
  * Copyright (C) 2005-2006 Thomas Bogendoerfer (tsbogend@alpha.franken.de)
  */
 
+#define DEBUG
+
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/string.h>
@@ -17,6 +19,7 @@
 #include <asm/addrspace.h>
 #include <asm/sni.h>
 #include <asm/mipsprom.h>
+#include <asm/mipsregs.h>
 #include <asm/bootinfo.h>
 
 /* special SNI prom calls */
 #define PROM_ENTRY(x)          (PROM_VEC + (x))
 
 
-#define DEBUG
-#ifdef DEBUG
-#define DBG_PRINTF(x...)     prom_printf(x)
-#else
-#define DBG_PRINTF(x...)
-#endif
-
 static int *(*__prom_putchar)(int)        = (int *(*)(int))PROM_ENTRY(PROM_PUTCHAR);
-static char *(*__prom_getenv)(char *)     = (char *(*)(char *))PROM_ENTRY(PROM_GETENV);
-static void (*__prom_get_memconf)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF);
 
-char *prom_getenv (char *s)
+void prom_putchar(char c)
 {
-       return __prom_getenv(s);
+       __prom_putchar(c);
 }
 
-void prom_printf(char *fmt, ...)
-{
-       va_list args;
-       char ppbuf[1024];
-       char *bptr;
-
-       va_start(args, fmt);
-       vsprintf(ppbuf, fmt, args);
-
-       bptr = ppbuf;
-
-       while (*bptr != 0) {
-               if (*bptr == '\n')
-                       __prom_putchar('\r');
+static char *(*__prom_getenv)(char *)     = (char *(*)(char *))PROM_ENTRY(PROM_GETENV);
+static void (*__prom_get_memconf)(void *) = (void (*)(void *))PROM_ENTRY(PROM_GET_MEMCONF);
 
-               __prom_putchar(*bptr++);
-       }
-       va_end(args);
+char *prom_getenv(char *s)
+{
+       return __prom_getenv(s);
 }
 
 void __init prom_free_prom_memory(void)
@@ -90,24 +72,24 @@ const char *get_system_type(void)
 #define SNI_IDPROM_SIZE        0x1000
 
 #ifdef DEBUG
-static void sni_idprom_dump(void)
+static void __init sni_idprom_dump(void)
 {
        int     i;
 
-       prom_printf("SNI IDProm dump:\n");
+       pr_debug("SNI IDProm dump:\n");
        for (i = 0; i < 256; i++) {
                if (i%16 == 0)
-                       prom_printf("%04x ", i);
+                       pr_debug("%04x ", i);
 
-               prom_printf("%02x ", *(unsigned char *) (SNI_IDPROM_BASE + i));
+               printk("%02x ", *(unsigned char *) (SNI_IDPROM_BASE + i));
 
                if (i % 16 == 15)
-                       prom_printf("\n");
+                       printk("\n");
        }
 }
 #endif
 
-static void sni_mem_init(void )
+static void __init sni_mem_init(void )
 {
        int i, memsize;
        struct membank {
@@ -121,12 +103,12 @@ static void sni_mem_init(void )
        /* MemSIZE from prom in 16MByte chunks */
        memsize = *((unsigned char *) SNI_IDPROM_MEMSIZE) * 16;
 
-       DBG_PRINTF("IDProm memsize: %lu MByte\n", memsize);
+       pr_debug("IDProm memsize: %lu MByte\n", memsize);
 
        /* get memory bank layout from prom */
        __prom_get_memconf(&memconf);
 
-       DBG_PRINTF("prom_get_mem_conf memory configuration:\n");
+       pr_debug("prom_get_mem_conf memory configuration:\n");
        for (i = 0;i < 8 && memconf[i].size; i++) {
                if (sni_brd_type == SNI_BRD_PCI_TOWER ||
                    sni_brd_type == SNI_BRD_PCI_TOWER_CPLUS) {
@@ -135,7 +117,7 @@ static void sni_mem_init(void )
                                memconf[i].base -= 0x20000000;
                        }
        }
-               DBG_PRINTF("Bank%d: %08x @ %08x\n", i,
+               pr_debug("Bank%d: %08x @ %08x\n", i,
                        memconf[i].size, memconf[i].base);
                add_memory_region(memconf[i].base, memconf[i].size, BOOT_MEM_RAM);
        }
@@ -149,9 +131,9 @@ static void __init sni_console_setup(void)
        int port;
        static char options[8];
 
-       cdev = prom_getenv ("console_dev");
+       cdev = prom_getenv("console_dev");
        if (strncmp (cdev, "tty", 3) == 0) {
-               ctype = prom_getenv ("console");
+               ctype = prom_getenv("console");
                switch (*ctype) {
                default:
                case 'l':
@@ -165,7 +147,10 @@ static void __init sni_console_setup(void)
                }
                if (baud)
                        strcpy(options, baud);
-               add_preferred_console("ttyS", port, baud ? options : NULL);
+               if (strncmp (cdev, "tty552", 6) == 0)
+                       add_preferred_console("ttyS", port, baud ? options : NULL);
+               else
+                       add_preferred_console("ttySC", port, baud ? options : NULL);
        }
 }
 
@@ -248,7 +233,7 @@ void __init prom_init(void)
                systype = "RM300-Exx";
                break;
        }
-       DBG_PRINTF("Found SNI brdtype %02x name %s\n", sni_brd_type,systype);
+       pr_debug("Found SNI brdtype %02x name %s\n", sni_brd_type, systype);
 
 #ifdef DEBUG
        sni_idprom_dump();