From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Duje Mihanović" <duje@dujemihanovic.xyz>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Karel Balej" <balejk@matfyz.cz>, "Lee Jones" <lee@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"David Wronek" <david@mainlining.org>,
phone-devel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, "Mark Brown" <broonie@kernel.org>,
"Jean Delvare" <jdelvare@suse.com>,
"Guenter Roeck" <linux@roeck-us.net>
Subject: Re: [PATCH v3 2/3] iio: adc: Add driver for Marvell 88PM886 PMIC ADC
Date: Sun, 7 Sep 2025 11:36:09 +0100 [thread overview]
Message-ID: <20250907113609.6060e557@jic23-huawei> (raw)
In-Reply-To: <CAHp75VewzAN+tcJ9GrWESY38Uq+qeA4QH=qeaEV8g35H67GcMg@mail.gmail.com>
On Fri, 5 Sep 2025 16:39:05 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> On Fri, Sep 5, 2025 at 2:01 PM Duje Mihanović <duje@dujemihanovic.xyz> wrote:
> >
> > Marvell's 88PM886 PMIC has a so-called General Purpose ADC used for
> > monitoring various system voltages and temperatures. Add the relevant
> > register definitions to the MFD header and a driver for the ADC.
>
> Jonathan et al. The Q here is do we want to somehow make values
> spelling (in the comments and documentation) be unified with the
> Scientific Style [1]? Personally I find the article very useful and
> one style for the whole subsystem would be good to enforce (in my
> humble opinion). Thoughts?
>
> [1]: https://poynton.ca/notes/units/
Consistency is indeed good, but I'm always careful about putting up
barriers to submission. So I'd prefer starting with guidance and general
review comments about consistent style, but probably not pushing back too
hard initially at least on new code where a consistent slightly different
style is applied. e.g. there is inconsistency in this patch as Volt and
Ampere get capitals but not Ohm (which should given all 3 are named
after people)
To actually move to such a style we'd need to fix up at least some existing
comments but that would be a trade off against churn.
I've been useless for years about putting an IIO maintainer entry profile in place.
https://docs.kernel.org/doc-guide/maintainer-profile.html but that is where
probably where this sort of extra documentation of specific requirements would belong
unless we can get broad agreement across subsystems where comments with units
are common.
Before moving to any standard on this I think we'd want to make sure
we at least don't 'clash' with what is accepted in other subsystems where
these units are common. +CC some relevant maintainers.
Jonathan
>
> ...
>
> > +static int gpadc_get_raw(struct iio_dev *iio, enum pm886_gpadc_channel chan)
> > +{
> > + struct pm886_gpadc *gpadc = iio_priv(iio);
> > + __be16 buf;
> > + int ret;
> > +
> > + ret = regmap_bulk_read(gpadc->map, pm886_gpadc_regs[chan], &buf, sizeof(buf));
> > + if (ret)
> > + return ret;
> > +
> > + return be16_to_cpu(buf) >> 4;
>
> + asm/byteorder.h (after linux/* but before linux/iio/*)
>
> > +}
>
> ...
>
> > + /*
> > + * Vendor kernel errors out above 1.25V, but testing shows that
>
> 1.25 V
>
> > + * the resistance of the battery detection channel (GPADC2 on
> > + * coreprimevelte) reaches about 1.4Mohm when the battery is
>
> 1.4 MOhm or even 1.4 MΩ
>
>
> > + * removed, which can't be measured with such a low upper
> > + * limit. Therefore, to be able to detect the battery without
> > + * ugly externs as used in the vendor fuelgauge driver,
>
> fuel gauge
>
> > + * increase this limit a bit.
> > + */
> > + if (WARN_ON(*raw_uV > 1500 * (MICRO / MILLI)))
>
> + bug.h
>
> > + return -EIO;
>
> ...
>
> > + /*
> > + * Vendor kernel errors out under 300mV, but for the same
>
> 300 mV
>
> > + * reason as above (except the channel hovers around 3.5kohm
>
> 3.5 kOhm / 3.5 kΩ
>
> > + * with battery present) reduce this limit.
> > + */
> > + if (*raw_uV < 200 * (MICRO / MILLI)) {
> > + dev_dbg(&iio->dev, "bad bias for chan %d: %duA @ %duV\n", chan->channel,
>
> Also add spaces before units.
>
> > + *raw_uA, *raw_uV);
> > + continue;
> > + }
> > +
> > + dev_dbg(&iio->dev, "good bias for chan %d: %duA @ %duV\n", chan->channel,
> > + *raw_uA, *raw_uV);
>
> Ditto.
>
> > + return 0;
> > + }
> > +
> > + dev_err(&iio->dev, "failed to find good bias for chan %d\n", chan->channel);
> > + return -EINVAL;
> > +}
>
> ...
>
> > + ret = DIV_ROUND_CLOSEST(raw_uV, raw_uA);
>
> + math.h
>
> ...
>
> > + page = devm_i2c_new_dummy_device(dev, client->adapter,
> > + client->addr + PM886_PAGE_OFFSET_GPADC);
> > + if (IS_ERR(page))
>
> + err.h
>
> > + return dev_err_probe(dev, PTR_ERR(page), "Failed to initialize GPADC page\n");
>
>
next prev parent reply other threads:[~2025-09-07 10:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 11:00 [PATCH v3 0/3] Marvell 88PM886 PMIC GPADC driver Duje Mihanović
2025-09-05 11:00 ` [PATCH v3 1/3] dt-bindings: mfd: 88pm886: Add #io-channel-cells Duje Mihanović
2025-09-05 11:00 ` [PATCH v3 2/3] iio: adc: Add driver for Marvell 88PM886 PMIC ADC Duje Mihanović
2025-09-05 13:39 ` Andy Shevchenko
2025-09-07 10:36 ` Jonathan Cameron [this message]
2025-09-07 10:40 ` Jonathan Cameron
2025-09-06 12:41 ` Karel Balej
2025-09-05 11:00 ` [PATCH v3 3/3] mfd: 88pm886: Add GPADC cell Duje Mihanović
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=20250907113609.6060e557@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=balejk@matfyz.cz \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=david@mainlining.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=duje@dujemihanovic.xyz \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nuno.sa@analog.com \
--cc=phone-devel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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®