rtc: ti-k3: Add support to resume from IO DDR low power mode
PATCH 1/1 rtc: ti-k3: Add support to resume from IO DDR low power mode
During IO DDR low power mode, the RTC IP is reset and loses its register configuration. The DDR memory still preserves all driver states (reference counts, software context). System clocks are saved and restored by Device Manager (DM) firmware during the resume sequence. Add support to reconfigure the RTC IP registers in resume handler only if resume hook is called during IO DDR low power mode resume.
---
Tested deep sleep with rtcwake after IO DDR resume on AM62P-SK.
--- drivers/rtc/rtc-ti-k3.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ti-k3.c +9 -1
@@ -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
Quoted 5 lines · Akashdeep Kaur
During IO DDR low power mode, the RTC IP is reset and loses its register configuration.
The DDR memory still preserves all driver states
(reference counts, software context).
That's the definition of Suspend to RAM
Quoted 2 lines
System clocks are saved and restored
by Device Manager (DM) firmware during the resume sequence.
Not relevant for this patch in particular.
Quoted 3 lines
Add support to reconfigure the RTC IP registers in resume handler only if resume hook is called during IO DDR low power mode resume.
Above all is probably bit too verbose. Below text is all thats needed:
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 33 lines
Signed-off-by Akashdeep Kaur <[email protected]>---
Tested deep sleep with rtcwake after IO DDR resume on AM62P-SK.
--- drivers/rtc/rtc-ti-k3.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/rtc/rtc-ti-k3.c +9
-1@@ -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 · 3 lines
Regards Vignesh https://ti.com/opensource
Hi Vignesh,
Quoted 20 lines · Vignesh Raghavendra
Quoted 5 lines · Akashdeep Kaur
During IO DDR low power mode, the RTC IP is reset and loses its register configuration.
The DDR memory still preserves all driver states
(reference counts, software context).That's the definition of Suspend to RAM
Quoted 2 lines
System clocks are saved and restored
by Device Manager (DM) firmware during the resume sequence.Not relevant for this patch in particular.
Quoted 3 lines
Add support to reconfigure the RTC IP registers in resume handler only if resume hook is called during IO DDR low power mode resume.
Quoted 6 lines
Above all is probably bit too verbose. Below text is all thats needed:
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.
Updated the commit message as suggested.
Regards,
Akashdeep Kaur
Quoted 35 lines
Quoted 34 lines
Signed-off-by Akashdeep Kaur <[email protected]>---
Tested deep sleep with rtcwake after IO DDR resume on AM62P-SK.
--- drivers/rtc/rtc-ti-k3.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/rtc/rtc-ti-k3.c +9
-1@@ -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);