Linux RTC
 help / color / mirror / Atom feed
* Re: [PATCH v1] rtc: Use named initializers for arrays of i2c_device_data
From: Alexandre Belloni @ 2026-06-24 21:16 UTC (permalink / raw)
  To: Uwe Kleine-König (The Capable Hub)
  Cc: Antoniu Miclaus, Andrew Jeffery, Avi Fishman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	Tóth János, Dianlong Li, linux-rtc, linux-kernel,
	openbmc
In-Reply-To: <20260515154720.406128-2-u.kleine-koenig@baylibre.com>

On Fri, 15 May 2026 17:47:20 +0200, Uwe Kleine-König (The Capable Hub) wrote:
> While being less compact, using named initializers allows to more easily
> see which members of the structs are assigned which value without having
> to lookup the declaration of the struct. And it's also more robust
> against changes to the struct definition.
> 
> The mentioned robustness is relevant for a planned change to struct
> i2c_device_id that replaces .driver_data by an anonymous union.
> 
> [...]

Applied, thanks!

[1/1] rtc: Use named initializers for arrays of i2c_device_data
      https://git.kernel.org/abelloni/c/3eebec1cb5dc

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* Re: [PATCH] rtc: interface: fix typos in rtc_handle_legacy_irq() documentation
From: Alexandre Belloni @ 2026-06-24 21:17 UTC (permalink / raw)
  To: Yahya Saqban; +Cc: linux-rtc, linux-kernel
In-Reply-To: <20260512210235.343070-1-yahyasaqban@gmail.com>

On Wed, 13 May 2026 00:02:35 +0300, Yahya Saqban wrote:
> Fix spelling of 'occurence' to 'occurrence' and 'of' to 'or' in the
> kernel-doc comment for rtc_handle_legacy_irq().

Applied, thanks!

[1/1] rtc: interface: fix typos in rtc_handle_legacy_irq() documentation
      https://git.kernel.org/abelloni/c/4202e4254403

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* Re: [PATCH v2 3/3] rtc: ds1307: Add driver for Epson RX8901CE
From: Alexandre Belloni @ 2026-06-24 21:38 UTC (permalink / raw)
  To: Fredrik M Olsson
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Nobuhiro Iwamatsu,
	linux-rtc, devicetree, linux-kernel, kernel
In-Reply-To: <20260520-ds1307-rx8901-add-v2-3-e069ea32e1db@axis.com>

On 20/05/2026 16:48:55+0200, Fredrik M Olsson wrote:
> +static int do_trickle_setup_rx8901(struct ds1307 *ds1307, u32 ohms __always_unused, bool diode)
> +{
> +	int ret;
> +	unsigned int setup;
> +
> +	ret = regmap_read(ds1307->regmap, RX8901_REG_PWSW_CFG, &setup);
> +	if (ret) {
> +		dev_err(ds1307->dev, "Failed to read PWSW_CFG register\n");
> +		return ret;
> +	}
> +
> +	/* Enable low battery voltage detection */
> +	setup |= RX8901_REG_PWSW_CFG_VBATLDETEN;
> +
> +	if (diode)
> +		setup |= RX8901_REG_PWSW_CFG_CHGEN;

When diode is false, you need to explicitly clear
RX8901_REG_PWSW_CFG_CHGEN so it is possible to actually disable trickle
charging once it has been enabled has the register is battery backed.


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* Re: [PATCH v3] rtc: bq32000: add configurable delay between RTC reads
From: Alexandre Belloni @ 2026-06-24 21:42 UTC (permalink / raw)
  To: Adriana Stancu
  Cc: linux-rtc, devicetree, linux-kernel, robh, krzk+dt, conor+dt
In-Reply-To: <20260416142151.3385827-1-adriana@arista.com>

On Thu, 16 Apr 2026 07:21:51 -0700, Adriana Stancu wrote:
> When the RTC is used on systems without a interrupt line, userspace
> tools like `hwclock` fall back to a frequent polling loop to synchronize
> with the edge of the next second.
> 
> On the BQ32000, this aggressive polling can temporarly lock the register
> refresh cycle, because the continuous transfers prevent the hardware from
> updating the buffer. This results in stale data reads or select() timeouts
> in userspace.
> 
> [...]

Applied, thanks!

[1/1] rtc: bq32000: add configurable delay between RTC reads
      https://git.kernel.org/abelloni/c/d4992b7050a1

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* Re: (subset) [PATCH v2 0/3] rtc: ds1307: Add support for Epson RX8901CE
From: Alexandre Belloni @ 2026-06-24 21:42 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Nobuhiro Iwamatsu,
	Fredrik M Olsson
  Cc: linux-rtc, devicetree, linux-kernel, kernel, Krzysztof Kozlowski,
	Nobuhiro Iwamatsu
In-Reply-To: <20260520-ds1307-rx8901-add-v2-0-e069ea32e1db@axis.com>

On Wed, 20 May 2026 16:48:52 +0200, Fredrik M Olsson wrote:
> Add basic support for the Epson RX8901CE RTC.
> Datasheet: https://download.epsondevice.com/td/pdf/app/RX8901CE_en.pdf
> 
> Also includes a bug fix for an issue with reading the weekday from the
> RTC which affects both the existing rx8130 and this rx8901 driver.
> 
> 
> [...]

Applied, thanks!

[1/3] dt-bindings: rtc: ds1307: Add epson,rx8901
      https://git.kernel.org/abelloni/c/cc387941c0a1
[2/3] rtc: ds1307: Fix off-by-one issue with wday for rx8130
      https://git.kernel.org/abelloni/c/6882aab3c661

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* Re: [PATCH] rtc: cmos: unregister HPET IRQ handler on probe failure
From: Alexandre Belloni @ 2026-06-24 21:49 UTC (permalink / raw)
  To: bwalle, akpm, Haoxiang Li; +Cc: linux-rtc, linux-kernel
In-Reply-To: <20260623100848.2127281-1-haoxiang_li2024@163.com>

On Tue, 23 Jun 2026 18:08:48 +0800, Haoxiang Li wrote:
> cmos_do_probe() registers cmos_interrupt() as the HPET RTC IRQ
> handler before requesting the RTC IRQ and registering the RTC
> device. If either request_irq() or devm_rtc_register_device()
> fails afterwards, the error path leaves the HPET RTC IRQ handler
> installed. This leaves a stale handler behind and make a later
> hpet_register_irq_handler() fail with -EBUSY.
> 
> [...]

Applied, thanks!

[1/1] rtc: cmos: unregister HPET IRQ handler on probe failure
      https://git.kernel.org/abelloni/c/a5bb580df018

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* Re: (subset) [PATCH v2 1/2] rtc: Add rtc_read_next_alarm() to read next expiring timer
From: Mario Limonciello @ 2026-06-24 23:30 UTC (permalink / raw)
  To: Shyam Sundar S K, Ilpo Järvinen
  Cc: Hans de Goede, platform-driver-x86, linux-kernel, linux-rtc,
	Thomas Gleixner, Alexandre Belloni
In-Reply-To: <178233558814.1517260.7453046865036017375.b4-ty@b4>



On 6/24/26 14:15, Alexandre Belloni wrote:
> On Wed, 20 May 2026 23:37:13 -0500, Mario Limonciello wrote:
>> Add a new function rtc_read_next_alarm() that reads the next expiring
>> alarm from the RTC timerqueue. This is different from rtc_read_alarm(),
>> which only reads the aie_timer.
>>
>> The wakealarm sysfs file programs the rtc->aie_timer, whereas the
>> alarmtimer suspend routine programs its own timer into the RTC timerqueue.
>> Both timers end up in the RTC's timerqueue, and the first expiring timer
>> is what gets armed in the hardware.
>>
>> [...]
> 
> Applied, thanks!
> 
> [1/2] rtc: Add rtc_read_next_alarm() to read next expiring timer
>        https://git.kernel.org/abelloni/c/947d7ea6f60b
> 
> Best regards,
> 

Thanks!

Ilpo, Shyam,

How do you want to handle patch 2/2?  Immutable branch and come through 
pdx86?  Or would you rather it go through Alexandre's tree?

Thanks,

^ permalink raw reply

* Re: [PATCH v2 2/2] platform/x86: amd-pmc: Fix S0i3 wakeup with alarmtimer
From: Ilpo Järvinen @ 2026-06-25 10:06 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Shyam Sundar S K, Alexandre Belloni, Hans de Goede,
	platform-driver-x86, LKML, linux-rtc, Thomas Gleixner
In-Reply-To: <20260521043714.1022930-3-mario.limonciello@amd.com>

[-- Attachment #1: Type: text/plain, Size: 2080 bytes --]

On Wed, 20 May 2026, Mario Limonciello wrote:

> It was reported that suspend-then-hibernate stopped working with modern
> systemd versions on AMD Cezanne systems. The reason for this breakage
> was because systemd switched to using alarmtimer instead of the wakealarm
> sysfs file.
> 
> On AMD Cezanne systems, amd_pmc_verify_czn_rtc() programs a secondary
> timer with the alarm time. This was introduced by
> commit 59348401ebed ("platform/x86: amd-pmc: Add special handling for
> timer based S0i3 wakeup"). However, this function uses rtc_read_alarm(),
> which only reads the aie_timer, not the next expiring timer from the
> timerqueue.
> 
> When both alarmtimer and wakealarm are active, the first expiring timer
> might be the alarmtimer, but amd_pmc_verify_czn_rtc() would only see
> the aie_timer, potentially missing the earlier alarm.
> 
> Switch to rtc_read_next_alarm() to read whichever timer will fire next.
> Also handle -ENOENT (no alarm pending) explicitly as a non-error case.
> 
> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3591
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/platform/x86/amd/pmc/pmc.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
> index 50f5784f2aa2e..8cd2db0ccaacd 100644
> --- a/drivers/platform/x86/amd/pmc/pmc.c
> +++ b/drivers/platform/x86/amd/pmc/pmc.c
> @@ -595,9 +595,12 @@ static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg)
>  	rtc_device = rtc_class_open("rtc0");
>  	if (!rtc_device)
>  		return 0;
> -	rc = rtc_read_alarm(rtc_device, &alarm);
> -	if (rc)
> -		return rc;
> +	rc = rtc_read_next_alarm(rtc_device, &alarm);
> +	if (rc) {
> +		if (rc == -ENOENT)
> +			dev_dbg(pdev->dev, "no alarm pending\n");
> +		return rc == -ENOENT ? 0 : rc;
> +	}
>  	if (!alarm.enabled) {
>  		dev_dbg(pdev->dev, "alarm not enabled\n");
>  		return 0;

Acked-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

^ permalink raw reply

* Re: (subset) [PATCH v2 1/2] rtc: Add rtc_read_next_alarm() to read next expiring timer
From: Ilpo Järvinen @ 2026-06-25 10:08 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Shyam Sundar S K, Hans de Goede, platform-driver-x86, LKML,
	linux-rtc, Thomas Gleixner, Alexandre Belloni
In-Reply-To: <9415b405-ec6c-425b-8abb-42964f5a2b3a@amd.com>

On Wed, 24 Jun 2026, Mario Limonciello wrote:
> On 6/24/26 14:15, Alexandre Belloni wrote:
> > On Wed, 20 May 2026 23:37:13 -0500, Mario Limonciello wrote:
> > > Add a new function rtc_read_next_alarm() that reads the next expiring
> > > alarm from the RTC timerqueue. This is different from rtc_read_alarm(),
> > > which only reads the aie_timer.
> > > 
> > > The wakealarm sysfs file programs the rtc->aie_timer, whereas the
> > > alarmtimer suspend routine programs its own timer into the RTC timerqueue.
> > > Both timers end up in the RTC's timerqueue, and the first expiring timer
> > > is what gets armed in the hardware.
> > > 
> > > [...]
> > 
> > Applied, thanks!
> > 
> > [1/2] rtc: Add rtc_read_next_alarm() to read next expiring timer
> >        https://git.kernel.org/abelloni/c/947d7ea6f60b
> > 
> > Best regards,
> > 
> 
> Thanks!
> 
> Ilpo, Shyam,
> 
> How do you want to handle patch 2/2?  Immutable branch and come through pdx86?
> Or would you rather it go through Alexandre's tree?

It would be easier if it too goes through Alexandre's tree and I don't 
expect conflicts on that area. I've replied with my Ack to 2/2.

-- 
 i.


^ permalink raw reply

* Re: (subset) [PATCH v2 0/2] Fix S0i3 wakeup with alarmtimer
From: Alexandre Belloni @ 2026-06-25 12:43 UTC (permalink / raw)
  To: Shyam Sundar S K, Mario Limonciello
  Cc: Hans de Goede, Ilpo Järvinen, platform-driver-x86,
	linux-kernel, linux-rtc, Thomas Gleixner
In-Reply-To: <20260521043714.1022930-1-mario.limonciello@amd.com>

On Wed, 20 May 2026 23:37:12 -0500, Mario Limonciello wrote:
> It was reported that suspend-then-hibernate stopped working with modern
> systemd versions on AMD Cezanne systems. The reason for this breakage
> was because systemd switched to using alarmtimer instead of the wakealarm
> sysfs file.
> 
> But really it uncovered deeper problems with how these timers work.  Adjust
> the code accordingly.
> 
> [...]

Applied, thanks!

[2/2] platform/x86: amd-pmc: Fix S0i3 wakeup with alarmtimer
      https://git.kernel.org/abelloni/c/f7ecfc3fe575

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* Re: [PATCH] rtc: ds1307: update reference to removed CONFIG_RTC_DRV_DS1307_HWMON
From: Alexandre Belloni @ 2026-06-25 12:45 UTC (permalink / raw)
  To: linux-rtc, Ethan Nelson-Moore; +Cc: Heiner Kallweit
In-Reply-To: <20260610054723.261008-1-enelsonmoore@gmail.com>

On Tue, 09 Jun 2026 22:47:22 -0700, Ethan Nelson-Moore wrote:
> The CONFIG_RTC_DRV_DS1307_HWMON macro was removed in favor of
> CONFIG_HWMON in commit 6b583a64fd1e ("rtc: ds1307: simplify hwmon
> config"), but a reference to it remained in a comment. Correct this
> reference.
> 
> Discovered while searching for CONFIG_* symbols referenced in code but
> not defined in any Kconfig file.
> 
> [...]

Applied, thanks!

[1/1] rtc: ds1307: update reference to removed CONFIG_RTC_DRV_DS1307_HWMON
      https://git.kernel.org/abelloni/c/3c8f28578a0d

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply

* [PATCH 1/2] rtc: mv: fix potential race condition
From: alexandre.belloni @ 2026-06-25 13:02 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Grégory Clement, linux-rtc, linux-kernel

From: Alexandre Belloni <alexandre.belloni@bootlin.com>

Since the driver allocates the IRQ using devm_request_irq(), this means the
IRQ is going to be automatically unregistered by devres after
mv_rtc_remove() returns.

However, mv_rtc_remove() explicitly disables the hardware clock before
devres teardown happens so the interrupt handler may run while the clock is
disabled leading to a possible bus hang when accessing registers.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-mv.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index f88976fd6d5d..c0f1bcd838e3 100644
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -219,17 +219,15 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(pdata->ioaddr))
 		return PTR_ERR(pdata->ioaddr);
 
-	pdata->clk = devm_clk_get(&pdev->dev, NULL);
-	/* Not all SoCs require a clock.*/
-	if (!IS_ERR(pdata->clk))
-		clk_prepare_enable(pdata->clk);
+	pdata->clk = devm_clk_get_optional_prepared(&pdev->dev, NULL);
+	if (IS_ERR(pdata->clk))
+		return PTR_ERR(pdata->clk);
 
 	/* make sure the 24 hour mode is enabled */
 	rtc_time = readl(pdata->ioaddr + RTC_TIME_REG_OFFS);
 	if (rtc_time & RTC_HOURS_12H_MODE) {
 		dev_err(&pdev->dev, "12 Hour mode is enabled but not supported.\n");
-		ret = -EINVAL;
-		goto out;
+		return  -EINVAL;
 	}
 
 	/* make sure it is actually functional */
@@ -238,8 +236,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
 		rtc_time = readl(pdata->ioaddr + RTC_TIME_REG_OFFS);
 		if (rtc_time == 0x01000000) {
 			dev_err(&pdev->dev, "internal RTC not ticking\n");
-			ret = -ENODEV;
-			goto out;
+			return -ENODEV;
 		}
 	}
 
@@ -249,8 +246,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
 
 	pdata->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(pdata->rtc)) {
-		ret = PTR_ERR(pdata->rtc);
-		goto out;
+		return PTR_ERR(pdata->rtc);
 	}
 
 	if (pdata->irq >= 0) {
@@ -275,9 +271,6 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
 	ret = devm_rtc_register_device(pdata->rtc);
 	if (!ret)
 		return 0;
-out:
-	if (!IS_ERR(pdata->clk))
-		clk_disable_unprepare(pdata->clk);
 
 	return ret;
 }
@@ -288,9 +281,6 @@ static void __exit mv_rtc_remove(struct platform_device *pdev)
 
 	if (pdata->irq >= 0)
 		device_init_wakeup(&pdev->dev, false);
-
-	if (!IS_ERR(pdata->clk))
-		clk_disable_unprepare(pdata->clk);
 }
 
 #ifdef CONFIG_OF
-- 
2.54.0


^ permalink raw reply related

* [PATCH 2/2] rtc: mv: remove mv_rtc_remove
From: alexandre.belloni @ 2026-06-25 13:02 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: Grégory Clement, linux-rtc, linux-kernel
In-Reply-To: <20260625130202.1621692-1-alexandre.belloni@bootlin.com>

From: Alexandre Belloni <alexandre.belloni@bootlin.com>

Use devm_device_init_wakeup() so we can avoid having to explicitly teardown
of module removal.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/rtc/rtc-mv.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c
index c0f1bcd838e3..db64c459ee19 100644
--- a/drivers/rtc/rtc-mv.c
+++ b/drivers/rtc/rtc-mv.c
@@ -260,7 +260,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
 	}
 
 	if (pdata->irq >= 0)
-		device_init_wakeup(&pdev->dev, true);
+		devm_device_init_wakeup(&pdev->dev);
 	else
 		clear_bit(RTC_FEATURE_ALARM, pdata->rtc->features);
 
@@ -275,14 +275,6 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static void __exit mv_rtc_remove(struct platform_device *pdev)
-{
-	struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-
-	if (pdata->irq >= 0)
-		device_init_wakeup(&pdev->dev, false);
-}
-
 #ifdef CONFIG_OF
 static const struct of_device_id rtc_mv_of_match_table[] = {
 	{ .compatible = "marvell,orion-rtc", },
@@ -313,14 +305,7 @@ static int mv_rtc_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(mv_rtc_pm_ops, mv_rtc_suspend, mv_rtc_resume);
 
-/*
- * mv_rtc_remove() lives in .exit.text. For drivers registered via
- * module_platform_driver_probe() this is ok because they cannot get unbound at
- * runtime. So mark the driver struct with __refdata to prevent modpost
- * triggering a section mismatch warning.
- */
-static struct platform_driver mv_rtc_driver __refdata = {
-	.remove		= __exit_p(mv_rtc_remove),
+static struct platform_driver mv_rtc_driver = {
 	.driver		= {
 		.name	= "rtc-mv",
 		.of_match_table = of_match_ptr(rtc_mv_of_match_table),
-- 
2.54.0


^ permalink raw reply related


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