Skip to content

Add ADT7604 support to LTC2983 driver#3278

Open
leaveyoustun wants to merge 2 commits into
mainfrom
adt7604-support
Open

Add ADT7604 support to LTC2983 driver#3278
leaveyoustun wants to merge 2 commits into
mainfrom
adt7604-support

Conversation

@leaveyoustun
Copy link
Copy Markdown
Collaborator

PR Description

This series adds support for the ADT7604 multi-sensor temperature
measurement and leak detection system to the 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 as a
copper trace resistance sensor and the custom thermistor type as a
leak detector, removing thermocouple, diode and direct ADC support.

Initial patch updates the device-tree bindings:

  • Add adi,adt7604 compatible entry to adi,ltc2983.yaml;
  • Add copper-trace@ sensor node (custom RTD type, sub-ohm and
    standard variants, new adi,copper-trace-sub-ohm property);
  • Add leak-detector@ sensor node (custom thermistor type, new
    adi,custom-leak-detector property).
  • Add example for ADT7604

Driver changes:

  • Add adt7604_chip_info with has_copper_trace capability flag;
  • Add resistance result register bank (0x060-0x00AF) to regmap
    readable ranges;
  • Hardcode sensor configuration bits for copper trace (0b1001)
    and leak detector (0b001) per datasheet;
  • Clear bits 17:0 in the channel word for sub-ohm copper trace;
  • Reject unsupported sensor types (thermocouple, diode, direct
    ADC) at probe time for ADT7604;
  • Make custom table optional for copper trace (adi,custom-rtd)
    and leak detector (adi,custom-leak-detector); sensors without
    a table are valid and produce resistance output only;
  • Add base_reg parameter to ltc2983_chan_read to select between
    temperature and resistance result registers;
  • In ltc2983_chan_read, return bits[30:0] via GENMASK(30, 0)
    early for resistance registers, the temperature result format
    (valid bit, fault bits, sign extension) does not apply;
  • Add LTC2983_RESISTANCE_CHAN macro for defining IIO_RESISTANCE
    channels with info_mask_separate for RAW and SCALE, with
    scale 1/1,024,000 for copper trace and 1/1024 for
    leak detector;
  • Copper trace sensors and leak detectors without a
    custom table emit only IIO_RESISTANCE; sensors with
    a custom table emit both IIO_TEMP and IIO_RESISTANCE;
  • Add adi,copper-trace-sub-ohm and adi,custom-leak-detector
    DT property parsing;
  • Consolidate channel result address macros into a single
    two-argument LTC2983_CHAN_RES_ADDR(chan, base).

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have compiled my changes, including the documentation
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly
  • I have provided links for the relevant upstream lore

Requesting internal review before proceeding with the upstream
submission process. Data sheet is not yet publicly available.

@leaveyoustun
Copy link
Copy Markdown
Collaborator Author

Modified sign-off messages to fix DCO error

Comment thread Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml Outdated
Comment thread Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
Comment thread drivers/iio/temperature/ltc2983.c Outdated
Comment thread drivers/iio/temperature/ltc2983.c Outdated
Comment thread drivers/iio/temperature/ltc2983.c
The ADT7604 shares the same die as the LTC2984. It repurposes the
custom RTD sensor type (18) as a copper trace resistance sensor
and the custom thermistor type (27) as a leak detector, and
removes thermocouple, diode and direct ADC sensor types.

Add adi,adt7604 to the compatible list and introduce two new
sensor node types specific to this device:

- copper-trace@: maps to the custom RTD sensor type (18). Two
  variants: sub-ohm (< 1 ohm, adi,copper-trace-sub-ohm boolean,
  no custom table) and standard (> 1 ohm, optional adi,custom-rtd
  table). Primary output is resistance in mOhm.

- leak-detector@: maps to the custom thermistor sensor type (27).
  Takes an optional adi,custom-leak-detector lookup table encoding
  resistance (uOhm) against coverage data (P + 273.15 in uK).
  Primary output is resistance in Ohm; when a table is provided,
  IIO_TEMP reports coverage percentage (raw / 1024).

allOf conditions are added to restrict thermocouple, diode, direct
ADC and active temperature nodes to non-ADT7604 devices, and to
restrict copper-trace and leak-detector nodes to the ADT7604.

Signed-off-by: leaveyoustun <liviu.stan@analog.com>
The ADT7604 shares the same die as the LTC2984. It repurposes the
custom RTD sensor type (18) as a copper trace resistance sensor
and the custom thermistor type (27) as a leak detector, and
removes thermocouple, diode and direct ADC sensor types.

Custom RTD (type 18) becomes the copper trace sensor. Sensor
configuration bits 21:18 are hardcoded to 0b1001 per the
datasheet. Two variants are supported via the new
adi,copper-trace-sub-ohm DT property: sub-ohm traces (< 1 ohm)
have bits 17:0 cleared with no excitation current or custom
table; standard traces (> 1 ohm) accept an optional
resistance-to-temperature table.

Custom thermistor (type 27) becomes the leak detector. Sensor
configuration bits are hardcoded to 0b001. The custom table
uses a resolution of 16 (20+4 bit resistance field) instead of
64, and is specified via the new adi,custom-leak-detector DT
property.

Both sensor types expose an IIO_RESISTANCE channel reading from
the resistance result register bank (0x060-0x00AF), added to
the regmap readable ranges. Scales are 1/1,024,000 for copper
trace (result in mOhm) and 1/1024 for leak detector (result
in Ohm).

A has_copper_trace capability flag is introduced in
ltc2983_chip_info to identify the ADT7604, following the
existing has_temp and has_eeprom pattern.

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

Signed-off-by: leaveyoustun <liviu.stan@analog.com>
@leaveyoustun
Copy link
Copy Markdown
Collaborator Author

leaveyoustun commented Apr 27, 2026

Changes in v2:

  • Modified both commits to solve the issues raised by the reviews

@gastmaier gastmaier added the llm review Request a review from a LLM Reviewer label Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

LLM review

This series adds ADT7604 support (copper trace resistance sensor + leak detector)
to the existing ltc2983 IIO temperature driver and its DT binding.

run: 25067352091

bfae69d1 - dt-bindings: iio: temperature: Add ADT7604 support to adi,ltc2983

Missing datasheet URL: The ADT7604 datasheet is not listed in the binding
description block alongside the other four device datasheets. All other
supported devices have a URL entry; the ADT7604 should too.

Ambiguous page reference: copper-trace@/adi,custom-rtd includes
"See Page 62 of the datasheet" — copied from the generic rtd@ section where
it correctly points to the LTC2984 custom-RTD section. In the ADT7604-specific
copper-trace context the reference is ambiguous. The binding should either cite
the ADT7604 datasheet explicitly or drop the page reference.

24f096c4 - iio: temperature: ltc2983: Add support for ADT7604

Missing validation for sub-ohm excitation current: The DT binding states
that adi,excitation-current-microamp is "not allowed" for sub-ohm copper trace
sensors. The driver correctly zeroes the excitation field in
ltc2983_rtd_assign_chan() via chan_val &= ~GENMASK(17, 0), but it does not
reject or warn when the property is present alongside adi,copper-trace-sub-ohm.
A DT author specifying both will get silent data loss with no diagnostic.

Suggested fix (add before the excitation-current parsing block in ltc2983_rtd_new()):

if (rtd->sub_ohm && fwnode_property_present(child, "adi,excitation-current-microamp"))
    return dev_err_ptr_probe(dev, -EINVAL,
                             "excitation current not allowed for sub-ohm copper trace\n");

CI warnings

checkpatch reports "Duplicate signature" and "DT binding docs and includes
should be a separate patch" when both patches are checked together as a series,
but each patch is individually clean. The DT binding warning is a false positive
since the binding IS in its own commit.

Verification data

  • LTC2984 datasheet 2984fb.md fetched from the doctools docling mirror and
    used to verify the memory map (temperature results 0x010–0x05F, resistance
    range 0x060–0x0AF "Reserved" on LTC2984 / repurposed on ADT7604), sensor
    configuration Table 32 (RTD 0b1001 = 4-wire, internal, no rotate, rsense
    share — valid, not reserved) and Table 56 (thermistor 0b001 = differential,
    share, rotate — valid).
  • Driver compiled warning-free with gcc-13 for arm and arm64 (W=1).
  • DT binding validation: make dt_binding_check passes (exit 0).
  • iio_channels counter traced through all ADT7604 sensor combinations;
    count matches channels emitted in ltc2983_setup() in all cases.
  • Coverage percentage encoding verified: storing (P + 273.15) uK in the
    temperature column causes the device to subtract the 273.15 °C offset and
    output P in the result register; raw / 1024 = coverage % is correct.

Suggested patches

Apply the suggested patches with:

cd path/to/repository
export GITHUB_TOKEN=ghp_***
apply-patches --repo=analogdevicesinc/linux 25067352091
Install instructions

The following one-liner installs the script if not present already:

grep "/apply-patches.sh" ~/.bashrc ||  { curl "https://raw.githubusercontent.com/analogdevicesinc/doctools/refs/heads/main/ci/scripts/apply-patches.sh"    -o ~/.local/bin/apply-patches.sh &&  echo "source ~/.local/bin/apply-patches.sh" >> ~/.bashrc ; source ~/.bashrc ; }

More information at AI Usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm review Request a review from a LLM Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants