[PATCH v1 0/7] iio: adc: Add support for AD4170 series of ADCs

From: Marcelo Schmitt
Date: Wed Apr 09 2025 - 11:19:12 EST


This patch set adds support for Analog Devices AD4170 and similar sigma-delta ADCs.

I've arranged the patches so that the first ones comprise changes more typical
of IIO device drivers while the last one has the most uncommon changes.
I believe to have applied all suggestions to the RFC version.

Patch 1 adds device tree documentation for the parts.
Patch 2 adds basic device support.
Patch 3 adds support for buffered ADC reading.
Patch 4 adds clock provider support
Patch 5 adds GPIO controller support.
Patch 6 adds internal temperature sensor support.
Patch 7 adds support for external RTD and bridge circuit sensors.

For context, an initial version of the ad4170 driver was developed by
Ana-Maria Cusco. I then picked that up, created dt docs, and did several
improvements to the driver.

This first version has so many changes compared to the RFC version that it's not
worth listing them all. The most significant one, though, are listed below.

Change log RFC -> v1

[IIO driver changes]
- Split off extra features into smaller additional patches.
- No longer pushing timestamp data to buffers.
- Used iio_for_each_active_channel() to iterate over channels in trigger handler.
- Correctly implemented incomplete/broken usage of SPI optimized messages.
- No longer setting interrupt direction in driver.
- Register names, register field names, and names of constants for register
fields now follow an established pattern.
- Data ready interrupt config now set according to interrupt-names dt property.
- Added scan_mask to validate chan 0 is enabled when multiple chans are enabled.
- Added a comment explaining the reason to disable all channel at buffer_predisable().
- Complemented comment about channel 0 being required to be enabled when more
than one channel is enabled.
- New GPIO controller support patch.
- New internal temperature sensor support patch.

There are some places where I used find_closest() to match/verify values from
dt. On the last patch, I added ad4170_find_table_index() to avoid find_closest()
but may use something else if there are any generic helper for such thing.

[device tree changes]
- Dropped adi,ad4170.h. All dt documentation is now in adi,ad4170.yaml.
- Described external bridge circuits and RTD sensors as specialized channels
with specific properties for excitation control.
- Bridge circuit excitation properties are now sensor-node only.
- Added compatibles for 2 more similar chips.
- Added ldac-gpios.
- Dropped adi,dig-aux1, DIG_AUX1 now set according to Data Ready interrupt choice.
- Dropped adi,dig-aux2, DIG_AUX2 now set according to LDAC GPIO presence.
- Dropped adi,sync-option, SYNC_CTRL will only of be set for multi-device sync.
- Dropped adi,burnout-current-nanoamp since open wire detection should be a runtime config.
- Complemented adi,buffered-pos/neg description with possible reason to not enable them.
- adi,gpion-power-down-switch renamed to adi,power-down-switch-pin is now a
sensor-node only prop.

About the bridge power-down-switch pins, it was mentioned that maybe they could
be described as regulators that the bridge circuit would consume. One
complication of that approach is that the AD4170 powerdown switches close to
AVSS/GND and that doesn't help determining regulator maximum voltage. It may
also be desired to control the power switches at runtime to save power by
closing the power down switches when the bridge would not be in use. Because of
that, I have removed pw-down switch props from the dt-binding.

Not sure what to do about the various possible multiplexed inputs to the ADC.
Even though the IIO driver doesn't handle all of them, I'm keeping those since
dt-bindings are intended to be OS agnostic and we are expected to make bindings
complete.

Ana-Maria Cusco (1):
iio: adc: Add basic support for AD4170

Marcelo Schmitt (6):
dt-bindings: iio: adc: Add AD4170
iio: adc: ad4170: Add support for buffered data capture
iio: adc: ad4170: Add clock provider support
iio: adc: ad4170: Add GPIO controller support
iio: adc: ad4170: Add support for internal temperature sensor
iio: adc: ad4170: Add support for weigh scale and RTD sensors

.../bindings/iio/adc/adi,ad4170.yaml | 527 +++
MAINTAINERS | 8 +
drivers/iio/adc/Kconfig | 16 +
drivers/iio/adc/Makefile | 1 +
drivers/iio/adc/ad4170.c | 2817 +++++++++++++++++
5 files changed, 3369 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad4170.yaml
create mode 100644 drivers/iio/adc/ad4170.c


base-commit: 1c2409fe38d5c19015d69851d15ba543d1911932
--
2.47.2