[PATCH v5 0/7] Add support for AD4000 series of ADCs

Marcelo Schmitt
2024-06-25T21:52:53Z

This patch series extends the SPI bitbang, gpio, and spi-engine controllers to
support configurable MOSI line idle states.
It then introduces the ad4000 driver which uses the MOSI idle configuration to
provide improved support for the AD4000 series of ADCs.
Documentation is added describing the new extension to the SPI protocol.
The currently supported wiring modes for AD4000 devices were documented under
IIO documentation directory.

Change log v4 -> v5:

[SPI]
- spi: Fixed spi_setup() not failing if controller doesn't support requested MOSI config.
- spi-summary: CS active -> CS asserted; use of `` to highlight code elements.
- spi: spi-engine: renamed SPI_ENGINE_CONFIG_SDO_IDLE -> SPI_ENGINE_CONFIG_SDO_IDLE_HIGH.
[Device tree]
- Added missing compatibles for ADAQ4001 and ADAQ4003.
- Removed example comments.
- Split adi,spi-mode property into adi,sdi-pin and adi,cnv-pin properties.
- Updated property constraints.
[IIO]
- ad4000: Reviewed includes.
- ad4000: Fixed devm_regulator_get_enable_read_voltage() usage.
- ad4000: Used local lock to protect scale change read modify write cycle.
- ad4000: renamed _3wire -> _reg_access; three_w_chan_spec -> reg_access_chan_spec.
- ad4000: Use u8 tx_buf[2] and u8 rx_buf[2] for reg access transfers.
- ad4000: Simplified dt property read.
- ad4000: Use sample >>= chan->scan_type.shift;
- ad4000: Use devm_spi_optimize_message().
- ad4000: Improvement to macros.
[Documentation]
- [New patch] iio: Added documentation for AD4000 describing wiring connection modes.

Link to v4: https://lore.kernel.org/linux-iio/cover.1718749981.git.marcelo.schmitt@analog.com/
Link to v3: https://lore.kernel.org/linux-iio/cover.1717539384.git.marcelo.schmitt@analog.com/
Link to v2: https://lore.kernel.org/linux-iio/cover.1712585500.git.marcelo.schmitt@analog.com/
Link to v1: https://lore.kernel.org/linux-iio/cover.1711131830.git.marcelo.schmitt@analog.com/

I believe to have made everything suggested in v4, except for the following:

- Use of spi_w8r8().
I tried that but then the values I got from reg read alternated between 0x65 and
0xFF (sometimes 0x00).
I didn't find out why so I kept with spi_sync_transfer().
May investigate it better if re-spinning.

- Reducing sample buffer size
I agree we may save some memory reducing the sample buffer size from 32 to 24 bits.
I will probably use get_unaligned_be24() to get the data back but will have to
declare sample buffers as arrays. It was very tricky to get the buffer
declarations correct the first time and I didn't want to take much longer to
provide a v5.
May do it for v6 if re-spinning.

Thanks,
Marcelo

Marcelo Schmitt (7):
spi: Enable controllers to extend the SPI protocol with MOSI idle
configuration
spi: bitbang: Implement support for MOSI idle state configuration
spi: spi-gpio: Add support for MOSI idle state configuration
spi: spi-axi-spi-engine: Add support for MOSI idle configuration
dt-bindings: iio: adc: Add AD4000
iio: adc: Add support for AD4000
docs: iio: Add documentation for AD4000

.../bindings/iio/adc/adi,ad4000.yaml | 190 +++++
Documentation/iio/ad4000.rst | 131 ++++
Documentation/iio/index.rst | 1 +
Documentation/spi/spi-summary.rst | 83 ++
MAINTAINERS | 9 +
drivers/iio/adc/Kconfig | 12 +
drivers/iio/adc/Makefile | 1 +
drivers/iio/adc/ad4000.c | 711 ++++++++++++++++++
drivers/spi/spi-axi-spi-engine.c | 8 +
drivers/spi/spi-bitbang.c | 24 +
drivers/spi/spi-gpio.c | 12 +-
drivers/spi/spi.c | 7 +
include/linux/spi/spi.h | 6 +
include/linux/spi/spi_bitbang.h | 1 +
include/uapi/linux/spi/spi.h | 5 +-
15 files changed, 1198 insertions(+), 3 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad4000.yaml
create mode 100644 Documentation/iio/ad4000.rst
create mode 100644 drivers/iio/adc/ad4000.c

--
2.43.0