]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/sparc64/kernel/sstate.c
[ARM] MX3: Use ioremap wrapper to map SoC devices nonshared
[linux-2.6-omap-h63xx.git] / arch / sparc64 / kernel / sstate.c
index 5b6e75b7f0526dadf4935ace3ed23d0f2353a834..8cdbe5946b43eb6afde994aea6e36e47c58f51b6 100644 (file)
@@ -1,14 +1,15 @@
 /* sstate.c: System soft state support.
  *
- * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
+ * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net>
  */
 
 #include <linux/kernel.h>
 #include <linux/notifier.h>
+#include <linux/reboot.h>
 #include <linux/init.h>
 
 #include <asm/hypervisor.h>
-#include <asm/sstate.h>
+#include <asm/spitfire.h>
 #include <asm/oplib.h>
 #include <asm/head.h>
 #include <asm/io.h>
@@ -50,31 +51,34 @@ static const char rebooting_msg[32] __attribute__((aligned(32))) =
 static const char panicing_msg[32] __attribute__((aligned(32))) =
        "Linux panicing";
 
-void sstate_booting(void)
+static int sstate_reboot_call(struct notifier_block *np, unsigned long type, void *_unused)
 {
-       do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg);
-}
+       const char *msg;
 
-void sstate_running(void)
-{
-       do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg);
-}
+       switch (type) {
+       case SYS_DOWN:
+       default:
+               msg = rebooting_msg;
+               break;
 
-void sstate_halt(void)
-{
-       do_set_sstate(HV_SOFT_STATE_TRANSITION, halting_msg);
-}
+       case SYS_HALT:
+               msg = halting_msg;
+               break;
 
-void sstate_poweroff(void)
-{
-       do_set_sstate(HV_SOFT_STATE_TRANSITION, poweroff_msg);
-}
+       case SYS_POWER_OFF:
+               msg = poweroff_msg;
+               break;
+       }
 
-void sstate_reboot(void)
-{
-       do_set_sstate(HV_SOFT_STATE_TRANSITION, rebooting_msg);
+       do_set_sstate(HV_SOFT_STATE_TRANSITION, msg);
+
+       return NOTIFY_OK;
 }
 
+static struct notifier_block sstate_reboot_notifier = {
+       .notifier_call = sstate_reboot_call,
+};
+
 static int sstate_panic_event(struct notifier_block *n, unsigned long event, void *ptr)
 {
        do_set_sstate(HV_SOFT_STATE_TRANSITION, panicing_msg);
@@ -87,18 +91,37 @@ static struct notifier_block sstate_panic_block = {
        .priority       =       INT_MAX,
 };
 
-void __init sun4v_sstate_init(void)
+static int __init sstate_init(void)
 {
        unsigned long major, minor;
 
+       if (tlb_type != hypervisor)
+               return 0;
+
        major = 1;
        minor = 0;
        if (sun4v_hvapi_register(HV_GRP_SOFT_STATE, major, &minor))
-               return;
+               return 0;
 
        hv_supports_soft_state = 1;
 
        prom_sun4v_guest_soft_state();
+
+       do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg);
+
        atomic_notifier_chain_register(&panic_notifier_list,
                                       &sstate_panic_block);
+       register_reboot_notifier(&sstate_reboot_notifier);
+
+       return 0;
 }
+
+core_initcall(sstate_init);
+
+static int __init sstate_running(void)
+{
+       do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg);
+       return 0;
+}
+
+late_initcall(sstate_running);