[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4e7e3080857b5822011734776de7456787dda546.camel@gmail.com>
Date: Fri, 14 Jun 2024 17:23:37 +0200
From: Nuno Sá <noname.nuno@...il.com>
To: Antoniu Miclaus <antoniu.miclaus@...log.com>, Lars-Peter Clausen
<lars@...afoo.de>, Michael Hennerich <Michael.Hennerich@...log.com>,
Jonathan Cameron
<jic23@...nel.org>, Rob Herring <robh@...nel.org>, Krzysztof Kozlowski
<krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/2] iio: frequency: adf4350: add clk provider
On Wed, 2024-06-12 at 16:02 +0300, Antoniu Miclaus wrote:
> Add clk provider feature for the adf4350.
>
> Even though the driver was sent as an IIO driver in most cases the
> device is actually seen as a clock provider.
>
> This patch aims to cover actual usecases requested by users in order to
> completely control the output frequencies from userspace.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@...log.com>
> ---
> changes in v4:
> - rename macro to `to_adf4350_state`
> - do not expose ADF4350_FREQ and ADF4350_FREQ_REFIN if driver is used as clk
> provider.
> - initialize flags with CLK_SET_RATE_PARENT
> drivers/iio/frequency/adf4350.c | 134 +++++++++++++++++++++++++++++++-
> 1 file changed, 133 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c
> index 4abf80f75ef5..8309ddfca9af 100644
> --- a/drivers/iio/frequency/adf4350.c
> +++ b/drivers/iio/frequency/adf4350.c
> @@ -19,6 +19,7 @@
> #include <linux/gpio/consumer.h>
> #include <asm/div64.h>
> #include <linux/clk.h>
> +#include <linux/clk-provider.h>
>
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
> @@ -36,6 +37,9 @@ struct adf4350_state {
> struct gpio_desc *lock_detect_gpiod;
> struct adf4350_platform_data *pdata;
> struct clk *clk;
> + struct clk *clkout;
> + const char *clk_out_name;
> + struct clk_hw hw;
> unsigned long clkin;
> unsigned long chspc; /* Channel Spacing */
> unsigned long fpfd; /* Phase Frequency Detector */
> @@ -61,6 +65,8 @@ struct adf4350_state {
> __be32 val __aligned(IIO_DMA_MINALIGN);
> };
>
> +#define to_adf4350_state(_hw) container_of(_hw, struct adf4350_state, hw)
> +
> static struct adf4350_platform_data default_pdata = {
> .channel_spacing = 10000,
> .r2_user_settings = ADF4350_REG2_PD_POLARITY_POS |
> @@ -370,6 +376,12 @@ static const struct iio_chan_spec_ext_info adf4350_ext_info[]
> = {
> { },
> };
>
> +static const struct iio_chan_spec_ext_info adf4350_clk_ext_info[] = {
> + _ADF4350_EXT_INFO("frequency_resolution", ADF4350_FREQ_RESOLUTION),
> + _ADF4350_EXT_INFO("powerdown", ADF4350_PWRDOWN),
> + { },
Do we really need powerdown? Dunno :). I would expect one of unprepare/disable to
take care of that. Moreover, imagine userspace powers down the device while an in
kernel consumer was using it? Not cool right ehhe?
Even the frequency_resolution is arguable as that is also a DT property but to keep
consistency why not? That one I can live with...
Also note that you're still not including the clock maintainers in the loop.
- Nuno Sá
Powered by blists - more mailing lists