Skip to content

Commit

Permalink
rtc: sun6i: Allow RTC wakeup after shutdown
Browse files Browse the repository at this point in the history
Only IRQs that have enable_irq_wake() called on them can wake the system
from sleep or after it has been shut down. Currently, the RTC alarm can
only wake the system from sleep. Run the suspend callback to arm the IRQ
during the shutdown process, so the RTC alarm also works after shutdown.

Signed-off-by: Samuel Holland <samuel@sholland.org>
  • Loading branch information
smaeul authored and repojohnray committed Jun 22, 2022
1 parent 0293c4a commit cf35c00
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/rtc/rtc-sun6i.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ static const struct rtc_class_ops sun6i_rtc_ops = {
.alarm_irq_enable = sun6i_rtc_alarm_irq_enable
};

#ifdef CONFIG_PM_SLEEP
/* Enable IRQ wake on suspend, to wake up from RTC. */
static int sun6i_rtc_suspend(struct device *dev)
{
Expand All @@ -692,7 +691,7 @@ static int sun6i_rtc_suspend(struct device *dev)
}

/* Disable IRQ wake on resume. */
static int sun6i_rtc_resume(struct device *dev)
static int __maybe_unused sun6i_rtc_resume(struct device *dev)
{
struct sun6i_rtc_dev *chip = dev_get_drvdata(dev);

Expand All @@ -701,7 +700,6 @@ static int sun6i_rtc_resume(struct device *dev)

return 0;
}
#endif

static SIMPLE_DEV_PM_OPS(sun6i_rtc_pm_ops,
sun6i_rtc_suspend, sun6i_rtc_resume);
Expand Down Expand Up @@ -817,6 +815,11 @@ static int sun6i_rtc_probe(struct platform_device *pdev)
return 0;
}

static void sun6i_rtc_shutdown(struct platform_device *pdev)
{
sun6i_rtc_suspend(&pdev->dev);
}

/*
* As far as RTC functionality goes, all models are the same. The
* datasheets claim that different models have different number of
Expand All @@ -839,6 +842,7 @@ MODULE_DEVICE_TABLE(of, sun6i_rtc_dt_ids);

static struct platform_driver sun6i_rtc_driver = {
.probe = sun6i_rtc_probe,
.shutdown = sun6i_rtc_shutdown,
.driver = {
.name = "sun6i-rtc",
.of_match_table = sun6i_rtc_dt_ids,
Expand Down

0 comments on commit cf35c00

Please sign in to comment.