Re: [PATCH 5/7] clk: amlogic: Add S7 PLL clock controller driver

From: Jerome Brunet

Date: Thu Nov 19 2026 - 03:11:25 EST


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@xxxxxxxxxxxx>> > +
>
> [...]
> > > +/* 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