Re: [PATCH v13 3/3] iio: adc: ad7173: add AD7173 driver

From: Nuno Sá
Date: Tue Feb 20 2024 - 05:38:49 EST


On Tue, 2024-02-20 at 11:43 +0200, Dumitru Ceclan wrote:
> The AD7173 family offer a complete integrated Sigma-Delta ADC solution
> which can be used in high precision, low noise single channel
> applications or higher speed multiplexed applications. The Sigma-Delta
> ADC is intended primarily for measurement of signals close to DC but also
> delivers outstanding performance with input bandwidths out to ~10kHz.
>
> Reviewed-by: Andy Shevchenko <andy@xxxxxxxxxx> # for changes up until V12
> Reviewed-by: Michael Walle <michael@xxxxxxxx> # for gpio-regmap
> Signed-off-by: Dumitru Ceclan <mitrutzceclan@xxxxxxxxx>
> ---
>

Hi Dumitru,

Just a couple of things... With those addressed:

Reviewed-by: Nuno Sa <nuno.sa@xxxxxxxxxx>

..

>
> +static int ad7173_disable_all(struct ad_sigma_delta *sd)
> +{
> + struct ad7173_state *st = ad_sigma_delta_to_ad7173(sd);
> + int ret;
> + int i;
> +
> + for (i = 0; i < st->num_channels; i++) {
> + ret = ad_sd_write_reg(sd, AD7173_REG_CH(i), 2, 0);
> + if (ret < 0)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +static struct ad_sigma_delta_info ad7173_sigma_delta_info = {
> + .set_channel = ad7173_set_channel,
> + .append_status = ad7173_append_status,
> + .disable_all = ad7173_disable_all,
> + .set_mode = ad7173_set_mode,
> + .has_registers = true,
> + .addr_shift = 0,
> + .read_mask = BIT(6),
> + .status_ch_mask = GENMASK(3, 0),
> + .data_reg = AD7173_REG_DATA,
> + .irq_flags = IRQF_TRIGGER_FALLING,

You need to rebase on the current testing (or maybe Jonathan can fix it if this get's
applied in this version). Basically, I would drop the above .irq_flags assigment. The
lib will now check if you gave the trigger over Firmware (like device tree) and use
it. And that#s how we should set the IRQ trigger type. I did not removed the variable
just for backward compatibility [1].

..

> +};
>
> + indio_dev->name = st->info->name;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->info = &ad7173_info;
> +
> + spi->mode = SPI_MODE_3;
> +

I don't think we need the above. We should just enforce it to SPI_CPOL| SPI_CPHA in
the bindings [2].

[1]: https://lore.kernel.org/linux-iio/20240117-dev_sigma_delta_no_irq_flags-v1-2-db39261592cf@xxxxxxxxxx/
[2]: https://elixir.bootlin.com/linux/latest/source/Documentation/devicetree/bindings/iio/imu/adi,adis16475.yaml#L45

- Nuno Sá
>