public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
From: "Benoît Monin" <benoit.monin@bootlin.com>
To: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
	"Gregory CLEMENT" <gregory.clement@bootlin.com>,
	"Théo Lebrun" <theo.lebrun@bootlin.com>,
	"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Michael Turquette" <mturquette@baylibre.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Linus Walleij" <linusw@kernel.org>
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
	linux-mips@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	linux-gpio@vger.kernel.org,
	"Benoît Monin" <benoit.monin@bootlin.com>
Subject: [PATCH v4 08/13] clk: eyeq: Adjust PLL accuracy computation
Date: Mon, 16 Mar 2026 16:25:45 +0100	[thread overview]
Message-ID: <20260316-eyeq6lplus-v4-8-bf44dfc7a261@bootlin.com> (raw)
In-Reply-To: <20260316-eyeq6lplus-v4-0-bf44dfc7a261@bootlin.com>

The spread spectrum of the PLL found in eyeQ OLB is in 1/1024 parts of the
frequency, not in 1/1000, so adjust the computation of the accuracy. Also
correct the downspreading to match.

Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
 drivers/clk/clk-eyeq.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/clk-eyeq.c b/drivers/clk/clk-eyeq.c
index 904d7d77d415..abffa46364f5 100644
--- a/drivers/clk/clk-eyeq.c
+++ b/drivers/clk/clk-eyeq.c
@@ -164,7 +164,7 @@ static void eqc_pll_downshift_factors(unsigned long *mult, unsigned long *div)
 static int eqc_pll_parse_registers(u32 r0, u32 r1, unsigned long *mult,
 				   unsigned long *div, unsigned long *acc)
 {
-	u32 spread;
+	unsigned long spread;
 
 	if (r0 & PCSR0_BYPASS) {
 		*mult = 1;
@@ -196,23 +196,23 @@ static int eqc_pll_parse_registers(u32 r0, u32 r1, unsigned long *mult,
 	/*
 	 * Spread spectrum.
 	 *
-	 * Spread is 1/1000 parts of frequency, accuracy is half of
-	 * that. To get accuracy, convert to ppb (parts per billion).
+	 * Spread is in 1/1024 parts of frequency. Clock accuracy
+	 * is half the spread value expressed in parts per billion.
 	 *
-	 * acc = spread * 1e6 / 2
-	 *   with acc in parts per billion and,
-	 *        spread in parts per thousand.
+	 * accuracy = (spread * 1e9) / (1024 * 2)
+	 *
+	 * Care is taken to avoid overflowing or losing precision.
 	 */
 	spread = FIELD_GET(PCSR1_SPREAD, r1);
-	*acc = spread * 500000;
+	*acc = DIV_ROUND_CLOSEST(spread * 1000000000, 1024 * 2);
 
 	if (r1 & PCSR1_DOWN_SPREAD) {
 		/*
 		 * Downspreading: the central frequency is half a
 		 * spread lower.
 		 */
-		*mult *= 2000 - spread;
-		*div *= 2000;
+		*mult *= 2048 - spread;
+		*div *= 2048;
 
 		/*
 		 * Previous operation might overflow 32 bits. If it

-- 
2.53.0


  parent reply	other threads:[~2026-03-16 15:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 15:25 [PATCH v4 00/13] Introducing the Mobileye EyeQ6Lplus SoC Benoît Monin
2026-03-16 15:25 ` [PATCH v4 01/13] dt-bindings: mips: Add " Benoît Monin
2026-03-16 15:25 ` [PATCH v4 02/13] dt-bindings: soc: mobileye: Add EyeQ6Lplus OLB Benoît Monin
2026-03-23  9:03   ` Linus Walleij
2026-03-24  0:26   ` Stephen Boyd
2026-03-16 15:25 ` [PATCH v4 03/13] MIPS: Add Mobileye EyeQ6Lplus support Benoît Monin
2026-03-16 15:25 ` [PATCH v4 04/13] reset: eyeq: Add Mobileye EyeQ6Lplus OLB Benoît Monin
2026-03-16 15:25 ` [PATCH v4 05/13] pinctrl: eyeq5: Use match data Benoît Monin
2026-03-23  9:04   ` Linus Walleij
2026-03-16 15:25 ` [PATCH v4 06/13] pinctrl: eyeq5: Add Mobileye EyeQ6Lplus OLB Benoît Monin
2026-03-23  9:05   ` Linus Walleij
2026-03-24 14:04     ` Thomas Bogendoerfer
2026-03-25 12:50       ` Benoît Monin
2026-03-16 15:25 ` [PATCH v4 07/13] clk: eyeq: Skip post-divisor when computing PLL frequency Benoît Monin
2026-03-24  0:30   ` Stephen Boyd
2026-03-16 15:25 ` Benoît Monin [this message]
2026-03-24  0:30   ` [PATCH v4 08/13] clk: eyeq: Adjust PLL accuracy computation Stephen Boyd
2026-03-16 15:25 ` [PATCH v4 09/13] clk: eyeq: Add Mobileye EyeQ6Lplus OLB Benoît Monin
2026-03-24  0:30   ` Stephen Boyd
2026-03-16 15:25 ` [PATCH v4 10/13] MIPS: Add Mobileye EyeQ6Lplus SoC dtsi Benoît Monin
2026-03-16 15:25 ` [PATCH v4 11/13] MIPS: Add Mobileye EyeQ6Lplus evaluation board dts Benoît Monin
2026-03-16 15:25 ` [PATCH v4 12/13] MIPS: config: add eyeq6lplus_defconfig Benoît Monin
2026-03-16 15:25 ` [PATCH v4 13/13] MAINTAINERS: Mobileye: Add EyeQ6Lplus files Benoît Monin

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=20260316-eyeq6lplus-v4-8-bf44dfc7a261@bootlin.com \
    --to=benoit.monin@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregory.clement@bootlin.com \
    --cc=krzk+dt@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tawfik.bayouk@mobileye.com \
    --cc=theo.lebrun@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tsbogend@alpha.franken.de \
    --cc=vladimir.kondratiev@mobileye.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