From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: "Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>, "Lee Jones" <lee@kernel.org>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-iio@vger.kernel.org, mfd@lists.linux.dev
Subject: Re: [PATCH v2 3/4] iio: adc: Add support for MAX8907 ADC cell
Date: Tue, 17 Nov 2026 09:14:57 +0200 [thread overview]
Message-ID: <avv-8RT_btJ6dTzi@ashevche-desk.local> (raw)
In-Reply-To: <20261115091120.108684-4-clamor95@gmail.com>
On Sun, Nov 15, 2026 at 11:11:19AM +0200, Svyatoslav Ryhel wrote:
> The MAX8907 PMIC has a dedicated ADC cell, which provides 8 ADC channels
> with information about different parts of the power system, including the
> battery, charger/plug, jack and thermal readings.
...
> +config MAX8907_ADC
> + tristate "Maxim MAX8907 ADC driver"
Make MODULE_DESCRIPTION() to use the same text.
> + depends on MFD_MAX8907
> + help
> + Say yes here to build support for 8 channel 12-bit ADC
> + interface found in the Maxim MAX8907 PMIC.
> +
> + To compile this driver as a module, choose M here:
> + the module will be called max8907-adc.
...
IWYU, please. + bits.h, types.h, et cetera.
> +#include <linux/iio/iio.h>
> +#include <linux/module.h>
> +#include <linux/mfd/max8907.h>
It's better to move to a separate group, as this is related to the certain HW.
But since it's a single header I'm not too picky about it.
> +#include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/regmap.h>
Should be also a group for asm/byteorder.h.
> +#define MAX8907_TO_REG(n) ((n) & 0xff)
> +#define MAX8907_TO_MEASURE(n) (((n) >> 8) & 0xff)
...
> +enum {
> + TDIE, THM, ISNS, VMBATT, VBBATT, VCHG, AUX2, AUX1
Leave trailing comma, but what is this? Is it HW related or pure Linux
abstraction? In other words, is the order strict? Looking at the code
below I think you have to initialise all of them to make the order strict.
> +};
...
> +static const u32 max8907_default_ref[] = {
> + [TDIE] = 4096,
> + [THM] = 4096,
> + [ISNS] = 4096,
> + [VMBATT] = 8192,
> + [VBBATT] = 8192,
> + [VCHG] = 8192,
> + [AUX2] = 2500,
> + [AUX1] 4096,
Funny thing, actually we used to have an interesting case in the kernel,
id est 113ec87b0f26 ("pinctrl: npcm8xx: Fix incorrect struct npcm8xx_pincfg
assignment").
> +};
...
> +static int max8907_adc_init(struct regmap *regmap)
> +{
> + u32 value;
> + int ret;
> +
> + /* Enable internal voltage reference. Exact purpose of bits is not known. */
> + ret = regmap_update_bits(regmap, MAX8907_REG_TSC_CNFG1, GENMASK(1, 0), BIT(1));
> + if (ret)
> + return ret;
> +
> + /* Check for internal reference IRQ */
> + ret = regmap_read_poll_timeout(regmap, MAX8907_REG_TSC_STA_INT, value,
> + !(value & MAX8907_MASK_NREF_OK), 0, 1000);
0? This makes it a tough loop. Needs a comment why.
> + if (ret)
> + return ret;
> +
> + return regmap_update_bits(regmap, MAX8907_REG_ADC_SCHED,
> + MAX8907_ADC_SCHED_AUTOSCH_ENABLE |
> + MAX8907_ADC_SCHED_AUTOSCH_TIME,
> + MAX8907_ADC_SCHED_AUTOSCH_ENABLE);
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-11-17 7:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 9:11 [PATCH v2 0/4] " Svyatoslav Ryhel
2026-11-15 9:11 ` [PATCH v2 1/4] regulator: dt-bindings: maxim,max8907: Document io-channel-cells property Svyatoslav Ryhel
2026-11-15 9:11 ` [PATCH v2 2/4] mfd: max8907: Add ADC client support Svyatoslav Ryhel
2026-11-15 9:11 ` [PATCH v2 3/4] iio: adc: Add support for MAX8907 ADC cell Svyatoslav Ryhel
2026-11-17 7:14 ` Andy Shevchenko [this message]
2026-11-15 9:11 ` [PATCH v2 4/4] mfd: max8907: Add " Svyatoslav Ryhel
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=avv-8RT_btJ6dTzi@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=clamor95@gmail.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=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--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®