drivers: firmware: psci: notify regulators on system-suspend
authorHeiko Stuebner <heiko@sntech.de>
Wed, 16 Mar 2016 11:18:43 +0000 (12:18 +0100)
committerGerrit Code Review <gerrit@rock-chips.com>
Fri, 25 Mar 2016 02:14:39 +0000 (10:14 +0800)
On some systems regulators need to do special actions on suspend/resume.
These get set from the generic regulator_suspend_prepare and
regulator_suspend_finish functions so these should be called from the
psci suspend ops as well.

Change-Id: I6fbf7b39ceae936ed5bd9df6719ccd3cd360840f
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Shengfei xu <xsf@rock-chips.com>
drivers/firmware/psci.c

index d24f35d74b27079afeae5c08d601c3bcd899dee6..a33bfddd5f6742a6ff1eb666a90e70e29fc72b25 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/psci.h>
 #include <linux/reboot.h>
 #include <linux/suspend.h>
+#include <linux/regulator/machine.h>
 
 #include <uapi/linux/psci.h>
 
@@ -236,9 +237,25 @@ static int psci_system_suspend_enter(suspend_state_t state)
        return cpu_suspend(0, psci_system_suspend);
 }
 
+static int psci_system_suspend_prepare(void)
+{
+       return regulator_suspend_prepare(PM_SUSPEND_MEM);
+}
+
+static void psci_system_suspend_finish(void)
+{
+       int ret;
+
+       ret = regulator_suspend_finish();
+       if (ret < 0)
+               pr_warn("regulator_suspend_finish failed (%d)\n", ret);
+}
+
 static const struct platform_suspend_ops psci_suspend_ops = {
        .valid          = suspend_valid_only_mem,
        .enter          = psci_system_suspend_enter,
+       .prepare        = psci_system_suspend_prepare,
+       .finish         = psci_system_suspend_finish,
 };
 
 static void __init psci_init_system_suspend(void)