Re: [PATCH v5 1/2] clk: en7523: convert to full clk_hw implementation for en7581
From: Christian Marangi (Ansuel)
Date: Thu Nov 19 2026 - 15:10:34 EST
Il giorno gio 19 nov 2026 alle ore 20:35 Brian Masney
<masneyb@xxxxxxxxxx> ha scritto:
>
> Hi Christian,
>
> On Tue, Nov 17, 2026 at 05:51:50PM +0100, Christian Marangi wrote:
> > On Wed, Nov 11, 2026 at 06:55:58PM -0500, Brian Masney wrote:
> > > > 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@xxxxxxxxx>
> > > > ---
> > > > 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...
>
> It's ok if it changes the behavior to make things interact with the
> framework correctly. I just pointed out that the commit message says
> there is no behavior change. You can drop that sentence and just
> describe the behavior change in the commit message.
>
Thanks a lot for the followup even if it was on a previous revision.
Ok I will change it for v7.