[PATCH v2 7/8] alarmtimer: Read the wakeup states of an RTC from linux,wakeup-states

From: Igor Velkov via B4 Relay

Date: Sun Nov 15 2026 - 19:25:22 EST


From: Igor Velkov <iav@xxxxxx>

Every RTC is taken to wake the system from all suspend states, so the
first RTC with an alarm and a wakeup capable parent takes all of them.

Take the suspend states listed in the linux,wakeup-states property of the
RTC's parent instead, all of them without the property. An RTC with
"none" is not used.

On ODROID-HC4 this lets the pcf8563 wake the board from s2idle and
meson-vrtc from deep sleep.

Signed-off-by: Igor Velkov <iav@xxxxxx>
---
kernel/time/alarmtimer.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 4153cce182a4..0770f4b0ca86 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -26,6 +26,7 @@
#include <linux/freezer.h>
#include <linux/compat.h>
#include <linux/module.h>
+#include <linux/property.h>
#include <linux/suspend.h>
#include <linux/time_namespace.h>

@@ -111,10 +112,21 @@ static void alarmtimer_link_state(int state, struct device *dev)
dev_warn(&wakeup_ctl.pdev->dev, "Cannot link %s to %s\n", name, dev_name(dev));
}

-/* Suspend states from which an alarm of the RTC on @dev wakes the system */
+/* Suspend states from linux,wakeup-states, all of them without the property */
static unsigned long alarmtimer_wakeup_states(struct device *dev)
{
- return ALARMTIMER_STATES_ALL;
+ unsigned long states = 0;
+ int state;
+
+ if (!device_property_present(dev, "linux,wakeup-states"))
+ return ALARMTIMER_STATES_ALL;
+
+ for (state = ALARMTIMER_STATE_MIN; state < ALARMTIMER_STATE_MAX; state++) {
+ if (device_property_match_string(dev, "linux,wakeup-states",
+ alarmtimer_state_names[state]) >= 0)
+ states |= BIT(state);
+ }
+ return states;
}

static int alarmtimer_rtc_add_device(struct device *dev)

--
2.43.0