mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jerome Brunet <jbrunet@baylibre.com>
To: Changhuang Liang <changhuang.liang@starfivetech.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>,
	Brian Masney <bmasney@redhat.com>,
	 Jerome Brunet <jbrunet+clk@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	 Philipp Zabel <p.zabel@pengutronix.de>,
	 Emil Renner Berthing <kernel@esmil.dk>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	linux-clk@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org,
	 Hal Feng <hal.feng@starfivetech.com>
Subject: Re: [PATCH v6 08/15] clk: starfive: Introduce idiv ops for inverted divider clocks
Date: Sat, 17 Oct 2026 16:22:06 +0200	[thread overview]
Message-ID: <179224692686.859276.1840996329833650526.b4-reply@b4> (raw)
In-Reply-To: <ZQ4PR01MB12029910538E78B60432F9B8F29D2@ZQ4PR01MB1202.CHNPR01.prod.partner.outlook.cn>

On 2026-10-14 03:16 +0000, Changhuang Liang wrote:
> Hi, Jerome
> 
> > > Some StarFive clocks only advertise the divider and invert
> > > capabilities (via JH71X0_CLK_INVERT, without ENABLE). Add the
> > > JH71X0_IDIV() macro to declare such clocks, and jh71x0_clk_idiv_ops,
> > > which combines the divider rate operations with get_phase/set_phase.
> > >
> > 
> > Please rephrase, I don't understand what you mean
> > 
> > > Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
> > > ---
> > >  drivers/clk/starfive/clk-starfive-jh71x0.c | 13 ++++++++++++-
> > > drivers/clk/starfive/clk-starfive-jh71x0.h |  8 ++++++++
> > >  2 files changed, 20 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/clk/starfive/clk-starfive-jh71x0.c
> > > b/drivers/clk/starfive/clk-starfive-jh71x0.c
> > > index c5ee82db3c92..224fcc3d08db 100644
> > > --- a/drivers/clk/starfive/clk-starfive-jh71x0.c
> > > +++ b/drivers/clk/starfive/clk-starfive-jh71x0.c
> > > @@ -303,6 +303,15 @@ static const struct clk_ops jh71x0_clk_inv_ops = {
> > >  	.debug_init = jh71x0_clk_debug_init,  };
> > >
> > > +static const struct clk_ops jh71x0_clk_idiv_ops = {
> > > +	.get_phase = jh71x0_clk_get_phase,
> > > +	.set_phase = jh71x0_clk_set_phase,
> > > +	.recalc_rate = jh71x0_clk_recalc_rate,
> > > +	.determine_rate = jh71x0_clk_determine_rate,
> > > +	.set_rate = jh71x0_clk_set_rate,
> > > +	.debug_init = jh71x0_clk_debug_init,
> > 
> > Instead of trying to cover all the combination that could exist, can you just
> > chain 2 elements ?
> > a div then an inv ?
> 
> This may require introducing quite a few new changes.
> 
> In the current code, struct clk_hw *hw is used to obtain struct jh71x0_clk *clk through hw, and then the register offset is obtained through clk->idx.
> 
> static void jh71x0_clk_reg_rmw(struct jh71x0_clk *clk, u32 mask, u32 value)
> {
> 	struct jh71x0_clk_priv *priv = jh71x0_priv_from(clk);
> 	void __iomem *reg = priv->base + 4 * clk->idx;
> 	unsigned long flags;
> 
> 	spin_lock_irqsave(&priv->rmw_lock, flags);
> 	value |= readl_relaxed(reg) & ~mask;
> 	writel_relaxed(value, reg);
> 	spin_unlock_irqrestore(&priv->rmw_lock, flags);
> }
> 
> static int jh71x0_clk_enable(struct clk_hw *hw)
> {
> 	struct jh71x0_clk *clk = jh71x0_clk_from(hw);
> 
> 	jh71x0_clk_reg_rmw(clk, JH71X0_CLK_ENABLE, JH71X0_CLK_ENABLE);
> 	return 0;
> }
> 
> Therefore, the existing code has one struct clk_hw corresponding to one register offset.
> 
> If it is split into a div and an inv, two struct clk_hw descriptions will be needed.
> The jh71x0_crg_probe() will need to implement different branches for different clocks:
> 
> if (a div and an inv) {
>     devm_clk_hw_register (div)
>     devm_clk_hw_register (inv)
> } else {
>     devm_clk_hw_register (other)
> }
> 
> Do you need me to make this part of the adjustment?

No, it is ok this time around but understand that if this patterns repeats, you will have to
fix this. Best would be to start thinking about it at least.

-- 
Jerome


  reply	other threads:[~2026-10-17 14:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 12:33 [PATCH v6 00/15] Add basic clocks and resets for JHB100 SoC Changhuang Liang
2026-10-08 12:33 ` [PATCH v6 01/15] clk: starfive: jh7110-sys: Fix memory leak in reset controller register Changhuang Liang
2026-10-08 12:33 ` [PATCH v6 02/15] clk: starfive: jh71x0: Move reset controller registration to jh71x0 common code Changhuang Liang
2026-10-12 10:21   ` Jerome Brunet
2026-10-08 12:33 ` [PATCH v6 03/15] reset: starfive: jh7110: Match auxiliary device names to jh71x0 clk driver Changhuang Liang
2026-10-12 10:21   ` Jerome Brunet
2026-10-08 12:33 ` [PATCH v6 04/15] clk: starfive: jh71x0: Add generic CRG probe helper Changhuang Liang
2026-10-12 10:21   ` Jerome Brunet
2026-10-08 12:33 ` [PATCH v6 05/15] clk: starfive: Add JHB100 System-0 clock generator driver Changhuang Liang
2026-10-12 10:21   ` Jerome Brunet
2026-10-13  5:29     ` Changhuang Liang
2026-10-13  9:05       ` Jerome Brunet
2026-10-08 12:33 ` [PATCH v6 06/15] clk: starfive: Add JHB100 System-1 " Changhuang Liang
2026-10-12 10:21   ` Jerome Brunet
2026-10-08 12:33 ` [PATCH v6 07/15] clk: starfive: Add JHB100 System-2 " Changhuang Liang
2026-10-12 10:21   ` Jerome Brunet
2026-10-08 12:33 ` [PATCH v6 08/15] clk: starfive: Introduce idiv ops for inverted divider clocks Changhuang Liang
2026-10-12 10:21   ` Jerome Brunet
2026-10-14  3:16     ` Changhuang Liang
2026-10-17 14:22       ` Jerome Brunet [this message]
2026-10-08 12:33 ` [PATCH v6 09/15] clk: starfive: Expand the storage of clock parent index Changhuang Liang
2026-10-08 12:33 ` [PATCH v6 10/15] clk: starfive: Add StarFive JHB100 Peripheral-0 clock driver Changhuang Liang
2026-10-12 10:21   ` Jerome Brunet
2026-10-14  2:13     ` Changhuang Liang
2026-10-17 14:18       ` Jerome Brunet
2026-10-08 12:33 ` [PATCH v6 11/15] clk: starfive: Add StarFive JHB100 Peripheral-1 " Changhuang Liang
2026-10-08 12:33 ` [PATCH v6 12/15] clk: starfive: Add StarFive JHB100 Peripheral-2 " Changhuang Liang
2026-10-08 12:33 ` [PATCH v6 13/15] clk: starfive: Add StarFive JHB100 Peripheral-3 " Changhuang Liang
2026-10-08 12:33 ` [PATCH v6 14/15] reset: starfive: jh71x0: Support discontiguous reset IDs Changhuang Liang
2026-10-08 12:33 ` [PATCH v6 15/15] reset: starfive: Add StarFive JHB100 reset driver Changhuang Liang
2026-10-12 10:21 ` [PATCH v6 00/15] Add basic clocks and resets for JHB100 SoC Jerome Brunet
2026-10-12 19:03   ` Conor Dooley
2026-10-12 19:16     ` Jerome Brunet
2026-10-13  5:15       ` Changhuang Liang

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=179224692686.859276.1840996329833650526.b4-reply@b4 \
    --to=jbrunet@baylibre.com \
    --cc=bmasney@redhat.com \
    --cc=changhuang.liang@starfivetech.com \
    --cc=conor+dt@kernel.org \
    --cc=hal.feng@starfivetech.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=kernel@esmil.dk \
    --cc=krzk+dt@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=p.zabel@pengutronix.de \
    --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®