Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/8] alarmtimer: Pick the wakeup RTC per suspend state
@ 2026-11-16  0:24 Igor Velkov via B4 Relay
  2026-11-16  0:25 ` [PATCH v2 1/8] alarmtimer: Replace alarmtimer_get_rtcdev() with alarmtimer_has_rtcdev() Igor Velkov via B4 Relay
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Igor Velkov via B4 Relay @ 2026-11-16  0:24 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner, Alexandre Belloni, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Neil Armstrong, Kevin Hilman
  Cc: Stephen Boyd, Miroslav Lichvar, Jerome Brunet,
	Martin Blumenstingl, linux-rtc, devicetree, linux-arm-kernel,
	linux-amlogic, linux-kernel, Igor Velkov

alarmtimer takes the first RTC with an alarm and a wakeup capable parent
and programs it on every suspend. Which RTC wakes the system can depend
on the suspend state. On ODROID-HC4, meson-vrtc is a register the SoC
firmware reads when the application processors suspend: it wakes the
board from deep sleep only, and only with a BL301 that handles it, while
the pcf8563 wakes it from s2idle. meson-vrtc registers first, so an
alarm does not wake the board from s2idle.

The series keeps an RTC per suspend state, taken from a new
linux,wakeup-states property of the RTC's parent, structured as Thomas
suggested:

  1-2  alarmtimer_has_rtcdev(), the state in struct rtc_wakeup
  3    the freezer delta replaced with per type expiry times
  4    a platform device without a parent, linked to the RTC, with
       sysfs links per suspend state
  5    an RTC per suspend state; suspend is rejected when an alarm is
       pending and no RTC wakes the system from the target state
  6-7  the binding and its parser
  8    ODROID-HC4

Without the property every RTC is taken for every state, so the first
one is used as before.

The user space found to look the platform device up (omarchy-mobile,
hostmobility, z13ctl) matches it by name under
/sys/bus/platform/devices or by a glob over /sys, and still finds it
under /sys/devices/platform.

Patch 8 needs the pcf8563 interrupt [1] for s2idle. Without it the
pcf8563 takes s2idle but cannot wake the board, which is no worse than
today.

Tested on ODROID-HC4 on top of timers/core with [1]:
- s2idle: the pcf8563 alarm wakes the board
- deep: meson-vrtc wakes it, the pcf8563 is not programmed
- a CLOCK_BOOTTIME_ALARM clock_nanosleep() interrupted by the freezer
  wakes the board from deep sleep
- with the pcf8563 limited to "deep", s2idle with an alarm pending
  fails with -EOPNOTSUPP
The PCIe root port was removed for s2idle: pci-meson has no PM
callbacks and the board does not resume otherwise. The same tests
passed on v7.3.4 with the five alarmtimer commits from timers/core and
lockdep enabled. sparse reports nothing new.

[1] https://lore.kernel.org/r/20261019-hc4-rtc-alarm-irq-v1-1-078fc79e596f@iav.lv

Signed-off-by: Igor Velkov <iav@iav.lv>
---
Changes in v2:
- restructured as suggested, no priority property, no list of RTCs
- one platform device for all RTCs, ordered by a device link to each
- sysfs links per suspend state
- the freezer delta replaced
- suspend rejected when no RTC covers the target state
- binding: s2idle, shallow, deep or none; hibernate and off dropped
- based on tip timers/core
- Link to v1: https://lore.kernel.org/r/20261104-b4-alarmtimer-rtc-priority-v1-0-e996681b8086@iav.lv

---
Igor Velkov (8):
      alarmtimer: Replace alarmtimer_get_rtcdev() with alarmtimer_has_rtcdev()
      alarmtimer: Move the wakeup state into struct rtc_wakeup
      alarmtimer: Replace the freezer delta with per type expiry times
      alarmtimer: Register the platform device without a parent
      alarmtimer: Keep an RTC per suspend state
      dt-bindings: rtc: Add linux,wakeup-states
      alarmtimer: Read the wakeup states of an RTC from linux,wakeup-states
      arm64: dts: amlogic: meson-sm1-odroid-hc4: Describe which RTC wakes the board

 .../bindings/rtc/amlogic,meson-vrtc.yaml           |   2 +
 .../devicetree/bindings/rtc/nxp,pcf8563.yaml       |   2 +
 Documentation/devicetree/bindings/rtc/rtc.yaml     |  17 ++
 .../boot/dts/amlogic/meson-sm1-odroid-hc4.dts      |   5 +
 drivers/power/supply/charger-manager.c             |   2 +-
 include/linux/alarmtimer.h                         |   7 +-
 kernel/time/alarmtimer.c                           | 228 +++++++++++++--------
 7 files changed, 174 insertions(+), 89 deletions(-)
---
base-commit: 0359ecff58853a491dd0f09792fea8e87235ae06
change-id: 20261104-b4-alarmtimer-rtc-priority-2e25131a2917

Best regards,
-- 
Igor Velkov <iav@iav.lv>



_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-16  0:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16  0:24 [PATCH v2 0/8] alarmtimer: Pick the wakeup RTC per suspend state Igor Velkov via B4 Relay
2026-11-16  0:25 ` [PATCH v2 1/8] alarmtimer: Replace alarmtimer_get_rtcdev() with alarmtimer_has_rtcdev() Igor Velkov via B4 Relay
2026-11-16  0:25 ` [PATCH v2 2/8] alarmtimer: Move the wakeup state into struct rtc_wakeup Igor Velkov via B4 Relay
2026-11-16  0:25 ` [PATCH v2 3/8] alarmtimer: Replace the freezer delta with per type expiry times Igor Velkov via B4 Relay
2026-11-16  0:25 ` [PATCH v2 4/8] alarmtimer: Register the platform device without a parent Igor Velkov via B4 Relay
2026-11-16  0:25 ` [PATCH v2 5/8] alarmtimer: Keep an RTC per suspend state Igor Velkov via B4 Relay
2026-11-16  0:25 ` [PATCH v2 6/8] dt-bindings: rtc: Add linux,wakeup-states Igor Velkov via B4 Relay
2026-11-16  0:34   ` sashiko-bot
2026-11-16  0:25 ` [PATCH v2 7/8] alarmtimer: Read the wakeup states of an RTC from linux,wakeup-states Igor Velkov via B4 Relay
2026-11-16  0:25 ` [PATCH v2 8/8] arm64: dts: amlogic: meson-sm1-odroid-hc4: Describe which RTC wakes the board Igor Velkov via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox