Devicetree
 help / color / mirror / Atom feed
* [PATCH v4 0/2] iio: adc: add MAX40080 current-sense amplifier driver
@ 2026-07-17 12:38 Stefan Popa
  2026-07-17 12:38 ` [PATCH v4 1/2] dt-bindings: iio: adc: add maxim,max40080 Stefan Popa
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stefan Popa @ 2026-07-17 12:38 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, andriy.shevchenko, nuno.sa, devicetree, Stefan Popa

This series adds support for the Maxim MAX40080, a bidirectional
current-sense amplifier with an integrated 12-bit ADC and an I2C/SMBus
interface. It measures the voltage across an external shunt resistor and
the input bus voltage.

The driver operates in direct (INDIO_DIRECT_MODE) mode. Each raw read
triggers a single on-demand conversion (SMBus Quick Command) and reads
back the matched current/voltage pair, so results are always fresh. It
exposes the current and voltage channels with raw and scale attributes,
a configurable oversampling (digital averaging) ratio, and PEC-protected
register access. The two selectable current-sense ranges are exposed
through scale/scale_available; the current scale is derived from the
shunt-resistor-micro-ohms device-tree property.

Tested on hardware with four MAX40080 devices on an I2C bus.

Regarding regmap: it does not support SMBus PEC or Quick Command, both of
which are required by this device. The mlx90614 driver uses the same raw
i2c_smbus approach for similar reasons.

Changes in v4:
  - Split MAINTAINERS between patches: binding file in patch 1, driver
    file in patch 2 (Andy, Nuno, checkpatch)
  - Use Datasheet: tag instead of Link: for datasheet URL (Andy)
  - Remove blank line before Co-developed-by tag (Andy)
  - Consistent comment style: capital first letter + period (Andy)
  - Rename shunt_resistor_uohm to shunt_resistor_uOhm for SI convention (Andy)
  - Inline trigger_measurement() into read_iv(), removing the helper (Nuno)
  - Add DMA-safe buffer to struct with ____cacheline_aligned (Nuno)
  - Rework read_iv: use local tmp variable, add comment explaining why
    *iv is updated even on timeout (Andy)
  - Refactor calc_current_scale: C99 loop variable, named numerator/denominator
    variables with 1ULL * promotion trick (Andy)
  - Use unsigned int for loop variable in oversampling_to_filter (Andy)
  - Add propname variable to deduplicate "shunt-resistor-micro-ohms" string (Andy)
  - Fix locking: rename to __max40080_update_bits (unlocked helper), hold
    lock through cache update in set_range/set_oversampling_ratio (Nuno, Sashiko)
  - Fix torn-read in read_raw: use local copy of st->range (Nuno)
  - Return inline instead of breaks in read_raw switch cases (Nuno)
  - Remove lock from resume function (Nuno)

Changes in v3:
  - Remove mod_devicetable.h include (Andy, Uwe's rework)
  - Use lowercase _mV suffix for unit defines: MAX40080_INTER_VREF_mV,
    MAX40080_CSA_50mV_GAIN, MAX40080_CSA_10mV_GAIN (Andy)
  - Remove MAX40080_NUM_RANGES macro, use ARRAY_SIZE() directly (Andy)
  - Fix reversed xmas tree ordering in get_oversampling_ratio() (Andy)
  - Split semantically different variable declarations in
    set_oversampling_ratio() and max40080_init() (Andy)
  - Join *val, *val2, long mask on same line in read_raw signature (Andy)
  - Use const int * cast in read_avail (Andy)
  - Join FIFO_CFG write onto single line in max40080_init() (Andy)
  - Return i2c_smbus_write_word_data() directly at end of
    max40080_init() (Andy)
  - Use device_property_present() pattern for optional shunt-resistor
    property (Andy)
  - Make vdd-supply required in DT bindings (Conor)
  - Restore i2c_set_clientdata() needed for PM resume (Sashiko)
  - Add bounds check in get_oversampling_ratio() for hardware register
    values outside expected range (Sashiko)

Changes in v2:
  - Add vdd-supply and interrupts properties to the binding (David)
  - Add types.h and time.h includes (Andy)
  - Use USEC_PER_MSEC for poll timeout readability (Andy)
  - Use 1 * MICRO for default shunt resistor (Andy)
  - Rename field macros to include register name, e.g. MAX40080_CFG_MODE_MSK
    (Jonathan, David)
  - Add indexed defines for RANGE field values and use in gain array
    (Jonathan)
  - Use array lookup in get_oversampling_ratio instead of formula (Andy)
  - Use switch statement for chan->type in read_raw (David)
  - Simplify update_bits: one-liner RMW, return write directly (Andy)
  - Add local client variable in trigger_measurement (Andy)
  - Add braces to for loops and use C99 loop variables (Siratul, Andy)
  - Flip if/else in reg_access, separate declaration from assignment (Andy)
  - Add .name= in i2c_device_id (David, Siratul)
  - Reorder declarations to reverse christmas tree (Siratul)
  - Return directly from oversampling case in write_raw (Andy)
  - Add blank lines before return in read_avail (Siratul)
  - Add Co-developed-by tag for Ciprian (Andy)
  - Use Link: tag for datasheet URL in commit message

Stefan Popa (2):
  dt-bindings: iio: adc: add maxim,max40080
  iio: adc: add MAX40080 current-sense amplifier driver

 .../bindings/iio/adc/maxim,max40080.yaml      |  64 ++
 MAINTAINERS                                   |   9 +
 drivers/iio/adc/Kconfig                       |  11 +
 drivers/iio/adc/Makefile                      |   1 +
 drivers/iio/adc/max40080.c                    | 636 ++++++++++++++++++
 5 files changed, 721 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/maxim,max40080.yaml
 create mode 100644 drivers/iio/adc/max40080.c

--
2.53.0


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

end of thread, other threads:[~2026-07-17 18:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17 12:38 [PATCH v4 0/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-17 12:38 ` [PATCH v4 1/2] dt-bindings: iio: adc: add maxim,max40080 Stefan Popa
2026-07-17 12:38 ` [PATCH v4 2/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-17 12:48   ` sashiko-bot
2026-07-17 17:58   ` Andy Shevchenko
2026-07-17 18:38     ` Jonathan Cameron
2026-07-17 14:03 ` [PATCH v4 0/2] " Siratul Islam

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