[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180619135518.8990-3-geert+renesas@glider.be>
Date: Tue, 19 Jun 2018 15:55:18 +0200
From: Geert Uytterhoeven <geert+renesas@...der.be>
To: "Rafael J . Wysocki" <rjw@...ysocki.net>,
Pavel Machek <pavel@....cz>, Len Brown <len.brown@...el.com>,
Marek Vasut <marek.vasut+renesas@...il.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
Cc: linux-pm@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
linux-kernel@...r.kernel.org,
Geert Uytterhoeven <geert+renesas@...der.be>
Subject: [PATCH v2 2/2] regulator: bd9571mwv: Add support for toggle power switches
Extend the existing support for backup mode to toggle power switches.
With a toggle power switch (or level signal), the following steps must
be followed exactly:
1. Configure PMIC for backup mode,
2. Switch accessory power switch off, to prepare for system suspend,
which is a manual step not controlled by software,
3. Suspend system,
4. Switch accessory power switch on to wake up system.
Hence the PMIC is configured for backup mode when "enabled" is written
to the PMIC's "wakeup" virtual file in sysfs, using the newly introduced
callback for wake-up change notification. Conversely, writing
"disabled" reverts the role of the accessory switch to a power switch.
Unlike with momentary switches, backup mode is not enabled by default,
as enabling it prevents the board from being powered off using the power
switch, which may confuse the user.
Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
---
v2:
- Improve patch description,
- Drop "return;" at end of function.
---
drivers/regulator/bd9571mwv-regulator.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/regulator/bd9571mwv-regulator.c b/drivers/regulator/bd9571mwv-regulator.c
index be574eb444ebda97..403bc3fa1f2513de 100644
--- a/drivers/regulator/bd9571mwv-regulator.c
+++ b/drivers/regulator/bd9571mwv-regulator.c
@@ -171,6 +171,24 @@ static int bd9571mwv_bkup_mode_write(struct bd9571mwv *bd, unsigned int mode)
return 0;
}
+static void bd9571mwv_wakeup_change_notify(struct device *dev, bool enable)
+{
+ struct bd9571mwv_reg *bdreg = dev_get_drvdata(dev);
+
+ unsigned int mode;
+ int ret;
+
+ ret = bd9571mwv_bkup_mode_read(bdreg->bd, &mode);
+ if (ret)
+ return;
+
+ mode &= ~BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK;
+ if (enable)
+ mode |= bdreg->bkup_mode_cnt_keepon;
+
+ bd9571mwv_bkup_mode_write(bdreg->bd, mode);
+}
+
static int bd9571mwv_suspend(struct device *dev)
{
struct bd9571mwv_reg *bdreg = dev_get_drvdata(dev);
@@ -277,6 +295,11 @@ static int bd9571mwv_regulator_probe(struct platform_device *pdev)
* explicit user setup in level mode.
*/
device_set_wakeup_enable(&pdev->dev, bdreg->rstbmode_pulse);
+#ifdef CONFIG_PM_SLEEP
+ if (bdreg->rstbmode_level)
+ pdev->dev.power.wakeup_change_notify =
+ bd9571mwv_wakeup_change_notify;
+#endif /* CONFIG_PM_SLEEP */
}
return 0;
--
2.17.1
Powered by blists - more mailing lists