[PATCH 0/8] Add iio backend compatibility for ad7606

Guillaume Stols
2024-08-15T12:12:05Z

This series aims to add iio backend support for AD7606X ADCs.

In a nutshell, iio backend is a paradigm to shift the logic establishing
the connexion between iio buffers and backend buffers into the backend's
driver. This provides a more stable programming interface to the driver
developers, and give more flexibility in the way the hardware communicates.

The support will be first added on AD7606B, and on next patches AD7606C16
and AD7606C18 will be added. The series have been tested on a Zedboard,
using the latest HDL available, i.e
https://github.com/analogdevicesinc/hdl/commit/7d0a4cee1b5fa403f175af513d7eb804c3bd75d0
and an AD7606B FMCZ EKV. This HDL handles both the conversion trigger
(through a PWM), and the end of conversion interruption, and is compatible
with axi-adc, which is "iio-backendable".

More information about this HDL design can be found at:
https://wiki.analog.com/resources/eval/user-guides/ad7606x-fmc/hdl

The support is thus separated in two parts:

- PWM support was first added. My first intention was to make it available
for any version of the driver, but the time required to handle the
interruption is not neglectable, and I saw drifts that would eventually
cause an overlapping SPI read with a new conversion trigger, whith
catastrphic consequences. To mitigate this, CRC check must be
implemented, but indeed increasing the samplerate causes more sample to
be lost. Therefore, I decided to only allow PWM for iio-backend
powered device as a first intention, leaving open the possibility to
add the general compatibility afterwards.

- IIO backend support was added: Once the PWM support was ready, the driver
can be extended to iio-backend. The iio-backend powered version of the
driver is a platform driver, and an exemple devicetree node is available
in the bindings.

The following features will be added in subsequent patch series:
- software mode for iio backend
- 18 bits mode (AD7606C18)
- single read (IIO_CHAN_READ_RAW)

Signed-off-by: Guillaume Stols <gstols@baylibre.com>
---
Guillaume Stols (8):
dt-bindings: iio: adc: ad7606: Make corrections on spi conditions
dt-bindings: iio: adc: ad7606: Add iio backend bindings
Documentation: iio: Document ad7606 driver
pwm: Export pwm_get_state_hw
platform: add platform_get_device_match_data() helper
iio: adc: ad7606: Add PWM support for conversion trigger
iio: adc: ad7606: Switch to xxx_get_device_match_data
iio:adc:ad7606: Add iio-backend support

.../devicetree/bindings/iio/adc/adi,ad7606.yaml | 90 ++++-
Documentation/iio/ad7606.rst | 142 ++++++++
drivers/base/platform.c | 12 +
drivers/iio/adc/Kconfig | 3 +-
drivers/iio/adc/ad7606.c | 363 +++++++++++++--------
drivers/iio/adc/ad7606.h | 151 ++++++++-
drivers/iio/adc/ad7606_par.c | 120 ++++++-
drivers/iio/adc/ad7606_spi.c | 31 +-
drivers/pwm/core.c | 3 +-
include/linux/platform_device.h | 1 +
include/linux/pwm.h | 1 +
11 files changed, 733 insertions(+), 184 deletions(-)
---
base-commit: 7cad163c39cb642ed587d3eeb37a5637ee02740f
change-id: 20240725-ad7606_add_iio_backend_support-c401305a6924
prerequisite-message-id: 20240705211452.1157967-2-u.kleine-koenig@baylibre.com
prerequisite-patch-id: 0e21153cd012f41ba9db52357fd08219af53e26c
prerequisite-message-id: 20240712171821.1470833-2-u.kleine-koenig@baylibre.com
prerequisite-patch-id: b22c91bbc4e3412f8e7e1f796ed18570ae021c96
prerequisite-message-id: cover.1721040875.git.u.kleine-koenig@baylibre.com
prerequisite-patch-id: bfc36d041b9e5d417c6b18268dd91171d627d04e
prerequisite-patch-id: adec4b066442de64275ebc3bd310ebaea99a0e8d
prerequisite-patch-id: b536b9607ae40bd58f3e56c4ccd304b7880b5b90
prerequisite-patch-id: fe43e064fe174b830d5a11f83e3cd7252089820e
prerequisite-patch-id: a1cd565094d86ff473724db1fd6dbb61aca996dd
prerequisite-patch-id: d7b5d697839f0a6cea0aa37810df4d02a7762ead
prerequisite-patch-id: e86302e513cfdf80831da4d79a7a950eecf7c557
prerequisite-patch-id: 05b25465694c5640e42e67d2059e84f34e259670

Best regards,
--
Guillaume Stols <gstols@baylibre.com>