From: Jerome Brunet <jbrunet@baylibre.com>
To: Carlo Caione <ccaione@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Jian Hu <jian.hu@amlogic.com>, Chuan Liu <chuan.liu@amlogic.com>,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org, linux-amlogic@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 5/7] clk: amlogic: Add S7 PLL clock controller driver
Date: Thu, 19 Nov 2026 09:11:12 +0100 [thread overview]
Message-ID: <179507587229.639563.16969059581009770947.b4-reply@b4> (raw)
In-Reply-To: <av2kitSLJNxlAKiv@macbook.homenet.telecomitalia.it>
On 2026-11-18 19:51 +0100, Carlo Caione wrote:
> On Wed, Nov 18, 2026 at 11:01:12 +0100, Jerome Brunet wrote:
> > > The S7 PLL controller provides the fixed PLL with its fclk dividers,
> > > the GP0, HIFI0 and HIFI1 PLLs, and the HDMI PLL.
> > >
> > > Add a driver for it. The GP0 and HIFI PLLs are expected to run with
> > > their input divided by 2 (div0p5) and the HDMI PLL without it, as the
> > > firmware and the init sequences set them up.
> > >
> > > Signed-off-by: Carlo Caione <ccaione@baylibre.com>> > +
>
> [...]
> > > +/* The datasheet documents FIXPLL_CTRL1[30:26] as a single fclk_en field */
> >
> > Not sure what this imply ?
>
> It means that each of the five bits enables one divider, while the
> datasheet only documents the five bits as a single field. I'll reword
> the comment to say that.
>
> > > +S7_FCLK(fclk_div2, 1, 2, FIXPLL_CTRL1, 30);
> > > +S7_FCLK(fclk_div3, 1, 3, FIXPLL_CTRL1, 26);
> > > +S7_FCLK(fclk_div4, 1, 4, FIXPLL_CTRL1, 27);
> > > +S7_FCLK(fclk_div5, 1, 5, FIXPLL_CTRL1, 28);
> > > +S7_FCLK(fclk_div7, 1, 7, FIXPLL_CTRL1, 29);
> > > +S7_FCLK(fclk_div2p5, 2, 5, FIXPLL_CTRL0, 25);
> > > +
> > > +static const struct pll_mult_range s7_pll_mult_range = {
> > > + .min = 134,
> > > + .max = 265,
> > > +};
> > > +
> > > +static const struct reg_sequence s7_gp0_pll_init_regs[] = {
> > > + { .reg = GP0PLL_CTRL0, .def = 0x02520800 },
> > > + { .reg = GP0PLL_CTRL1, .def = 0x09900322 },
> > > + { .reg = GP0PLL_CTRL2, .def = 0x00000000 },
> > > + { .reg = GP0PLL_CTRL3, .def = 0x00000006 },
> > > +};
> > > +
> > > +static struct clk_fixed_factor s7_gp0_pll_div0p5 = {
> > > + .mult = 1,
> > > + .div = 2,
> > > + .hw.init = &(struct clk_init_data) {
> > > + .name = "gp0_pll_div0p5",
> > > + .ops = &clk_fixed_factor_ops,
> > > + .parent_data = &(const struct clk_parent_data) {
> > > + .fw_name = "gp0",
> > > + },
> > > + .num_parents = 1,
> > > + },
> >
> > Is it the good old predivider here ? Shouldn't it be modelled with
> > a read-only divider rather that a fixed factor ? just in case whatever
> > came before did not leave things as we first expected ?
> >
> > Applies to the other PLL instances
>
> Nope, not the good old provider, this is separate from N: N is in CTRL0
> and our init sequence sets it to 1. This is CTRL1[27], div0p5_en.
>
Humm, still looks very much like it ...
> Now, it was indeed a read-only divider in an earlier (messier and
> unpublished) version. The problem was that with a cold PLL it could
> cache the power-on setting (/1) at registration, then the VCO init
> sequence would enable /2 without updating that cached parent rate
> basically breaking both rate reporting and set_rate. The fixed factor
> avoids this mismatch when Linux initializes the PLL.
>
If the divider is part of the VCO init (which I'm not a fan of),
this makes sense but it needs a comment near the fixed factor to
explain how this works on the HW, that you are setting this up
with the VCO init() otherwise it looks like there is an actual fixed
divider in front of the VCO no matter what.
> After dropping NOINIT_ENABLED from the HIFI PLLs, the remaining
> assumption is that an already-running GP0 has div0p5 enabled. That
> matches the firmware I tested, but the driver does not check it.
>
If a PLL is going to use NOINIT_ENABLED, then a RO divider is the
required approach because you no longer control the init.
To get the rate right, we could play a little trick but it would need
a BIG FAT WARNING comment.
Register VCO first - basically re-order the IDs. .init() runs if the PLL is
disabled or if it does not have NOINIT_ENABLED. At this point you know the
predivider is set and the VCO orphaned. Then register the RO divider with
NOCACHE, it should pick up its correct rate.
It is a bit fragile but safer and more correct that the fixed_factor
approach IMO.
--
Jerome
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-11-19 8:11 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 8:30 [PATCH 0/7] Add Amlogic S7 clock controllers Carlo Caione
2026-11-06 8:30 ` [PATCH 1/7] dt-bindings: clock: Add Amlogic S7 SCMI clock IDs Carlo Caione
2026-11-08 23:21 ` Conor Dooley
2026-11-09 8:37 ` Jerome Brunet
2026-11-09 20:00 ` Conor Dooley
2026-11-09 20:59 ` Carlo Caione
2026-11-09 8:49 ` Carlo Caione
2026-11-06 8:30 ` [PATCH 2/7] clk: meson: pll: Support PLLs without a pre-divider Carlo Caione
2026-11-06 8:35 ` sashiko-bot
2026-11-18 10:01 ` Jerome Brunet
2026-11-06 8:30 ` [PATCH 3/7] clk: meson: pll: Support active-low resets Carlo Caione
2026-11-18 10:01 ` Jerome Brunet
2026-11-06 8:30 ` [PATCH 4/7] dt-bindings: clock: Add Amlogic S7 PLL clock controller Carlo Caione
2026-11-06 17:35 ` Conor Dooley
2026-11-08 23:21 ` Conor Dooley
2026-11-18 10:01 ` Jerome Brunet
2026-11-06 8:30 ` [PATCH 5/7] clk: amlogic: Add S7 PLL clock controller driver Carlo Caione
2026-11-06 8:51 ` sashiko-bot
2026-11-18 10:01 ` Jerome Brunet
2026-11-18 18:51 ` Carlo Caione
2026-11-19 8:11 ` Jerome Brunet [this message]
2026-11-06 8:30 ` [PATCH 6/7] dt-bindings: clock: Add Amlogic S7 peripherals clock controller Carlo Caione
2026-11-06 17:34 ` Conor Dooley
2026-11-06 19:34 ` Carlo Caione
2026-11-06 20:48 ` Conor Dooley
2026-11-06 22:27 ` Carlo Caione
2026-11-08 23:17 ` Conor Dooley
2026-11-06 8:30 ` [PATCH 7/7] clk: amlogic: Add S7 peripherals clock controller driver Carlo Caione
2026-11-18 10:01 ` Jerome Brunet
2026-11-18 18:55 ` Carlo Caione
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=179507587229.639563.16969059581009770947.b4-reply@b4 \
--to=jbrunet@baylibre.com \
--cc=bmasney+clk@redhat.com \
--cc=ccaione@baylibre.com \
--cc=chuan.liu@amlogic.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jbrunet+clk@baylibre.com \
--cc=jian.hu@amlogic.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--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=neil.armstrong@linaro.org \
--cc=robh@kernel.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®