linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Marius.Cristea@microchip.com>
To: <jic23@kernel.org>
Cc: <dlechner@baylibre.com>, <nuno.sa@analog.com>,
	<broonie@kernel.org>, <linux-iio@vger.kernel.org>,
	<robh@kernel.org>, <linux-kernel@vger.kernel.org>,
	<andy@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<devicetree@vger.kernel.org>
Subject: Re: [PATCH v3 2/2] iio: adc: adding support for PAC194X
Date: Tue, 10 Jun 2025 15:58:13 +0000	[thread overview]
Message-ID: <a2d9c24e2f72378d445b40d24bd808f29b87d122.camel@microchip.com> (raw)
In-Reply-To: <20250607162721.0142ba42@jic23-huawei>

On Sat, 2025-06-07 at 16:27 +0100, Jonathan Cameron wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> On Fri, 6 Jun 2025 12:39:29 +0300
> <marius.cristea@microchip.com> wrote:
> 
> > From: Marius Cristea <marius.cristea@microchip.com>
> > 
> > This is the iio driver for Microchip PAC194X and PAC195X series of
> > Power Monitors with Accumulator. The PAC194X family supports 9V
> > Full-Scale Range and the PAC195X supports 32V Full-Scale Range.
> > 
> > There are two versions of the PAC194X/5X: the PAC194X/5X-1 devices
> > are for high-side current sensing and the PAC194X/5X-2 devices are
> > for low-side current sensing or floating VBUS applications. The
> > PAC194X/5X-1 is named shortly PAC194X/5X.
> > 
> > Signed-off-by: Marius Cristea <marius.cristea@microchip.com>
> Hi Marius,
> 
> I entirely agree with David on this wanting splitting up into
> a base driver + patches that add features to that in order to
> make it easier to review.  That also potentially allows me to pick up
> the basic support whilst any more controversial parts are still under
> discussion.
> 
> Jonathan

I will try to make it smaller and build on that.

> 
> > diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> > index 09ae6edb2650..ee47d880babf 100644
> > --- a/drivers/iio/adc/Makefile
> > +++ b/drivers/iio/adc/Makefile
> > @@ -103,6 +103,7 @@ obj-$(CONFIG_NCT7201) += nct7201.o
> >  obj-$(CONFIG_NPCM_ADC) += npcm_adc.o
> >  obj-$(CONFIG_PAC1921) += pac1921.o
> >  obj-$(CONFIG_PAC1934) += pac1934.o
> > +obj-$(CONFIG_PAC1944) += pac1944.o
> >  obj-$(CONFIG_PALMAS_GPADC) += palmas_gpadc.o
> >  obj-$(CONFIG_QCOM_PM8XXX_XOADC) += qcom-pm8xxx-xoadc.o
> >  obj-$(CONFIG_QCOM_SPMI_ADC5) += qcom-spmi-adc5.o
> > diff --git a/drivers/iio/adc/pac1944.c b/drivers/iio/adc/pac1944.c
> > new file mode 100644
> > index 000000000000..ce09334b076a
> > --- /dev/null
> > +++ b/drivers/iio/adc/pac1944.c
> > @@ -0,0 +1,2841 @@
> 
> 
> > +/* Available Sample Modes */
> > +static const char * const pac1944_frequency_avail[] = {
> > +     "1024_ADAP",
> > +     "256_ADAP",
> 
> This adaptive mode shouldn't be controlled via this standard
> ABI.  That needs to be considered separately.
> 
> > +     "64_ADAP",
> > +     "8_ADAP",
> > +     "1024",
> > +     "256",
> > +     "64",
> > +     "8",
> This does not look even close to ABI complaint.
> 
> The numbers cases are fine. The others not really.
> > +     "single_shot_1x",
> 
> That has nothing directly to do with the sampling frequency.
> Some others look suspicious.  I'd stick to normal
> sampling_frequency handling and have the discussion about the other
> modes in here at a later date.
> 
> > +     "single_shot_8x",
> > +     "fast",
> > +     "burst",
> > +};

The adaptive mode is used to lower the power consumption of the device
and keep the "same" calculation into the driver. I will try to look
over an ABI to put the device into a low power mode and in this way I
could change the frequency to ADAPTIVE.

The "single_shot_1x" and "single_shot_8x" is a special case when the
user could take only one measurement and that measurement could be
triggered/synched.

> > 
> > 
...

> 
> 
> 
> 
> 
> > +static struct attribute *pac1944_power_acc_attr[] = {
> > +     &iio_dev_attr_in_energy1_raw.dev_attr.attr,
> > +     &iio_dev_attr_in_energy2_raw.dev_attr.attr,
> > +     &iio_dev_attr_in_energy3_raw.dev_attr.attr,
> > +     &iio_dev_attr_in_energy4_raw.dev_attr.attr,
> > +     &iio_dev_attr_in_energy1_scale.dev_attr.attr,
> > +     &iio_dev_attr_in_energy2_scale.dev_attr.attr,
> > +     &iio_dev_attr_in_energy3_scale.dev_attr.attr,
> > +     &iio_dev_attr_in_energy4_scale.dev_attr.attr,
> 
> These look like standard read_raw / info_mask based attributes will
> work.
> So do that, not custom attributes that are both harder to review and
> don't work with in kernel consumers (which we may well see for a
> power
> monitoring chip).
> 

Because the device could support different modes of operation for the
same accumulator, but only one at a time. I was trying to add to the
sysfs only the mode that was set from the device tree.

> 
> 

  reply	other threads:[~2025-06-10 15:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06  9:39 [PATCH v3 0/2] adding support for Microchip PAC194X Power Monitor marius.cristea
2025-06-06  9:39 ` [PATCH v3 1/2] dt-bindings: iio: adc: adding support for PAC194X marius.cristea
2025-06-06 15:53   ` David Lechner
2025-06-10 14:46     ` Marius.Cristea
2025-06-10 15:22       ` David Lechner
2025-06-10 16:04         ` Marius.Cristea
2025-06-10 16:35           ` David Lechner
2025-06-17 15:21             ` Marius.Cristea
2025-06-06 16:24   ` Conor Dooley
2025-06-06  9:39 ` [PATCH v3 2/2] " marius.cristea
2025-06-06 17:02   ` David Lechner
2025-06-10 15:07     ` Marius.Cristea
2025-06-10 16:11       ` David Lechner
2025-06-11 15:59         ` Jonathan Cameron
2025-06-10 20:20       ` Andy Shevchenko
2025-06-07 15:27   ` Jonathan Cameron
2025-06-10 15:58     ` Marius.Cristea [this message]
2025-06-11 16:12       ` 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=a2d9c24e2f72378d445b40d24bd808f29b87d122.camel@microchip.com \
    --to=marius.cristea@microchip.com \
    --cc=andy@kernel.org \
    --cc=broonie@kernel.org \
    --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 \
    /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;
as well as URLs for NNTP newsgroup(s).