From: Andre Przywara <andre.przywara@arm.com>
To: Chen-Yu Tsai <wens@csie.org>
Cc: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>, <linux-clk@vger.kernel.org>,
<devicetree@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-sunxi@lists.linux.dev>,
Mikhail Kalashnikov <iuncuim@gmail.com>
Subject: Re: [PATCH 3/5] clk: sunxi-ng: mp: support clocks with just a shift register
Date: Wed, 3 Sep 2025 11:20:54 +0100 [thread overview]
Message-ID: <20250903112054.173fe7b8@donnerap> (raw)
In-Reply-To: <CAGb2v66DHvE5gcWDvHwoiiCgNEnPiGjB6ash407PwJr8oMwyhw@mail.gmail.com>
On Wed, 3 Sep 2025 12:20:55 +0800
Chen-Yu Tsai <wens@csie.org> wrote:
> On Wed, Sep 3, 2025 at 8:09 AM Andre Przywara <andre.przywara@arm.com> wrote:
> >
> > The "mp" clock models a mod clock with divider and a shift field. At
> > least one clock in the Allwinner A523 features just a power-of-2 divider
> > field, so support an initialisation of the clock without providing an
> > actual divider field.
> >
> > Add a check whether the "width" field is 0, and skip the divider
> > handling in this case, as the GENMASK macro will not work with a zero
> > length.
> >
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > ---
>
> In my series I have a patch that adds this to the divider clocks,
> thus adding a P-clock type to the M-clock bits.
Yeah, I saw that, but wasn't convinced this would be better. Hence wanted
to post my version as an alternative.
> Maybe use that instead? I prefer we use actual matching types instead
> of disabling one part of a complex clock type.
Good that you bring up that topic: when looking for matching clocks I saw
we have a lot of them, though often one is just a subset of some others,
with some code duplication. And we use the pattern of "use type A, but
without feature X" already, for instance for "NKMP without the K".
So I was wondering if we should revisit this and clean this up. IIUC those
clocks were all modelled after the H3 and earlier generation, and the
clocks have changed since then. For instance I don't see PLLs with two
multipliers (NK) after the A64 anymore.
So what about we consolidate the various types into just a few distinct
ones, like NKMP for all PLLs, for instance, and provides macros that
disable fields as needed? This could ideally be done under the hood,
leaving the per-SoC drivers mostly alone, hopefully.
What do people think about that?
Cheers,
Andre
> > drivers/clk/sunxi-ng/ccu_mp.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c
> > index 354c981943b6f..a03dac294d048 100644
> > --- a/drivers/clk/sunxi-ng/ccu_mp.c
> > +++ b/drivers/clk/sunxi-ng/ccu_mp.c
> > @@ -236,9 +236,11 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long rate,
> > spin_lock_irqsave(cmp->common.lock, flags);
> >
> > reg = readl(cmp->common.base + cmp->common.reg);
> > - reg &= ~GENMASK(cmp->m.width + cmp->m.shift - 1, cmp->m.shift);
> > + if (cmp->m.width)
> > + reg &= ~GENMASK(cmp->m.width + cmp->m.shift - 1, cmp->m.shift);
> > reg &= ~GENMASK(cmp->p.width + cmp->p.shift - 1, cmp->p.shift);
> > - reg |= (m - cmp->m.offset) << cmp->m.shift;
> > + if (cmp->m.width)
> > + reg |= (m - cmp->m.offset) << cmp->m.shift;
> > if (shift)
> > reg |= ilog2(p) << cmp->p.shift;
> > else
> > --
> > 2.46.3
> >
next prev parent reply other threads:[~2025-09-03 10:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 0:09 [PATCH 0/5] arm64: allwinner: a523: Enable CPU clocks Andre Przywara
2025-09-03 0:09 ` [PATCH 1/5] dt-bindings: clock: sun55i-a523-ccu: Add A523 CPU CCU clock controller Andre Przywara
2025-09-03 8:08 ` Krzysztof Kozlowski
2025-09-03 9:46 ` Andre Przywara
2025-09-03 10:25 ` Krzysztof Kozlowski
2025-09-03 0:09 ` [PATCH 2/5] clk: sunxi-ng: generalise update bit Andre Przywara
2025-09-03 0:09 ` [PATCH 3/5] clk: sunxi-ng: mp: support clocks with just a shift register Andre Przywara
2025-09-03 4:20 ` Chen-Yu Tsai
2025-09-03 10:20 ` Andre Przywara [this message]
2025-09-03 0:09 ` [PATCH 4/5] clk: sunxi-ng: add support for the A523/T527 CPU CCU Andre Przywara
2025-09-03 10:26 ` Krzysztof Kozlowski
2025-09-03 0:09 ` [PATCH 5/5] arm64: dts: allwinner: a523: add CPU clocks Andre Przywara
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=20250903112054.173fe7b8@donnerap \
--to=andre.przywara@arm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=iuncuim@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=samuel@sholland.org \
--cc=sboyd@kernel.org \
--cc=wens@csie.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;
as well as URLs for NNTP newsgroup(s).