armbian_build/patch/kernel/archive/sunxi-6.13/patches.megous/rtc-sun6i-Allow-RTC-wakeup-after-shutdown.patch
2025-03-21 10:24:35 +01:00

70 lines
2.0 KiB
Diff

From 0d9b608a78c6583d97a7af470d991ff3a7e5f550 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Sat, 2 Jan 2021 15:52:27 -0600
Subject: rtc: sun6i: Allow RTC wakeup after shutdown
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>
---
drivers/rtc/rtc-sun6i.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index e681c1745866..3e6917c9130e 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -710,6 +710,7 @@ static struct nvmem_config sun6i_rtc_nvmem_cfg = {
};
#ifdef CONFIG_PM_SLEEP
+
/* Enable IRQ wake on suspend, to wake up from RTC. */
static int sun6i_rtc_suspend(struct device *dev)
{
@@ -722,7 +723,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);
@@ -731,6 +732,7 @@ static int sun6i_rtc_resume(struct device *dev)
return 0;
}
+
#endif
static SIMPLE_DEV_PM_OPS(sun6i_rtc_pm_ops,
@@ -850,6 +852,13 @@ static int sun6i_rtc_probe(struct platform_device *pdev)
return 0;
}
+static void sun6i_rtc_shutdown(struct platform_device *pdev)
+{
+#ifdef CONFIG_PM_SLEEP
+ sun6i_rtc_suspend(&pdev->dev);
+#endif
+}
+
/*
* As far as RTC functionality goes, all models are the same. The
* datasheets claim that different models have different number of
@@ -874,6 +883,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,
--
2.35.3