All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: bd718x7: Ensure SNVS power state is used as requested
@ 2025-05-01 14:48 Esben Haabendal
  2025-05-02  5:24 ` Matti Vaittinen
  0 siblings, 1 reply; 7+ messages in thread
From: Esben Haabendal @ 2025-05-01 14:48 UTC (permalink / raw)
  To: Matti Vaittinen, Liam Girdwood, Mark Brown; +Cc: linux-kernel, Esben Haabendal

With the introduction of the rohm,reset-snvs-powered DT binding [2], the
PMIC settings were only changed when the new property was not found.

As mentioned in [1] the default for BD71387 and BD71847 is to switch to
SNVS power state on watchdog reset.

So even with rohm,reset-snvs-powered added to DT, a watchdog reset causes
transitions through READY instead of SNVS. And with the default reboot
method in mxc_restart() is to cause a watchdog reset, we ended up powering
off the SNVS domains, and thus losing SNVS state such as SNVS RTC and
LPGPR, on reboots.

With this change, the rohm,reset-snvs-powered property results in the PMIC
configuration being modified so POWEROFF transitions to SNVS for all reset
types, including watchdog reset.

[1] commit e770b18bbbae ("regulator: bd718x7: Change next state after poweroff to ready")
[2] commit 049369d46428 ("regulator: bd718x7: Support SNVS low power state")

Signed-off-by: Esben Haabendal <esben@geanix.com>
---
 drivers/regulator/bd718x7-regulator.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c
index 1bb048de3ecd5a8df1087a48afc728a64623a024..d8c7fb2e73986a39066c9e8a114dd8d733bc8a33 100644
--- a/drivers/regulator/bd718x7-regulator.c
+++ b/drivers/regulator/bd718x7-regulator.c
@@ -1715,23 +1715,24 @@ static int bd718xx_probe(struct platform_device *pdev)
 					 "rohm,reset-snvs-powered");
 
 	/*
-	 * Change the next stage from poweroff to be READY instead of SNVS
-	 * for all reset types because OTP loading at READY will clear SEL
-	 * bit allowing HW defaults for power rails to be used
+	 * Set next power state from poweroff to be either READY or SNVS for all
+	 * reset types. The default is READY state because OTP loading at READY
+	 * will clear SEL bit allowing HW defaults for power rails to be used.
+	 * Using SNVS power state instead allows SNVS state, such as RTC and
+	 * LPGPR to be persisted over reboots.
 	 */
-	if (!use_snvs) {
-		err = regmap_update_bits(regmap, BD718XX_REG_TRANS_COND1,
-					 BD718XX_ON_REQ_POWEROFF_MASK |
-					 BD718XX_SWRESET_POWEROFF_MASK |
-					 BD718XX_WDOG_POWEROFF_MASK |
-					 BD718XX_KEY_L_POWEROFF_MASK,
-					 BD718XX_POWOFF_TO_RDY);
-		if (err)
-			return dev_err_probe(&pdev->dev, err,
-					     "Failed to change reset target\n");
-
-		dev_dbg(&pdev->dev, "Changed all resets from SVNS to READY\n");
-	}
+	err = regmap_update_bits(regmap, BD718XX_REG_TRANS_COND1,
+				 BD718XX_ON_REQ_POWEROFF_MASK |
+				 BD718XX_SWRESET_POWEROFF_MASK |
+				 BD718XX_WDOG_POWEROFF_MASK |
+				 BD718XX_KEY_L_POWEROFF_MASK,
+				 use_snvs ? 0 : BD718XX_POWOFF_TO_RDY);
+	if (err)
+		return dev_err_probe(&pdev->dev, err,
+				     "Failed to change reset target\n");
+
+	dev_dbg(&pdev->dev, "Changed all resets from %s to %s\n",
+		use_snvs ? "READY" : "SNVS", use_snvs ? "SNVS" : "READY");
 
 	config.dev = pdev->dev.parent;
 	config.regmap = regmap;

---
base-commit: b4432656b36e5cc1d50a1f2dc15357543add530e
change-id: 20250501-bd718x7-snvs-reset-186d934b37c1

Best regards,
-- 
Esben Haabendal <esben@geanix.com>


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

end of thread, other threads:[~2025-05-08 17:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01 14:48 [PATCH] regulator: bd718x7: Ensure SNVS power state is used as requested Esben Haabendal
2025-05-02  5:24 ` Matti Vaittinen
2025-05-02  6:46   ` Esben Haabendal
2025-05-02  8:20     ` Matti Vaittinen
2025-05-03  9:23       ` Esben Haabendal
2025-05-05  6:07         ` Matti Vaittinen
2025-05-08 17:20           ` Esben Haabendal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.