mbox series

[v3,0/4] AM437x: Add rtc-only + DDR mode support

Message ID 20190403045742.2243-1-j-keerthy@ti.com (mailing list archive)
Headers show
Series AM437x: Add rtc-only + DDR mode support | expand

Message

J, KEERTHY April 3, 2019, 4:57 a.m. UTC
RTC plus DDR in self-refresh is a power saving mode where in the entire
system including the different voltage rails from PMIC are shutdown except
the ones feeding on to RTC and DDR. DDR is kept in self-refresh hence the
contents are preserved.

RTC ALARM2 is connected to PMIC_EN line. TPS65218 PMIC has granular voltage rail
control. The voltage rail feeding RTC is kept on while the rest of the PMIC
regulators are powered off.

Once the ALARM2 is triggered we enter the mode with DDR in self-refresh
and RTC Ticking. After a predetermined time an RTC ALARM1 triggers
waking up the system. The control goes to bootloader. The bootloader then checks
RTC scratchpad registers to confirm it was an rtc_only wakeup and follows
a different path, configure bare minimal clocks for ddr and then jumps to
the resume address in another RTC scratchpad registers and transfers the
control to Kernel. Kernel then restores the saved context.

The patch series adds rtc-only + DDR mode support am am437x
Tested DS0, rtc+ddr back and forth on am437x-gp-evm board.

This mode works only with u-boot built with am43xx_evm_rtconly_defconfig

Additional patch is needed for omap-gpio save restore which will
come as fixes later.

Hardware Description of this mode can be found here: 

http://www.ti.com/lit/ug/spruhl7h/spruhl7h.pdf Page 2884.

Changes in v3:

  * Exported out omap_rtc_poweroff_program function & removed
    the patch to add a generic rtc interface as it is specific
    to am43 at the moment.

Keerthy (4):
  rtc: OMAP: Add support for rtc-only mode
  arm: mach-omap2: pm33xx: Add support for rtc+ddr in self  refresh mode
  soc: ti: pm33xx: Push the am33xx_push_sram_idle to the top
  soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support

 arch/arm/mach-omap2/pm33xx-core.c    |  76 +++++++-
 drivers/rtc/rtc-omap.c               |  49 ++++-
 drivers/soc/ti/Kconfig               |   5 +-
 drivers/soc/ti/pm33xx.c              | 273 ++++++++++++++++++++++-----
 include/linux/platform_data/pm33xx.h |   5 +
 include/linux/rtc/rtc-omap.h         |   7 +
 6 files changed, 354 insertions(+), 61 deletions(-)
 create mode 100644 include/linux/rtc/rtc-omap.h

Comments

Tony Lindgren April 8, 2019, 5:26 p.m. UTC | #1
* Keerthy <j-keerthy@ti.com> [190402 21:57]:
> RTC plus DDR in self-refresh is a power saving mode where in the entire
> system including the different voltage rails from PMIC are shutdown except
> the ones feeding on to RTC and DDR. DDR is kept in self-refresh hence the
> contents are preserved.
> 
> RTC ALARM2 is connected to PMIC_EN line. TPS65218 PMIC has granular voltage rail
> control. The voltage rail feeding RTC is kept on while the rest of the PMIC
> regulators are powered off.
> 
> Once the ALARM2 is triggered we enter the mode with DDR in self-refresh
> and RTC Ticking. After a predetermined time an RTC ALARM1 triggers
> waking up the system. The control goes to bootloader. The bootloader then checks
> RTC scratchpad registers to confirm it was an rtc_only wakeup and follows
> a different path, configure bare minimal clocks for ddr and then jumps to
> the resume address in another RTC scratchpad registers and transfers the
> control to Kernel. Kernel then restores the saved context.
> 
> The patch series adds rtc-only + DDR mode support am am437x
> Tested DS0, rtc+ddr back and forth on am437x-gp-evm board.
> 
> This mode works only with u-boot built with am43xx_evm_rtconly_defconfig
> 
> Additional patch is needed for omap-gpio save restore which will
> come as fixes later.
> 
> Hardware Description of this mode can be found here: 
> 
> http://www.ti.com/lit/ug/spruhl7h/spruhl7h.pdf Page 2884.
>
> Changes in v3:
> 
>   * Exported out omap_rtc_poweroff_program function & removed
>     the patch to add a generic rtc interface as it is specific
>     to am43 at the moment.

Thanks I'll be applying this series into omap-for-v5.2/am4-pm
today.

Regards,

Tony
Tony Lindgren April 8, 2019, 5:43 p.m. UTC | #2
* Tony Lindgren <tony@atomide.com> [190408 10:26]:
> * Keerthy <j-keerthy@ti.com> [190402 21:57]:
> > Changes in v3:
> > 
> >   * Exported out omap_rtc_poweroff_program function & removed
> >     the patch to add a generic rtc interface as it is specific
> >     to am43 at the moment.
> 
> Thanks I'll be applying this series into omap-for-v5.2/am4-pm
> today.

Sorry correction for the branch named above. I noticed a build
warning and folded in the following fix. We need to return
-EINVAL if tm2bcd() fails like we do elsewhere in the driver.

So I just pushed out a new branch omap-for-v5.2/am4-pm-v2.
Please just ignore the earlier branch omap-for-v5.2/am4-pm.

Regards,

Tony

8< --------------------
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -447,7 +447,7 @@ int omap_rtc_power_off_program(struct device *dev)
 	if (tm2bcd(&tm) < 0) {
 		dev_err(&rtc->rtc->dev, "power off failed\n");
 		rtc->type->lock(rtc);
-		return;
+		return -EINVAL;
 	}
 
 	rtc_wait_not_busy(rtc);
J, KEERTHY April 9, 2019, 3:59 a.m. UTC | #3
On 08/04/19 11:13 PM, Tony Lindgren wrote:
> * Tony Lindgren <tony@atomide.com> [190408 10:26]:
>> * Keerthy <j-keerthy@ti.com> [190402 21:57]:
>>> Changes in v3:
>>>
>>>    * Exported out omap_rtc_poweroff_program function & removed
>>>      the patch to add a generic rtc interface as it is specific
>>>      to am43 at the moment.
>>
>> Thanks I'll be applying this series into omap-for-v5.2/am4-pm
>> today.
> 
> Sorry correction for the branch named above. I noticed a build
> warning and folded in the following fix. We need to return
> -EINVAL if tm2bcd() fails like we do elsewhere in the driver.
> 
> So I just pushed out a new branch omap-for-v5.2/am4-pm-v2.
> Please just ignore the earlier branch omap-for-v5.2/am4-pm.

Thanks Tony!

> 
> Regards,
> 
> Tony
> 
> 8< --------------------
> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
> --- a/drivers/rtc/rtc-omap.c
> +++ b/drivers/rtc/rtc-omap.c
> @@ -447,7 +447,7 @@ int omap_rtc_power_off_program(struct device *dev)
>   	if (tm2bcd(&tm) < 0) {
>   		dev_err(&rtc->rtc->dev, "power off failed\n");
>   		rtc->type->lock(rtc);
> -		return;
> +		return -EINVAL;
>   	}
>   
>   	rtc_wait_not_busy(rtc);
>
J, KEERTHY April 9, 2019, 5:21 a.m. UTC | #4
On 09/04/19 9:29 AM, Keerthy wrote:
> 
> 
> On 08/04/19 11:13 PM, Tony Lindgren wrote:
>> * Tony Lindgren <tony@atomide.com> [190408 10:26]:
>>> * Keerthy <j-keerthy@ti.com> [190402 21:57]:
>>>> Changes in v3:
>>>>
>>>>    * Exported out omap_rtc_poweroff_program function & removed
>>>>      the patch to add a generic rtc interface as it is specific
>>>>      to am43 at the moment.
>>>
>>> Thanks I'll be applying this series into omap-for-v5.2/am4-pm
>>> today.
>>
>> Sorry correction for the branch named above. I noticed a build
>> warning and folded in the following fix. We need to return
>> -EINVAL if tm2bcd() fails like we do elsewhere in the driver.
>>
>> So I just pushed out a new branch omap-for-v5.2/am4-pm-v2.
>> Please just ignore the earlier branch omap-for-v5.2/am4-pm.
> 
> Thanks Tony!

Tony,

Seems like your for-next is a little behind. Hence you noticed the 
compilation error which i did not notice. The rtc driver patch i 
formatted from your for-next branch does not apply cleanly on linux-next 
as there are more patches already applied by Alexandre on next.

So the patch you made to return -EINVAL is no longer needed on latest next.

Thanks,
Keerthy
> 
>>
>> Regards,
>>
>> Tony
>>
>> 8< --------------------
>> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
>> --- a/drivers/rtc/rtc-omap.c
>> +++ b/drivers/rtc/rtc-omap.c
>> @@ -447,7 +447,7 @@ int omap_rtc_power_off_program(struct device *dev)
>>       if (tm2bcd(&tm) < 0) {
>>           dev_err(&rtc->rtc->dev, "power off failed\n");
>>           rtc->type->lock(rtc);
>> -        return;
>> +        return -EINVAL;
>>       }
>>       rtc_wait_not_busy(rtc);
>>
Tony Lindgren April 9, 2019, 2:20 p.m. UTC | #5
* Keerthy <j-keerthy@ti.com> [190409 05:21]:
> 
> 
> On 09/04/19 9:29 AM, Keerthy wrote:
> > 
> > 
> > On 08/04/19 11:13 PM, Tony Lindgren wrote:
> > > * Tony Lindgren <tony@atomide.com> [190408 10:26]:
> > > > * Keerthy <j-keerthy@ti.com> [190402 21:57]:
> > > > > Changes in v3:
> > > > > 
> > > > >    * Exported out omap_rtc_poweroff_program function & removed
> > > > >      the patch to add a generic rtc interface as it is specific
> > > > >      to am43 at the moment.
> > > > 
> > > > Thanks I'll be applying this series into omap-for-v5.2/am4-pm
> > > > today.
> > > 
> > > Sorry correction for the branch named above. I noticed a build
> > > warning and folded in the following fix. We need to return
> > > -EINVAL if tm2bcd() fails like we do elsewhere in the driver.
> > > 
> > > So I just pushed out a new branch omap-for-v5.2/am4-pm-v2.
> > > Please just ignore the earlier branch omap-for-v5.2/am4-pm.
> > 
> > Thanks Tony!
> 
> Tony,
> 
> Seems like your for-next is a little behind. Hence you noticed the
> compilation error which i did not notice. The rtc driver patch i formatted
> from your for-next branch does not apply cleanly on linux-next as there are
> more patches already applied by Alexandre on next.
> 
> So the patch you made to return -EINVAL is no longer needed on latest next.

Yeah I noticed there's now a minor conflict with the rtc
tree changes, that's trivial to resolve though.

Regards,

Tony