From: Chuan Liu <chuan.liu@amlogic.com>
To: Jerome Brunet <jbrunet@baylibre.com>,
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>,
linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] clk: meson: Support PLL with fixed fractional denominators
Date: Fri, 6 Sep 2024 16:24:27 +0800 [thread overview]
Message-ID: <9ef42da8-ac90-43de-8630-04cc8dc50783@amlogic.com> (raw)
In-Reply-To: <1j34mds2ak.fsf@starbuckisacylon.baylibre.com>
On 2024/9/6 14:51, Jerome Brunet wrote:
> [ EXTERNAL EMAIL ]
>
> On Fri 06 Sep 2024 at 13:52, 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 that
>> are fixed to "100000" instead of the previous "(1 << pll->frac.width)".
>>
>> Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
>> ---
>> drivers/clk/meson/clk-pll.c | 22 +++++++++++++++++++---
>> drivers/clk/meson/clk-pll.h | 1 +
>> 2 files changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c
>> index bc570a2ff3a3..f0009c174564 100644
>> --- a/drivers/clk/meson/clk-pll.c
>> +++ b/drivers/clk/meson/clk-pll.c
>> @@ -36,6 +36,12 @@
>> #include "clk-regmap.h"
>> #include "clk-pll.h"
>>
>> +/*
>> + * Some PLLs with fractional multipliers have fractional denominators that
>> + * are fixed to "100000" instead of the previous "(1 << pll->frac.width)".
>> + */
>> +#define FIXED_FRAC_MAX 100000
> When the next arbitrary limit comes around, this will get very ugly.
> Instead, please add frac_max to the pll parameter
I also had this consideration before, and after confirmation, the
hifi_pll of the subsequent chip design will continue to be this value,
and the hifi_pll of the chip in recent years is also this value. So
let's define it here.
In the next version I replaced it with a member inside the structure
member of meson_clk_pll_data.
>
>> +
>> static inline struct meson_clk_pll_data *
>> meson_clk_pll_data(struct clk_regmap *clk)
>> {
>> @@ -57,12 +63,17 @@ 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;
>>
>> 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));
>> + if (pll->flags & CLK_MESON_PLL_FIXED_FRAC_MAX)
>> + frac_max = FIXED_FRAC_MAX;
>> + else
>> + frac_max = (1 << pll->frac.width);
>> +
>> + rate += DIV_ROUND_UP_ULL(frac_rate, frac_max);
>> }
>>
>> return DIV_ROUND_UP_ULL(rate, n);
>> @@ -100,13 +111,18 @@ 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;
>> u64 val = (u64)rate * n;
>>
>> /* Bail out if we are already over the requested rate */
>> if (rate < parent_rate * m / n)
>> return 0;
>>
>> + if (pll->flags & CLK_MESON_PLL_FIXED_FRAC_MAX)
> Certainly don't need a flag for that. Use a parameter and default to (1
> << pll->frac.width) if unset.
Okay
>
>> + frac_max = FIXED_FRAC_MAX;
>> + else
>> + frac_max = (1 << pll->frac.width);
>> +
>> if (pll->flags & CLK_MESON_PLL_ROUND_CLOSEST)
>> val = DIV_ROUND_CLOSEST_ULL(val * frac_max, parent_rate);
>> else
>> diff --git a/drivers/clk/meson/clk-pll.h b/drivers/clk/meson/clk-pll.h
>> index 7b6b87274073..e996d3727eb1 100644
>> --- a/drivers/clk/meson/clk-pll.h
>> +++ b/drivers/clk/meson/clk-pll.h
>> @@ -29,6 +29,7 @@ struct pll_mult_range {
>>
>> #define CLK_MESON_PLL_ROUND_CLOSEST BIT(0)
>> #define CLK_MESON_PLL_NOINIT_ENABLED BIT(1)
>> +#define CLK_MESON_PLL_FIXED_FRAC_MAX BIT(2)
> Remove this.
>
>> struct meson_clk_pll_data {
>> struct parm en;
> --
> Jerome
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2024-09-06 8:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-06 5:52 [PATCH 0/4] clk: meson: Fix an issue with inaccurate hifi_pll frequency Chuan Liu via B4 Relay
2024-09-06 5:52 ` [PATCH 1/4] clk: meson: Support PLL with fixed fractional denominators Chuan Liu via B4 Relay
2024-09-06 6:51 ` Jerome Brunet
2024-09-06 8:24 ` Chuan Liu [this message]
2024-09-06 5:52 ` [PATCH 2/4] clk: meson: c3: pll: hifi_pll frequency is not accurate Chuan Liu via B4 Relay
2024-09-06 6:55 ` Jerome Brunet
2024-09-06 8:26 ` Chuan Liu
2024-09-06 5:52 ` [PATCH 3/4] clk: meson: s4: pll: hifi_pll support fractional multiplier Chuan Liu via B4 Relay
2024-09-06 6:58 ` Jerome Brunet
2024-09-06 5:52 ` [PATCH 4/4] clk: meson: s4: pll: hifi_pll frequency is not accurate Chuan Liu via B4 Relay
2024-09-06 7:04 ` [PATCH 0/4] clk: meson: Fix an issue with inaccurate hifi_pll frequency Jerome Brunet
2024-09-06 8:12 ` Chuan Liu
2024-09-06 7:11 ` (subset) " Jerome Brunet
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=9ef42da8-ac90-43de-8630-04cc8dc50783@amlogic.com \
--to=chuan.liu@amlogic.com \
--cc=devnull+chuan.liu.amlogic.com@kernel.org \
--cc=jbrunet@baylibre.com \
--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
all inboxes | Powered by JetHome®