public inbox for devicetree@vger.kernel.org
 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 v2 2/2] regulator: add SGM3804 Dual Output driver
Date: Thu, 30 Apr 2026 15:28:43 +0200	[thread overview]
Message-ID: <150cdb85-d0ac-4802-a09b-9dab1b9b805a@linaro.org> (raw)
In-Reply-To: <afMwIVRDxl11Ty_P@sirena.co.uk>

On 4/30/26 12:34, Mark Brown wrote:
> On Thu, Apr 30, 2026 at 10:48:47AM +0200, Neil Armstrong wrote:
> 
>> Add support for the SG Micro SGM3804 Single Inductor Dual Output
>> Buck/Boost Converter used to power LCD panels a provide positive
>> and negative power rails with configurable voltage and active
>> discharge function for each output.
> 
>> +config REGULATOR_SGM3804
>> +	tristate "SGMicro SGM3804 voltage regulator"
>> +	depends on I2C && OF
>> +	help
>> +	  This driver supports SGMicro SGM3804 dual-output voltage regulator.
>> +
> 
> This needs to select REGMAP_I2C.

Oops forgot

> 
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * SGMicro SGM3804 regulator Driver
>> + *
>> + * Copyright (C) 2025 Kancy Joe <kancy2333@outlook.com>
>> + * Copyright (C) 2026 Linaro Limited
>> + * Author: Neil Armstrong <neil.armstrong@linaro.org>
>> + */
> 
> Please make the entire comment block a C++ one so things look more
> intentional.

Sure, converted into:
+ * Copyright (C) 2026 Linaro Limited (Neil Armstrong <neil.armstrong@linaro.org>)

> 
>> +/*
>> + * Since all registers are only writeable & volatile,
>> + * regmap will only read from the cache data.
>> + */
>> +static bool sgm3804_readable_reg(struct device *dev, unsigned int reg)
>> +{
>> +	return false;
>> +}
> 
> Non-readable registers can't be volatile, volatile means always do a
> read.

Right I overlooked volatile and indeed it's incorrect.

> 
>> +static int sgm3804_enable(struct regulator_dev *rdev)
>> +{
>> +	struct sgm3804_data *ctx = rdev->reg_data;
>> +	int ret;
>> +
>> +	ret = gpiod_set_value(ctx->gpios[rdev_get_id(rdev)], 1);
>> +	if (ret)
>> +		return ret;
> 
> This could use _cansleep() for wider interoperability.

Good idea

> 
>> +
>> +	ret = regmap_write(ctx->regmap, rdev->desc->vsel_reg,
>> +			   ctx->sel[rdev_get_id(rdev)]);
>> +	if (ret)
>> +		goto err;
>> +
>> +	ret = regulator_set_active_discharge_regmap(rdev,
>> +						    ctx->active_discharge[rdev_get_id(rdev)]);
>> +	if (ret)
>> +		goto err;
> 
> I'm still not clear why this isn't doing a regcache sync instead of
> writing things out individually.

OK indeed I misunderstood you comment, fully switched to cache_only/cache_sync
which is cleaner and simpler.

> 
>> +		ctx->gpios[i] = devm_gpiod_get_index(dev, "enable",
>> +						     i, GPIOD_OUT_LOW);
>> +		if (IS_ERR(ctx->gpios[i]))
>> +			return dev_err_probe(dev, PTR_ERR(ctx->gpios[i]),
>> +					"failed to get enable GPIO %d\n", i);
> 
> Perhaps use GPIOD_ASIS for a smoother handover?

Done

Thanks,
Neil

  reply	other threads:[~2026-04-30 13:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30  8:48 [PATCH v2 0/2] regulator: add support for SGM3804 Dual Output driver Neil Armstrong
2026-04-30  8:48 ` [PATCH v2 1/2] regulator: dt-bindings: document the SGM3804 Dual Output regulator Neil Armstrong
2026-04-30 10:25   ` Rob Herring (Arm)
2026-04-30  8:48 ` [PATCH v2 2/2] regulator: add SGM3804 Dual Output driver Neil Armstrong
2026-04-30 10:34   ` Mark Brown
2026-04-30 13:28     ` Neil Armstrong [this message]
2026-04-30 23:46       ` Mark Brown
2026-05-04  6:55         ` Neil Armstrong
2026-05-04 12:50           ` Mark Brown

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=150cdb85-d0ac-4802-a09b-9dab1b9b805a@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