Re: [PATCH v3 5/5] iio: adc: ad4080: add support for AD4880 dual-channel ADC

From: Jonathan Cameron

Date: Sun Feb 15 2026 - 13:43:04 EST


On Fri, 13 Feb 2026 16:47:37 +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>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@xxxxxxxxxx>

One small thing inline.

> @@ -617,13 +731,34 @@ 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);
> + /* 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]);
>
> - st->info = spi_get_device_match_data(spi);
> - if (!st->info)
> - return -ENODEV;
> + /* Setup ancillary SPI devices for additional channels */
> + if (st->info->num_channels > 1) {
> + u32 reg[AD4080_MAX_CHANNELS];
> +
> + ret = device_property_read_u32_array(dev, "reg", reg,
> + st->info->num_channels);
Can we just use

spi_get_chipselect(spi, 1) ?

I think the generic firmware parser will have already parsed the DT and filled
that in by this point.

> + if (ret)
> + return dev_err_probe(dev, ret,
> + "missing reg entries for multi-channel device\n");
> +
> + for (int i = 1; i < st->info->num_channels; i++) {
> + st->spi[i] = devm_spi_new_ancillary_device(spi, reg[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]);
> + }
> + }