mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Brian Masney <masneyb@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
	Brian Masney <bmasney+clk@redhat.com>,
	Jerome Brunet <jbrunet+clk@baylibre.com>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 1/2] clk: en7523: convert to full clk_hw implementation for en7581
Date: Tue, 17 Nov 2026 17:51:50 +0100	[thread overview]
Message-ID: <6afc8629.c6df0648.3437b8.c961@mx.google.com> (raw)
In-Reply-To: <179444135864.1126566.17591616173966524369.b4-review@b4>

On Wed, Nov 11, 2026 at 06:55:58PM -0500, Brian Masney wrote:
> Hi Christian,
> 
> > In preparation for support of .set_rate, convert the clock register
> > logic from fixed clock implementation to full clk_hw implementation with
> > dedicated OPs for Airoha EN7581 SoC.
> > 
> > This is just a rework and no behaviour change is expected.
> > 
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> > ---
> >  drivers/clk/clk-en7523.c | 75 +++++++++++++++++++++++++++++-----------
> >  1 file changed, 55 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c
> > index 24fdec2e6198..6640e814d36a 100644
> > --- a/drivers/clk/clk-en7523.c
> > +++ b/drivers/clk/clk-en7523.c
> > @@ -126,6 +126,12 @@ struct en_clk_gate {
> >  	struct clk_hw hw;
> >  };
> >  
> > +struct en_clk {
> > +	struct regmap *map;
> > +	const struct en_clk_desc *desc;
> > +	struct clk_hw hw;
> > +};
> > +
> >  struct en_rst_data {
> >  	const u16 *bank_ofs;
> >  	const u16 *idx_map;
> > @@ -742,42 +748,71 @@ static int en7523_clk_hw_init(struct platform_device *pdev,
> >  				     en7581_rst_ofs);
> >  }
> >  
> > +static unsigned long en7581_recalc_rate(struct clk_hw *hw,
> > +					unsigned long parent_rate)
> > +{
> > +	struct en_clk *c = container_of(hw, struct en_clk, hw);
> > +	const struct en_clk_desc *desc = c->desc;
> > +	struct device *dev = clk_hw_get_dev(hw);
> > +	struct regmap *map = c->map;
> > +	u32 val, reg;
> > +	u32 rate;
> > +	int err;
> > +
> > +	err = regmap_read(map, desc->base_reg, &val);
> > +	if (err) {
> > +		dev_err(dev, "Failed reading fixed clk rate %s: %d\n",
> > +			desc->name, err);
> > +		return 0;
> > +	}
> > +	rate = en7523_get_base_rate(desc, val);
> > +
> > +	reg = desc->div_reg ? desc->div_reg : desc->base_reg;
> > +	err = regmap_read(map, reg, &val);
> > +	if (err) {
> > +		dev_err(dev, "Failed reading fixed clk div %s: %d\n",
> > +			desc->name, err);
> > +		return 0;
> > +	}
> > +
> > +	return rate / en7523_get_div(desc, val);
> > +}
> > +
> > +static const struct clk_ops en7581_clk_ops = {
> > +	.recalc_rate = en7581_recalc_rate,
> > +};
> > +
> >  static void en7581_register_clocks(struct device *dev, struct clk_hw_onecell_data *clk_data,
> >  				   struct regmap *map, void __iomem *base)
> >  {
> >  	struct clk_hw *hw;
> > -	u32 rate;
> >  	int i;
> >  
> >  	for (i = 0; i < ARRAY_SIZE(en7581_base_clks); i++) {
> >  		const struct en_clk_desc *desc = &en7581_base_clks[i];
> > -		u32 val, reg = desc->div_reg ? desc->div_reg : desc->base_reg;
> > +		struct clk_init_data init = {
> > +			.ops = &en7581_clk_ops,
> > +		};
> > +		struct en_clk *en_clk;
> >  		int err;
> >  
> > -		err = regmap_read(map, desc->base_reg, &val);
> > +		en_clk = devm_kzalloc_obj(dev, *en_clk);
> > +		if (!en_clk)
> > +			continue;
>
> return -ENOMEM;

Hi Brain,

as you pointed out in the previous revision, returning would change the
behaviour so I currently skip the clock in such case...
 
-- 
	Ansuel

  reply	other threads:[~2026-11-17 16:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  0:11 [PATCH v5 0/2] clk: en7523: full clk_hw + set_rate " Christian Marangi
2026-11-10  0:11 ` [PATCH v5 1/2] clk: en7523: convert to full clk_hw implementation " Christian Marangi
2026-11-11 23:55   ` Brian Masney
2026-11-17 16:51     ` Christian Marangi [this message]
2026-11-10  0:11 ` [PATCH v5 2/2] clk: en7523: add support for .set_rate " Christian Marangi
2026-11-11 23:55   ` Brian Masney

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=6afc8629.c6df0648.3437b8.c961@mx.google.com \
    --to=ansuelsmth@gmail.com \
    --cc=bmasney+clk@redhat.com \
    --cc=jbrunet+clk@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masneyb@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®