[PATCH v2 00/19] iio: resolver: move ad2s1210 out of staging

From: David Lechner
Date: Thu Sep 21 2023 - 16:02:10 EST


Resending v2 with proper `PATCH v2` prefix.

Changes since v1:
* Address initial device tree patch feedback
* Drop "iio: sysfs: add IIO_DEVICE_ATTR_NAMED_RW macro" (related cleanups
also dropped for now, will address in a future series if needed)
* Apply improvements as a series as patches to the staging driver. It is not
quite ready for the move out of staging patch yet.

This series has been tested on actual hardware using a EVAL-AD2S1210 evaluation
board. (Note: not all device tree features have been implemented in the driver
since the eval board doesn't support them out of the box. We plan to add them
later if needed.)

One thing left over from the staging driver that probably needs more attention
still is the fault handling (both the fault threshold attributes and how
userspace gets notified of fault conditions). We considered adding these as
events, but the fault conditions are related to internal measurements in the
chip that aren't available as channels.

Since the chip is designed to read the fault register each time we read the
data registers for one of the two channels it seems like faults should be
associated with channels one way or another. Would it make sense to add extra
channels for the internal signals that only have fault events (mostly with
IIO_EV_TYPE_THRESH)? Or would it make sense to add a new "flags" channel type
where the "raw" value is bit flags? Or something else?

Here is the table of available faults for context. Sine/cosine inputs are
internal signals.

| Bit | Description
+-----+------------
| D7 | Sine/cosine inputs clipped
| D6 | Sine/cosine inputs below LOS threshold
| D5 | Sine/cosine inputs exceed DOS overrange threshold
| D4 | Sine/cosine inputs exceed DOS mismatch threshold
| D3 | Tracking error exceeds LOT threshold
| D2 | Velocity exceeds maximum tracking rate
| D1 | Phase error exceeds phase lock range
| D0 | Configuration parity error

David Lechner (19):
dt-bindings: iio: resolver: add devicetree bindings for ad2s1210
staging: iio: Documentation: document IIO resolver AD2S1210 sysfs
attributes
staging: iio: resolver: ad2s1210: fix ad2s1210_show_fault
staging: iio: resolver: ad2s1210: fix not restoring sample gpio in
channel read
staging: iio: resolver: ad2s1210: fix probe
staging: iio: resolver: ad2s1210: always use 16-bit value for raw read
staging: iio: resolver: ad2s1210: implement IIO_CHAN_INFO_SCALE
staging: iio: resolver: ad2s1210: use devicetree to get fclkin
staging: iio: resolver: ad2s1210: use regmap for config registers
staging: iio: resolver: ad2s1210: add debugfs reg access
staging: iio: resolver: ad2s1210: remove config attribute
staging: iio: resolver: ad2s1210: rework gpios
staging: iio: resolver: ad2s1210: implement hysteresis as channel attr
staging: iio: resolver: ad2s1210: refactor setting excitation
frequency
staging: iio: resolver: ad2s1210: read excitation frequency from
control register
staging: iio: resolver: ad2s1210: rename fexcit attribute
staging: iio: resolver: ad2s1210: convert resolution to devicetree
property
staging: iio: resolver: ad2s1210: add phase_lock_range attributes
staging: iio: resolver: ad2s1210: add triggered buffer support

.../bindings/iio/resolver/adi,ad2s1210.yaml | 150 +++
.../sysfs-bus-iio-resolver-ad2s1210 | 109 ++
drivers/staging/iio/resolver/Kconfig | 1 +
drivers/staging/iio/resolver/ad2s1210.c | 948 +++++++++++-------
4 files changed, 857 insertions(+), 351 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/resolver/adi,ad2s1210.yaml
create mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-resolver-ad2s1210

--
2.34.1