From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: "Daniel Viaño" <danividanivi@gmail.com>
Cc: Michal Simek <michal.simek@amd.com>,
linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] rtc: zynqmp: Enable crystal oscillator in initialization
Date: Fri, 25 Sep 2026 00:46:57 +0200 [thread overview]
Message-ID: <20260924224657b2d275e7@mail.local> (raw)
In-Reply-To: <20260924071917.80004-1-danividanivi@gmail.com>
On 24/09/2026 09:19:16+0200, Daniel Viaño wrote:
> Enable the RTC crystal oscillator bit in the control register (RTC_CTRL,
> offset 0x40) during driver initialization.
>
> Although the RTC_OSC_EN macro was defined when the driver was originally
> introduced, it was never asserted in xlnx_init_rtc(). On cold boots, after
> battery exhaustion, or on platforms where firmware does not pre-initialize
> RTC_CTRL, the oscillator remains disabled and the counter never ticks.
>
> Asserting RTC_OSC_EN alongside RTC_BATT_EN ensures the oscillator starts
> without relying on bootloader initialization. Per the Zynq UltraScale+
> TRM (UG1085), bit 24 (OSC_CNTRL) is a static level enable for the crystal
> inverter rather than an edge-triggered reset; re-asserting it when the
> oscillator is already running is a non-destructive no-op that does not
> glitch or reset the ticking counters.
>
> Tested on Zynq UltraScale+ hardware, confirming that the counter freezes
> when RTC_OSC_EN is cleared, advances reliably once enabled, and is
> unaffected when re-asserted while running.
>
> Fixes: 11143c19eb57 ("rtc: add xilinx zynqmp rtc driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Daniel Viaño <danividanivi@gmail.com>
> ---
> drivers/rtc/rtc-zynqmp.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
> index 5bcb7536e973..278705ec09f5 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -167,9 +167,12 @@ static void xlnx_init_rtc(struct xlnx_rtc_dev *xrtcdev)
> {
> u32 rtc_ctrl;
>
> - /* Enable RTC switch to battery when VCC_PSAUX is not available */
> + /*
> + * Enable crystal oscillator, and enable RTC switch to battery
> + * when VCC_PSAUX is not available.
> + */
> rtc_ctrl = readl(xrtcdev->reg_base + RTC_CTRL);
> - rtc_ctrl |= RTC_BATT_EN;
> + rtc_ctrl |= RTC_BATT_EN | RTC_OSC_EN;
No, you need to keep it disabled until you now the time is correct, that
is in set_time and you need to test for it in read_time and return
-EINVAL when it is not set.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
prev parent reply other threads:[~2026-09-24 22:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 7:19 [PATCH] rtc: zynqmp: Enable crystal oscillator in initialization Daniel Viaño
2026-09-24 7:29 ` sashiko-bot
2026-09-24 22:46 ` Alexandre Belloni [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924224657b2d275e7@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=danividanivi@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.