mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Popa <stefan.popa@analog.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sa" <nuno.sa@analog.com>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Siratul Islam" <siratul.islam@linux.dev>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Ciprian Hegbeli" <ciprian.hegbeli@analog.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Stefan Popa" <stefan.popa@analog.com>
Subject: [PATCH v2 0/2] iio: adc: add MAX40080 current-sense amplifier driver
Date: Mon, 13 Jul 2026 15:02:24 +0300	[thread overview]
Message-ID: <20260713120226.90303-1-stefan.popa@analog.com> (raw)
In-Reply-To: <20260703102941.1141341-1-stefan.popa@analog.com>

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.

Why a new driver (Andy): No existing IIO driver covers this device or a
register-compatible part. The closest relatives (max9611, max34408) target
different silicon with incompatible register maps. The MAX40080 has a
unique combination of bidirectional 13-bit current, 64-entry FIFO, mandatory
PEC, single-measurement mode triggered by SMBus Quick Command, and two
selectable input ranges. See the driver commit message for the full
rationale.

The datasheet link is in the binding YAML description.

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 range is chosen by writing the
desired scale); the current scale is derived from the
shunt-resistor-micro-ohms device-tree property.

Continuous FIFO buffering, threshold events and the alert interrupt are
intentionally left out of this initial submission and may be added
later.

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

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)
  - Remove unused i2c_set_clientdata call (Andy)
  - 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

Regarding mod_devicetable.h (Uwe): kept for now as the replacement
headers (linux/device-id/*.h) are not yet available in mainline.

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

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

--
2.53.0


  parent reply	other threads:[~2026-07-13 12:03 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 10:29 [PATCH v1 " Stefan Popa
2026-07-03 10:29 ` [PATCH v1 1/2] dt-bindings: iio: adc: add maxim,max40080 Stefan Popa
2026-07-03 16:21   ` Conor Dooley
2026-07-03 20:42   ` David Lechner
2026-07-03 10:29 ` [PATCH v1 2/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-03 12:08   ` Andy Shevchenko
2026-07-03 23:36     ` Jonathan Cameron
2026-07-03 19:42   ` Siratul Islam
2026-07-03 20:29     ` David Lechner
2026-07-04 12:05     ` Andy Shevchenko
2026-07-04 16:32       ` Siratul Islam
2026-07-04 17:05         ` Andy Shevchenko
2026-07-04 17:30           ` Siratul Islam
2026-07-04 18:52             ` Andy Shevchenko
2026-07-03 21:04   ` David Lechner
2026-07-03 23:53   ` Jonathan Cameron
2026-07-06 17:17   ` Uwe Kleine-König
2026-07-03 11:34 ` [PATCH v1 0/2] " Andy Shevchenko
2026-07-13 12:02 ` Stefan Popa [this message]
2026-07-13 12:02   ` [PATCH v2 1/2] dt-bindings: iio: adc: add maxim,max40080 Stefan Popa
2026-07-13 16:06     ` Conor Dooley
2026-07-13 12:02   ` [PATCH v2 2/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-13 16:04     ` Andy Shevchenko
2026-07-13 12:16   ` [PATCH v2 0/2] " Joshua Crofts
2026-07-14 12:24   ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260713120226.90303-1-stefan.popa@analog.com \
    --to=stefan.popa@analog.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ciprian.hegbeli@analog.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=siratul.islam@linux.dev \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox