[PATCH v3 0/8] iio: temperature: ltc2983: Add support for ADT7604

Liviu Stan posted 8 patches 3 days, 2 hours ago
Documentation/ABI/testing/sysfs-bus-iio       |  17 +
.../bindings/iio/temperature/adi,ltc2983.yaml | 207 +++++-
drivers/iio/industrialio-core.c               |   1 +
drivers/iio/temperature/ltc2983.c             | 614 +++++++++++++++---
include/uapi/linux/iio/types.h                |   1 +
tools/iio/iio_event_monitor.c                 |   2 +
6 files changed, 741 insertions(+), 101 deletions(-)
[PATCH v3 0/8] iio: temperature: ltc2983: Add support for ADT7604
Posted by Liviu Stan 3 days, 2 hours ago
This series adds support for the ADT7604 multi-sensor temperature
measurement and leak detection system to the existing ltc2983 driver.

The ADT7604 shares the same die as the LTC2984, reusing its register
map and SPI interface. It repurposes the custom RTD sensor type (18)
as a copper trace resistance sensor and the custom thermistor type (27)
as a leak detector, removing thermocouple, diode and direct ADC support.

Patches 1-5 fix pre-existing bugs in the ltc2983 driver: macro
parenthesization and renaming, inconsistent use of the local device
pointer, inconsistent channel wording in log messages, missing
fwnode_property_present() guards for optional properties, and an
n_wires default that silently bypassed the current-rotate validation.

Patch 6 adds IIO_COVERAGE, a new channel type for sensors reporting
fractional surface coverage as a percentage.

Patch 7 updates the device tree bindings: adds adi,adt7604 compatible,
copper-trace@ and leak-detector@ sensor node types with their respective
properties, and an ADT7604 example.

Patch 8 updates the driver: introduces two new software sensor type
values (LTC2983_SENSOR_COPPER_TRACE = 32, LTC2983_SENSOR_LEAK_DETECTOR
= 33) with dedicated structs and parser functions rather than extending
the existing RTD and thermistor paths. The hardware configuration bits
are fully hardcoded for both sensor types, and several RTD/thermistor
DT properties have no meaning for them. A u64 supported_sensors bitmask
in ltc2983_chip_info gates sensor type validation per chip, replacing
the has_temp bool pattern. BIT_ULL() is used for the new type values
at bits 32 and 33 to avoid shifting beyond 32 bits on 32-bit builds.

Tested on EVAL-ADT7604-AZ connected to Raspberry Pi 5 via SPI.

Changes in v3:

Patch 1 - macro parenthesization and rename:
- Dropped the Fixes: tag
- Removed the "base" parameter from ADT7604_RES_RES_ADDR(); the resistance
  result memory region is (currently) ADT7604-specific so the macro's
  modification belongs in the driver patch

Patch 2 - use local device pointer consistently:
- Dropped the Fixes: tag
- Fixed one remaining dev_dbg() call in __ltc2983_chan_assign_common()
  that was still using the raw device pointer instead of the dev local
  variable introduced by this patch

Patch 3 - fix inconsistent channel wording in messages:
- Dropped both Fixes: tags
- Removed the "all" from "all occurrences" in the commit message
- Fixed some missed "chan" / "chann" occurrences

Patch 4 - use fwnode_property_present() for optional properties:
- Dropped the Fixes: tag
- Fixed other occurrences brought up by sashiko

Patch 5 - Fix n_wires default bypassing rotation check:
- New patch

Patch 6 - IIO_COVERAGE channel type:
- Renamed the sysfs attribute from in_coveragepercentX_raw to
  in_coverageX_raw
- Added a _scale ABI documentation entry
- Corrected KernelVersion in the ABI documentation from 6.15 to 7.2
- Added IIO_COVERAGE to the event_is_known() switch in
  tools/iio/iio_event_monitor.c

Patch 7 - DT bindings:
- Changed the custom leak detector table encoding, users now specify
  plain coverage percentage values (0-100) in the device tree and the
  driver applies the +273.15 C offset internally before writing the
  hardware table
- Changed custom-rtd to custom-copper-trace to better represent the
  copper trace custom table, and made it required for > 1 ohm variants
- Made custom-leak-detector required for leak detector sensors
- Updated commit message to reflect the changes
- Updated leak detector node description
- Updated adi,custom-leak-detector description
- Modified the example leak detector custom table to match the datasheet

Patch 8 - driver:
- Relocated the "base" parameter addition from patch 1 to this one since
  the resistance result memory region is (currently) ADT7604-specific
- Updated the commit message to mention the base and base_reg parameters
  added to the result-bank read helpers
- Stacked the IIO_RESISTANCE and IIO_COVERAGE case labels in
  ltc2983_read_raw()
- Added LTC2983_SENSOR_NUM sentinel at the end of the sensor-type enum
- Changed the sensor-type bounds check from > LTC2983_SENSOR_LEAK_DETECTOR
  to >= LTC2983_SENSOR_NUM
- Reordered the ltm2985_chip_info_data struct initializer so has_eeprom
  doesn't look like it was added to the ltm2985 in the diff
- Changed the custom leak detector table encoding, users now specify
  plain coverage percentage values (0-100) in the device tree and the
  driver applies the +273.15 C offset internally before writing the
  hardware table
- Changed custom-rtd to custom-copper-trace to better represent the
  copper trace custom table, and made it required for > 1 ohm variants
- Made custom-leak-detector required for leak detector sensors, _new
  and _assign_chan functions were updated for both sensor types
- Updated commit message to reflect the changes
- Removed "..." from "rsense channel must be configured" error message
  from ltc2983_leak_detector_new()
- Removed blank line before hw_type declaration in
  __ltc2983_chan_assign_common

Liviu Stan (8):
  iio: temperature: ltc2983: Fix macro parenthesization and rename
  iio: temperature: ltc2983: Use local device pointer consistently
  iio: temperature: ltc2983: Fix inconsistent channel wording in
    messages
  iio: temperature: ltc2983: Use fwnode_property_present() for optional
    properties
  iio: temperature: ltc2983: Fix n_wires default bypassing rotation
    check
  iio: core: Add IIO_COVERAGE channel type
  dt-bindings: iio: temperature: Add ADT7604 support to adi,ltc2983
  iio: temperature: ltc2983: Add support for ADT7604

 Documentation/ABI/testing/sysfs-bus-iio       |  17 +
 .../bindings/iio/temperature/adi,ltc2983.yaml | 207 +++++-
 drivers/iio/industrialio-core.c               |   1 +
 drivers/iio/temperature/ltc2983.c             | 614 +++++++++++++++---
 include/uapi/linux/iio/types.h                |   1 +
 tools/iio/iio_event_monitor.c                 |   2 +
 6 files changed, 741 insertions(+), 101 deletions(-)

-- 
2.43.0