Re: [PATCH v4 6/8] iio: adc: ad4030: Add SPI offload support

From: Nuno Sá
Date: Fri Oct 10 2025 - 15:45:18 EST


On Fri, 2025-10-10 at 11:18 -0500, David Lechner wrote:
> On 10/10/25 6:19 AM, Nuno Sá wrote:
> > On Wed, 2025-10-08 at 10:51 -0300, Marcelo Schmitt wrote:
> > > AD4030 and similar ADCs can capture data at sample rates up to 2 mega
> > > samples per second (MSPS). Not all SPI controllers are able to achieve such
> > > high throughputs and even when the controller is fast enough to run
> > > transfers at the required speed, it may be costly to the CPU to handle
> > > transfer data at such high sample rates. Add SPI offload support for AD4030
> > > and similar ADCs to enable data capture at maximum sample rates.
> > >
> > > Co-developed-by: Trevor Gamblin <tgamblin@xxxxxxxxxxxx>
> > > Signed-off-by: Trevor Gamblin <tgamblin@xxxxxxxxxxxx>
> > > Co-developed-by: Axel Haslam <ahaslam@xxxxxxxxxxxx>
> > > Signed-off-by: Axel Haslam <ahaslam@xxxxxxxxxxxx>
> > > Signed-off-by: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx>
> > > ---
> > > Change log v3 -> v4
> > > - Applied code adjustments suggested to SPI offload patch.
> > > - Only select SPI_OFFLOAD_TRIGGER_PWM if (SPI_OFFLOAD && PWM).
> > >
> > >  drivers/iio/adc/Kconfig  |   3 +
> > >  drivers/iio/adc/ad4030.c | 504 +++++++++++++++++++++++++++++++++++----
> > >  2 files changed, 465 insertions(+), 42 deletions(-)
> > >
> > > diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> > > index 58a14e6833f6..1ed091b6731a 100644
> > > --- a/drivers/iio/adc/Kconfig
> > > +++ b/drivers/iio/adc/Kconfig
> > > @@ -62,7 +62,10 @@ config AD4030
> > >   depends on GPIOLIB
> > >   select REGMAP
> > >   select IIO_BUFFER
> > > + select IIO_BUFFER_DMA
> > > + select IIO_BUFFER_DMAENGINE
> > >   select IIO_TRIGGERED_BUFFER
> > > + select SPI_OFFLOAD_TRIGGER_PWM if (SPI_OFFLOAD && PWM)
> >
> > Two things as I mentioned in [1]:
> >
> > 1) Wouldn't 'imply SPI_OFFLOAD_TRIGGER_PWM' accomplish the same?
> > 2) Don't we also need stubs for spi/offload/consumer.h?
>
> It doesn't hurt to enable SPI offload support even if no controller
> supports it, so I would prefer that drivers that use it just select
> SPI_OFFLOAD.

It does not hurt for sure. I just don't love enabling code when the feature is
optional. For things like GPIO it not does not matter much because it's most likely
always enabled anyways.

But, fair enough! I don't feel strong about this at all and if we wanted to be picky
then we would also have to take into account that IIO_BUFFER_DMA and
IIO_BUFFER_DMAENGINE also depend on SPI_OFFLOAD being present and we just select
those.

- Nuno Sá

>
> >
> > [1]:
> > https://lore.kernel.org/linux-pwm/2e82eaf275b5c8df768c8b842167c3562991e50c.camel@xxxxxxxxx/T/#t
> > - Nuno Sá
> >