ssb: Fix the horrible crash of innocent cardbus cards.
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / files / arch / mips / bcm947xx / setup.c
index bd99afaab4d8bd9916270018c2c513fbc2b02b40..85ff1cf813e2d9c76b0641c1ad654ae21a7e87ea 100644 (file)
@@ -2,7 +2,7 @@
  *  Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
  *  Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
  *  Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
- *  Copyright (C) 2006 Michael Buesch
+ *  Copyright (C) 2006-2008 Michael Buesch <mb@bu3sch.de>
  *
  *  This program is free software; you can redistribute  it and/or modify it
  *  under  the terms of  the GNU General  Public License as published by the
@@ -38,6 +38,7 @@
 #include <asm/cfe.h>
 #include <linux/pm.h>
 #include <linux/ssb/ssb.h>
+#include <linux/ssb/ssb_embedded.h>
 
 #include <nvram.h>
 
@@ -55,7 +56,8 @@ static void bcm47xx_machine_restart(char *command)
         */
 
        /* Set the watchdog timer to reset immediately */
-       ssb_chipco_watchdog_timer_set(&ssb.chipco, 1);
+       if (ssb_watchdog_timer_set(&ssb, 1))
+               printk(KERN_EMERG "SSB watchdog-triggered reboot failed!\n");
        while (1)
                cpu_relax();
 }
@@ -64,7 +66,8 @@ static void bcm47xx_machine_halt(void)
 {
        /* Disable interrupts and watchdog and spin forever */
        local_irq_disable();
-       ssb_chipco_watchdog_timer_set(&ssb.chipco, 0);
+       if (ssb_watchdog_timer_set(&ssb, 0))
+               printk(KERN_EMERG "Failed to disable SSB watchdog!\n");
        while (1)
                cpu_relax();
 }
@@ -87,11 +90,6 @@ static void e_aton(char *str, char *dest)
 }
 
 static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
-{
-       // TODO
-}
-
-static void bcm47xx_fill_sprom_nvram(struct ssb_sprom *sprom)
 {
        char *s;
 
@@ -99,49 +97,53 @@ static void bcm47xx_fill_sprom_nvram(struct ssb_sprom *sprom)
 
        sprom->revision = 1;
        if ((s = nvram_get("il0macaddr")))
-               e_aton(s, sprom->r1.il0mac);
+               e_aton(s, sprom->il0mac);
        if ((s = nvram_get("et0macaddr")))
-               e_aton(s, sprom->r1.et0mac);
+               e_aton(s, sprom->et0mac);
        if ((s = nvram_get("et1macaddr")))
-               e_aton(s, sprom->r1.et1mac);
+               e_aton(s, sprom->et1mac);
        if ((s = nvram_get("et0phyaddr")))
-               sprom->r1.et0phyaddr = simple_strtoul(s, NULL, 0);
+               sprom->et0phyaddr = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("et1phyaddr")))
-               sprom->r1.et1phyaddr = simple_strtoul(s, NULL, 0);
+               sprom->et1phyaddr = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("et0mdcport")))
-               sprom->r1.et0mdcport = !!simple_strtoul(s, NULL, 10);
+               sprom->et0mdcport = !!simple_strtoul(s, NULL, 10);
        if ((s = nvram_get("et1mdcport")))
-               sprom->r1.et1mdcport = !!simple_strtoul(s, NULL, 10);
+               sprom->et1mdcport = !!simple_strtoul(s, NULL, 10);
        if ((s = nvram_get("pa0b0")))
-               sprom->r1.pa0b0 = simple_strtoul(s, NULL, 0);
+               sprom->pa0b0 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa0b1")))
-               sprom->r1.pa0b1 = simple_strtoul(s, NULL, 0);
+               sprom->pa0b1 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa0b2")))
-               sprom->r1.pa0b2 = simple_strtoul(s, NULL, 0);
+               sprom->pa0b2 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa1b0")))
-               sprom->r1.pa1b0 = simple_strtoul(s, NULL, 0);
+               sprom->pa1b0 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa1b1")))
-               sprom->r1.pa1b1 = simple_strtoul(s, NULL, 0);
+               sprom->pa1b1 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa1b2")))
-               sprom->r1.pa1b2 = simple_strtoul(s, NULL, 0);
+               sprom->pa1b2 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("wl0gpio0")))
-               sprom->r1.gpio0 = simple_strtoul(s, NULL, 0);
+               sprom->gpio0 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("wl0gpio1")))
-               sprom->r1.gpio1 = simple_strtoul(s, NULL, 0);
+               sprom->gpio1 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("wl0gpio2")))
-               sprom->r1.gpio2 = simple_strtoul(s, NULL, 0);
+               sprom->gpio2 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("wl0gpio3")))
-               sprom->r1.gpio3 = simple_strtoul(s, NULL, 0);
+               sprom->gpio3 = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa0maxpwr")))
-               sprom->r1.maxpwr_bg = simple_strtoul(s, NULL, 0);
+               sprom->maxpwr_bg = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa1maxpwr")))
-               sprom->r1.maxpwr_a = simple_strtoul(s, NULL, 0);
+               sprom->maxpwr_a = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa0itssit")))
-               sprom->r1.itssi_bg = simple_strtoul(s, NULL, 0);
+               sprom->itssi_bg = simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("pa1itssit")))
-               sprom->r1.itssi_a = simple_strtoul(s, NULL, 0);
+               sprom->itssi_a = simple_strtoul(s, NULL, 0);
+       sprom->boardflags_lo = 0;
        if ((s = nvram_get("boardflags")))
-               sprom->r1.boardflags_lo = simple_strtoul(s, NULL, 0);
+               sprom->boardflags_lo = simple_strtoul(s, NULL, 0);
+       sprom->boardflags_hi = 0;
+       if ((s = nvram_get("boardflags2")))
+               sprom->boardflags_hi = simple_strtoul(s, NULL, 0);
 }
 
 static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
@@ -153,7 +155,12 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariant
                iv->boardinfo.type = (u16)simple_strtoul(s, NULL, 0);
        if ((s = nvram_get("boardrev")))
                iv->boardinfo.rev = (u16)simple_strtoul(s, NULL, 0);
+
        bcm47xx_fill_sprom(&iv->sprom);
+
+       if ((s = nvram_get("cardbus")))
+               iv->has_cardbus_slot = !!simple_strtoul(s, NULL, 10);
+
        return 0;
 }
 
@@ -171,10 +178,6 @@ void __init plat_mem_setup(void)
        }
        mcore = &ssb.mipscore;
 
-       /* FIXME: the nvram init depends on the ssb being fully initializes,
-        * can't use the fill_sprom callback yet! */
-       bcm47xx_fill_sprom_nvram(&ssb.sprom);
-       
        s = nvram_get("kernel_args");
        if (s && !strncmp(s, "console=ttyS1", 13)) {
                struct ssb_serial_port port;
@@ -193,7 +196,7 @@ void __init plat_mem_setup(void)
                memset(&s, 0, sizeof(s));
                s.line = i;
                s.membase = port->regs;
-               s.irq = port->irq + 2;//FIXME?
+               s.irq = port->irq + 2;
                s.uartclk = port->baud_base;
                s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
                s.iotype = SERIAL_IO_MEM;