From: Daniel Balint <dbalint@google.com>
To: Jonathan Cameron <jic23@kernel.org>, Lee Jones <lee@kernel.org>
Cc: linux-iio@vger.kernel.org, mfd@lists.linux.dev,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
mwojtas@google.com, Daniel Balint <dbalint@google.com>
Subject: [PATCH v2 0/2] Introduce cros_ec power monitoring
Date: Thu, 26 Nov 2026 10:47:55 +0000 [thread overview]
Message-ID: <20261126104757.2860272-1-dbalint@google.com> (raw)
This series adds the ChromeOS EC On-Device Power Monitoring
(cros_ec_pwrmon) driver to read onboard power-monitoring ADCs, such as
PAC194x, wired through the embedded controller (EC).
Several ChromeOS platforms are equipped with onboard ADCs connected to
the EC via I2C. The driver interfaces with the EC via the existing
EC_CMD_PWRMON host command API and EC_MKBP_EVENT_PWRMON events to manage
ADC accumulation and expose per-rail accumulated energy through IIO
energy channels and a triggered buffer. The driver is only loaded when
EC_FEATURE_PWRMON is advertised by the EC.
This is a borderline case between IIO and hwmon. IIO is used rather than
hwmon [1] because userspace queries all rails (up to 64) together as a
coherent frame -- for example, to compare per-rail drain contributions
across device-state transitions (such as screen on/off triggering a
snapshot) and to correlate fine-grained ODPM frames with other
timestamped system diagnostics for off-device per-process, per-rail
energy attribution, where relative deltas across channels are as
important as absolute values. Since a single EC latch and MKBP delivery
takes non-trivial bus time, latching per sysfs read across 64 files
would introduce significant inter-channel skid and redundant EC work.
While driver-side caching in hwmon could avoid per-read latching, hwmon
has neither an on-demand trigger ABI to force a fresh latch nor a
timestamp ABI to report the actual latch time (or expose whether a read
hit cached data or crossed a mid-sweep cache expiry), making IIO's
explicit trigger, latch timestamp, and single buffer read a cleaner fit.
Reference to detailed v1 discussion:
[1] https://lore.kernel.org/linux-iio/20261120091022.1459658-1-dbalint@google.com/
Changes in v2:
- Dropped v1 patch 1/3 ("platform/chrome: cros_ec: fix alignment of
ec_params_pwrmon"), already applied to chrome-platform/for-next
(346739bcdf65).
- Replaced custom multi-value energy_value sysfs attribute and its ABI
doc with standard buffer-only IIO_ENERGY channels (.read_label, scale)
and an IIO triggered buffer with IIO_CHAN_SOFT_TIMESTAMP
(CLOCK_BOOTTIME); selected IIO_BUFFER and IIO_TRIGGERED_BUFFER in
Kconfig.
- Replaced wait_queue_head_t with struct completion.
- Grouped per-channel state into struct cros_ec_pwrmon_chan, and used
aligned_u64 scan buffer.
- Switched EC host commands from legacy cros_ec_cmd_xref_status() to
cros_ec_cmd(), which manages msg buffers and cleanup automatically.
- Dropped redundant st->ec and st->msg fields, used local params/resp
variables instead of casts.
- Added an event_size check in the MKBP notifier.
- Fixed signed/unsigned energy integration and channel counting for
duplicate/out-of-range MKBP events; returned -EINVAL for missing
channel labels.
- Switched probe error paths to dev_err_probe(), clamped channel count
with min(), hardcoded indio_dev->name to "cros-ec-pwrmon", switched to
devm_blocking_notifier_chain_register(), dropped direct
<linux/mod_devicetable.h> include, and used named initializer with
"{ }" sentinel in cros_ec_pwrmon_id[].
- Capitalized "Load" in the mfd patch subject.
Daniel Balint (2):
iio: adc: add cros_ec_pwrmon driver
mfd: cros_ec: Load cros_ec_pwrmon on supported ECs
MAINTAINERS | 7 +
drivers/iio/adc/Kconfig | 13 ++
drivers/iio/adc/Makefile | 1 +
drivers/iio/adc/cros_ec_pwrmon.c | 370 +++++++++++++++++++++++++++++++
drivers/mfd/cros_ec_dev.c | 9 +
5 files changed, 400 insertions(+)
create mode 100644 drivers/iio/adc/cros_ec_pwrmon.c
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.56.1.839.g22a8290db9-goog
next reply other threads:[~2026-11-26 10:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 10:47 Daniel Balint [this message]
2026-11-26 10:47 ` [PATCH v2 1/2] iio: adc: add cros_ec_pwrmon driver Daniel Balint
2026-11-26 10:47 ` [PATCH v2 2/2] mfd: cros_ec: Load cros_ec_pwrmon on supported ECs Daniel Balint
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=20261126104757.2860272-1-dbalint@google.com \
--to=dbalint@google.com \
--cc=jic23@kernel.org \
--cc=lee@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=mwojtas@google.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
all inboxes | Powered by JetHome®