powerpc/powernv: Hookup reboot and poweroff functions
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 19 Sep 2011 18:28:03 +0000 (18:28 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 20 Sep 2011 06:09:55 +0000 (16:09 +1000)
This calls the respective HAL functions, and spin on hal_poll_event()
to ensure the HAL has a chance to communicate with the FSP to trigger
the reboot or shutdown operation

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/powernv/setup.c

index 07ba1ecd1807e9aab058ea119f06df6aff38f63c..0fac0a6c951ead5b664d01e3835acd1c76b0be4f 100644 (file)
@@ -83,19 +83,39 @@ static void pnv_show_cpuinfo(struct seq_file *m)
        of_node_put(root);
 }
 
-static void pnv_restart(char *cmd)
+static void  __noreturn pnv_restart(char *cmd)
 {
-       for (;;);
+       long rc = OPAL_BUSY;
+
+       while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
+               rc = opal_cec_reboot();
+               if (rc == OPAL_BUSY_EVENT)
+                       opal_poll_events(NULL);
+               else
+                       mdelay(10);
+       }
+       for (;;)
+               opal_poll_events(NULL);
 }
 
-static void pnv_power_off(void)
+static void __noreturn pnv_power_off(void)
 {
-       for (;;);
+       long rc = OPAL_BUSY;
+
+       while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
+               rc = opal_cec_power_down(0);
+               if (rc == OPAL_BUSY_EVENT)
+                       opal_poll_events(NULL);
+               else
+                       mdelay(10);
+       }
+       for (;;)
+               opal_poll_events(NULL);
 }
 
-static void pnv_halt(void)
+static void __noreturn pnv_halt(void)
 {
-       for (;;);
+       pnv_power_off();
 }
 
 static unsigned long __init pnv_get_boot_time(void)