Re: [PATCH 6/7] iio: imu: adis16607: Add FIFO-based buffered capture

From: Jonathan Cameron

Date: Sat Nov 28 2026 - 17:00:21 EST


On Mon, 23 Nov 2026 15:25:30 +0200
Radu Sabau via B4 Relay <devnull+radu.sabau.analog.com@xxxxxxxxxx> wrote:

> From: Radu Sabau <radu.sabau@xxxxxxxxxx>
>
> Add buffered capture via the device's hardware FIFO, the only capture
> mode this driver supports. Popping the FIFO uses a dedicated command and
> payload format (FIFO_DATA_CMD, 52 bytes, no checksum). The channels are
> described as big endian words with the value in their upper bits, as the
> device sends them, so the samples are copied to the buffer unchanged.
>
> The samples go to a kfifo buffer set up with the adislib kfifo helper,
> filled from a threaded interrupt: the device raises one interrupt per
> watermark, not per sample, so there is nothing to trigger on. The
> watermark-met condition is signaled via DEV_NOK on the device's one
> interrupt pin, which stays asserted until DIAG_STAT is read and cleared.
> The interrupt is therefore level-triggered and oneshot, and it is enabled
> only while the buffer is. DEV_NOK fires on any DIAG_STAT flag, not just
> FIFO_THRESH_MET, so the handler checks that specific bit before popping
> anything and leaves interrupts it did not raise to the core. DR_GPIO_MASK
> stays enabled unconditionally: DR pulses drive the FIFO controller's
> internal sample enqueue, independent of pin routing.
>
> Watermark is configurable via the standard hwfifo_set_watermark callback
> and the usual hwfifo_* sysfs attributes. Changing the sampling frequency
> while the buffer is enabled returns -EBUSY, as the decimation can't change
> during capture.

Unless I read it wrong, this changes the driver from doing some useful
stuff without interrupts being wired, to nothing at all. That is not
a change we should make in an upstream driver (even if maybe this
lands in the same cycle).

Jonathan

>
> Signed-off-by: Radu Sabau <radu.sabau@xxxxxxxxxx>

> diff --git a/drivers/iio/imu/adis16607.c b/drivers/iio/imu/adis16607.c
> index 749ed7445f73..60433c97a855 100644
> --- a/drivers/iio/imu/adis16607.c
> +++ b/drivers/iio/imu/adis16607.c



> +static int adis16607_buffer_postenable(struct iio_dev *indio_dev)
> +{
> + struct adis16607 *st = iio_priv(indio_dev);
> + struct adis *adis = &st->adis;
> + u16 threshold;
> + int ret;
> +
> + adis_dev_auto_lock(adis);
> +
> + /* Flush FIFO to start clean */
> + ret = __adis_write_reg_16(adis, ADIS16607_REG_USER_FIFO_CFG,
> + ADIS16607_FIFO_FLUSH_MASK);
> + if (ret)
> + return ret;
> +
> + /* Enable FIFO with watermark threshold (in word count) */
> + threshold = st->fifo_watermark * ADIS16607_FIFO_WORDS_PER_SAMPLE;
> + ret = __adis_write_reg_16(adis, ADIS16607_REG_USER_FIFO_CFG,
> + threshold & ADIS16607_FIFO_THR_MASK);
> + if (ret)
> + return ret;
> +
> + /*
> + * The device cannot mask DEV_NOK for us: unrouting it leaves the pin
> + * on its weak pull-up, which reads as asserted. Mask it on the host.
> + */

Ah. This is the comment we need for the earlier patches. Is that generally
true for all the kfifo supported devices, or should we be using some sort
of flag to let the adis helper know if this is required?

> + enable_irq(adis->spi->irq);
> +
> + return 0;
> +}

>
> /*
> @@ -814,6 +1158,7 @@ static const struct adis_data adis16607_data = {
> .diag_stat_size = 2,
> .prod_id_reg = ADIS16607_REG_DEV_ID,
> .prod_id = 0x6000,
> + .has_fifo = true,
> .unmasked_drdy = true,
> .init = adis16607_init,
> .self_test = adis16607_self_test,
> @@ -972,7 +1317,19 @@ static int adis16607_probe(struct spi_device *spi)
> indio_dev->info = &adis16607_info;
> indio_dev->modes = INDIO_DIRECT_MODE;
>
> + if (!spi->irq)
> + return dev_err_probe(dev, -EINVAL, "interrupt is required\n");

The driver is upstream without that requirement. We should not add it now as
I assume it works to some degree without it? Just modify the reported channels
etc to have it support current functionality if no irq. That probably means
multiple iio_info, possibly channels etc.


> +
> + /* The core's default; the device watermark follows buffer/watermark */
> + st->fifo_watermark = 1;
> +
> st->adis.ops = &adis16607_ops;
> + /*
> + * DEV_NOK is the OR of the DIAG_STAT flags and stays high until
> + * DIAG_STAT is read. Use a level interrupt so a flag raised while it
> + * is already high is not lost.
> + */
> + st->adis.irq_flag = IRQF_TRIGGER_HIGH;
For a modern driver explain why we don't get this from the firmware.

Thanks,

Jonathan

>