[MIPS] TXx9: Cleanup restart/halt/power_off
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Wed, 23 Jul 2008 15:25:17 +0000 (00:25 +0900)
committerRalf Baechle <ralf@linux-mips.org>
Wed, 30 Jul 2008 20:54:38 +0000 (21:54 +0100)
Unify machine_restart/machine_halt/pm_power_off and add fallback
machine_halt routine.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/txx9/generic/setup.c
arch/mips/txx9/jmr3927/setup.c
arch/mips/txx9/rbtx4927/setup.c
arch/mips/txx9/rbtx4938/setup.c

index 4fbd7baa7037284b442eb5dad961fb94e4ccf5f0..82272e85a04212c31b5cf207be06661bf166c7aa 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/gpio.h>
 #include <asm/bootinfo.h>
 #include <asm/time.h>
+#include <asm/reboot.h>
 #include <asm/txx9/generic.h>
 #include <asm/txx9/pci.h>
 #ifdef CONFIG_CPU_TX49XX
@@ -188,6 +189,25 @@ char * __init prom_getcmdline(void)
        return &(arcs_cmdline[0]);
 }
 
+static void __noreturn txx9_machine_halt(void)
+{
+       local_irq_disable();
+       clear_c0_status(ST0_IM);
+       while (1) {
+               if (cpu_wait) {
+                       (*cpu_wait)();
+                       if (cpu_has_counter) {
+                               /*
+                                * Clear counter interrupt while it
+                                * breaks WAIT instruction even if
+                                * masked.
+                                */
+                               write_c0_compare(0);
+                       }
+               }
+       }
+}
+
 /* wrappers */
 void __init plat_mem_setup(void)
 {
@@ -195,6 +215,12 @@ void __init plat_mem_setup(void)
        ioport_resource.end = ~0UL;     /* no limit */
        iomem_resource.start = 0;
        iomem_resource.end = ~0UL;      /* no limit */
+
+       /* fallback restart/halt routines */
+       _machine_restart = (void (*)(char *))txx9_machine_halt;
+       _machine_halt = txx9_machine_halt;
+       pm_power_off = txx9_machine_halt;
+
 #ifdef CONFIG_PCI
        pcibios_plat_setup = txx9_pcibios_setup;
 #endif
index 7c16c402ff60f50d367f4a509c201828f4589739..fa0503efc840528fbc144f31bedf34ac479d8d9c 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/types.h>
 #include <linux/ioport.h>
 #include <linux/delay.h>
-#include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #ifdef CONFIG_SERIAL_TXX9
 #include <asm/txx9/jmr3927.h>
 #include <asm/mipsregs.h>
 
-extern void puts(const char *cp);
-
 /* don't enable - see errata */
 static int jmr3927_ccfg_toeon;
 
-static inline void do_reset(void)
+static void jmr3927_machine_restart(char *command)
 {
+       local_irq_disable();
 #if 1  /* Resetting PCI bus */
        jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
        jmr3927_ioc_reg_out(JMR3927_IOC_RESET_PCI, JMR3927_IOC_RESET_ADDR);
@@ -61,25 +59,8 @@ static inline void do_reset(void)
        jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
 #endif
        jmr3927_ioc_reg_out(JMR3927_IOC_RESET_CPU, JMR3927_IOC_RESET_ADDR);
-}
-
-static void jmr3927_machine_restart(char *command)
-{
-       local_irq_disable();
-       puts("Rebooting...");
-       do_reset();
-}
-
-static void jmr3927_machine_halt(void)
-{
-       puts("JMR-TX3927 halted.\n");
-       while (1);
-}
-
-static void jmr3927_machine_power_off(void)
-{
-       puts("JMR-TX3927 halted. Please turn off the power.\n");
-       while (1);
+       /* fallback */
+       (*_machine_halt)();
 }
 
 static void __init jmr3927_time_init(void)
@@ -102,8 +83,6 @@ static void __init jmr3927_mem_setup(void)
        set_io_port_base(JMR3927_PORT_BASE + JMR3927_PCIIO);
 
        _machine_restart = jmr3927_machine_restart;
-       _machine_halt = jmr3927_machine_halt;
-       pm_power_off = jmr3927_machine_power_off;
 
        /* Reboot on panic */
        panic_timeout = 180;
index 65b72247d320f01115965ee6969978c93d1a0182..54c33c3e9f7dba9af2bf8c6ca9c68d101e5faf46 100644 (file)
 #include <linux/types.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
-#include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <asm/io.h>
-#include <asm/processor.h>
 #include <asm/reboot.h>
 #include <asm/txx9/generic.h>
 #include <asm/txx9/pci.h>
@@ -167,17 +165,8 @@ static void __init rbtx4937_arch_init(void)
 #define rbtx4937_arch_init NULL
 #endif /* CONFIG_PCI */
 
-static void __noreturn wait_forever(void)
-{
-       while (1)
-               if (cpu_wait)
-                       (*cpu_wait)();
-}
-
 static void toshiba_rbtx4927_restart(char *command)
 {
-       printk(KERN_NOTICE "System Rebooting...\n");
-
        /* enable the s/w reset register */
        writeb(1, rbtx4927_softresetlock_addr);
 
@@ -188,24 +177,8 @@ static void toshiba_rbtx4927_restart(char *command)
        /* do a s/w reset */
        writeb(1, rbtx4927_softreset_addr);
 
-       /* do something passive while waiting for reset */
-       local_irq_disable();
-       wait_forever();
-       /* no return */
-}
-
-static void toshiba_rbtx4927_halt(void)
-{
-       printk(KERN_NOTICE "System Halted\n");
-       local_irq_disable();
-       wait_forever();
-       /* no return */
-}
-
-static void toshiba_rbtx4927_power_off(void)
-{
-       toshiba_rbtx4927_halt();
-       /* no return */
+       /* fallback */
+       (*_machine_halt)();
 }
 
 static void __init rbtx4927_clock_init(void);
@@ -233,8 +206,6 @@ static void __init rbtx4927_mem_setup(void)
        }
 
        _machine_restart = toshiba_rbtx4927_restart;
-       _machine_halt = toshiba_rbtx4927_halt;
-       pm_power_off = toshiba_rbtx4927_power_off;
 
 #ifdef CONFIG_PCI
        txx9_alloc_pci_controller(&txx9_primary_pcic,
index 4454b7901cd351a4d1e904e058f27c946f5193ee..e1177b3b91033f50bf4523a64c9a5e0828101c3a 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/console.h>
-#include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 
 #include <asm/txx9/spi.h>
 #include <asm/txx9pio.h>
 
-static void rbtx4938_machine_halt(void)
-{
-        printk(KERN_NOTICE "System Halted\n");
-       local_irq_disable();
-
-       while (1)
-               __asm__(".set\tmips3\n\t"
-                       "wait\n\t"
-                       ".set\tmips0");
-}
-
-static void rbtx4938_machine_power_off(void)
-{
-        rbtx4938_machine_halt();
-        /* no return */
-}
-
 static void rbtx4938_machine_restart(char *command)
 {
        local_irq_disable();
-
-       printk("Rebooting...");
        writeb(1, rbtx4938_softresetlock_addr);
        writeb(1, rbtx4938_sfvol_addr);
        writeb(1, rbtx4938_softreset_addr);
-       while(1)
-               ;
+       /* fallback */
+       (*_machine_halt)();
 }
 
 static void __init rbtx4938_pci_setup(void)
@@ -263,8 +243,6 @@ static void __init rbtx4938_mem_setup(void)
                printk("request resource for fpga failed\n");
 
        _machine_restart = rbtx4938_machine_restart;
-       _machine_halt = rbtx4938_machine_halt;
-       pm_power_off = rbtx4938_machine_power_off;
 
        writeb(0xff, rbtx4938_led_addr);
        printk(KERN_INFO "RBTX4938 --- FPGA(Rev %02x) DIPSW:%02x,%02x\n",