Linux clock framework development
 help / color / mirror / Atom feed
From: "Xuyang Dong" <dongxuyang@eswincomputing.com>
To: gaohan@iscas.ac.cn, "Stephen Boyd" <sboyd@kernel.org>,
	"Brian Masney" <bmasney+clk@redhat.com>,
	"Jerome Brunet" <jbrunet+clk@baylibre.com>
Cc: "Brian Masney" <bmasney@redhat.com>,
	"Han Gao" <rabenda.cn@gmail.com>,
	linux-clk@vger.kernel.org,
	"Jingkun Zheng" <zhengjingkun@iscas.ac.cn>,
	"Yifeng Huang" <huangyifeng@eswincomputing.com>,
	"Pinkesh Vaghela" <pinkesh.vaghela@einfochips.com>,
	"Min Lin" <linmin@eswincomputing.com>
Subject: Re: [PATCH 1/2] clk: eswin: Fix the EIC7700 PLL post-divider
Date: Wed, 25 Nov 2026 16:12:08 +0800 (GMT+08:00)	[thread overview]
Message-ID: <34f87a48.d67.1a211c31945.Coremail.dongxuyang@eswincomputing.com> (raw)
In-Reply-To: <20261125-eic7700-cpu-pll-postdiv-v1-1-b1ccd6339a20@iscas.ac.cn>

> 
> Both PLL clocks are FOUT1 of their PLL. Per the TRM:
> 
>   FOUT1 = FREF * (FBDIV + FRAC / 2^24) /
>           (4 * REFDIV * (POSTDIV1_A + 1) * (POSTDIV1_B + 1))
> 
> The driver leaves the post-dividers out of its rate math, but
> clk_pll_set_rate() sets POSTDIV1_A (bits 10:8) to 1, which halves the
> output. It also writes bits 18:16 as "POSTDIV2", which is really
> POSTDIV2_A for FOUT2.
> 
> On the HiFive Premier P550 the CPU ran at 699 MHz when CPUFreq set
> 1.4 GHz.
> 
> Clear POSTDIV1_A and POSTDIV1_B (bits 14:12) instead, and leave FOUT2
> alone.
> 
> Fixes: cd44f127c1d4 ("clk: eswin: Add eic7700 clock driver")
> Reported-by: Jingkun Zheng <zhengjingkun@iscas.ac.cn>
> Link: https://github.com/eswincomputing/EIC7700X-SoC-Technical-Reference-Manual/releases/download/v1.0.0-20250103/EIC7700X_SoC_Technical_Reference_Manual_Part1.pdf
> Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
> ---
>  drivers/clk/eswin/clk.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/clk/eswin/clk.c b/drivers/clk/eswin/clk.c
> index e8851283ccdbf0ea57002511f991c9d68a7f4788..7d51d3a8fc06d7b4a0d7435aeb0cb0e58e16708e 100644
> --- a/drivers/clk/eswin/clk.c
> +++ b/drivers/clk/eswin/clk.c
> @@ -21,8 +21,8 @@
>  #define PLL_REFDIV_MASK		GENMASK(17, 12)
>  #define PLL_FBDIV_MASK		GENMASK(31, 20)
>  #define PLL_FRAC_MASK		GENMASK(27, 4)
> -#define PLL_POSTDIV1_MASK	GENMASK(10, 8)
> -#define PLL_POSTDIV2_MASK	GENMASK(18, 16)
> +#define PLL_POSTDIV1_A_MASK	GENMASK(10, 8)
> +#define PLL_POSTDIV1_B_MASK	GENMASK(14, 12)
>  
>  struct eswin_clock_data *eswin_clk_init(struct platform_device *pdev,
>  					size_t nr_clks)
> @@ -110,10 +110,9 @@ static int clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
>  	val |= FIELD_PREP(PLL_FRAC_MASK, frac_val);
>  	writel_relaxed(val, clk->ctrl_reg1);
>  
> +	/* eswin_calc_pll() assumes FOUT1 is not post-divided */
>  	val = readl_relaxed(clk->ctrl_reg2);
> -	val &= ~(PLL_POSTDIV1_MASK | PLL_POSTDIV2_MASK);
> -	val |= FIELD_PREP(PLL_POSTDIV1_MASK, 1);
> -	val |= FIELD_PREP(PLL_POSTDIV2_MASK, 1);
> +	val &= ~(PLL_POSTDIV1_A_MASK | PLL_POSTDIV1_B_MASK);
>  	writel_relaxed(val, clk->ctrl_reg2);
>  
>  	/* Last, enable pll */
> 

Thanks for catching this. You're right - the register usage and 
configuration here are incorrect. 

The fix as described looks good to me.

Acked-by: Xuyang Dong <dongxuyang@eswincomputing.com>

Thanks,
Xuyang Dong

  reply	other threads:[~2026-11-25  8:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 18:41 [PATCH 0/2] clk: eswin: Fix the EIC7700 PLL post-divider Han Gao via B4 Relay
2026-11-24 18:41 ` [PATCH 1/2] " Han Gao via B4 Relay
2026-11-25  8:12   ` Xuyang Dong [this message]
2026-11-24 18:41 ` [PATCH 2/2] clk: eswin: Use REFDIV and the post-dividers in the EIC7700 PLL rate Han Gao via B4 Relay
2026-11-25  8:12   ` Xuyang Dong

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=34f87a48.d67.1a211c31945.Coremail.dongxuyang@eswincomputing.com \
    --to=dongxuyang@eswincomputing.com \
    --cc=bmasney+clk@redhat.com \
    --cc=bmasney@redhat.com \
    --cc=gaohan@iscas.ac.cn \
    --cc=huangyifeng@eswincomputing.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=linmin@eswincomputing.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=pinkesh.vaghela@einfochips.com \
    --cc=rabenda.cn@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=zhengjingkun@iscas.ac.cn \
    /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