]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/mips/txx9/generic/setup_tx4938.c
MIPS: TXx9: Default machine_restart using watchdog reset
[linux-2.6-omap-h63xx.git] / arch / mips / txx9 / generic / setup_tx4938.c
index 630a7aac61f6c4dd219e1b86e001f6cdbf8d824e..4fbc85a8597fafe2db012b05269c77c9e066a8be 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/param.h>
 #include <linux/mtd/physmap.h>
+#include <asm/reboot.h>
 #include <asm/txx9irq.h>
 #include <asm/txx9tmr.h>
 #include <asm/txx9pio.h>
 
 static void __init tx4938_wdr_init(void)
 {
+       /* report watchdog reset status */
+       if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_WDRST)
+               pr_warning("Watchdog reset detected at 0x%lx\n",
+                          read_c0_errorepc());
        /* clear WatchDogReset (W1C) */
        tx4938_ccfg_set(TX4938_CCFG_WDRST);
        /* do reset on watchdog */
@@ -34,6 +39,27 @@ void __init tx4938_wdt_init(void)
        txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL);
 }
 
+static void tx4938_machine_restart(char *command)
+{
+       local_irq_disable();
+       pr_emerg("Rebooting (with %s watchdog reset)...\n",
+                (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_WDREXEN) ?
+                "external" : "internal");
+       /* clear watchdog status */
+       tx4938_ccfg_set(TX4938_CCFG_WDRST);     /* W1C */
+       txx9_wdt_now(TX4938_TMR_REG(2) & 0xfffffffffULL);
+       while (!(____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_WDRST))
+               ;
+       mdelay(10);
+       if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_WDREXEN) {
+               pr_emerg("Rebooting (with internal watchdog reset)...\n");
+               /* External WDRST failed.  Do internal watchdog reset */
+               tx4938_ccfg_clear(TX4938_CCFG_WDREXEN);
+       }
+       /* fallback */
+       (*_machine_halt)();
+}
+
 static struct resource tx4938_sdram_resource[4];
 static struct resource tx4938_sram_resource;
 
@@ -229,6 +255,8 @@ void __init tx4938_setup(void)
                                   TX4938_CLKCTR_ETH1CKD);
                }
        }
+
+       _machine_restart = tx4938_machine_restart;
 }
 
 void __init tx4938_time_init(unsigned int tmrnr)