-
Notifications
You must be signed in to change notification settings - Fork 905
add max31732 driver #2959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sdivarci
wants to merge
3
commits into
analogdevicesinc:main
Choose a base branch
from
sdivarci:dev-max31732
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add max31732 driver #2959
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
Documentation/devicetree/bindings/hwmon/adi,max31732.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# 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 | ||
|
||
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 degC offset) at probe time. | ||
|
||
adi,alarm1-mask: | ||
description: Bitmask disabling ALARM1 events per channel (bit0 = local channel). | ||
$ref: /schemas/types.yaml#/definitions/uint32 | ||
minimum: 0 | ||
maximum: 0x1f | ||
|
||
adi,alarm2-mask: | ||
description: Bitmask disabling ALARM2 events per channel (bit0 = local channel). | ||
$ref: /schemas/types.yaml#/definitions/uint32 | ||
minimum: 0 | ||
maximum: 0x1f | ||
|
||
required: | ||
- compatible | ||
- reg | ||
|
||
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>; | ||
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,alarm1-mask = <0x08>; | ||
adi,alarm2-mask = <0x10>; | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,7 @@ Hardware Monitoring Kernel Drivers | |
max20751 | ||
max31722 | ||
max31730 | ||
max31732 | ||
max31760 | ||
max31785 | ||
max31790 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
.. 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 both the standard ``temp`` attributes and a set of | ||
chip-specific controls documented below. | ||
|
||
Key device capabilities | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
- Five measurement channels (local sensor + four remote diodes) | ||
- 12-bit temperature conversion with 0.0625degC resolution | ||
- Extended range option that shifts the readable window by +64degC | ||
- "highest temperature" recorded per enabled channel | ||
- Independent primary (ALARM1) and secondary (ALARM2) alarm thresholds | ||
- Per-channel programmable offsets, digital filtering and calibration | ||
- Non-volatile (MTP) storage for alarm/fault configuration | ||
|
||
Temperature data is reported in milli-degree Celsius through sysfs. | ||
|
||
Standard temperature attributes | ||
------------------------------- | ||
|
||
===================== == ===================================================== | ||
temp[1-5]_input RO Instantaneous temperature for local (1) and remote | ||
channels (2-5). | ||
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 status. | ||
temp[1-5]_crit RW Secondary over-temperature limit (asserts ALARM2). | ||
temp[1-5]_crit_alarm RO Secondary over-temperature status. | ||
temp[1-5]_min RW Primary under-temperature limit. Only ``temp1_min`` | ||
is writable; the value applies to all channels. | ||
temp[1-5]_min_alarm RO Primary under-temperature status. | ||
temp[1-5]_lcrit RW Secondary under-temperature limit. Only | ||
``temp1_lcrit`` is writable; the value applies to all | ||
channels and controls ALARM2. | ||
temp[1-5]_lcrit_alarm RO Secondary under-temperature status. | ||
temp[2-5]_offset RW Programmable offset for each remote channel. Offset | ||
writes automatically enable ``tempN_offset``. | ||
temp[2-5]_fault RO Indicates open/short fault detection on remote sensors. | ||
===================== == ===================================================== | ||
|
||
Extended features | ||
----------------- | ||
|
||
Highest temperature recorder | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
=============================== == ================================================= | ||
highest_temp_input RO Max temperature after each temperature conversion (millidegree Celsius). | ||
local_highest_temp_enable RW Enable highest-temperature capture for ``temp1``. | ||
remote[1-4]_highest_temp_enable RW Enable highest-temperature capture for remote sensors (``temp2`` - ``temp5``). | ||
=============================== == ================================================= | ||
|
||
Conversion control and configuration bits | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
========================= == ================================================== | ||
stop RW Halt (1) or resume (0) conversions (STOP bit). | ||
soft_por RW Trigger a soft power-on reset when written to ``1``. | ||
one_shot RW Initiate a single conversion when written to ``1``. | ||
extended_range RW Mirrors the ``EXTRANGE`` bit. When set, extended | ||
data format that allows temperatures greater than | ||
+127.9375°C to be read for the Primary threshold | ||
limits and +127°C for the Secondary threshold limits | ||
ignore_isc2gnd RW Mask short to ground faults. | ||
remote[1-4]_filter_enable RW Enable the filter that averages the previous four conversions. | ||
========================= == ================================================== | ||
|
||
Calibration helpers | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
==================================== == =========================================== | ||
remote[1-4]_custom_ideality_enable RW Enables use of the custom ideality value | ||
for a remote channel. | ||
remote[1-4]_custom_ideality_code RW Eight-bit code that programs the custom | ||
ideality factor. | ||
local_reference_temp RW Reference junction temperature for the | ||
local channel (mdegC). | ||
remote[1-4]_reference_temp RW Reference junction temperatures for | ||
remote channels (mdegC). | ||
remote[1-4]_beta_compensation_enable RW Turn beta compensation on/off per channel. | ||
remote[1-4]_beta_compensation_value RO Currently measured beta of the targeted transistor. | ||
==================================== == =========================================== | ||
|
||
Fault status indicators | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
======================== == ================================================ | ||
remote[1-4]_oc RO Open-circuit detected on the diode input. | ||
remote[1-4]_sc2gnd RO Short-circuit to ground detected. | ||
remote[1-4]_sc2vcc RO Short-circuit to VCC detected. | ||
remote[1-4]_sc2dxp RO DXP shorted to DXN or ground detected. | ||
======================== == ================================================ | ||
|
||
Alarm masking | ||
~~~~~~~~~~~~~ | ||
|
||
========================= == ================================================== | ||
local_alarm1_mask RW Mask ALARM1 assertions for local temperature fault. | ||
remote[1-4]_alarm1_mask RW Mask ALARM1 assertions for remote channel faults. | ||
local_alarm2_mask RW Mask ALARM2 assertions for local temperature fault. | ||
remote[1-4]_alarm2_mask RW Mask ALARM2 assertions for remote channel faults. | ||
========================= == ================================================== | ||
|
||
Write ``1`` to mask (disable) an alarm for the associated channel; write ``0`` to | ||
allow the interrupt comparator to operate normally. | ||
|
||
Multi-Time Programmable Nonvolatile Memory (MTP) access | ||
------------------------------------------------------- | ||
|
||
The MAX31732 provides a 512-bit MTP that helps facilitate device configuration during power-up or during normal operation if desired. | ||
|
||
=============================== == =========================================== | ||
mtp/mtp_config_store WO Start copying the current volatile register | ||
image into MTP when written ``1``. Returns | ||
``-EBUSY`` while a store operation is in | ||
progress. | ||
mtp/mtp_config_load WO Restore configuration from MTP when written | ||
``1``. Returns ``-EBUSY`` if a load is still | ||
running. | ||
mtp/mtp_user_software_revision RW User-defined 16-bit field stored in MTP. | ||
mtp/mtp_pu_load_enable RW Enable power-up MTP loading. | ||
mtp/mtp_fault_write_enable RW Allow updates to the MTP fault storage. | ||
mtp/temp[1-5]_fault_write_enable RW Per-channel gate that permits writing the | ||
associated fault register into MTP. | ||
mtp/mtp_temp[1-5]_max_alarm RO Alarm1 status bits as captured in MTP space. | ||
mtp/mtp_temp[1-5]_min_alarm RO Alarm1 low threshold status from MTP. | ||
mtp/mtp_temp[1-5]_fault_value RO Latched fault temperature stored in MTP | ||
(mdegC). | ||
=============================== == =========================================== | ||
|
||
Interrupt support | ||
----------------- | ||
|
||
The driver optionally registers threaded IRQ handlers for the ALARM1 and | ||
ALARM2 outputs. Provide ``interrupts`` and matching ``interrupt-names`` ("ALARM1", | ||
"ALARM2") in firmware/Device Tree to enable this path. When configured, the | ||
handler clears the corresponding status registers and issues | ||
``hwmon_notify_event()`` callbacks so userspace can react promptly. | ||
|
||
Device Tree properties | ||
---------------------- | ||
|
||
Refer to :doc:`/devicetree/bindings/hwmon/adi,max31732` for the authoritative | ||
schema. The driver currently consumes the following optional properties in | ||
addition to ``compatible`` and ``reg``: | ||
|
||
``interrupts`` / ``interrupt-names`` | ||
Map ALARM1/ALARM2 lines to the host controller. | ||
|
||
``adi,alarm1-interrupt-mode`` | ||
Configure ALARM1 output to function in interrupt mode. Absent -> comparator mode. | ||
|
||
``adi,alarm2-interrupt-mode`` | ||
Configure ALARM2 output to function in interrupt mode. Absent -> comparator mode. | ||
|
||
``adi,alarm1-fault-queue`` | ||
Number of consecutive faults before ALARM1 asserts. Permitted values: 1, 2, | ||
4, 6. Defaults to 1. | ||
|
||
``adi,alarm2-fault-queue`` | ||
Number of consecutive faults before ALARM2 asserts. Same domain as above. | ||
|
||
``adi,extended-range`` | ||
Set the extended range bit during probe so that sysfs temperatures cover the | ||
higher operating range without additional configuration. | ||
|
||
``adi,alarm1-mask`` / ``adi,alarm2-mask`` | ||
Bit mask applied at probe time to disable specific ALARM1/ALARM2 channels. | ||
Each bit corresponds to temp1..temp5 (bit0 = local channel). | ||
|
||
Usage notes | ||
----------- | ||
|
||
* All temperatures reported via sysfs are in milli-degree Celsius. | ||
* ``stop`` halts conversions but does not power-cycle the part; use ``soft_por`` | ||
to restore all the registers to their default values. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this patch can typically be squashed with the one adding the driver