Linux RTC
 help / color / mirror / Atom feed
From: "A. Sverdlin" <alexander.sverdlin@siemens.com>
To: linux-rtc@vger.kernel.org
Cc: Alexander Sverdlin <alexander.sverdlin@siemens.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/4] rtc: pcf85063: preserve the alarm flag in clkout register updates
Date: Fri, 28 Aug 2026 18:44:41 +0200	[thread overview]
Message-ID: <20260828164445.3907839-4-alexander.sverdlin@siemens.com> (raw)
In-Reply-To: <20260828164445.3907839-1-alexander.sverdlin@siemens.com>

From: Alexander Sverdlin <alexander.sverdlin@siemens.com>

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 <alexander.sverdlin@siemens.com>
---
Changelog:
v3:
- new patch

 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 af900fe8ae15e..a3af86456ccfc 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)
-- 
2.55.0


  parent reply	other threads:[~2026-08-28 16:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 16:44 [PATCH v3 0/4] rtc: pcf85063: Update interrupt support A. Sverdlin
2026-08-28 16:44 ` [PATCH v3 1/4] rtc: pcf85063: use devm_of_clk_add_hw_provider() for clkout A. Sverdlin
2026-08-28 16:51   ` sashiko-bot
2026-08-28 16:44 ` [PATCH v3 2/4] rtc: pcf85063: do not clear AIE in the interrupt handler A. Sverdlin
2026-08-28 17:05   ` sashiko-bot
2026-08-28 16:44 ` A. Sverdlin [this message]
2026-08-28 16:58   ` [PATCH v3 3/4] rtc: pcf85063: preserve the alarm flag in clkout register updates sashiko-bot
2026-08-28 17:21     ` Sverdlin, Alexander
2026-08-28 16:44 ` [PATCH v3 4/4] rtc: pcf85063: add 1 Hz update interrupt (UIE) support A. Sverdlin
2026-08-28 17:00   ` sashiko-bot

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=20260828164445.3907839-4-alexander.sverdlin@siemens.com \
    --to=alexander.sverdlin@siemens.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox