From 3aa441cd89e417c76495eda03224c9efd32f7fa7 Mon Sep 17 00:00:00 2001 From: Peter Chen Date: Thu, 22 Dec 2016 11:16:09 +0800 Subject: [PATCH] MLK-13638-4 regulator: fixed: add system pm routines for pinctrl At some systems, the pinctrl setting will be lost or needs to set as "sleep" state to save power consumption. So, we need to configure pinctrl as "sleep" state when system enters suspend, and as "default" state after system resumes. In this way, the pinctrl value can be recovered as "default" state after resuming. Signed-off-by: Peter Chen Signed-off-by: Vipul Kumar --- drivers/regulator/fixed.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index bc0bbd99e98d..29bb93c04b03 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -27,7 +27,7 @@ #include #include #include - +#include struct fixed_voltage_data { struct regulator_desc desc; @@ -275,11 +275,32 @@ static const struct of_device_id fixed_of_match[] = { MODULE_DEVICE_TABLE(of, fixed_of_match); #endif +#ifdef CONFIG_PM_SLEEP +static int reg_fixed_voltage_suspend(struct device *dev) +{ + pinctrl_pm_select_sleep_state(dev); + + return 0; +} +static int reg_fixed_voltage_resume(struct device *dev) +{ + pinctrl_pm_select_default_state(dev); + + return 0; +} +#endif + +static const struct dev_pm_ops reg_fixed_voltage_pm_ops = { + SET_LATE_SYSTEM_SLEEP_PM_OPS(reg_fixed_voltage_suspend, + reg_fixed_voltage_resume) +}; + static struct platform_driver regulator_fixed_voltage_driver = { .probe = reg_fixed_voltage_probe, .driver = { .name = "reg-fixed-voltage", .of_match_table = of_match_ptr(fixed_of_match), + .pm = ®_fixed_voltage_pm_ops, }, };