Re: [PATCH v5 15/16] iio: adc: ad4695: Add support for SPI offload
From: Jonathan Cameron
Date: Sun Nov 24 2024 - 12:35:41 EST
On Fri, 15 Nov 2024 14:18:54 -0600
David Lechner <dlechner@xxxxxxxxxxxx> wrote:
> Add support for SPI offload to the ad4695 driver. SPI offload allows
> sampling data at the max sample rate (500kSPS or 1MSPS).
>
> This is developed and tested against the ADI example FPGA design for
> this family of ADCs [1].
>
> [1]: http://analogdevicesinc.github.io/hdl/projects/ad469x_fmc/index.html
>
> Signed-off-by: David Lechner <dlechner@xxxxxxxxxxxx>
A few minor formatting type comments inline.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> +static bool ad4695_offload_trigger_match(struct spi_offload_trigger *trigger,
> + enum spi_offload_trigger_type type,
> + u64 *args, u32 nargs)
> +{
> + if (type != SPI_OFFLOAD_TRIGGER_DATA_READY)
> + return false;
> +
> + // args[0] is the trigger event.
> + // args[1] is the GPIO pin number.
/*
* args[0] etc
> + if (nargs != 2 || args[0] != AD4695_TRIGGER_EVENT_BUSY)
> + return false;
> +
> + return true;
> +}
> @@ -1260,12 +1639,36 @@ static int ad4695_probe(struct spi_device *spi)
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->channels = st->iio_chan;
>
> - ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
> - iio_pollfunc_store_time,
> - ad4695_trigger_handler,
> - &ad4695_buffer_setup_ops);
> - if (ret)
> - return ret;
> + static const struct spi_offload_config ad4695_offload_config = {
Whilst we do allow declarations other than at the top for use with things
like __free() there is no strong reason for this one. So move it up to the
top of the function.
> + .capability_flags = SPI_OFFLOAD_CAP_TRIGGER
> + | SPI_OFFLOAD_CAP_RX_STREAM_DMA,
> + };
> +
> + st->offload = devm_spi_offload_get(dev, spi, &ad4695_offload_config);
>