mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	KancyJoe <kancy2333@outlook.com>
Subject: Re: [PATCH v4 2/2] regulator: add SGM3804 Dual Output driver
Date: Fri, 22 May 2026 15:03:14 +0200	[thread overview]
Message-ID: <a2a08599-9682-440c-8b7e-a8b8256dc8b2@linaro.org> (raw)
In-Reply-To: <8916f45b-3a97-4a5e-b608-5feaea40f2b2@sirena.org.uk>

On 5/22/26 14:01, Mark Brown wrote:
> On Wed, May 06, 2026 at 09:34:07AM +0200, Neil Armstrong wrote:
> 
>> +config REGULATOR_SGM3804
>> +	tristate "SGMicro SGM3804 voltage regulator"
>> +	depends on I2C && OF
>> +	select REGMAP_I2C
>> +	help
>> +	  This driver supports SGMicro SGM3804 dual-output voltage regulator.
>> +
> 
> The GPIO usage in the driver looks non-optional so we should have a
> GPIOLIB dependency shouldn't we?

Indeed

> 
>> +static int sgm3804_sync_regcache_state(struct sgm3804_data *ctx)
>> +{
>> +	guard(mutex)(&ctx->lock);
>> +
>> +	/* If both GPIOs are down, IC is powered down and I2C writes will fail */
>> +	if (!gpiod_get_value_cansleep(ctx->gpios[SGM3804_POS_RAIL]) &&
>> +	    !gpiod_get_value_cansleep(ctx->gpios[SGM3804_NEG_RAIL])) {
>> +		regcache_cache_only(ctx->regmap, true);
>> +		regcache_mark_dirty(ctx->regmap);
>> +	} else {
>> +		/* At least a GPIO is up, we can write registers */
>> +		regcache_cache_only(ctx->regmap, false);
>> +		return regcache_sync(ctx->regmap);
> 
> This should really put the regmap back into cache only mode if the sync
> fails.

Right

> 
>> +static const struct regulator_desc sgm3804_regulator_desc[] = {
>> +	/* Positive Output */
>> +	{
>> +		.name = "pos",
>> +		.of_match = "pos",
>> +		.supply_name = "vin",
>> +		.id = SGM3804_POS_RAIL,
>> +		.ops = &sgm3804_ops,
>> +		.type = REGULATOR_VOLTAGE,
>> +		.linear_ranges = sgm3804_voltages,
>> +		.n_linear_ranges = ARRAY_SIZE(sgm3804_voltages),
>> +		.n_voltages = SGM3804_VOLTAGES_COUNT,
> 
> n_voltages is misnamed and should really be maximum selector, for a
> device like this with sparse selectors it doesn't do what you'd expect
> unfortunately.

OK indeed thanks, I overlooked this part

Neil

      reply	other threads:[~2026-05-22 13:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06  7:34 [PATCH v4 0/2] regulator: add support for " Neil Armstrong
2026-05-06  7:34 ` [PATCH v4 1/2] regulator: dt-bindings: document the SGM3804 Dual Output regulator Neil Armstrong
2026-05-13 18:10   ` Rob Herring (Arm)
2026-05-06  7:34 ` [PATCH v4 2/2] regulator: add SGM3804 Dual Output driver Neil Armstrong
2026-05-21  8:17   ` Neil Armstrong
2026-05-21 10:21     ` Mark Brown
2026-05-21 11:38       ` Neil Armstrong
2026-05-22 12:01   ` Mark Brown
2026-05-22 13:03     ` Neil Armstrong [this message]

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=a2a08599-9682-440c-8b7e-a8b8256dc8b2@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kancy2333@outlook.com \
    --cc=krzk+dt@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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®