From: Jonathan Cameron <jic23@kernel.org>
To: Antoniu Miclaus <antoniu.miclaus@analog.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
"Rob Herring" <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>, <linux-iio@vger.kernel.org>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 2/2] iio: frequency: adf4350: add clk provider
Date: Sat, 15 Jun 2024 14:24:59 +0100 [thread overview]
Message-ID: <20240615142459.382ca77d@jic23-huawei> (raw)
In-Reply-To: <20240612130232.7692-2-antoniu.miclaus@analog.com>
On Wed, 12 Jun 2024 16:02:29 +0300
Antoniu Miclaus <antoniu.miclaus@analog.com> 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@analog.com>
As Nuno reminded, this needs the clock maintainers in the loop
Trivial comments inline.
> +static int adf4350_clk_register(struct adf4350_state *st)
> +{
> + struct spi_device *spi = st->spi;
> + struct clk_init_data init;
> + struct clk *clk;
> + const char *parent_name;
> + int ret;
> +
> + if (!device_property_present(&spi->dev, "#clock-cells"))
> + return 0;
> +
> + init.name = devm_kasprintf(&spi->dev, GFP_KERNEL, "%s-clk",
> + fwnode_get_name(dev_fwnode(&spi->dev)));
Check for failure.
> + device_property_read_string(&spi->dev, "clock-output-names",
> + &init.name);
Also check for failure.
> +
> + parent_name = of_clk_get_parent_name(spi->dev.of_node, 0);
> + if (!parent_name)
> + return -EINVAL;
> +
> + init.ops = &adf4350_clk_ops;
> + init.parent_names = &parent_name;
> + init.num_parents = 1;
> + init.flags = CLK_SET_RATE_PARENT;
> +
> + st->hw.init = &init;
> + clk = devm_clk_register(&spi->dev, &st->hw);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> +
> + ret = of_clk_add_provider(spi->dev.of_node, of_clk_src_simple_get, clk);
> + if (ret)
> + return ret;
> +
> + st->clkout = clk;
> +
> + return devm_add_action_or_reset(&spi->dev, adf4350_clk_del_provider, st);
> +}
> +
> static struct adf4350_platform_data *adf4350_parse_dt(struct device *dev)
> {
> struct adf4350_platform_data *pdata;
> @@ -522,7 +646,6 @@ static int adf4350_probe(struct spi_device *spi)
>
> indio_dev->info = &adf4350_info;
> indio_dev->modes = INDIO_DIRECT_MODE;
> - indio_dev->channels = &adf4350_chan;
> indio_dev->num_channels = 1;
>
> mutex_init(&st->lock);
> @@ -551,6 +674,15 @@ static int adf4350_probe(struct spi_device *spi)
> return ret;
> }
>
> + ret = adf4350_clk_register(st);
> + if (ret)
> + return ret;
> +
> + if (st->clkout)
> + indio_dev->channels = &adf4350_clk_chan;
> + else
> + indio_dev->channels = &adf4350_chan;
> +
> ret = devm_add_action_or_reset(&spi->dev, adf4350_power_down, indio_dev);
> if (ret)
> return dev_err_probe(&spi->dev, ret,
prev parent reply other threads:[~2024-06-15 13:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 13:02 [PATCH v4 1/2] dt-bindings: iio: adf4350: add clk provider prop Antoniu Miclaus
2024-06-12 13:02 ` [PATCH v4 2/2] iio: frequency: adf4350: add clk provider Antoniu Miclaus
2024-06-14 15:23 ` Nuno Sá
2024-06-15 13:24 ` Jonathan Cameron [this message]
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=20240615142459.382ca77d@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=antoniu.miclaus@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@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