Add support for Analog Devices MAX30210
Subsystems (4)
v7 cover Add support for Analog Devices MAX30210
This series adds support for the Analog Devices MAX30210 I2C temperature sensor.
Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max30210.pdf
The device provides a 16-bit temperature output and includes features such as a hardware FIFO, programmable sampling rate, threshold alarms, and interrupt support. The FIFO is exposed as an IIO buffered capture (kfifo buffer, fed from the FIFO watermark interrupt) and the threshold alarms as IIO events. As far as I can tell hwmon has no equivalent for streaming samples out of a hardware FIFO, and the related MAX30208 is an IIO driver as well.
Although the MAX30210 belongs to the same device family as the MAX30208, it is implemented as a separate driver. The MAX30210 has a significantly different feature set, including a 64-sample hardware FIFO with configurable watermark interrupts, programmable sampling rates, and event support. These features require buffered operation and IRQ-driven data handling which are not present in the MAX30208 driver (which talks to the device directly via i2c_smbus_*() calls with no regmap, and has no IIO buffer or event interface at all).
In addition, the MAX30210 uses a different register map and a more flexible I2C address selection scheme. Supporting both devices in a single driver would introduce substantial conditional logic, so a separate driver keeps the implementation simpler and easier to maintain.
Patch 1 adds the devicetree binding (unchanged since v5). Patch 2 adds the IIO driver implementation.
Changes since v6:
https://lore.kernel.org/all/[email protected]/
- Request the interrupt before devm_iio_device_register(), after the quiesce action is registered. Jonathan asked for this on v4 and I refused it on v5 and v6 because I believed the event interface was freed on unregister. That was wrong: iio_device_unregister_eventset() is only called from iio_dev_release(), which runs after all other devm actions, so the order is safe. Removal is now: unregister (predisable() synchronizes a live interrupt), free the interrupt, quiesce, power down. The interrupt handler returns IRQ_NONE while INT_EN is 0, so requesting it early is harmless. Sorry about that, and thanks to Jonathan and sashiko for not letting it go.
- postenable(): only read STATUS to drop a stale A_FULL when no autonomous conversion user (threshold event) exists, and do it before the conversion is started. Otherwise the clear-on-read could swallow a pending TEMP_HI/TEMP_LO flag of an armed event (sashiko). With events armed a stale A_FULL may remain and fifo_read() skips the invalid samples.
- Rate-limit the error messages in the interrupt handler and in max30210_fifo_read().
- Style cleanups from Andy: multi-line comment in autoconv_put(), an index variable in max30210_fifo_read(), local regmap and m/v variables with field_prep() in max30210_write_raw(), clamp the watermark before checking it for zero, "5 µs" in the comment.
- Rebased on the current iio togreg.
Tested on real MAX30210 hardware (Raspberry Pi 4) with a 6.12 based vendor kernel, which has no KASAN or lockdep; this version is only build-tested against mainline (W=1, checkpatch --strict and dt_binding_check are clean). Re-run on this version: the sysfs scale against the raw reading, FIFO streaming with a fresh first sample, the watermark clamp, threshold events with the buffer off, disabled events staying silent while the FIFO interrupt runs, 50 buffer enable/disable cycles, the buffer enabled with events already armed and the other way round, 80 rmmod/insmod cycles (20 with interrupts firing and 60 timed to land within about 250 ms of live interrupt traffic), 60 more rmmod cycles with the buffer and events active, the no-interrupt and the no-powerdown-GPIO configurations, and the INT_EN/TEMP_CONV state the chip is left in after removal (checked against a driver without the quiesce action, which fails the check).
Changes since v5:
https://lore.kernel.org/all/[email protected]/
- Fix the temperature scale: one LSB is 5 milli degrees Celsius, so report 5 (IIO_VAL_INT) instead of 5/1000.
- Mask the interrupt status with the enabled interrupts, so threshold events and the FIFO that are not enabled are not serviced.
- Start the FIFO interrupt and the autonomous conversion in postenable(), after the watermark has been set, and stop them in predisable() followed by synchronize_irq(). This also removes the goto from preenable(), which mixed a guard with a goto.
- Read STATUS before enabling the FIFO interrupt so a stale A_FULL flag does not fire on the freshly flushed FIFO.
- Clamp the hardware FIFO watermark to the FIFO size instead of failing.
- Mark SYS_CONF_REG volatile (its reset bit is self-clearing).
- Use gpiod_set_value_cansleep() for the powerdown GPIO.
- Keep the powerdown GPIO asserted for 10 us before deasserting it, the datasheet lists a CVT/PDB input low-pulse width of 5 us.
- Do not expose the threshold events when there is no interrupt.
- Review cleanups: check the event type first, use a local regmap variable, regmap_test_bits(), simpler set/clear handling in write_event_config(), a logical split of the poll call, and rename the sampling frequency index to freq_idx.
- Not changed: autoconv_put() still drops its reference when the register write fails (a later direct read rewrites TEMP_CONV_REG without AUTO, which stops it).
- Cover letter: removed the incorrect statement about hwmon and interrupts, thanks to Guenter for pointing it out.
Changes since v4:
https://lore.kernel.org/all/[email protected]/
- Patch 1: restore Krzysztof's Reviewed-by, which was accidentally left out of v4.
- Add Datasheet: tags and a datasheet link in the driver header.
- Disable interrupt sources and autonomous conversion on removal, independently of whether a powerdown GPIO is present.
- Only take/release an autonomous-conversion reference when an interrupt enable bit really changes; repeated writes of the same value no longer leak a reference.
- buffer_preenable() now unwinds the A_FULL interrupt enable on failure and buffer_postdisable() always clears it.
- Return IRQ_NONE from the interrupt handler when none of the handled status bits is set.
- Wait tPU before the software reset when no powerdown GPIO is used.
- Minor review cleanups: error paths out of line in max30210_autoconv_get(), min() for the period clamp, devm_mutex_init(), designated initializer for i2c_device_id, header grouping, one-line val/val2/mask argument lists.
Changes since v3:
https://lore.kernel.org/all/[email protected]/
- regmap_noinc_read() for FIFO reads instead of regmap_bulk_read(), which (combined with regmap caching) could silently return stale cached values of unrelated registers instead of real FIFO data.
- Mark both bytes of TEMP_DATA_REG volatile for the same reason.
- Decouple threshold events from the buffer via a refcounted autoconv_get()/autoconv_put() pair, so either can be used independently or concurrently.
- Don't let a single-shot direct-mode read race with/clobber autonomous conversion mode if a threshold event or the buffer is already using it -- return -EBUSY instead.
- Don't hard-fail probe when there is no interrupt; fall back to direct-mode-only operation.
- Fix devm teardown ordering so an in-flight interrupt can't use a freed event interface on removal.
- Re-assert the powerdown GPIO on removal so the device reaches standby instead of staying powered indefinitely.
- Style/API fixes from review (register/field grouping, _MASK naming, FIELD_PREP/regmap_assign_bits usage, C99 initializers, dropped redundant i2c_check_functionality() check, comment cleanup).
Changes since v2:
https://lore.kernel.org/all/[email protected]/
- Fix FIFO byte-count handling and sample decoding.
- Fix IIO debug register read/write access.
- Validate event threshold values and sampling-frequency register values.
- Return the correct sampling-frequency format and reject direct reads while buffered capture is enabled.
- Clean up the Kconfig entry and device-tree supply declaration.
John Erasmus Mari Geronimo (2):
dt-bindings: iio: temperature: add ADI MAX30210
iio: temperature: add support for Analog Devices MAX30210
.../iio/temperature/adi,max30210.yaml | 61 ++ MAINTAINERS | 8 + drivers/iio/temperature/Kconfig | 13 + drivers/iio/temperature/Makefile | 1 + drivers/iio/temperature/max30210.c | 859 ++++++++++++++++++ 5 files changed, 942 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/adi,max30210.yaml create mode 100644 drivers/iio/temperature/max30210.c
Signature · 1 line
2.34.1
PATCH v7 1/2 dt-bindings: iio: temperature: add ADI MAX30210
Add device tree binding documentation for the Analog Devices MAX30210 temperature sensor.
Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max30210.pdf
--- .../iio/temperature/adi,max30210.yaml | 61 +++++++++++++++++++ MAINTAINERS | 7 +++ 2 files changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/adi,max30210.yaml
Documentation/devicetree/bindings/iio/temperature/adi,max30210.yaml new file +61 -0
@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright 2026 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/adi,max30210.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices MAX30210 Temperature Sensor + +maintainers: + - John Erasmus Mari Geronimo <[email protected]> + +description: | + The MAX30210 is a temperature sensor with an I2C interface. + https://www.analog.com/media/en/technical-documentation/data-sheets/max30210.pdf + +properties: + compatible: + enum: + - adi,max30210 + + reg: + maxItems: 1 + + vdd-supply: true + + powerdown-gpios: + description: GPIO connected to the CVT/PDB pin (active low). + maxItems: 1 + + interrupts: + description: Connected to INT pin. Interrupt triggered on both rising and falling edges. + maxItems: 1 + +required: + - compatible + - reg + - vdd-supply + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + temperature-sensor@40 { + compatible = "adi,max30210"; + reg = <0x40>; + vdd-supply = <&vdd>; + powerdown-gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + + interrupt-parent = <&gpio>; + interrupts = <17 IRQ_TYPE_EDGE_BOTH>; + }; + }; +...
MAINTAINERS +7 -0
@@ -1786,6 +1786,13 @@ W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/iio/dac/adi,max22007.yaml F: drivers/iio/dac/max22007.c +ANALOG DEVICES INC MAX30210 DRIVER +M: John Erasmus Mari Geronimo <[email protected]> +L: [email protected] +S: Supported +W: https://ez.analog.com/linux-software-drivers +F: Documentation/devicetree/bindings/iio/temperature/adi,max30210.yaml + ANALOG DEVICES INC ADA4250 DRIVER M: Antoniu Miclaus <[email protected]> L: [email protected]
Signature · 1 line
2.34.1
PATCH v7 2/2 iio: temperature: add support for Analog Devices MAX30210
In reply to John Erasmus Mari GeronimoAdd support for the Analog Devices MAX30210 I2C temperature sensor.
The driver uses regmap for register access and integrates with the IIO framework. It supports:
- Direct mode temperature conversion
- Configurable sampling frequency
- Threshold events
- FIFO operation with IIO kfifo buffer support
- Optional interrupt-driven data ready signaling
The device provides 16-bit signed temperature data and a 64-sample FIFO.
Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max30210.pdf
--- MAINTAINERS | 1 + drivers/iio/temperature/Kconfig | 13 + drivers/iio/temperature/Makefile | 1 + drivers/iio/temperature/max30210.c | 859 +++++++++++++++++++++++++++++ 4 files changed, 874 insertions(+) create mode 100644 drivers/iio/temperature/max30210.c
MAINTAINERS +1 -0
@@ -1792,6 +1792,7 @@ L: [email protected] S: Supported W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/iio/temperature/adi,max30210.yaml +F: drivers/iio/temperature/max30210.c ANALOG DEVICES INC ADA4250 DRIVER M: Antoniu Miclaus <[email protected]>
drivers/iio/temperature/Kconfig +13 -0
@@ -152,6 +152,19 @@ config MAX30208 This driver can also be built as a module. If so, the module will be called max30208. +config MAX30210 + tristate "Analog Devices MAX30210 temperature sensor" + depends on I2C + select REGMAP_I2C + select IIO_BUFFER + select IIO_KFIFO_BUF + help + If you say yes here you get support for MAX30210 low-power digital + temperature sensor chip connected via I2C. + + This driver can also be built as a module. If so, the module + will be called max30210. + config MAX31856 tristate "MAX31856 thermocouple sensor" depends on SPI
drivers/iio/temperature/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_LTC2983) += ltc2983.o obj-$(CONFIG_HID_SENSOR_TEMP) += hid-sensor-temperature.o obj-$(CONFIG_MAXIM_THERMOCOUPLE) += maxim_thermocouple.o obj-$(CONFIG_MAX30208) += max30208.o +obj-$(CONFIG_MAX30210) += max30210.o obj-$(CONFIG_MAX31856) += max31856.o obj-$(CONFIG_MAX31865) += max31865.o obj-$(CONFIG_MCP9600) += mcp9600.o
drivers/iio/temperature/max30210.c new file +859 -0
859 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v7 2/2] iio: temperature: add support for Analog Devices MAX30210
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] iio: temperature: max30210: stale status bits trigger spurious IRQs --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] iio: temperature: max30210: stale status bits trigger spurious IRQs
--
commit 2a3214dc2717ef12f1999e87ec7c0d52ca73b003
Author: John Erasmus Mari Geronimo <[email protected]>
iio: temperature: add support for Analog Devices MAX30210
This commit adds an IIO driver for the Analog Devices MAX30210 I2C temperature sensor with support for direct reads, threshold events, and a 64-sample hardware FIFO buffer.
Quoted 5 lines
drivers/iio/temperature/max30210.c new file +0
-0
[ ... ]
Quoted 16 lines
drivers/iio/temperature/max30210.c new file +16
-0+/* The core calls this after hwfifo_set_watermark(), so the watermark is stable here. */ +static int max30210_buffer_postenable (struct iio_dev *indio_dev) +{ +struct max30210_state *st =iio_priv (indio_dev); +unsigned int status; +int ret; + +guard (mutex)(&st->lock); + +/* +* Clear a stale A_FULL so it cannot fire on the flushed FIFO. With +* no autoconv user no threshold event is armed, so STATUS holds +* nothing worth keeping; otherwise leave it for the IRQ handler. +*/ +if (!st->autoconv_users) { + ret =regmap_read (st->regmap,MAX30210_STATUS_REG , &status);
drivers/iio/temperature/max30210.c line 630
Quoted 10 lines
drivers/iio/temperature/max30210.c new file +10
-0+if (ret) +return ret; + } + + ret =max30210_autoconv_get (st); +if (ret) +return ret; + + ret =regmap_set_bits (st->regmap,MAX30210_INT_EN_REG , +MAX30210_STATUS_A_FULL_MASK );
[Severity: Medium]
Does skipping the MAX30210_STATUS_REG read when st->autoconv_users is non-zero leave a stale MAX30210_STATUS_A_FULL_MASK bit latched?
When a threshold event is enabled first, autonomous conversions run with MAX30210_STATUS_A_FULL_MASK masked in MAX30210_INT_EN_REG, filling the unmonitored FIFO until A_FULL latches in MAX30210_STATUS_REG. When the buffer is then enabled, max30210_buffer_preenable() flushes the FIFO without clearing MAX30210_STATUS_REG, and unmasking MAX30210_STATUS_A_FULL_MASK here immediately fires an interrupt that calls max30210_fifo_read() on the empty FIFO.
Similarly, max30210_write_event_config() enables MAX30210_STATUS_TEMP_HI_MASK or MAX30210_STATUS_TEMP_LO_MASK in MAX30210_INT_EN_REG without clearing stale threshold bits latched in MAX30210_STATUS_REG during earlier conversions, which immediately pushes a spurious threshold event.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Jonathan Cameron
maintainerRe: [PATCH v7 2/2] iio: temperature: add support for Analog Devices MAX30210
In reply to John Erasmus Mari GeronimoQuoted 12 lines · On Wed, 25 Nov 2026 10:54:25 +0800 John Erasmus Mari Geronimo…
Add support for the Analog Devices MAX30210 I2C temperature sensor.
The driver uses regmap for register access and integrates with the IIO framework. It supports:
- Direct mode temperature conversion
- Configurable sampling frequency
- Threshold events
- FIFO operation with IIO kfifo buffer support
- Optional interrupt-driven data ready signaling
Quoted 5 lines
The device provides 16-bit signed temperature data and a 64-sample FIFO.
Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max30210.pdf
Signed-off-by John Erasmus Mari Geronimo <[email protected]>
Sashiko has a bit of feedback. If it is wrong then just reply here to say why. I didn't try to figure out if it is or not.
https://sashiko.dev/#/patchset/20261125025425.1176-1-johnerasmusmari.geronimo%40analog.com
The only thing I noted isn't a reason for a new spin, so just look at that if the sashiko comments mean we need a v8 (or some other feedback comes in).
Quoted 10 lines
drivers/iio/temperature/max30210.c new file +2
-0+static int max30210_buffer_predisable (struct iio_dev *indio_dev) +{
drivers/iio/temperature/max30210.c line 648
Quoted 10 lines
drivers/iio/temperature/max30210.c new file +10
-0+struct max30210_state *st =iio_priv (indio_dev); +int ret, err; + +/* Stop the FIFO interrupt and wait for a running handler before the buffer goes away. */ + ret =regmap_clear_bits (st->regmap,MAX30210_INT_EN_REG , +MAX30210_STATUS_A_FULL_MASK ); +synchronize_irq (st->irq); + +scoped_guard (mutex, &st->lock) + err = max30210_autoconv_put(st);
If you are rolling again for any reason, perhaps just use a guard() here.
Quoted 3 lines
drivers/iio/temperature/max30210.c new file +3
-0+ +return ret ?: err; +}
[email protected]
AI reviewSashiko has finished reviewing this 2-patch series:
Sashiko has finished reviewing this 2-patch series:
- Patch 1: no issues found.
- Patch 2 ("iio: temperature: add support for Analog Devices MAX..."): 1 potential issue (1 Medium)
A detailed review has been sent as a separate reply to patch 2.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]
Jonathan Cameron
maintainerQuoted 31 lines · On Wed, 25 Nov 2026 10:54:23 +0800 John Erasmus Mari Geronimo…
This series adds support for the Analog Devices MAX30210 I2C temperature sensor.
Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max30210.pdf
The device provides a 16-bit temperature output and includes features such as a hardware FIFO, programmable sampling rate, threshold alarms, and interrupt support. The FIFO is exposed as an IIO buffered capture (kfifo buffer, fed from the FIFO watermark interrupt) and the threshold alarms as IIO events. As far as I can tell hwmon has no equivalent for streaming samples out of a hardware FIFO, and the related MAX30208 is an IIO driver as well.
Although the MAX30210 belongs to the same device family as the MAX30208, it is implemented as a separate driver. The MAX30210 has a significantly different feature set, including a 64-sample hardware FIFO with configurable watermark interrupts, programmable sampling rates, and event support. These features require buffered operation and IRQ-driven data handling which are not present in the MAX30208 driver (which talks to the device directly via i2c_smbus_*() calls with no regmap, and has no IIO buffer or event interface at all).
In addition, the MAX30210 uses a different register map and a more flexible I2C address selection scheme. Supporting both devices in a single driver would introduce substantial conditional logic, so a separate driver keeps the implementation simpler and easier to maintain.
Patch 1 adds the devicetree binding (unchanged since v5). Patch 2 adds the IIO driver implementation.
Quoted 12 lines
Changes since v6:
https://lore.kernel.org/all/[email protected]/
- Request the interrupt beforedevm_iio_device_register(), after the quiesce action is registered. Jonathan asked for this on v4 and I refused it on v5 and v6 because I believed the event interface was freed on unregister. That was wrong:iio_device_unregister_eventset()is only called fromiio_dev_release(), which runs after all other devm actions, so the order is safe. Removal is now: unregister (predisable()synchronizes a live interrupt), free the interrupt, quiesce, power down. The interrupt handler returnsIRQ_NONEwhileINT_ENis 0, so requesting it early is harmless. Sorry about that, and thanks to Jonathan and sashiko for not letting it go.
Great. I hadn't caught up with your v6 because I wanted to look into what races we had around this in more detail. Now I can park this for a while at least. I'm less than confident that we are race free but at least seems we are ok for the case that was concerning you.
Thanks for digging into it. I'm snowed under with all the bugs that shook out in a refactor of some of the trigger handling (hopefully post a bunch of those in next few days) and events was after that!
Jonathan
Quoted 57 lines
-
postenable(): only read STATUS to drop a staleA_FULLwhen no autonomous conversion user (threshold event) exists, and do it before the conversion is started. Otherwise the clear-on-read could swallow a pending TEMP_HI/TEMP_LO flag of an armed event (sashiko). With events armed a staleA_FULLmay remain andfifo_read()skips the invalid samples.
- Rate-limit the error messages in the interrupt handler and inmax30210_fifo_read().
- Style cleanups from Andy: multi-line comment inautoconv_put(), an index variable inmax30210_fifo_read(), local regmap and m/v variables withfield_prep()inmax30210_write_raw(), clamp the watermark before checking it for zero, "5 µs" in the comment.
- Rebased on the current iio togreg.Tested on real MAX30210 hardware (Raspberry Pi 4) with a 6.12 based vendor kernel, which has no KASAN or lockdep; this version is only build-tested against mainline (W=1, checkpatch --strict and
dt_binding_checkare clean). Re-run on this version: the sysfs scale against the raw reading, FIFO streaming with a fresh first sample, the watermark clamp, threshold events with the buffer off, disabled events staying silent while the FIFO interrupt runs, 50 buffer enable/disable cycles, the buffer enabled with events already armed and the other way round, 80 rmmod/insmod cycles (20 with interrupts firing and 60 timed to land within about 250 ms of live interrupt traffic), 60 more rmmod cycles with the buffer and events active, the no-interrupt and the no-powerdown-GPIO configurations, and the INT_EN/TEMP_CONV state the chip is left in after removal (checked against a driver without the quiesce action, which fails the check).Changes since v5:
https://lore.kernel.org/all/[email protected]/
- Fix the temperature scale: one LSB is 5 milli degrees Celsius, so report 5 (IIO_VAL_INT) instead of 5/1000.
- Mask the interrupt status with the enabled interrupts, so threshold events and the FIFO that are not enabled are not serviced.
- Start the FIFO interrupt and the autonomous conversion inpostenable(), after the watermark has been set, and stop them inpredisable()followed bysynchronize_irq(). This also removes the goto frompreenable(), which mixed a guard with a goto.
- Read STATUS before enabling the FIFO interrupt so a staleA_FULLflag does not fire on the freshly flushed FIFO.
- Clamp the hardware FIFO watermark to the FIFO size instead of failing.
- MarkSYS_CONF_REGvolatile (its reset bit is self-clearing).
- Usegpiod_set_value_cansleep()for the powerdown GPIO.
- Keep the powerdown GPIO asserted for 10 us before deasserting it, the datasheet lists a CVT/PDB input low-pulse width of 5 us.
- Do not expose the threshold events when there is no interrupt.
- Review cleanups: check the event type first, use a local regmap variable,regmap_test_bits(), simpler set/clear handling inwrite_event_config(), a logical split of the poll call, and rename the sampling frequency index tofreq_idx.
- Not changed:autoconv_put()still drops its reference when the register write fails (a later direct read rewritesTEMP_CONV_REGwithout AUTO, which stops it).
- Cover letter: removed the incorrect statement about hwmon and interrupts, thanks to Guenter for pointing it out.