[PATCH] rtc: ac100: Program clock divider encodings without subtracting one

From: Zhu Jun

Date: Thu Nov 12 2026 - 02:20:00 EST


divider_get_val() already returns the hardware encoding for the
power-of-two divider, and ac100_clkout_prediv[].val is also a register
encoding. Subtracting one from either value programs the previous
divider setting and turns encoding zero into all ones.

For example, selecting a 32768 Hz output from the 32768 Hz parent
programs divider seven and produces 256 Hz. Write both encodings
directly so the programmed rate agrees with the requested rate.

Fixes: 04940631b8d2 ("rtc: ac100: Add clk output support")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
drivers/rtc/rtc-ac100.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c
index be57a33ecf53..a94248346bf3 100644
--- a/drivers/rtc/rtc-ac100.c
+++ b/drivers/rtc/rtc-ac100.c
@@ -243,8 +243,8 @@ static int ac100_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
regmap_update_bits(clk->regmap, clk->offset,
((1 << AC100_CLKOUT_DIV_WIDTH) - 1) << AC100_CLKOUT_DIV_SHIFT |
((1 << AC100_CLKOUT_PRE_DIV_WIDTH) - 1) << AC100_CLKOUT_PRE_DIV_SHIFT,
- (div - 1) << AC100_CLKOUT_DIV_SHIFT |
- (pre_div - 1) << AC100_CLKOUT_PRE_DIV_SHIFT);
+ div << AC100_CLKOUT_DIV_SHIFT |
+ pre_div << AC100_CLKOUT_PRE_DIV_SHIFT);

return 0;
}
--
2.51.0