From: Jerome Brunet <jbrunet@baylibre.com>
To: Chuan Liu via B4 Relay <devnull+chuan.liu.amlogic.com@kernel.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
chuan.liu@amlogic.com, linux-amlogic@lists.infradead.org,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] clk: meson: Support PLL with fixed fractional denominators
Date: Fri, 06 Sep 2024 13:22:57 +0200 [thread overview]
Message-ID: <1jjzfpqb5a.fsf@starbuckisacylon.baylibre.com> (raw)
In-Reply-To: <20240906-fix_clk-v2-1-7a3941eb2cdf@amlogic.com> (Chuan Liu via's message of "Fri, 06 Sep 2024 18:34:40 +0800")
On Fri 06 Sep 2024 at 18:34, Chuan Liu via B4 Relay <devnull+chuan.liu.amlogic.com@kernel.org> wrote:
> From: Chuan Liu <chuan.liu@amlogic.com>
>
> Some PLLS with fractional multipliers have fractional denominators with
> fixed values, instead of the previous "(1 << pll-> frc.width)".
>
> Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
> ---
> drivers/clk/meson/clk-pll.c | 8 +++++---
> drivers/clk/meson/clk-pll.h | 1 +
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
> index bc570a2ff3a3..a141ab450009 100644
> --- a/drivers/clk/meson/clk-pll.c
> +++ b/drivers/clk/meson/clk-pll.c
> @@ -57,12 +57,13 @@ static unsigned long __pll_params_to_rate(unsigned long parent_rate,
> struct meson_clk_pll_data *pll)
> {
> u64 rate = (u64)parent_rate * m;
> + unsigned int frac_max = unlikely(pll->frac_max) ? pll->frac_max
> :
^ Please don't play with this unless
you've got justification a for it.
By justification, I mean actual numbers showing the difference it makes
and not just for the platforms listed in this series, but all the
platforms supported by this driver.
> + (1 << pll->frac.width);
>
> if (frac && MESON_PARM_APPLICABLE(&pll->frac)) {
> u64 frac_rate = (u64)parent_rate * frac;
>
> - rate += DIV_ROUND_UP_ULL(frac_rate,
> - (1 << pll->frac.width));
> + rate += DIV_ROUND_UP_ULL(frac_rate, frac_max);
> }
>
> return DIV_ROUND_UP_ULL(rate, n);
> @@ -100,7 +101,8 @@ static unsigned int __pll_params_with_frac(unsigned long rate,
> unsigned int n,
> struct meson_clk_pll_data *pll)
> {
> - unsigned int frac_max = (1 << pll->frac.width);
> + unsigned int frac_max = unlikely(pll->frac_max) ? pll->frac_max :
> + (1 << pll->frac.width);
> u64 val = (u64)rate * n;
>
> /* Bail out if we are already over the requested rate */
> diff --git a/drivers/clk/meson/clk-pll.h b/drivers/clk/meson/clk-pll.h
> index 7b6b87274073..949157fb7bf5 100644
> --- a/drivers/clk/meson/clk-pll.h
> +++ b/drivers/clk/meson/clk-pll.h
> @@ -43,6 +43,7 @@ struct meson_clk_pll_data {
> unsigned int init_count;
> const struct pll_params_table *table;
> const struct pll_mult_range *range;
> + unsigned int frac_max;
> u8 flags;
> };
--
Jerome
next prev parent reply other threads:[~2024-09-06 11:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-06 10:34 [PATCH v2 0/3] clk: meson: Fix an issue with inaccurate hifi_pll frequency Chuan Liu via B4 Relay
2024-09-06 10:34 ` [PATCH v2 1/3] clk: meson: Support PLL with fixed fractional denominators Chuan Liu via B4 Relay
2024-09-06 11:22 ` Jerome Brunet [this message]
2024-09-09 1:55 ` Chuan Liu
2024-09-09 7:40 ` Jerome Brunet
2024-09-09 8:46 ` Chuan Liu
2024-09-09 8:50 ` Jerome Brunet
2024-09-06 10:34 ` [PATCH v2 2/3] clk: meson: c3: pll: fix frac maximum value for hifi_pll Chuan Liu via B4 Relay
2024-09-06 10:34 ` [PATCH v2 3/3] clk: meson: s4: " Chuan Liu via B4 Relay
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=1jjzfpqb5a.fsf@starbuckisacylon.baylibre.com \
--to=jbrunet@baylibre.com \
--cc=chuan.liu@amlogic.com \
--cc=devnull+chuan.liu.amlogic.com@kernel.org \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mturquette@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=sboyd@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