public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Sergiu Cuciurean" <sergiu.cuciurean@analog.com>,
	"Dragos Bogdan" <dragos.bogdan@analog.com>,
	"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
	"Olivier Moysan" <olivier.moysan@foss.st.com>,
	"Javier Carrasco" <javier.carrasco.cruz@gmail.com>,
	"Matti Vaittinen" <mazziesaccount@gmail.com>,
	"Tobias Sperling" <tobias.sperling@softing.com>,
	"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	"Alisa-Dariana Roman" <alisadariana@gmail.com>,
	"Esteban Blanc" <eblanc@baylibre.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/4] iio: adc: ad7405: add ad7405 driver
Date: Sun, 18 May 2025 17:33:45 +0100	[thread overview]
Message-ID: <20250518173345.338050e4@jic23-huawei> (raw)
In-Reply-To: <20250516105810.3028541-5-pop.ioan-daniel@analog.com>

On Fri, 16 May 2025 13:58:04 +0300
Pop Ioan Daniel <pop.ioan-daniel@analog.com> wrote:

> Add support for the AD7405/ADUM770x, a high performance isolated ADC,
> 1-channel, 16-bit with a second-order Σ-Δ modulator that converts an
> analog input signal into a high speed, single-bit data stream.
> 
> Signed-off-by: Pop Ioan Daniel <pop.ioan-daniel@analog.com>
More or less just one question to add to David's review.

It's around whether the clock is a separate thing or part of the backend
(which here kind of incorporates the bus controller).

We wouldn't bother specifying a clock line explicitly for SPI or PCIe so
why do we need one for this?

> ---
> changes in v3:
>  - edit ad7405_chip_info struct instances
>  - remove lock
>  - add implementation for IIO_CHAN_INFO_SCALE
>  - use IIO_CHAN_INFO_OVERSAMPLING_RATIO for controlling the decimation rate
>  - use IIO_CHAN_INFO_SAMP_FREQ for read-only
>  - remove dem_clk_get_enabled() function
>  - remove chip_info variable from probe function
>  - fix indentation
>  - remove max_rate
>  - rename ad7405_set_sampling_rate in ad7405_det_dec_rate
> add adum7702 and adum7703 chip_info
>  drivers/iio/adc/Kconfig  |  10 ++
>  drivers/iio/adc/Makefile |   1 +
>  drivers/iio/adc/ad7405.c | 276 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 287 insertions(+)
>  create mode 100644 drivers/iio/adc/ad7405.c

> diff --git a/drivers/iio/adc/ad7405.c b/drivers/iio/adc/ad7405.c
> new file mode 100644
> index 000000000000..1a96a283ab01
> --- /dev/null
> +++ b/drivers/iio/adc/ad7405.c
> @@ -0,0 +1,276 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Analog Devices AD7405 driver
> + *
> + * Copyright 2025 Analog Devices Inc.
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/util_macros.h>
> +
> +#include <linux/iio/backend.h>
> +#include <linux/iio/iio.h>
> +
> +static const unsigned int ad7405_scale_table[][2] = {
> +	{640, 0},
> +};
> +
> +static const unsigned int adum7702_scale_table[][2] = {
> +	{128, 0},

	{ 128, 0 },

Assuming you keep these (see David's feedback)

> +};

> +static int ad7405_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct iio_dev *indio_dev;
> +	struct ad7405_state *st;
> +	struct clk *clk;
> +	int ret;
> +
> +	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	st = iio_priv(indio_dev);
> +
> +	st->info = device_get_match_data(dev);
> +	if (!st->info)
> +		return dev_err_probe(dev, -EINVAL, "no chip info\n");
> +
> +	ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(ad7405_power_supplies),
> +					     ad7405_power_supplies);
> +
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to get and enable supplies");
> +
> +	clk = devm_clk_get_enabled(dev, NULL);
> +	if (IS_ERR(clk))
> +		return PTR_ERR(clk);
> +
> +	st->ref_frequency = clk_get_rate(clk);

Perhaps an odd question but for a clocked lvds bus like this
is the clock actually something we should represent as part of
the bus (so iio_backend interfaces) or separately like this?


> +	if (!st->ref_frequency)
> +		return -EINVAL;
> +
> +	ad7405_fill_samp_freq_table(st);
> +
> +	indio_dev->dev.parent = dev;
> +	indio_dev->name = st->info->name;
> +	indio_dev->channels = &st->info->channel;
> +	indio_dev->num_channels = 1;
> +	indio_dev->info = &ad7405_iio_info;
> +
> +	st->back = devm_iio_backend_get(dev, NULL);
> +	if (IS_ERR(st->back))
> +		return dev_err_probe(dev, PTR_ERR(st->back),
> +				     "failed to get IIO backend");
> +
> +	ret = iio_backend_chan_enable(st->back, 0);
> +	if (ret)
> +		return ret;
> +
> +	ret = devm_iio_backend_request_buffer(dev, st->back, indio_dev);
> +	if (ret)
> +		return ret;
> +
> +	ret = devm_iio_backend_enable(dev, st->back);
> +	if (ret)
> +		return ret;
> +
> +	ret = ad7405_set_dec_rate(indio_dev, &indio_dev->channels[0], 256);
> +	if (ret)
> +		return ret;
> +
> +	return devm_iio_device_register(dev, indio_dev);
> +}


      parent reply	other threads:[~2025-05-18 16:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16 10:58 [PATCH v3 0/4] Add support for AD7405/ADUM770x Pop Ioan Daniel
2025-05-16 10:58 ` [PATCH v3 1/4] iio: backend: update iio_backend_oversampling_ratio_set Pop Ioan Daniel
2025-05-16 15:06   ` David Lechner
2025-05-18 16:13     ` Jonathan Cameron
2025-05-16 10:58 ` [PATCH v3 2/4] iio: adc: adi-axi-adc: add axi_adc_oversampling_ratio_set Pop Ioan Daniel
2025-05-16 15:06   ` David Lechner
2025-05-16 10:58 ` [PATCH v3 3/4] dt-bindings: iio: adc: add ad7405 Pop Ioan Daniel
2025-05-16 14:18   ` Conor Dooley
2025-05-16 15:45     ` David Lechner
2025-05-16 19:30   ` Krzysztof Kozlowski
2025-05-18 16:44   ` Jonathan Cameron
2025-05-16 10:58 ` [PATCH v3 4/4] iio: adc: ad7405: add ad7405 driver Pop Ioan Daniel
2025-05-16 15:08   ` David Lechner
2025-05-18 16:33   ` 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=20250518173345.338050e4@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=alisadariana@gmail.com \
    --cc=andy@kernel.org \
    --cc=antoniu.miclaus@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=dragos.bogdan@analog.com \
    --cc=eblanc@baylibre.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=mazziesaccount@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=olivier.moysan@foss.st.com \
    --cc=pop.ioan-daniel@analog.com \
    --cc=robh@kernel.org \
    --cc=sergiu.cuciurean@analog.com \
    --cc=tobias.sperling@softing.com \
    /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