summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@nxp.com>2016-12-22 11:16:09 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:25:42 +0800
commit7741197dc7c55d9ff6afe0094ce4cb435c87a413 (patch)
tree4ebd66313607402c249a345b56668c8b20ac46d6
parent615234fb64578c18da522ea1825b579e87bdfe3f (diff)
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 <peter.chen@nxp.com>
-rw-r--r--drivers/regulator/fixed.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 988a7472c2ab..27b6d75cb954 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -30,6 +30,7 @@
#include <linux/of_gpio.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/machine.h>
+#include <linux/pinctrl/consumer.h>
struct fixed_voltage_data {
struct regulator_desc desc;
@@ -199,11 +200,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 = &reg_fixed_voltage_pm_ops,
},
};