Re: [PATCH 3/4] iio: adc: ad4000: Use device specific timing for SPI transfers
From: David Lechner
Date: Fri Nov 15 2024 - 12:07:47 EST
On 11/14/24 5:51 PM, Marcelo Schmitt wrote:
> The SPI transfers for AD4020, AD4021, and AD4022 have slightly different
> timing specifications. Use device specific timing constraints to set SPI
> transfer parameters.
>
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx>
> ---
> drivers/iio/adc/ad4000.c | 50 ++++++++++++++++++++++++++++++++--------
> 1 file changed, 41 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/adc/ad4000.c b/drivers/iio/adc/ad4000.c
> index 21731c4d31ee..68ac77494263 100644
> --- a/drivers/iio/adc/ad4000.c
> +++ b/drivers/iio/adc/ad4000.c
> @@ -35,10 +35,6 @@
>
> #define AD4000_SCALE_OPTIONS 2
>
> -#define AD4000_TQUIET1_NS 190
> -#define AD4000_TQUIET2_NS 60
> -#define AD4000_TCONV_NS 320
We are removing 3 but only adding 2 in the struct below?
If one of these was unused, best to mention it in the commit message.
> -
> #define __AD4000_DIFF_CHANNEL(_sign, _real_bits, _storage_bits, _reg_access) \
> { \
> .type = IIO_VOLTAGE, \
> @@ -122,10 +118,30 @@ static const int ad4000_gains[] = {
> 454, 909, 1000, 1900,
> };
>
> +struct ad4000_time_spec {
> + int t_conv_ns;
> + int t_quiet2_ns;
> +};
> +
> +/*
> + * Same timing specifications for all of AD4000, AD4001, ..., AD4008, AD4010,
> + * ADAQ4001, and ADAQ4003.
> + */
> +static const struct ad4000_time_spec ad4000_t_spec = {
> + .t_conv_ns = 320,
> + .t_quiet2_ns = 60,
> +};
> +
> +static const struct ad4000_time_spec ad4020_t_spec = {
> + .t_conv_ns = 350,
> + .t_quiet2_ns = 60,
> +};
t_quiet2_ns is the same in both cases, so do we actually need to
add it here instead of using a common macro? Or if it is for future
differences, mention that in the commit message.