Re: [PATCH v4 5/5] iio: adc: ad4080: add support for AD4880 dual-channel ADC
From: Jonathan Cameron
Date: Sat Feb 28 2026 - 15:27:04 EST
On Mon, 23 Feb 2026 18:21:04 +0200
Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx> wrote:
> Add support for the AD4880, a dual-channel 20-bit 40MSPS SAR ADC with
> integrated fully differential amplifiers (FDA).
>
> The AD4880 has two independent ADC channels, each with its own SPI
> configuration interface. The driver uses spi_new_ancillary_device() to
> create an additional SPI device for the second channel, allowing both
> channels to share the same SPI bus with different chip selects.
>
> Reviewed-by: David Lechner <dlechner@xxxxxxxxxxxx>
> Reviewed-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx>
Hi Antoniu
One minor question / comment below. Not particularly important
but as you will be doing a v5 anyway, seems reasonable to aks the
question.
> static int ad4080_properties_parse(struct ad4080_state *st)
> {
> - struct device *dev = regmap_get_device(st->regmap);
> + struct device *dev = regmap_get_device(st->regmap[0]);
>
> st->lvds_cnv_en = device_property_read_bool(dev, "adi,lvds-cnv-enable");
>
> @@ -602,6 +711,7 @@ static int ad4080_probe(struct spi_device *spi)
> struct device *dev = &spi->dev;
> struct ad4080_state *st;
> struct clk *clk;
> + unsigned int ch;
> int ret;
>
> indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> @@ -610,6 +720,10 @@ static int ad4080_probe(struct spi_device *spi)
>
> st = iio_priv(indio_dev);
>
> + st->info = spi_get_device_match_data(spi);
> + if (!st->info)
> + return -ENODEV;
> +
> ret = devm_regulator_bulk_get_enable(dev,
> ARRAY_SIZE(ad4080_power_supplies),
> ad4080_power_supplies);
> @@ -617,13 +731,27 @@ static int ad4080_probe(struct spi_device *spi)
> return dev_err_probe(dev, ret,
> "failed to get and enable supplies\n");
>
> - st->regmap = devm_regmap_init_spi(spi, &ad4080_regmap_config);
> - if (IS_ERR(st->regmap))
> - return PTR_ERR(st->regmap);
> -
> - st->info = spi_get_device_match_data(spi);
> - if (!st->info)
> - return -ENODEV;
Moving this up doesn't seem to be necessary. Am I missing a reason
st->info should be set earlier? If not I'd have left it down here simpl
to avoid the churn.
> + /* Setup primary SPI device (channel 0) */
> + st->spi[0] = spi;
> + st->regmap[0] = devm_regmap_init_spi(spi, &ad4080_regmap_config);
> + if (IS_ERR(st->regmap[0]))
> + return PTR_ERR(st->regmap[0]);
> +
> + /* Setup ancillary SPI devices for additional channels */
> + if (st->info->num_channels > 1) {
> + for (int i = 1; i < st->info->num_channels; i++) {
> + st->spi[i] = devm_spi_new_ancillary_device(spi,
> + spi_get_chipselect(spi, i));
> + if (IS_ERR(st->spi[i]))
> + return dev_err_probe(dev, PTR_ERR(st->spi[i]),
> + "failed to register ancillary device\n");
> +
> + st->regmap[i] = devm_regmap_init_spi(st->spi[i],
> + &ad4080_regmap_config);
> + if (IS_ERR(st->regmap[i]))
> + return PTR_ERR(st->regmap[i]);
> + }
> + }