linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] regulator: fixed: add system pm routines for pinctrl
@ 2020-03-12 10:38 Peter Chen
  2020-03-12 11:47 ` Mark Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Chen @ 2020-03-12 10:38 UTC (permalink / raw)
  To: lgirdwood, broonie; +Cc: linux-kernel, linux-imx, Peter Chen

At some systems, the pinctrl setting will be lost and needs to
set as "sleep" state to save power consumption after system
enters suspend. So, we need to configure pinctrl as "sleep" state
when system enters suspend, and set it as "default" state after
system resume. In this way, the pinctrl value can be recovered
as "default" state after resuming.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
This patch at NXP local tree serveral years, and fixed the
pinctrl value lost issue at some boards.

 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 <linux/regulator/of_regulator.h>
 #include <linux/regulator/machine.h>
 #include <linux/clk.h>
-
+#include <linux/pinctrl/consumer.h>
 
 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 = &reg_fixed_voltage_pm_ops,
 	},
 };
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-03-13 13:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 10:38 [PATCH 1/1] regulator: fixed: add system pm routines for pinctrl Peter Chen
2020-03-12 11:47 ` Mark Brown
2020-03-12 13:00   ` Peter Chen
2020-03-12 14:37     ` Mark Brown
2020-03-12 15:03       ` Peter Chen
2020-03-12 15:07         ` Mark Brown
2020-03-13  3:08           ` Peter Chen
2020-03-13 12:11             ` Mark Brown
2020-03-13 13:16               ` Peter Chen
2020-03-13 13:29                 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).