Devicetree
 help / color / mirror / Atom feed
* [PATCH v6 0/2] Add support for Analog Devices MAX30210
@ 2026-11-10  2:14 John Erasmus Mari Geronimo
  2026-11-10  2:14 ` [PATCH v6 1/2] dt-bindings: iio: temperature: add ADI MAX30210 John Erasmus Mari Geronimo
  2026-11-10  2:14 ` [PATCH v6 2/2] iio: temperature: add support for Analog Devices MAX30210 John Erasmus Mari Geronimo
  0 siblings, 2 replies; 6+ messages in thread
From: John Erasmus Mari Geronimo @ 2026-11-10  2:14 UTC (permalink / raw)
  To: linux-iio, devicetree
  Cc: krzk+dt, jic23, dlechner, nuno.sa, Michael.Hennerich, andy, robh,
	conor+dt, joshua.crofts1, Guenter Roeck, linux-hwmon

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.
Patch 2 adds the IIO driver implementation.

Changes since v5:
https://lore.kernel.org/all/20261023080623.1830-1-johnerasmusmari.geronimo@analog.com/
- 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: the interrupt is still requested after
  devm_iio_device_register(), because the event interface is freed
  in iio_device_unregister_eventset(), and 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.

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. What was run: 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 (checked against
v5, which leaked them), 50 buffer enable/disable cycles, 80
rmmod/insmod cycles (20 with armed events and 60 timed to land within
about 250 ms of live interrupt traffic), the no-interrupt and the
no-powerdown-GPIO configurations, and the INT_EN/TEMP_CONV state the
chip is left in after removal.

Changes since v4:
https://lore.kernel.org/all/20261015012159.44-1-johnerasmusmari.geronimo@analog.com/
- 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/cover.1789032019.git.johnerasmusmari.geronimo@analog.com/
- 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/20260304122509.67931-1-johnerasmusmari.geronimo@analog.com/
- 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            | 853 ++++++++++++++++++
 5 files changed, 936 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/temperature/adi,max30210.yaml
 create mode 100644 drivers/iio/temperature/max30210.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-10 20:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10  2:14 [PATCH v6 0/2] Add support for Analog Devices MAX30210 John Erasmus Mari Geronimo
2026-11-10  2:14 ` [PATCH v6 1/2] dt-bindings: iio: temperature: add ADI MAX30210 John Erasmus Mari Geronimo
2026-11-10  2:14 ` [PATCH v6 2/2] iio: temperature: add support for Analog Devices MAX30210 John Erasmus Mari Geronimo
2026-11-10  2:33   ` sashiko-bot
2026-11-10 20:53   ` Andy Shevchenko
2026-11-10 20:55     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox