From: Ettore Chimenti <ettore.chimenti@linaro.org>
To: Tero Kristo <kristo@kernel.org>, Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Tony Lindgren <tony@atomide.com>,
Aaro Koskinen <aaro.koskinen@iki.fi>,
Andreas Kemnade <andreas@kemnade.info>,
Kevin Hilman <khilman@baylibre.com>,
Roger Quadros <rogerq@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Andrew Goodbody <andrew.goodbody@linaro.org>,
Rouven Czerwinski <rouven.czerwinski@linaro.org>
Cc: linux-omap@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Ettore Chimenti <ettore.chimenti@linaro.org>
Subject: [PATCH v3 2/4] clk: ti: fapll: Fix clock speed calculation
Date: Fri, 13 Nov 2026 22:30:48 +0100 [thread overview]
Message-ID: <20261113-patch-ektor5-dm8168-clk-v3-2-a42cd1edc5f3@linaro.org> (raw)
In-Reply-To: <20261113-patch-ektor5-dm8168-clk-v3-0-a42cd1edc5f3@linaro.org>
From: Andrew Goodbody <andrew.goodbody@linaro.org>
The fractional part of the divider was being treated as 1/10000000
whereas it is in fact 1/2^24 (1/16777216). This led to incorrect clock
speeds being reported when a fractional divider was in use. Correct it.
As well as fixing the clock speed calculation when read, also update the
calculation on set in a similar manner.
Fixes: 163152cbbe32 ("clk: ti: Add support for FAPLL on dm816x")
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Ettore Chimenti <ettore.chimenti@linaro.org>
---
drivers/clk/ti/fapll.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index ae2f6fed10f6..bb9986508578 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -54,6 +54,9 @@
#define SYNTH_MAX_INT_DIV 0xf
#define SYNTH_MAX_DIV_M 0xff
+#define SYNTH_FRAC_DIV_BITS 24
+#define SYNTH_FRAC_DIV_SCALE BIT(SYNTH_FRAC_DIV_BITS)
+
struct fapll_data {
struct clk_hw hw;
void __iomem *base;
@@ -336,8 +339,9 @@ static unsigned long ti_fapll_synth_recalc_rate(struct clk_hw *hw,
v = readl_relaxed(synth->freq);
synth_int_div = (v >> 24) & 0xf;
synth_frac_div = v & 0xffffff;
- synth_div_freq = (synth_int_div * 10000000) + synth_frac_div;
- rate *= 10000000;
+ synth_div_freq = (synth_int_div * SYNTH_FRAC_DIV_SCALE)
+ + synth_frac_div;
+ rate *= SYNTH_FRAC_DIV_SCALE;
do_div(rate, synth_div_freq);
rate *= SYNTH_PHASE_K;
}
@@ -378,10 +382,10 @@ static u32 ti_fapll_synth_set_frac_rate(struct fapll_synth *synth,
for (; post_div_m < SYNTH_MAX_DIV_M; post_div_m++) {
synth_int_div = DIV_ROUND_UP_ULL((u64)parent_rate *
SYNTH_PHASE_K *
- 10000000,
+ SYNTH_FRAC_DIV_SCALE,
rate * post_div_m);
- synth_frac_div = synth_int_div % 10000000;
- synth_int_div /= 10000000;
+ synth_frac_div = synth_int_div % SYNTH_FRAC_DIV_SCALE;
+ synth_int_div /= SYNTH_FRAC_DIV_SCALE;
if (synth_int_div <= SYNTH_MAX_INT_DIV)
break;
--
2.56.1
next prev parent reply other threads:[~2026-11-13 21:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 21:30 [PATCH v3 0/4] clk: ti: fapll/dm816x: clock tree and calculation fixes Ettore Chimenti
2026-11-13 21:30 ` [PATCH v3 1/4] clk: ti: fapll: remove ti_dt_clk_name helper Ettore Chimenti
2026-11-13 21:30 ` Ettore Chimenti [this message]
2026-11-13 21:30 ` [PATCH v3 3/4] clk: ti: fapll: print clock name that fails to register Ettore Chimenti
2026-11-13 21:30 ` [PATCH v3 4/4] ARM: OMAP2+: ti81xx: use non-scalable voltage domains Ettore Chimenti
2026-11-13 22:02 ` Andreas Kemnade
2026-11-16 18:56 ` (subset) [PATCH v3 0/4] clk: ti: fapll/dm816x: clock tree and calculation fixes Brian Masney
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=20261113-patch-ektor5-dm8168-clk-v3-2-a42cd1edc5f3@linaro.org \
--to=ettore.chimenti@linaro.org \
--cc=aaro.koskinen@iki.fi \
--cc=andreas@kemnade.info \
--cc=andrew.goodbody@linaro.org \
--cc=bmasney+clk@redhat.com \
--cc=jbrunet+clk@baylibre.com \
--cc=khilman@baylibre.com \
--cc=kristo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=rogerq@kernel.org \
--cc=rouven.czerwinski@linaro.org \
--cc=sboyd@kernel.org \
--cc=tony@atomide.com \
/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
all inboxes | Powered by JetHome®