Support PSCI reboot/shutdown
authorRobin Murphy <Robin.Murphy@arm.com>
Wed, 13 Aug 2014 10:19:53 +0000 (11:19 +0100)
committerLiviu Dudau <Liviu.Dudau@arm.com>
Wed, 13 Aug 2014 16:34:16 +0000 (17:34 +0100)
Hack in the extra function IDs in lieu of 'proper' PSCi 0.2 support.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
arch/arm64/boot/dts/juno.dts
arch/arm64/kernel/psci.c

index 34a7b92..224d3c4 100644 (file)
                cpu_off = <0x84000002>;
                cpu_on = <0xc4000003>;
                migrate = <0xc4000005>;
+               sys_poweroff = <0x84000008>;
+               sys_reset = <0x84000009>;
        };
 
        pci0: pci@30000000 {
index 0e32ab4..51439b3 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/cpuidle.h>
 #include <linux/init.h>
 #include <linux/of.h>
+#include <linux/pm.h>
 #include <linux/smp.h>
 #include <linux/slab.h>
 
@@ -27,6 +28,7 @@
 #include <asm/psci.h>
 #include <asm/smp_plat.h>
 #include <asm/suspend.h>
+#include <asm/system_misc.h>
 
 #define PSCI_POWER_STATE_TYPE_STANDBY          0
 #define PSCI_POWER_STATE_TYPE_POWER_DOWN       1
@@ -54,6 +56,8 @@ enum psci_function {
        PSCI_FN_CPU_ON,
        PSCI_FN_CPU_OFF,
        PSCI_FN_MIGRATE,
+       PSCI_FN_SYSTEM_RESET,
+       PSCI_FN_SYSTEM_OFF,
        PSCI_FN_MAX,
 };
 
@@ -187,6 +191,16 @@ static int psci_migrate(unsigned long cpuid)
        return psci_to_linux_errno(err);
 }
 
+static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
+{
+       invoke_psci_fn(psci_function_id[PSCI_FN_SYSTEM_RESET], 0, 0, 0);
+}
+
+static void psci_sys_poweroff(void)
+{
+       invoke_psci_fn(psci_function_id[PSCI_FN_SYSTEM_OFF], 0, 0, 0);
+}
+
 static const struct of_device_id psci_of_match[] __initconst = {
        { .compatible = "arm,psci",     },
        {},
@@ -309,6 +323,16 @@ void __init psci_init(void)
                psci_ops.migrate = psci_migrate;
        }
 
+       if (!of_property_read_u32(np, "sys_reset", &id)) {
+               psci_function_id[PSCI_FN_SYSTEM_RESET] = id;
+               arm_pm_restart = psci_sys_reset;
+       }
+
+       if (!of_property_read_u32(np, "sys_poweroff", &id)) {
+               psci_function_id[PSCI_FN_SYSTEM_OFF] = id;
+               pm_power_off = psci_sys_poweroff;
+       }
+
 out_put_node:
        of_node_put(np);
        return;