[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fc5139294469450ead4baf595f041561319013ee.camel@gmail.com>
Date: Wed, 21 May 2025 15:32:42 +0100
From: Nuno Sá <noname.nuno@...il.com>
To: David Lechner <dlechner@...libre.com>, Uwe
Kleine-König
<ukleinek@...nel.org>
Cc: Michael Hennerich <michael.hennerich@...log.com>, Nuno
Sá <nuno.sa@...log.com>, Trevor Gamblin
<tgamblin@...libre.com>, Rob Herring <robh@...nel.org>, Krzysztof
Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
linux-pwm@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] pwm: axi-pwmgen: add support for external clock
On Wed, 2025-05-21 at 09:12 -0500, David Lechner wrote:
> On 5/21/25 8:54 AM, Uwe Kleine-König wrote:
> > Hello David,
> >
> > On Wed, May 21, 2025 at 08:19:51AM -0500, David Lechner wrote:
> > > On 5/21/25 4:22 AM, Uwe Kleine-König wrote:
> > > > Can you achieve the same effect with the (IMHO slightly nicer but
> > > > hand-crafted) following patch:
> > > >
> > > > ddata = pwmchip_get_drvdata(chip);
> > > > ddata->regmap = regmap;
> > > >
> > > > - clk = devm_clk_get_enabled(dev, NULL);
> > > > - if (IS_ERR(clk))
> > > > - return dev_err_probe(dev, PTR_ERR(clk), "failed to get
> > > > clock\n");
> > > > + axi_clk = devm_clk_get_enabled(dev, "axi");
> > > > + if (IS_ERR(axi_clk))
> > > > + return dev_err_probe(dev, PTR_ERR(axi_clk), "failed to
> > > > get axi clock\n");
> > > >
> > > > + clk = devm_clk_get_enabled_optional(dev, "ext");
> > > > + if (IS_ERR(clk))
> > > > + return dev_err_probe(dev, PTR_ERR(clk), "failed to get
> > > > ext clock\n");
> > > > + }
> > >
> > > The trouble with this is that it would not work with existing .dtbs
> > > that don't have clock-names set. I think it would need to be more like
> > > this:
> > >
> > >
> > > axi_clk = devm_clk_get_enabled(dev, NULL);
> > > if (IS_ERR(axi_clk))
> > > return dev_err_probe(dev, PTR_ERR(axi_clk), "failed to
> > > get axi clock\n");
> > >
> > > clk = devm_clk_get_enabled_optional(dev, "ext");
> > > if (IS_ERR(clk))
> > > return dev_err_probe(dev, PTR_ERR(clk), "failed to get
> > > ext clock\n");
> > >
> > > if (!clk)
> > > clk = axi_clk
> > >
> >
> > If there are no clock-names, the parameter is ignored. (I didn't test,
> > only quickly checked the code.) So passing "axi" instead of NULL should
> > work and yield a more robust solution.
> >
> > Best regards
> > Uwe
>
>
> I didn't know that. So with your suggestion, I guess we would get/enable
> the same clock twice. I guess that doesn't hurt anything. I will try it.
So, in the axi-dac we ended up doing this if you recall:
https://elixir.bootlin.com/linux/v6.15-rc7/source/drivers/iio/dac/adi-axi-dac.c#L837
But I do not think you need that here. I that what you suggested (with the first
call having id as NULL) should work fine.
I'm starting to think that always having clock-names just makes things easier
and more extendable (though the recommendation is to not have it in case there's
only one clock). Not the first time I see this (or go through this kind of
stuff). I had a similar situation in the axi-clkgen IP and IIRC, me and Conor
just agreed in making clock-names required and to handle backward compatibility
in the driver:
https://elixir.bootlin.com/linux/v6.14.7/source/drivers/clk/clk-axi-clkgen.c#L534
I'm actually now re-testing because I think I actually have a bug in there :)
- Nuno Sá
Powered by blists - more mailing lists