Re: [PATCH 3/4] iio: adc: ad4000: Use device specific timing for SPI transfers
From: Marcelo Schmitt
Date: Mon Nov 18 2024 - 06:35:26 EST
On 11/15, David Lechner wrote:
> 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.
One of them was unused (AD4000_TQUIET1_NS IRCC).
Sure, will add a comment about it in the commit body.
>
> > -
> > #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.
Okay, will add a macro for setting ad4000_time_spec. My plan is to also add a
t_quiet1_ns filed which will be needed for offloading support.
t_quiet1_ns will also differ between AD4000 and AD4020.