From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A415606A33C for ; Wed, 4 Nov 2026 05:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=FWiOp7o9; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oODXvuwQ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:MIME-Version:Message-Id :Date:Subject:From:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=bWRo5pUy/n7cpTnRm325iWDksx5tDfrOcm4dDg1iAbE=; b=FWiOp7o9FyZseXYmn6p/5MsQMV WOYoRENdziA5FTdrohX+T9HOzv/vIF/wwV6UVULunIRus39DvG7dmjHRYzIzIqYr+u/T2i+OQtmRj 0m95RIb24kEk1vKdbdavwXEYeVxzcHwamWE9DoIo5bO73iefN0uy65xUKS3972O/lcUxuJxM2MwRt 6l7XqX+3Nalad8KOfyasiH6J/ygjSYcSEU0u5bzgWeJEO+Sg5RshUWb/0TYOIZmOEN65eFmamJv64 kuLgNZ2R0mM9h4lYftI5nh6d9qIXpidPe4cnjhN2aIvHTaV69pPcz38PjQlLzT6TmPs6RExOu0jNP gWAONZBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOTxN-00000004Moo-2CV5; Wed, 04 Nov 2026 05:54:45 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOTxL-00000004MnO-0Hcv; Wed, 04 Nov 2026 05:54:43 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 1D724601F6; Wed, 4 Nov 2026 05:54:42 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1793771681; b=wPCgumpn0G5a+Pma8pYUHdPtGBCkuKVe8XuxVMo/0J3GdR/YKK3rmkyolfxAjc5L5zrR StZLNkrg8zhzkstD+nwpMm0TjjemjSF4S0NQ4g2jH/DKpGz+HQIZVDxW7S+NW7yQ0dh68 1BGi9D5kINqyBkWtoOSlRBzvjsL5IXYJ4Yx3KV0ZokaicZ5ju7hR7Nitock1ieFhril1+ k2FvjS3QWLZbgBvaXe5NjRs/qfcOYqkpzsZO30kOs+TUPM5ZVyDDJRbwUXmhYUx1gbaMw YFmqGiSxmz+3hZ7EvQ2zbJwmLNDnmlrCz5vZhI5e66orNRHkacxyfcSeopf2BeKcr7g== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1793771681; h=DKIM-Signature:Received:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To; bh=l6QTWAiT2pnjRja/ALYbiKuIFt7Nll81q03ZWRJukTo=; b=lgQyO0BV7yZb612/NPJ8FKJeOBW65eyseFUK7ODe3pe7Jcp76YVZnGN+kYWnWea+2hNn KdUjQLtoZjDcXewBi50S4FQ0w48TyYjbnsHv3Ym1oZ3IAXek+GnBJS+tTq8vM/Z6y0qnF MvBDMp2PI3j3hUWX5DEJMkBC6kUONdiVjON/HKkTuwqzF5gOHdoA95AOWsrNc1MzA6NR+ Wiiz0kpRzmCLwBc/zErbvpya82S04ezXrsLyZeGajVz7okZUhYL+GYMKtWghHYSFUi1gD GHx5P1toR5u5TQ0VlZd9bIz0BxlaInh6oqQC0V4v2qMlfRz7ebU+144TynkiVuwOIpQ== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 314551F000C1; Wed, 4 Nov 2026 05:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793771681; bh=l6QTWAiT2pnjRja/ALYbiKuIFt7Nll81q03ZWRJukTo=; h=From:Subject:Date:To:Cc:Reply-To; b=oODXvuwQ2dcUNulurxLj5q3EWvbva2U4hPPiYuHRVOnkA3UBC8o+MbJ2gQVAXI9DZ AqWbn9ZSXqnO5B/zYZes9LNsGq37KR/lWK3YOHqjphOAG+Ui+ho9WseeR+uyzxzs8O lfo9r/vkf9QZPHKTLu34nYyMZj7Jv2kWEZ+hTsmSOpxfMeooNqxHzA/ylmJNhSZEYq lH3x0OLPd5RM582nTQMbruoA/xjwIBVxD4XHEOBHc0duukhT+YQTjHVw3h7b5FQyHt osRqjg5Y/6kHopCmBgz6a8NdDy27Yz8X86c/bN0WMQBss0i0hpp7SibsBF8QZKKjeb nG53P9UfvSNAA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id B1C5E46C9F; Wed, 4 Nov 2026 05:54:40 +0000 (UTC) From: Igor Velkov via B4 Relay Subject: [PATCH RFC 0/3] alarmtimer: Choose the wakeup RTC per sleep state from the device tree Date: Wed, 04 Nov 2026 05:54:36 +0000 Message-Id: <20261104-b4-alarmtimer-rtc-priority-v1-0-e996681b8086@iav.lv> X-Archived-By: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAJ3I6moC/x3MSwrCQAwA0KuUrA00cWyxW6EHcCsuxmnaBvojM 4hSencHl2/zdohiKhGaYgeTt0Zdlww6FRBGvwyC2mUDl1wRlQ5fDv3kbU46i6GlgJvpapq+yMI XOpPnK9WQg82k188/f8C9vcHzOH4P0Y9gcQAAAA== 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@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, Igor Velkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4284; i=iav@iav.lv; h=from:subject:message-id; bh=0IYwb1SInrt3b80xHHEOcsUK/4uBWyP8cJUA4xS+Tyw=; b=owGbwMvMwCVmNH1q96v4SmbG02pJDFmvTswTXs/q8/O4/BzBn62T5ojfu5TIqLR8j/mNjgvVB 3iaZ5Sxd5SyMIhxMciKKbJMOKRxK2PJ1b/+HuYPYOawMoEMYeDiFICJ5FoxMlzdxL/urq5/yVIF OQEZ9kwdBc9Ufb4Tx/9Y+k/JunPsTSQjQ5tPQuWGiZ7ze80Tuu7nVl/167vQfeIwa0bkj0A3ZeF wVgA= X-Developer-Key: i=iav@iav.lv; a=openpgp; fpr=90C228DA68A4D5FD4F4837E03297958BEA5F7903 X-Endpoint-Received: by B4 Relay for iav@iav.lv/default with auth_id=1060 X-Original-From: Igor Velkov X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: iav@iav.lv Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 alarmtimer binds to the first registered RTC that has an alarm and a wakeup-capable parent and programs it on every suspend. On ODROID-HC4 that RTC is amlogic,meson-vrtc: a register the SoC firmware reads when the application processors suspend. It wakes the board from deep sleep only, and only when the firmware handles the alarm; it raises no interrupt in Linux, so it never wakes the board from s2idle. The board's pcf8563, whose interrupt line goes to a GPIO, registers later and is never used. Which RTC wakes the system depends on the sleep state and on the board's firmware, so the series lets the board device tree say it per RTC: - linux,wakeup-states: the sleep states an alarm of this RTC wakes the system from ("s2idle", "shallow", "deep" as in /sys/power/mem_sleep, plus "hibernate" and "off"), or "none". - linux,alarmtimer-priority: a weight to pick among several RTCs that wake the system from the same state. alarmtimer keeps each RTC that has an alarm and a wakeup-capable parent, unless an RTC registered before it, with at least the same priority, already wakes from every state it lists; each kept RTC gets its own "alarmtimer" platform device under the RTC. alarmtimer_suspend() picks, by pm_suspend_target_state, the RTC with the highest priority among those listing that state, the first registered among equals, and programs the alarm from that RTC's platform device only. The driver core suspends a device before its ancestors (dpm_suspend() takes dpm_prepared_list from the tail, in reverse registration order), so the chosen RTC and its parent, which drives the hardware, are still awake when the alarm is programmed. Without the properties only the first RTC gets a platform device and alarmtimer programs it on every suspend. An RTC without linux,wakeup-states is taken to wake the system from every state, so that adding the property to one RTC, e.g. from an overlay, does not change how the others are used; a priority on the new one settles which wins. Hibernation wakeups (.freeze/.poweroff callbacks) are not part of this series. Patch 3 sets linux,wakeup-states on ODROID-HC4: "s2idle" for the pcf8563 and "deep" for meson-vrtc, so that alarmtimer programs the pcf8563 for s2idle and meson-vrtc for deep sleep. The patch applies to the current tree, but the s2idle wakeup also needs the pcf8563 interrupt (GPIOX_5), which a patch under review adds [1]. Tested on ODROID-HC4 with v7.3.1, [1] and a BL301 that handles the vrtc alarm, waking by a CLOCK_BOOTTIME_ALARM timer, once per state: s2idle woke on the pcf8563 interrupt, deep sleep on meson-vrtc with the pcf8563 alarm left unset. Without the series the alarm went to meson-vrtc and the board did not wake from s2idle. Questions: - Are "linux,wakeup-states" and "linux,alarmtimer-priority" acceptable names, or should they be generic (no linux, prefix), given that the states describe the hardware and the firmware rather than Linux? - Is the device tree the right place for a capability that depends on the firmware the board runs? On HC4, meson-vrtc wakes from deep sleep only with a BL301 that handles its alarm. The alarm limit of meson-vrtc also depends on the firmware, and the kernel cannot learn it. Some API is needed to pass this information to the kernel. [1] https://lore.kernel.org/r/20261020-hc4-rtc-alarm-irq-v1-1-b2b8c68d54f5@iav.lv Signed-off-by: Igor Velkov --- Igor Velkov (3): dt-bindings: rtc: Add linux,wakeup-states and linux,alarmtimer-priority alarmtimer: Choose the wakeup RTC by sleep state and priority arm64: dts: amlogic: meson-sm1-odroid-hc4: Describe which RTC wakes the board .../bindings/rtc/amlogic,meson-vrtc.yaml | 3 + .../devicetree/bindings/rtc/nxp,pcf8563.yaml | 3 + Documentation/devicetree/bindings/rtc/rtc.yaml | 29 ++++ .../boot/dts/amlogic/meson-sm1-odroid-hc4.dts | 5 + kernel/time/alarmtimer.c | 157 ++++++++++++++++++--- 5 files changed, 180 insertions(+), 17 deletions(-) --- base-commit: 348f54c435bf3177baa78201952810b255d44b30 change-id: 20261104-b4-alarmtimer-rtc-priority-2e25131a2917 Best regards, -- Igor Velkov _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic