Skip to content

Commit

Permalink
rtc: pm8xxx: Attach wake irq to device
Browse files Browse the repository at this point in the history
Attach the interrupt as a wake-irq to the device, so that:
- A corresponding wakeup source is created (and reported in e.g
  /sys/kernel/debug/wakeup_sources).
- The power subsystem take cares of arming/disarming
  irq-wake automatically on suspend/resume.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1645025082-6138-1-git-send-email-loic.poulain@linaro.org
  • Loading branch information
Loic Poulain authored and Alexandre Belloni committed Mar 25, 2022
1 parent 1521ca5 commit b5bf5b2
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions drivers/rtc/rtc-pm8xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/rtc.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/pm_wakeirq.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
Expand Down Expand Up @@ -527,40 +528,28 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
return rc;
}

return devm_rtc_register_device(rtc_dd->rtc);
}

#ifdef CONFIG_PM_SLEEP
static int pm8xxx_rtc_resume(struct device *dev)
{
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
rc = devm_rtc_register_device(rtc_dd->rtc);
if (rc)
return rc;

if (device_may_wakeup(dev))
disable_irq_wake(rtc_dd->rtc_alarm_irq);
rc = dev_pm_set_wake_irq(&pdev->dev, rtc_dd->rtc_alarm_irq);
if (rc)
return rc;

return 0;
}

static int pm8xxx_rtc_suspend(struct device *dev)
static int pm8xxx_remove(struct platform_device *pdev)
{
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);

if (device_may_wakeup(dev))
enable_irq_wake(rtc_dd->rtc_alarm_irq);

dev_pm_clear_wake_irq(&pdev->dev);
return 0;
}
#endif

static SIMPLE_DEV_PM_OPS(pm8xxx_rtc_pm_ops,
pm8xxx_rtc_suspend,
pm8xxx_rtc_resume);

static struct platform_driver pm8xxx_rtc_driver = {
.probe = pm8xxx_rtc_probe,
.remove = pm8xxx_remove,
.driver = {
.name = "rtc-pm8xxx",
.pm = &pm8xxx_rtc_pm_ops,
.of_match_table = pm8xxx_id_table,
},
};
Expand Down

0 comments on commit b5bf5b2

Please sign in to comment.