From 09f5d9b8caafdfed36fb8115348e2cf1f1c31793 Mon Sep 17 00:00:00 2001 From: Alexander Sverdlin Date: Fri, 28 Aug 2026 18:44:41 +0200 Subject: [PATCH] rtc: pcf85063: preserve the alarm flag in clkout register updates The clkout rate and enable/disable helpers update CTRL2 with regmap_update_bits() but leave the alarm flag (AF) out of the mask. AF is write-0-to-clear, so an AF that gets asserted between the read and the write of the read-modify-write is written back as 0 and the pending alarm interrupt is lost. Add AF to the mask and write it back as 1 (write-1-to-preserve) so a concurrently asserted alarm flag survives a clkout reconfiguration. Signed-off-by: Alexander Sverdlin Link: https://patch.msgid.link/20260828164445.3907839-4-alexander.sverdlin@siemens.com Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-pcf85063.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c index af900fe8ae15..a3af86456ccf 100644 --- a/drivers/rtc/rtc-pcf85063.c +++ b/drivers/rtc/rtc-pcf85063.c @@ -431,7 +431,8 @@ static int pcf85063_clkout_set_rate(struct clk_hw *hw, unsigned long rate, if (clkout_rates[i] == rate) return regmap_update_bits(pcf85063->regmap, PCF85063_REG_CTRL2, - PCF85063_REG_CLKO_F_MASK, i); + PCF85063_REG_CLKO_F_MASK | PCF85063_CTRL2_AF, + i | PCF85063_CTRL2_AF); return -EINVAL; } @@ -460,7 +461,8 @@ static int pcf85063_clkout_control(struct clk_hw *hw, bool enable) } return regmap_update_bits(pcf85063->regmap, PCF85063_REG_CTRL2, - PCF85063_REG_CLKO_F_MASK, buf); + PCF85063_REG_CLKO_F_MASK | PCF85063_CTRL2_AF, + buf | PCF85063_CTRL2_AF); } static int pcf85063_clkout_prepare(struct clk_hw *hw)