mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Pawel Dembicki <paweldembicki@gmail.com>, linux-hwmon@vger.kernel.org
Cc: "Jean Delvare" <jdelvare@suse.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Shen Lichuan" <shenlichuan@vivo.com>,
	"Greg KH" <gregkh@linuxfoundation.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Charles Hsu" <ythsu0511@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH 4/5] hwmon: pmbus: mpq8785: Implement voltage scale loop configuration
Date: Mon, 28 Apr 2025 17:27:27 -0700	[thread overview]
Message-ID: <ec2dbc97-664a-4eee-80cc-929f13f80129@roeck-us.net> (raw)
In-Reply-To: <20250428221420.2077697-5-paweldembicki@gmail.com>

On 4/28/25 15:13, Pawel Dembicki wrote:
> Implement support for setting the VOUT_SCALE_LOOP PMBus register
> based on an optional device tree property "voltage-scale-loop".
> 
> This allows the driver to provide the correct VOUT value depending
> on the feedback voltage divider configuration for chips where the
> bootloader does not configure the voltage scale.
> 
> Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
> ---
>   drivers/hwmon/pmbus/mpq8785.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/hwmon/pmbus/mpq8785.c b/drivers/hwmon/pmbus/mpq8785.c
> index e6a643856f08..6e2325d7f37b 100644
> --- a/drivers/hwmon/pmbus/mpq8785.c
> +++ b/drivers/hwmon/pmbus/mpq8785.c
> @@ -78,6 +78,8 @@ static int mpq8785_probe(struct i2c_client *client)
>   	struct device *dev = &client->dev;
>   	struct pmbus_driver_info *info;
>   	enum chips chip_id;
> +	u32 voltage_scale;
> +	int ret;
>   
>   	info = devm_kmemdup(dev, &mpq8785_info, sizeof(*info), GFP_KERNEL);
>   	if (!info)
> @@ -105,6 +107,14 @@ static int mpq8785_probe(struct i2c_client *client)
>   		return -ENODEV;
>   	}
>   
> +	if (!of_property_read_u32(dev->of_node, "voltage-scale-loop",
> +				  &voltage_scale)) {
> +		ret = i2c_smbus_write_word_data(client, PMBUS_VOUT_SCALE_LOOP,
> +						voltage_scale);

Per PMBus specification this value can be in any supported scale.
Also, the chips do not support the full 16-bit value range. I see 10 bit for
mpq8785 and mpm3695, 7 bit for mp2853, and 12 bit for MPM82504. There will
have to be some device specific range check.

I don't understand the units. The devicetree document talks about
VOUT_SCALE_LOOP = VFB / VOUT * 1000, but I don't see how that translates
into chip values. For MPM82504, the datasheet says 1 LSB=2mV. For mpm3695
it is 0.001/LSB. I have no idea how that is supposed to translate to the
units suggested in the property patch.

Either case, I think the property needs to be something generic that is well
defined. Maybe "pmbus,voltage-scale-loop", but I really don't know what would
be acceptable for DT maintainers.

Guenter


  reply	other threads:[~2025-04-29  0:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 22:13 [PATCH 0/5] hwmon: pmbus: Add support for MPM82504 and MPM3695-10 Pawel Dembicki
2025-04-28 22:13 ` [PATCH 1/5] hwmon: pmbus: mpq8785: Prepare driver for multiple device support Pawel Dembicki
2025-04-28 22:13 ` [PATCH 2/5] hwmon: pmbus: mpq8785: Add support for MPM82504 Pawel Dembicki
2025-04-30  4:07   ` Guenter Roeck
2025-04-28 22:13 ` [PATCH 3/5] hwmon: pmbus: mpq8785: Add support for MPM3695 Pawel Dembicki
2025-04-30  4:10   ` Guenter Roeck
2025-04-28 22:13 ` [PATCH 4/5] hwmon: pmbus: mpq8785: Implement voltage scale loop configuration Pawel Dembicki
2025-04-29  0:27   ` Guenter Roeck [this message]
2025-04-28 22:13 ` [PATCH 5/5] dt-bindings: hwmon: Add bindings for mpq8785 driver Pawel Dembicki
2025-04-28 23:26   ` Rob Herring (Arm)
2025-04-29  7:30   ` Krzysztof Kozlowski
2025-04-29 13:28   ` kernel test robot

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=ec2dbc97-664a-4eee-80cc-929f13f80129@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jdelvare@suse.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paweldembicki@gmail.com \
    --cc=peterz@infradead.org \
    --cc=robh@kernel.org \
    --cc=shenlichuan@vivo.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=ythsu0511@gmail.com \
    /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®