Re: [PATCH v9 5/8] iio: adc: ad4030: Add SPI offload support

From: Marcelo Schmitt

Date: Mon Feb 23 2026 - 10:13:10 EST


Hi Jonathan

On 02/22, Jonathan Cameron wrote:
> On Mon, 16 Feb 2026 12:00:39 -0300
> Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx> 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.
> >
> > Reviewed-by: David Lechner <dlechner@xxxxxxxxxxxx>
> > 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>
>
...

> > +static int ad4030_pwm_get(struct ad4030_state *st)
> > +{
> > + struct device *dev = &st->spi->dev;
> > +
> > + st->cnv_trigger = devm_pwm_get(dev, NULL);
> > + if (IS_ERR(st->cnv_trigger))
> > + return dev_err_probe(dev, PTR_ERR(st->cnv_trigger),
> > + "Failed to get CNV PWM\n");
> > +
> > + /*
> > + * Preemptively disable the PWM, since we only want to enable it with
> > + * the buffer.
> > + */
> > + pwm_disable(st->cnv_trigger);
>
> Feels like there should really be a way to get a pwm disabled in one call
> so there isn't an edge case of it being on briefly.
> I'm a bit surprised it defaults to on. I guess this is because DT can provide
> the parameters?
>
Not really. DT doesn't specify any initial state for the PWM. It might, though,
be left enabled if another device was using it previously. Not a thing I've
ever seen during tests, but it may in theory happen.

We may have devm_pwm_get_disabled(). In IIO, ad7625 and this ad4030 would be
the users of such interface. Would you like me to propose that one?

Thanks,
Marcelo