From: Mark Brown <broonie@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.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 13:01:13 +0100 [thread overview]
Message-ID: <8916f45b-3a97-4a5e-b608-5feaea40f2b2@sirena.org.uk> (raw)
In-Reply-To: <20260506-topic-sm8650-ayaneo-pocket-s2-sgm3804-v4-2-7495e7905693@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 1568 bytes --]
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?
> +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.
> +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.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-05-22 12:01 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 [this message]
2026-05-22 13:03 ` Neil Armstrong
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=8916f45b-3a97-4a5e-b608-5feaea40f2b2@sirena.org.uk \
--to=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=neil.armstrong@linaro.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®