[v2] rtc: imxdi: add wakeup support
diff mbox series

Message ID 20210505163009.14252-1-martin@kaiser.cx
State Accepted
Commit bcae59d0d45b866d5b9525ea8ece6d671e6767c8
Headers show
Series
  • [v2] rtc: imxdi: add wakeup support
Related show

Commit Message

Martin Kaiser May 5, 2021, 4:30 p.m. UTC
The DryIce-based RTC supports alarms that trigger an interrupt.

Add an option to configure this interrupt as a wakeup source that wakes the
system up from standby mode.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
v2:
 - unconditionally declare rtc-imxdi as wakeup source
 - use dev_pm_set_wake_irq instead of manually coding suspend and resume

simple test (no need to configure the wakeup source via sysfs any more)

   [root@board ]# rtcwake -s 3 -m mem
   wakeup from "mem" at Fri Apr 30 09:23:52 2021
   ...
   [root@board ]#

 drivers/rtc/rtc-imxdi.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Alexandre Belloni May 5, 2021, 5:34 p.m. UTC | #1
Hi,

On 05/05/2021 18:30:09+0200, Martin Kaiser wrote:
> The DryIce-based RTC supports alarms that trigger an interrupt.
> 
> Add an option to configure this interrupt as a wakeup source that wakes the
> system up from standby mode.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
> v2:
>  - unconditionally declare rtc-imxdi as wakeup source
>  - use dev_pm_set_wake_irq instead of manually coding suspend and resume
> 
> simple test (no need to configure the wakeup source via sysfs any more)
> 
>    [root@board ]# rtcwake -s 3 -m mem
>    wakeup from "mem" at Fri Apr 30 09:23:52 2021
>    ...
>    [root@board ]#
> 
>  drivers/rtc/rtc-imxdi.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
> index c1806f4d68e7..4b712e5ab08a 100644
> --- a/drivers/rtc/rtc-imxdi.c
> +++ b/drivers/rtc/rtc-imxdi.c
> @@ -24,6 +24,7 @@
>  #include <linux/delay.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_wakeirq.h>
>  #include <linux/rtc.h>
>  #include <linux/sched.h>
>  #include <linux/spinlock.h>
> @@ -811,6 +812,9 @@ static int __init dryice_rtc_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, imxdi);
>  
> +	device_init_wakeup(&pdev->dev, true);
> +	dev_pm_set_wake_irq(&pdev->dev, norm_irq);
> +

That's nice and concise ;) I'll apply that once -rc1 is released

Patch
diff mbox series

diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index c1806f4d68e7..4b712e5ab08a 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -24,6 +24,7 @@ 
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/rtc.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
@@ -811,6 +812,9 @@  static int __init dryice_rtc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, imxdi);
 
+	device_init_wakeup(&pdev->dev, true);
+	dev_pm_set_wake_irq(&pdev->dev, norm_irq);
+
 	imxdi->rtc->ops = &dryice_rtc_ops;
 	imxdi->rtc->range_max = U32_MAX;