From: Jonathan Cameron <jic23@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] iio: adc: add driver for the MAX34417 Four-Channel High Dynamic Range Power Accumulator
Date: Sun, 27 Sep 2026 19:28:54 +0100 [thread overview]
Message-ID: <20260927192854.5666b68e@jic23-hlaptop> (raw)
In-Reply-To: <7abb65ec-e212-4af9-aedc-0a62ed44d1c1@linaro.org>
On Fri, 25 Sep 2026 10:46:33 +0200
Neil Armstrong <neil.armstrong@linaro.org> wrote:
> Hi,
>
> On 9/25/26 05:26, Jonathan Cameron wrote:
> > On Thu, 24 Sep 2026 15:14:16 +0200
> > Neil Armstrong <neil.armstrong@linaro.org> wrote:
> >
> >> The MAX34417 is a specialized current and voltage monitor used to
> >> determine power consumption of portable systems. The driver support
> >> getting the channels voltage and accumulated average power over an
> >> I2C/SMBUS serial interface.
> >>
> >> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> >
> > A few comments inline. For a new driver I'd wait a week before sending an
> > update. Whilst you've gotten quite a few reviews already it is good to make
> > sure any discussion has died down before moving on to the next version.
> >
> >
> > Thanks,
> >
> > Jonathan
> >
> >> diff --git a/drivers/iio/adc/max34417.c b/drivers/iio/adc/max34417.c
> >> new file mode 100644
> >> index 000000000000..98d961c5ecee
> >> --- /dev/null
> >> +++ b/drivers/iio/adc/max34417.c
> >> @@ -0,0 +1,374 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/*
> >> + * IIO driver for Maxim MAX34417 ADC, 4-Channels High Dynamic Range Power Accumulator
> >> + *
> >> + * Datasheet: https://www.analog.com/en/products/max34417.html
> >> + *
> >> + * TODO: Slow Mode, Continuous Accumulate Mode, Park Feature, Bulk Update, Perr_Verr Correction
> >> + */
> >
> >> +#define MAX34417_CHANNEL(_index, _v_address, _power_address) \
> >> + { \
> >> + .type = IIO_VOLTAGE, \
> >> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> >> + BIT(IIO_CHAN_INFO_SCALE), \
> >> + .channel = (_index), \
> >> + .address = (_v_address), \
> >> + .indexed = 1, \
> >> + }, \
> >> + { \
> >> + .type = IIO_POWER, \
> >
> > As below. This smells like it might not be an actual power channel if it
> > is accumulated on a fixed frequency. It'll be some sort of scaled IIO_ENERGY
> > channel. If you want to present it as power (which may make sense) then
> > it may need a little maths.
>
> So as I understand the ENERGY would need to provide Joules. Which would
> be doable if we take in account the accumulator sample rate (1024sps) from the
> datasheet.
>
> But this implementation tries to provide an initial support following
> the MAX34417 datasheet which provides calculation for Average Power (page 18),
> this is why I sticked to POWER and IIO_CHAN_INFO_AVERAGE_RAW.
Doing division in driver is a bit nasty but given there are a lot of bits
I suppose that's not too bad. I'd completely failed to notice the division
on my first read through :(
So power is fine.
Thanks,
Jonathan
>
> But you're right, knowing the sample rate we could indeed calculate the energy.
>
> I can try to do the math, but with manual updates it may no be very accurate so
> the Continuous Accumulate Mode should be implemented to provide
> accurate Energy measurements over time and would be enabled via an
> IIO_CHAN_INFO_ENABLE.
next prev parent reply other threads:[~2026-09-27 18:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 13:14 [PATCH v2 0/2] iio: adc: add support " Neil Armstrong
2026-09-24 13:14 ` [PATCH v2 1/2] dt-bindings: iio: add: document " Neil Armstrong
2026-09-24 16:43 ` Conor Dooley
2026-09-29 7:37 ` Krzysztof Kozlowski
2026-09-24 13:14 ` [PATCH v2 2/2] iio: adc: add driver for " Neil Armstrong
2026-09-24 15:13 ` Joshua Crofts
2026-09-25 3:26 ` Jonathan Cameron
2026-09-25 8:46 ` Neil Armstrong
2026-09-27 18:28 ` Jonathan Cameron [this message]
2026-09-25 3:13 ` [PATCH v2 0/2] iio: adc: add support " Jonathan Cameron
2026-09-25 8:12 ` Neil Armstrong
2026-09-27 18:50 ` Jonathan Cameron
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=20260927192854.5666b68e@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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®