Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions Documentation/devicetree/bindings/hwmon/adi,max31732.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/hwmon/adi,max31732.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices MAX31732 Temperature Sensor

maintainers:
- Sinan Divarci <Sinan.Divarci@analog.com>

description: |
The Analog Devices MAX31732 is a local plus four-channel remote temperature
sensor that exposes two ALARM outputs, programmable limits and calibration
aids. The driver reports readings through the Linux hwmon subsystem and can
optionally use the ALARM pins as interrupts.

properties:
compatible:
const: adi,max31732

reg:
description: I2C address of the device.
maxItems: 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guideline is to make dt docs as complete as possible. So, we can also describe the voltage supply here.

vcc-supply: true

interrupts:
description: Optional ALARM1/ALARM2 interrupt lines.
minItems: 1
maxItems: 2

interrupt-names:
description: Names matching the provided interrupts.
minItems: 1
maxItems: 2
items:
- const: ALARM1
- const: ALARM2

adi,alarm1-interrupt-mode:
type: boolean
description: Use the ALARM1 output in interrupt (latching) mode.

adi,alarm2-interrupt-mode:
type: boolean
description: Use the ALARM2 output in interrupt (latching) mode.

adi,alarm1-fault-queue:
description: Number of consecutive faults required to assert ALARM1.
enum: [1, 2, 4, 6]
default: 1

adi,alarm2-fault-queue:
description: Number of consecutive faults required to assert ALARM2.
enum: [1, 2, 4, 6]
default: 1

adi,extended-range:
type: boolean
description: |
Enable the device extended range (+64°C offset) at probe time. When set,
the temperature reading range shifts from [-128°C, +127.9375°C] to
[-64°C, +191.9375°C] for primary limits and [-64°C, +191°C] for
secondary limits.

adi,ignore-isc2gnd:
type: boolean
description: |
Mask short-circuit-to-ground faults for remote channels. When set,
the device ignores shorts between DXN and ground.

adi,custom-ideality-factor-r1:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 1
maximum: 255
description: |
Custom ideality factor for remote channel 1. Allows calibration for
non-standard diode characteristics. When specified, overrides the
default ideality factor for this channel.

adi,custom-ideality-factor-r2:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 1
maximum: 255
description: Custom ideality factor for remote channel 2.

adi,custom-ideality-factor-r3:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 1
maximum: 255
description: Custom ideality factor for remote channel 3.

adi,custom-ideality-factor-r4:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 1
maximum: 255
description: Custom ideality factor for remote channel 4.

adi,filter-channels:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 0
maximum: 0x1e
description: |
Bitmask to enable digital filtering on remote channels (bits 1-4).
The filter averages the previous four temperature conversions.
Bit 0 (local channel) is ignored. Bit 1 = remote1, bit 2 = remote2,
bit 3 = remote3, bit 4 = remote4.

adi,beta-compensation-channels:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 0
maximum: 0x1e
description: |
Bitmask to enable beta compensation on remote channels (bits 1-4).
Bit encoding same as adi,filter-channels.

adi,highest-temp-channels:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 0
maximum: 0x1f
description: |
Bitmask to enable highest temperature tracking per channel (bits 0-4).
Bit 0 = local, bits 1-4 = remote channels 1-4. The hardware records
the highest temperature seen on enabled channels.

adi,reference-temp-local:
$ref: /schemas/types.yaml#/definitions/int32
description: |
Reference junction temperature for the local channel in milli-degrees
Celsius. Used for calibration purposes.

adi,reference-temp-remote1:
$ref: /schemas/types.yaml#/definitions/int32
description: Reference junction temperature for remote channel 1 (in m°C).

adi,reference-temp-remote2:
$ref: /schemas/types.yaml#/definitions/int32
description: Reference junction temperature for remote channel 2 (in m°C).

adi,reference-temp-remote3:
$ref: /schemas/types.yaml#/definitions/int32
description: Reference junction temperature for remote channel 3 (in m°C).

adi,reference-temp-remote4:
$ref: /schemas/types.yaml#/definitions/int32
description: Reference junction temperature for remote channel 4 (in m°C).

adi,alarm1-mask:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 0
maximum: 0x1f
description: |
Bitmask to disable ALARM1 assertions for specific channels at probe time.
Bit 0 = local channel, bits 1-4 = remote channels 1-4.
Set bit to 1 to mask (disable) the alarm for that channel.

adi,alarm2-mask:
$ref: /schemas/types.yaml#/definitions/uint32
minimum: 0
maximum: 0x1f
description: |
Bitmask to disable ALARM2 assertions for specific channels at probe time.
Same bit encoding as adi,alarm1-mask.

required:
- compatible
- reg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm missing something, the device requires a power supply to operate, so

required:
  - compatible
  - reg
  - vcc-supply


additionalProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/gpio/gpio.h>

i2c {
#address-cells = <1>;
#size-cells = <0>;

sensor@1c {
compatible = "adi,max31732";
reg = <0x1c>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it also needs to appear in the example. e.g.

            vcc-supply = <&supply_3_3V>;

interrupt-parent = <&gpio>;
interrupts = <17 IRQ_TYPE_EDGE_FALLING>, <27 IRQ_TYPE_EDGE_FALLING>;
interrupt-names = "ALARM1", "ALARM2";
adi,alarm1-interrupt-mode;
adi,alarm1-fault-queue = <4>;
adi,alarm2-fault-queue = <2>;
adi,extended-range;
adi,ignore-isc2gnd;
adi,custom-ideality-factor-r1 = <100>;
adi,filter-channels = <0x1e>; /* Enable for all remote channels */
adi,beta-compensation-channels = <0x06>; /* Enable for remote 1 and 2 */
adi,highest-temp-channels = <0x1f>; /* Track all channels */
adi,reference-temp-local = <25000>; /* 25°C in m°C */
adi,reference-temp-remote1 = <25000>;
adi,alarm1-mask = <0x08>;
adi,alarm2-mask = <0x10>;
};
};
1 change: 1 addition & 0 deletions Documentation/hwmon/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Hardware Monitoring Kernel Drivers
max20751
max31722
max31730
max31732
max31760
max31785
max31790
Expand Down
171 changes: 171 additions & 0 deletions Documentation/hwmon/max31732.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
.. SPDX-License-Identifier: GPL-2.0

Analog Devices MAX31732 hardware monitor
========================================

Supported chips
---------------

* Analog Devices MAX31732 - 4-channel remote plus on-chip temperature sensor

Prefix: ``max31732``

I2C addresses: 0x1c - 0x4f (can be selected by connecting a resistor between ADD pin and GND)

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max31732.pdf

Overview
--------

The MAX31732 combines a local temperature sensor with four remote
probes. The local sensor monitors the chip's own temperature, while the remote probes monitor external diode-connected transistors.
The device supports comparator or interrupt behaviour on
two open-drain ALARM outputs, implements programmable fault queues,
and exposes calibration features such as custom ideality factors and beta compensation.
The Linux driver uses the regmap abstraction on top of the I2C bus and integrates with the HWMON
subsystem, exposing standard hwmon ``temp`` attributes through the modern hwmon API.

Key device capabilities
~~~~~~~~~~~~~~~~~~~~~~~

- Five measurement channels (local sensor + four remote diodes)
- 12-bit temperature conversion with 0.0625°C resolution
- Extended range option that shifts the readable window by +64°C
- Independent primary (ALARM1) and secondary (ALARM2) alarm thresholds
- Per-channel programmable offsets, digital filtering and calibration
- Comparator or interrupt mode for alarm outputs
- Non-volatile (MTP) storage for alarm/fault configuration (not exposed by driver)

Temperature data is reported in milli-degree Celsius through standard hwmon sysfs attributes.

Standard temperature attributes
-------------------------------

The driver implements standard hwmon temperature attributes.
All attributes follow the standard hwmon sysfs interface.

===================== == =====================================================
temp[1-5]_input RO Instantaneous temperature for local (1) and remote
channels (2-5). Returns -ENODATA if channel is
disabled.
temp[1-5]_enable RW Enable (1) or disable (0) a channel.
temp[1-5]_max RW Primary over-temperature limit (asserts ALARM1).
temp[1-5]_max_alarm RO Primary over-temperature alarm status.
temp[1-5]_crit RW Secondary over-temperature limit (asserts ALARM2).
temp[1-5]_crit_alarm RO Secondary over-temperature alarm status.
temp1_min RW Primary under-temperature limit (asserts ALARM1).
This is a shared limit that applies to all channels.
temp[1-5]_min_alarm RO Primary under-temperature alarm status.
temp1_lcrit RW Secondary under-temperature limit (asserts ALARM2).
This is a shared limit that applies to all channels.
temp[1-5]_lcrit_alarm RO Secondary under-temperature alarm status.
temp[2-5]_offset RW Programmable offset for each remote channel
(-14.875°C to +17°C in 0.125°C steps). Writing
a non-zero offset automatically enables the offset
for that channel.
temp[2-5]_fault RO Indicates open/short fault detection on remote
sensors (0=no fault, 1=fault detected).
===================== == =====================================================

Notes:

* temp1 represents the local (on-chip) temperature sensor
* temp2-5 represent remote channels 1-4 respectively
* Only temp1_min and temp1_lcrit are writable; these limits apply globally
* Offsets are only available for remote channels (temp2-5), not the local channel
* All temperatures are in milli-degrees Celsius
* The extended_range mode (configured via device tree) adds a +64°C offset
to all temperature readings, allowing measurements above +127.9375°C

Device Tree configuration
-------------------------

The driver accepts several device tree properties to configure the device at
probe time. These properties configure hardware behavior but are not exposed
as runtime sysfs attributes.

Refer to ``Documentation/devicetree/bindings/hwmon/adi,max31732.yaml`` for the
complete device tree binding specification.

Configuration properties
~~~~~~~~~~~~~~~~~~~~~~~~

``interrupts`` / ``interrupt-names``
Optional interrupt lines for ALARM1/ALARM2 outputs. When specified, the
driver registers threaded IRQ handlers that clear status registers and
issue hwmon_notify_event() callbacks to userspace.

``adi,alarm1-interrupt-mode`` / ``adi,alarm2-interrupt-mode``
Configure ALARM outputs to function in interrupt (latching) mode.
When absent, outputs operate in comparator mode.

``adi,alarm1-fault-queue`` / ``adi,alarm2-fault-queue``
Number of consecutive faults (1, 2, 4, or 6) required before the
corresponding ALARM output asserts. Defaults to 1.

``adi,extended-range``
Enable extended temperature range at probe time. When set, adds a +64°C
offset to all temperature readings, allowing measurements from -64°C to
+191.9375°C (primary limits) or +191°C (secondary limits).

``adi,ignore-isc2gnd``
Mask short-circuit-to-ground faults for remote channels.

``adi,alarm1-mask`` / ``adi,alarm2-mask``
5-bit mask (0x00-0x1f) to disable ALARM assertions for specific channels
at probe time. Bit 0 = local channel, bits 1-4 = remote channels 1-4.
Set bit to 1 to mask (disable) the alarm for that channel.

``adi,custom-ideality-factor-r[1-4]``
Custom ideality factor (1-255) for each remote channel. Allows calibration
for non-standard diode characteristics.

``adi,filter-channels``
Bitmask (bits 1-4) to enable digital filtering on remote channels. The
filter averages the previous four conversions.

``adi,beta-compensation-channels``
Bitmask (bits 1-4) to enable beta compensation on remote channels.

``adi,highest-temp-channels``
Bitmask (bits 0-4) to enable highest temperature tracking per channel.
Note: The highest temperature values are not currently exposed via sysfs.

``adi,reference-temp-local``
Reference junction temperature for the local channel (in milli-degrees C).

``adi,reference-temp-remote[1-4]``
Reference junction temperatures for remote channels (in milli-degrees C).

Interrupt support
-----------------

The driver optionally registers threaded IRQ handlers for the ALARM1 and
ALARM2 outputs. Provide ``interrupts`` and matching ``interrupt-names``
("ALARM1", "ALARM2") in the device tree to enable interrupt handling.

When an alarm interrupt fires, the driver:

1. Reads the status registers (PRIMARY/SECONDARY HIGH/LOW STATUS)
2. Logs critical messages identifying which channels triggered the alarm
3. Calls hwmon_notify_event() for each affected channel
4. Returns IRQ_HANDLED

This allows userspace monitoring tools to react promptly to temperature events
through the standard hwmon notification mechanism.

If interrupts are not specified in device tree, the corresponding ALARM outputs
are masked (all channels disabled) and polling must be used to detect alarm
conditions via the _alarm sysfs attributes.

Usage notes
-----------

* All temperatures are in milli-degree Celsius (m°C)
* The driver uses REGCACHE_MAPLE for register caching with explicit volatile ranges
* Channel enable/disable state is checked at probe; if all channels are disabled,
the STOP bit is set to halt conversions
* The extended_range setting and other hardware configurations are applied once
at probe time and cannot be changed at runtime
* Temperature offset writes automatically enable/disable the offset feature based
on whether a non-zero value is written
11 changes: 11 additions & 0 deletions drivers/hwmon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,17 @@ config SENSORS_MAX31730
This driver can also be built as a module. If so, the module
will be called max31730.

config SENSORS_MAX31732
tristate "Analog Devices MAX31732"
depends on I2C
select REGMAP_I2C
help
Support for the Analog Devices MAX31732 4-Channel Remote
Temperature Sensor.

This driver can also be built as a module. If so, the module
will be called max31732.

config SENSORS_MAX31760
tristate "MAX31760 fan speed controller"
depends on I2C
Expand Down
Loading