Skip to contentSkip to conversation

rtc: ti-k3: Add support to resume from IO DDR low power mode

PATCH Applied Akashdeep Kaur 3 participants 3 messages Mar 13 – Apr 12 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rtc: ti-k3: Add support to resume from IO DDR low power mode

Restore the RTC HW context which may be lost when system enters certain low power mode (IO+DDR mode).
Check if the RTC registers are locked which would indicate loss of context (reset) and restore the context as needed.

---

Tested deep sleep with rtcwake after IO DDR resume on AM62P-SK.

Changes in v2:
-Updated the commit message as suggested in review
-Link to v1: https://lore.kernel.org/all/[email protected]/

---
 drivers/rtc/rtc-ti-k3.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ti-k3.c +9 -1
index ec759d8f7023..e801f5b9d757 100644
@@ -640,10 +640,18 @@ static int __maybe_unused ti_k3_rtc_suspend(struct device *dev)
 static int __maybe_unused ti_k3_rtc_resume(struct device *dev)
 {
 	struct ti_k3_rtc *priv = dev_get_drvdata(dev);
+	int ret = 0;
+
+	if (k3rtc_check_unlocked(priv)) {
+		/* RTC locked implies low power mode exit where RTC loses context */
+		ret = k3rtc_configure(dev);
+		if (ret)
+			return ret;
+	}
 
 	if (device_may_wakeup(dev))
 		disable_irq_wake(priv->irq);
-	return 0;
+	return ret;
 }
 
 static SIMPLE_DEV_PM_OPS(ti_k3_rtc_pm_ops, ti_k3_rtc_suspend, ti_k3_rtc_resume);
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Akashdeep Kaur

Restore the RTC HW context which may be lost when system enters certain low power mode (IO+DDR mode).
Check if the RTC registers are locked which would indicate loss of context (reset) and restore the context as needed.

Quoted 36 lines

---

Tested deep sleep with rtcwake after IO DDR resume on AM62P-SK.

Changes in v2:
-Updated the commit message as suggested in review
-Link to v1: https://lore.kernel.org/all/[email protected]/

---
 drivers/rtc/rtc-ti-k3.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ti-k3.c +9 -1
index ec759d8f7023..e801f5b9d757 100644
@@ -640,10 +640,18 @@ static int __maybe_unused ti_k3_rtc_suspend(struct device *dev)
 static int __maybe_unused ti_k3_rtc_resume(struct device *dev)
 {
 	struct ti_k3_rtc *priv = dev_get_drvdata(dev);
+	int ret = 0;
+
+	if (k3rtc_check_unlocked(priv)) {
+		/* RTC locked implies low power mode exit where RTC loses context */
+		ret = k3rtc_configure(dev);
+		if (ret)
+			return ret;
+	}
 
 	if (device_may_wakeup(dev))
 		disable_irq_wake(priv->irq);
-	return 0;
+	return ret;
 }
 
 static SIMPLE_DEV_PM_OPS(ti_k3_rtc_pm_ops, ti_k3_rtc_suspend, ti_k3_rtc_resume);
maintainer Applied
#2 lore raw
In reply to Akashdeep Kaur
Quoted 4 lines · Akashdeep Kaur

Restore the RTC HW context which may be lost when system enters certain low power mode (IO+DDR mode).
Check if the RTC registers are locked which would indicate loss of context (reset) and restore the context as needed.

Applied, thanks!

[1/1] rtc: ti-k3: Add support to resume from IO DDR low power mode

      https://git.kernel.org/abelloni/c/0e9b12ee74c5

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com