]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/mips/txx9/generic/setup_tx4927.c
MIPS: TXx9: Add board_be_init for TX4927/TX4938
[linux-2.6-omap-h63xx.git] / arch / mips / txx9 / generic / setup_tx4927.c
index 0840ef930e40fede1577d49e7d5082625c5ff58b..c4248cbbd84a923a4e3fbf7292601b372b380a2d 100644 (file)
 #include <linux/ioport.h>
 #include <linux/delay.h>
 #include <linux/param.h>
+#include <linux/ptrace.h>
 #include <linux/mtd/physmap.h>
+#include <asm/reboot.h>
+#include <asm/traps.h>
 #include <asm/txx9irq.h>
 #include <asm/txx9tmr.h>
 #include <asm/txx9pio.h>
 
 static void __init tx4927_wdr_init(void)
 {
+       /* report watchdog reset status */
+       if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_WDRST)
+               pr_warning("Watchdog reset detected at 0x%lx\n",
+                          read_c0_errorepc());
        /* clear WatchDogReset (W1C) */
        tx4927_ccfg_set(TX4927_CCFG_WDRST);
        /* do reset on watchdog */
@@ -34,6 +41,47 @@ void __init tx4927_wdt_init(void)
        txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL);
 }
 
+static void tx4927_machine_restart(char *command)
+{
+       local_irq_disable();
+       pr_emerg("Rebooting (with %s watchdog reset)...\n",
+                (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_WDREXEN) ?
+                "external" : "internal");
+       /* clear watchdog status */
+       tx4927_ccfg_set(TX4927_CCFG_WDRST);     /* W1C */
+       txx9_wdt_now(TX4927_TMR_REG(2) & 0xfffffffffULL);
+       while (!(____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_WDRST))
+               ;
+       mdelay(10);
+       if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_WDREXEN) {
+               pr_emerg("Rebooting (with internal watchdog reset)...\n");
+               /* External WDRST failed.  Do internal watchdog reset */
+               tx4927_ccfg_clear(TX4927_CCFG_WDREXEN);
+       }
+       /* fallback */
+       (*_machine_halt)();
+}
+
+void show_registers(struct pt_regs *regs);
+static int tx4927_be_handler(struct pt_regs *regs, int is_fixup)
+{
+       int data = regs->cp0_cause & 4;
+       console_verbose();
+       pr_err("%cBE exception at %#lx\n", data ? 'D' : 'I', regs->cp0_epc);
+       pr_err("ccfg:%llx, toea:%llx\n",
+              (unsigned long long)____raw_readq(&tx4927_ccfgptr->ccfg),
+              (unsigned long long)____raw_readq(&tx4927_ccfgptr->toea));
+#ifdef CONFIG_PCI
+       tx4927_report_pcic_status();
+#endif
+       show_registers(regs);
+       panic("BusError!");
+}
+static void __init tx4927_be_init(void)
+{
+       board_be_handler = tx4927_be_handler;
+}
+
 static struct resource tx4927_sdram_resource[4];
 
 void __init tx4927_setup(void)
@@ -169,6 +217,9 @@ void __init tx4927_setup(void)
        txx9_gpio_init(TX4927_PIO_REG & 0xfffffffffULL, 0, TX4927_NUM_PIO);
        __raw_writel(0, &tx4927_pioptr->maskcpu);
        __raw_writel(0, &tx4927_pioptr->maskext);
+
+       _machine_restart = tx4927_machine_restart;
+       board_be_init = tx4927_be_init;
 }
 
 void __init tx4927_time_init(unsigned int tmrnr)