summaryrefslogtreecommitdiff
path: root/drivers/rtc
AgeCommit message (Collapse)Author
11 daysrtc: pcf8563: pass the driver data to the alarm interrupt handlerIgor Velkov
pcf8563_irq() takes its dev_id as struct pcf8563, but probe still registers the interrupt with the i2c client. The handler then takes the regmap pointer from the wrong structure: the first alarm oopses, the level-low INT is never acknowledged, and the interrupt gets disabled as spurious. Only an RTC that has an interrupt (client->irq > 0) reaches this path. Fixes: 00f1bb9b8486 ("rtc: pcf8563: Switch to regmap") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Igor Velkov <iav@iav.lv> Reviewed-by: Nobuhiro Iwamtasu <iwamatsu@nigauri.org> Link: https://patch.msgid.link/20261004-pcf8563-irq-data-v1-1-f176763ddf2f@iav.lv Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
11 daysrtc: nvidia-vrs10: remove locking in IRQ handlerAlexandre Belloni
Remove locking in the interrupt handler as it is not necessary to be locked while calling rtc_update_irq(). Link: https://patch.msgid.link/20261009212347.490403-1-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
11 daysrtc: sun6i: add Allwinner B288 compatiblePablo Mazzini
The 32 kHz clocks are the same as the A23's. Only one alarm interrupt is wired, which is all the driver uses. Signed-off-by: Pablo Mazzini <pmazzini@gmail.com> Link: https://patch.msgid.link/20261012100816.331033-7-pmazzini@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
11 daysrtc: sun6i: fix error handling in sun6i_rtc_clk_init()Pablo Mazzini
Set sun6i_rtc only once all clocks are registered, and unwind fully on error. Signed-off-by: Pablo Mazzini <pmazzini@gmail.com> Link: https://patch.msgid.link/20261014193220.38055-1-pmazzini@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
11 daysrtc: cmos: Honor explicit use_acpi_alarm parameter valueGregory Price
An explicit rtc_cmos.use_acpi_alarm=0 command-line argument is ignored on systems where use_acpi_alarm_quirks() enables ACPI RTC alarms. The argument appears in /proc/cmdline, but the read-only parameter reports Y. The boolean parameter defaults to false, so the driver cannot distinguish an omitted argument from an explicit false value. Use a custom setter to record whether parsing occurred and skip automatic selection when it did. Preserve the bool parameter type metadata. Automatic selection remains unchanged when the parameter is omitted. On the affected system, the explicit false value reports N after this change. The HPET-emulated path completed 100 test runs without a failure while the ACPI RTC event counter remained at zero. Fixes: 36d91a4d401c ("rtc: cmos: introduce quirks to enable use_acpi_alarm mode") Cc: stable@vger.kernel.org Signed-off-by: Gregory Price (Meta) <gourry@gourry.net> Link: https://patch.msgid.link/20261015173029.3091872-3-gourry@gourry.net Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
11 daysrtc: cmos: Disable ACPI RTC event before handling itGregory Price
Users of RTC_UIE_ON can stop receiving update interrupts when rtc-cmos handles alarms through ACPI. In one 50-run test, 40 runs passed and 10 timed out after receiving between one and four of five expected events. The ACPI ff_rt_clk counter stopped at 218, exactly matching the number of events delivered to userspace, and reported: 218 STS disabled unmasked rtc_handler() runs in the threaded ACPI SCI handler and calls cmos_interrupt(), which schedules rtc->irqwork. The work can run before rtc_handler() returns: ACPI SCI thread rtc->irqwork cmos_interrupt() schedule_work() __rtc_set_alarm() rtc_wake_on() acpi_clear_event() acpi_disable_event() The SCI thread then disables the event that the worker enabled for the next alarm. That alarm sets its status while delivery remains disabled, so no update interrupt reaches userspace. Clear and disable the current ACPI RTC event before cmos_interrupt() schedules the work. The worker can then enable the next event without the handler undoing it. With this ordering, 150 runs delivered all 750 events without a stall. Fixes: 311ee9c151ad ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET") Cc: stable@vger.kernel.org Signed-off-by: Gregory Price (Meta) <gourry@gourry.net> Link: https://patch.msgid.link/20261015173029.3091872-2-gourry@gourry.net Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-14drivers: Replace __MODULE_STRING() with __stringify()Petr Pavlu
__MODULE_STRING() has been an alias for __stringify() since "[PATCH] MODULE_PARM support for older modules" [1] in 2002-12. That change also moved it to the graveyard section at the end of linux/module.h Replace the remaining uses of __MODULE_STRING() with __stringify() in preparation for its removal. Link: https://git.kernel.org/tglx/history/c/136839a1b4 [1] Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Andi Shyti <andi.shyti@kernel.org> Acked-by: Ian Abbott <abbotti@mev.co.uk> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Mika Westerberg <westeri@kernel.org> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
2026-10-09rtc: abx80x: add support for ABX81XAntoni Pokusinski
Abracon ABX81X is a family of RTCs with SPI interface featuring the same functionalities as the ABX80X I2C clocks. Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com> Link: https://patch.msgid.link/20260916205138.16771-10-apokusinski01@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-09rtc: abx80x: create abx80x_i2c_probe()Antoni Pokusinski
Move the I2C-specific code from abx80x_probe() to the newly created function. This is a preparation for introducing the support for ABX81X RTCs which use SPI interface. Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com> Link: https://patch.msgid.link/20260916205138.16771-9-apokusinski01@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-09rtc: abx80x: replace read-modify-write pattern with regmap helpersAntoni Pokusinski
Before introducing the regmap usage in the driver, updating specific bits of a register was performed using the read-modify-write pattern. Now, the functions regmap_update_bits() and regmap_write_bits() can be used to simplify the code. Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com> Link: https://patch.msgid.link/20260916205138.16771-8-apokusinski01@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-09rtc: abx80x: use regmap instead of I2C specific APIAntoni Pokusinski
Rework the driver so that it uses regmap_* functions for communication with the device instead of the i2c_smbus_* API. This way the support for ABX81X RTCs which use SPI can be added later. Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com> Link: https://patch.msgid.link/20260916205138.16771-7-apokusinski01@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-09rtc: abx80x: add irq to struct abx80x_privAntoni Pokusinski
This way the irq number is not tied to the i2c_client and can be easily accessed also in the case of ABX81X SPI clocks. Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com> Link: https://patch.msgid.link/20260916205138.16771-6-apokusinski01@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-09rtc: abx80x: properly handle shared IRQsAntoni Pokusinski
The abx80x RTC driver registers its interrupt handler with IRQF_SHARED, but the handler always returned IRQ_HANDLED and cleared the status register even when no interrupt source from the RTC was active. This could cause the driver to claim interrupts belonging to other devices sharing the same IRQ line and could also clear unrelated status bits in the RTC status register. Only handle the interrupt when the alarm or watchdog flags are set, and clear only those interrupt status bits that were handled. Return IRQ_NONE when the interrupt was not generated by the RTC. Fixes: 718a820a303c ("rtc: abx80x: add alarm support") Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com> Link: https://patch.msgid.link/20260916205138.16771-5-apokusinski01@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-09rtc: abx80x: add mutex protection for register writesAntoni Pokusinski
The ABX80X RTC driver performs multi-step register operations such as NVMEM transfers or register writes preceded by a configuration key write. Add a mutex to serialize all the register writes to protect these sequences against race conditions. Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com> Link: https://patch.msgid.link/20260916205138.16771-4-apokusinski01@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-09rtc: abx80x: fix error check after i2c_smbus_read in read_alarm()Antoni Pokusinski
i2c_smbus_read_i2c_block_data() returns the number of bytes read on success and a negative error code on failure. The existing code treated any non-zero return value as an error. Fix the error handling by checking only for negative return values. Fixes: 718a820a303c ("rtc: abx80x: add alarm support") Signed-off-by: Antoni Pokusinski <apokusinski01@gmail.com> Link: https://patch.msgid.link/20260916205138.16771-3-apokusinski01@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-08rtc: pcf8563: add SMBus supportMichael Walle
Since commit 00f1bb9b8486 ("rtc: pcf8563: Switch to regmap") the driver uses regmap to access the RTC. Regmap itself will figure out if there is a suitable I2C or SMBus host controllers. Thus, don't restict the driver to just I2C controllers and make it work on SMBus controllers supporting i2c block accesses, too. This was tested on a custom x86 board. Signed-off-by: Michael Walle <mwalle@kernel.org> Link: https://patch.msgid.link/20261008071408.3548442-1-mwalle@kernel.org Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-08rtc: ftrtc010: fix castAlexandre Belloni
The hour and minute registers will rollover before the multiplication to convert to a number of seconds can exceed an 32bit integer, there is no need to cast them. Reported-by: Dan Carpenter <error27@gmail.com> Link: https://patch.msgid.link/20261002105946.8rdteIpO7uWGEcTlS65F8iSi4gsRoXi2kgq8FTSaDPA@z/ Reviewed-by: Linus Walleij <linusw@kernel.org> Link: https://patch.msgid.link/20261005111502.159855-1-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-02rtc: ftrtc010: fix integer overflow in time calculationLiu Dalin
In ftrtc010_rtc_read_time() and ftrtc010_rtc_set_time(), all variables (offset, days, hour, min, sec) are u32. The expression "days * 86400 + hour * 3600 + min * 60 + sec" is evaluated in 32-bit arithmetic, which silently wraps around for dates beyond approximately year 2106 (U32_MAX / 86400 ≈ 49710 days). In ftrtc010_rtc_read_time(), perform the addition in 32-bit arithmetic first to preserve two's complement wrapping for negative offsets, then cast the result to timeu64_t. In ftrtc010_rtc_set_time(), cast individual u32 operands to timeu64_t before multiplication to prevent overflow in the right-hand side of the offset calculation. Fixes: 1d61d2592c1f ("rtc: gemini/ftrtc010: rename driver and symbols") Assisted-by: Sashiko AI [static analysis] Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn> Reviewed-by: Linus Walleij <linusw@kernel.org> Tested-by: Liu Dalin <liudalin@kylinsec.com.cn> Link: https://patch.msgid.link/42C8FBD59AA34EA9+20260827080320.3351155-4-liudalin@kylinsec.com.cn Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-01rtc: ftrtc010: use devm clock APIs to fix use-after-disable in removeLiu Dalin
The driver mixes devm_rtc_register_device() with manual clock disabling in ftrtc010_rtc_remove(). Because the RTC device was registered via devm, it remains registered until devres cleanup runs after .remove() returns. An unprivileged process holding an open /dev/rtc0 file descriptor could issue ioctl(RTC_RD_TIME) during this window, triggering MMIO reads on clock-gated hardware and causing a synchronous external abort. Replace devm_clk_get() + clk_prepare_enable() with devm_clk_get_enabled() to tie clock lifecycle to devres. Remove the manual .remove() callback and the corresponding error handling labels in ftrtc010_rtc_probe(). Fixes: 1d61d2592c1f ("rtc: ftrtc010: Rename to Faraday FTRTC010") Assisted-by: Sashiko AI [static analysis] Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn> Reviewed-by: Linus Walleij <linusw@kernel.org> Tested-by: Liu Dalin <liudalin@kylinsec.com.cn> Link: https://patch.msgid.link/0238203A74C9B9F6+20260827080320.3351155-3-liudalin@kylinsec.com.cn Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-10-01rtc: ftrtc010: fix clock resource leak on probe failureLiu Dalin
When devm_rtc_register_device() fails, ftrtc010_rtc_probe() returns the error directly without releasing clocks obtained via clk_prepare_enable(). This leaks both extclk and pclk resources, which may prevent subsequent probe attempts or module removal. Capture the return value and jump to the error handling path to properly release clocks via clk_disable_unprepare(). Fixes smatch warnings: - drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn: 'rtc->extclk' from clk_prepare_enable() not released on lines: 183. - drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn: 'rtc->pclk' from clk_prepare_enable() not released on lines: 183. Fixes: fdcfd854333b ("rtc: rework rtc_register_device() resource management") Assisted-by: smatch:2.0 [static analysis] Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn> Reviewed-by: Linus Walleij <linusw@kernel.org> Tested-by: Liu Dalin <liudalin@kylinsec.com.cn> Link: https://patch.msgid.link/AC51B5F2C5FFEBB0+20260827080320.3351155-2-liudalin@kylinsec.com.cn Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-30rtc: bd70528: properly enable wakeupAndreas Kemnade
Wakeup on RTC alarm now only accidentially works when wakeup for the power button connected to the same PMIC is also enabled. Fix that by properly specifying the wakeup irq. Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Fixes: 32a4a4ebf768 ("rtc: bd70528: Initial support for ROHM bd70528 RTC") Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Link: https://patch.msgid.link/20260922-rtc-bd-v3-1-7f2580c55d58@kemnade.info Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-30rtc: mt6397: expose the spare bytes of the alarm registers as nvmemRyan Brue
Each alarm field lives in the low bits of its register and the driver masks its writes accordingly, so the high byte of four of them is storage the RTC never touches. MediaTek names these RTC_NEW_SPARE0 to RTC_NEW_SPARE3 and gives the first to a fuel gauge, which is how its PMIC battery drivers carry a state of charge over a reboot. Offer all four as a battery-backed nvmem provider, so that a consumer does not have to reach into this block behind the driver's back. Doing it here is what makes it safe: a write lands under the same lock the alarm paths take, so it can neither be lost inside mtk_rtc_set_alarm()'s read-modify-write nor fire the write trigger in the middle of one. The nvmem core does not range check a cell against the provider size, so the callbacks check the offset themselves. Tested on an MT6397; MediaTek's spare map for mt6323 matches, and the alarm field masks are common to every compatible this driver binds. Assisted-by: LLM Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://patch.msgid.link/20260917-rbrue-suez-upstreaming-mt6397-rtc-nvmem-v1-2-558b8f95cfbc@gmail.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-30rtc: rzn1: add R-Car X5H supportWolfram Sang
The RTC on R-Car X5H is a bit special because interrupts are not wired. Future R-Car Gen5 SoCs will have them wired again. So, create a dedicated entry for X5H without interrupts. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/20260917185903.61253-10-wsa+renesas@sang-engineering.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-30rtc: omap: remove unused argumentAlexandre Belloni
omap_rtc_power_off_program takes one argument that is never used. One call passes the struct device of the rtc but the other one passes its parent. To avoid confusion, stop taking any argument Reviewed-by: Nishanth Menon <nm@ti.com> Link: https://patch.msgid.link/20260917142654.2576889-1-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-23rtc: bd70528: Support RTC on ROHM BD73800Matti Vaittinen
BD73800 contains similar RTC block as BD71828 and BD71815. Only the address offsets seem different. Support also BD73800 RTC using the rtc-bd70528. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://patch.msgid.link/1ff511f419fcbd72dd241f598127608a6a0c9598.1789538455.git.mazziesaccount@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
2026-09-21rtc: spear: initialize IRQ state before requesting alarm IRQRunyu Xiao
devm_request_irq() enables the interrupt before it returns, so the handler may run while probe is still initializing the device. Initialize the MMIO address and spinlock before requesting the alarm IRQ. Fixes: 0942a71e435f ("rtc: add support for spear rtc") Cc: stable@vger.kernel.org Assisted-by: Codex:GPT-5 Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn> Link: https://patch.msgid.link/20260902080318.3498434-1-runyu.xiao@seu.edu.cn Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-21rtc: mpfs: fix unchecked devm_clk_get() error pointer in probe()Manush Prajwal
devm_clk_get(&pdev->dev, "rtcref")'s return value was passed straight into clk_get_rate() without checking it for an error first, unlike the "rtc" clock a few lines above which is correctly checked with IS_ERR(). clk_get_rate() only guards against a NULL clk, not an error pointer: if (!clk) return 0; ... rate = clk_core_get_rate_recalc(clk->core); so if devm_clk_get() ever returns an error pointer here (for example ERR_PTR(-EPROBE_DEFER), which is the normal, expected outcome if the clkcfg clock-provider this RTC depends on has not registered its clocks yet by the time this driver probes), clk_get_rate() dereferences that error pointer instead of returning 0, crashing instead of letting probe defer. Capture the clock in the existing 'clk' local and check it with IS_ERR() before calling clk_get_rate(), matching the handling already used for the "rtc" clock in this same function. Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com> Fixes: 0b31d703598d ("rtc: Add driver for Microchip PolarFire SoC") Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://patch.msgid.link/6a9d4b02.7d74b517.206c4c.75f8@mx.google.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-21rtc: ac100: Fix clock provider use-after-free on probe failureAamir Ahmed
ac100_rtc_register_clks() registers the RTC-32k clock with clk_hw_register_fixed_rate() and the clock provider with of_clk_add_hw_provider(). Neither is device managed, and both are released only from ac100_rtc_remove(). The driver core does not call remove() when probe() fails: really_probe() reaches probe_failed below the device_remove() call and goes straight to releasing the device's managed resources. ac100_rtc_probe() ends with return devm_rtc_register_device(chip->rtc); so if that fails after the clocks have been registered, the provider is left on the global of_clk_providers list holding chip->clk_data, which was allocated with devm_kzalloc() and is freed while probe() unwinds. A later lookup on this device tree node then reads freed memory in of_clk_hw_onecell_get(). Consumers that do exactly that exist in tree: the wifi power sequence nodes on sun8i-a83t-bananapi-m3 and sun8i-a83t-cubietruck-plus take <&ac100_rtc 1>, and the sun9i-a80 boards route osc32k through <&ac100_rtc 0>. The window is narrow, as devm_rtc_register_device() can only fail with -ENOMEM here, but the provider is left dangling whenever it does. The RTC-32k clock is leaked on the same path. Since clk_core_lookup() searches a global list that is not scoped per device, __clk_register() rejects the duplicate name with -EEXIST, so the leak also makes a later probe of the same device fail. The error path that returns -EINVAL when the ADDA 4M parent clock cannot be found leaks the RTC-32k clock in the same way. No provider has been registered at that point, so that one is a leak rather than a use-after-free. Register both with devm_clk_hw_register_fixed_rate() and devm_of_clk_add_hw_provider() so that they are released whenever the device goes away, on a failed probe as well as on unbind. Devres releases in reverse order of acquisition, so the provider is removed before chip->clk_data is freed, and the clkout children are now unregistered before their parent rather than after it. ac100_rtc_unregister_clks() and the remove callback then have nothing left to do and are removed. Fixes: d00a18a42c14 ("rtc: ac100: Add RTC driver for X-Powers AC100") Reported-by: Sashiko AI <sashiko-bot@kernel.org> Closes: https://lore.kernel.org/linux-rtc/20260905184936.155E11F00A3A@smtp.kernel.org/ Assisted-by: LLM Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk> Link: https://patch.msgid.link/AS8P251MB0001A489CC45A591ABBB9BDCC8B42@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-21rtc: ac100: Assign .num before accessing .hwsAamir Ahmed
Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") annotated the hws member of 'struct clk_hw_onecell_data' with __counted_by, which informs the bounds sanitizer (UBSAN_BOUNDS) about the number of elements in .hws[], so that it can warn when .hws[] is accessed out of bounds. As noted in that change, the __counted_by member must be initialized with the number of elements before the first array access happens, otherwise there will be a warning from each access prior to the initialization because the number of elements is zero. This occurs in ac100_rtc_register_clks() due to .num being assigned only after every clkout clock has been stored in .hws[]. With CONFIG_UBSAN_BOUNDS and a compiler that implements __counted_by (GCC 15.1+ or Clang 20.1+), this triggers an array-index-out-of-bounds report during probe, and with CONFIG_UBSAN_TRAP the first store traps. Initialize .num with AC100_CLKOUT_NUM, the number of elements .hws[] was allocated with, right after the allocation. That is the value the loop counter ends up at on the success path anyway, so the provider's behaviour is unchanged. Cc: stable@vger.kernel.org Fixes: f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") Assisted-by: LLM Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk> Reviewed-by: Chen-Yu Tsai <wens@kernel.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://patch.msgid.link/AS8P251MB00013E724A77A355668B6CCEC8B42@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-21rtc: efi: restore alarm support with runtime capability probeJohnny.Fan
Restore the EFI RTC alarm functionality (read_alarm/set_alarm and procfs output) that was removed by commit 18a3510bc87d ("rtc: efi: Remove wakeup functionality"). The removal was motivated by the observation that many EFI platforms lack RTC wakeup support while also omitting the RT_PROP table, causing the wakeup capability to be incorrectly advertised. While that is true, removing the feature entirely also breaks platforms where the wakeup runtime service actually works. On CIX SoCs, the RTC is an I2C device owned by firmware, and in the ACPI boot configuration the I2C bus it sits on is not exposed to the OS, so the EFI runtime services are the only way Linux can access the RTC at all. Both Linux and Windows use this same interface by design, so the RTC state is consistent across the operating systems installed on the machine, and Windows relies on the EFI wakeup services for its own RTC alarm support. With the alarm support removed from rtc-efi, Linux loses the equivalent capability entirely on these platforms: rtcwake fails for both suspend-to-RAM and power-off wakeup, as there is no other path to program the RTC alarm. This is a real product requirement that CIX customers have explicitly requested, not a hypothetical use case. To avoid exposing a broken alarm on firmware that does not implement the wakeup runtime services, probe the capability at ->probe() time by actually calling GetWakeupTime() -- if it fails, clear RTC_FEATURE_ALARM and the device behaves as before the removal. Also set RTC_FEATURE_ALARM_WAKEUP_ONLY since EFI wakeup time is a wakeup-only alarm, not a periodic/update interrupt source. Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Feng Tang <feng.tang@linux.alibaba.com> Reviewed-by: Fugang Duan <fugang.duan@cixtech.com> Signed-off-by: Johnny.Fan <Johnny.Fan@cixtech.com> Link: https://patch.msgid.link/20260831140014.839222-1-johnny.fan@cixtech.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-09-21rtc: dev: zero-initialize struct rtc_wkalrm to prevent information leakLiu Dalin
The struct rtc_wkalrm has padding holes after the 'pending' member. When returned to userspace via the RTC_WKALRM_RD ioctl, uninitialized kernel stack data residing in these holes may be leaked. Zero-initialize the struct at declaration to eliminate this information leak risk. Fixes smatch warnings: - drivers/rtc/dev.c:392 rtc_dev_ioctl() warn: check that 'alarm' doesn't leak information (struct has a hole after 'pending') Fixes: 36e14f5fdfdf ("rtc: rename core files") Assisted-by: smatch:2.0 [static analysis] Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn> Link: https://patch.msgid.link/B28B7DE18F3A9447+20260827015444.3314227-1-liudalin@kylinsec.com.cn Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-28Merge tag 'rtc-7.3' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux Pull RTC updates from Alexandre Belloni: "The RZN1 driver got a fairly comprehensive cleanup. More DT binding are converted to DT schema, leaving only 5 remaining files to convert. Subsystem: - patchwork project is moving to kernel.org - fully initialize clk_init_data - add missing MODULE_DEVICE_TABLE() - DT bindings conversions to DT schema Drivers: - ds1307: fix WADA bit for alarms on RX8130 - rzn1: add support for RZ/T2H and RZ/N2H, many fixes" * tag 'rtc-7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (42 commits) MAINTAINERS: update rtc subsystem patchwork location rtc: msc313: Select by default on MSTARV7 rtc: microcrystal: Make sure clk_init_data is fully initialized rtc: philips: Make sure clk_init_data is fully initialized rtc: nct3018y: Make sure clk_init_data is fully initialized rtc: m41t80: Make sure clk_init_data is fully initialized rtc: hym8563: Make sure clk_init_data is fully initialized rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs rtc: rzn1: Drop trailing comma from OF match table sentinel rtc: rzn1: Add OF match data to gate SUBU register access rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register access rtc: rzn1: Consistently use dev_err_probe() rtc: rzn1: Use temporary variable for struct device rtc: rzn1: Dynamically calculate synchronization delay based on clock rate rtc: rzn1: Replace remove callback with devm_add_action_or_reset() rtc: rzn1: Use pm_runtime_put_sync() rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESAS rtc: rzn1: Fix malformed MODULE_AUTHOR string rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers rtc: rzn1: Fix alarm range check truncation on 32-bit systems ...
2026-08-24rtc: msc313: Select by default on MSTARV7Daniel Palmer
All of the ARCH_MSTARV7 chips have this RTC so it's more likely ARCH_MSTARV7 wants it than doesn't. At the same time fix up the indent on the depends on line that looks like it got converted from a tab to spaces at some point. Signed-off-by: Daniel Palmer <daniel@0x0f.com> Link: https://patch.msgid.link/20260713133919.1356748-1-daniel@thingy.jp Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: microcrystal: Make sure clk_init_data is fully initializedGeert Uytterhoeven
The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled. Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/6e7b5258ff73e93fe23dd83cf56f806ee60fa7a9.1787241693.git.geert+renesas@glider.be Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: philips: Make sure clk_init_data is fully initializedGeert Uytterhoeven
The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled. Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/8281eaf605069aac2211d83233e11285b8e8ca84.1787241693.git.geert+renesas@glider.be Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: nct3018y: Make sure clk_init_data is fully initializedGeert Uytterhoeven
The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled. Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/6dba18b645aeea279a67f4625d5ec48037c76f0c.1787241693.git.geert+renesas@glider.be Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: m41t80: Make sure clk_init_data is fully initializedGeert Uytterhoeven
The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled. Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/c5290fb9a28b45d6bcec724d5897f8bcbf96ea50.1787241693.git.geert+renesas@glider.be Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: hym8563: Make sure clk_init_data is fully initializedGeert Uytterhoeven
The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled. Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/657f2b3a871074087aee0b7a70bf527ab0f48da8.1787241693.git.geert+renesas@glider.be Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCsLad Prabhakar
Add support for the RTC block found on the Renesas RZ/T2H (R9A09G077) and RZ/N2H (R9A09G087) SoCs. These SoCs integrate a closely related variant of the RZ/N1 RTC IP, but do not implement the RTCA0SUBU register. Use variant-specific match data to disable SUBU support for these SoCs. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-18-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Drop trailing comma from OF match table sentinelLad Prabhakar
Drop the trailing comma from the final empty entry in the RZN1 RTC OF match table and mark it explicitly as the sentinel. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-17-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Add OF match data to gate SUBU register accessLad Prabhakar
The RZ/N1 RTC driver selects SCMP mode only when an optional xtal clock is provided at a valid rate other than 32768 Hz. Without an xtal clock, or when it runs at 32768 Hz, the driver uses SUBU mode. However, the RTCA0SUBU register used by SUBU mode is not present on all SoCs that integrate a similar variant of the RTC block. Allowing SUBU mode on those variants would expose RTC offset operations that access a non-existent register. Add OF match data to describe whether the RTC supports the SUBU register. Reject probe with -EOPNOTSUPP when SUBU mode would be selected on a variant without SUBU support. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Suggested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-16-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register accessLad Prabhakar
Replace open-coded shift and mask operations with the bitfield API. Note that the weekday field is changed from an explicit 0x0f mask to an 8-bit field definition, matching the hardware manual. This does not change behaviour, as valid weekday values cannot exceed 7. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-15-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Consistently use dev_err_probe()Lad Prabhakar
Use dev_err_probe() in the IRQ request error path to make error handling consistent with the rest of rzn1_rtc_probe(). Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-14-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Use temporary variable for struct deviceLad Prabhakar
Use a temporary variable for the struct device pointers to avoid dereferencing. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-13-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Dynamically calculate synchronization delay based on clock rateLad Prabhakar
Replace the hardcoded hardware synchronization delays with a calculated time window derived from the operating sub-clock frequency. The driver currently hardcodes microsecond ranges assuming a fixed sub-clock frequency of 32.768 kHz. Newer SoC variants, such as the RZ/T2H, drive this hardware block using a much faster clock rate (~195.3 kHz). Hardcoding these wait windows forces faster blocks to over-sleep, introducing unnecessary delays during clock initialization and register configuration. Calculate the duration of the required clock cycles in microseconds based on the runtime clock rate, and store this value in the driver private structure to adjust the usleep_range() and readl_poll_timeout() boundaries dynamically. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-12-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Replace remove callback with devm_add_action_or_reset()Lad Prabhakar
Simplify the driver teardown by registering a managed cleanup action with devm_add_action_or_reset(). This eliminates the explicit probe error path and allows the .remove() callback to be dropped. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-11-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Use pm_runtime_put_sync()Lad Prabhakar
pm_runtime_put() may trigger the idle check after pm_runtime_disable() is run as part of devm_pm_runtime_enable()'s cleanup action, leaving runtime PM active. Use pm_runtime_put_sync() to ensure the idle check runs synchronously. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-10-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESASLad Prabhakar
Replace the ARCH_RZN1 dependency with ARCH_RENESAS for the RTC_DRV_RZN1 config option to make the driver available across both ARM32 and ARM64 Renesas architectures. The newer RZ/T2H and RZ/N2H ARM64 SoCs integrate a closely related variant of the RTC IP block found on the RZ/N1 SoCs. Update the build dependency and expand the Kconfig help text to allow this driver to be selected for these additional platforms. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-9-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Fix malformed MODULE_AUTHOR stringLad Prabhakar
Fix a malformed MODULE_AUTHOR macro in the rtc-rzn1 driver where a missing closing angle bracket on the second author entry creates an invalid format. Correct it to the standard "Name <email>" format. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-8-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2026-08-23rtc: rzn1: Disable alarm interrupt before reprogramming alarm registersLad Prabhakar
rzn1_rtc_set_alarm() updates RZN1_RTC_ALM, RZN1_RTC_ALH and RZN1_RTC_ALW using separate MMIO writes without first disabling the alarm interrupt. If a previous alarm is still enabled, the interrupt can fire while the alarm registers contain a mixture of old and newly written values. Fix this by disabling the alarm interrupt before reprogramming ALM, ALH and ALW with a call to rzn1_rtc_alarm_irq_enable(). Fixes: b5ad1bf00d2c4 ("rtc: rzn1: Add alarm support") Cc: stable@vger.kernel.org Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://patch.msgid.link/20260821211032.13554-7-prabhakar.mahadev-lad.rj@bp.renesas.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>