[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d578893e-167a-404f-bdd0-8e5b187af816@roeck-us.net>
Date: Fri, 9 May 2025 06:26:37 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Pawel Dembicki <paweldembicki@...il.com>, linux-hwmon@...r.kernel.org
Cc: Jean Delvare <jdelvare@...e.com>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Jonathan Corbet <corbet@....net>,
Noah Wang <noahwang.wang@...look.com>, Michal Simek <michal.simek@....com>,
Naresh Solanki <naresh.solanki@...ements.com>,
Fabio Estevam <festevam@...il.com>, Grant Peltier
<grantpeltier93@...il.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Shen Lichuan <shenlichuan@...o.com>, Peter Zijlstra <peterz@...radead.org>,
Greg KH <gregkh@...uxfoundation.org>, Charles Hsu <ythsu0511@...il.com>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org
Subject: Re: [PATCH v2 4/5] hwmon: pmbus: mpq8785: Implement VOUT feedback
resistor divider ratio configuration
On 5/8/25 23:51, Pawel Dembicki wrote:
> Implement support for setting the VOUT_SCALE_LOOP PMBus register
> based on an optional device tree property
> "mps,vout-fb-divider-ratio-permille".
>
> 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 VOUT_SCALE_LOOP register.
>
> Signed-off-by: Pawel Dembicki <paweldembicki@...il.com>
>
> ---
> v2:
> - rename property to mps,vout-fb-divider-ratio-permille
> - add register value range checking
> ---
> drivers/hwmon/pmbus/mpq8785.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/drivers/hwmon/pmbus/mpq8785.c b/drivers/hwmon/pmbus/mpq8785.c
> index 34245d0d2125..1d0e7ac9daf4 100644
> --- a/drivers/hwmon/pmbus/mpq8785.c
> +++ b/drivers/hwmon/pmbus/mpq8785.c
> @@ -12,6 +12,13 @@
>
> enum chips { mpq8785, mpm82504, mpm3695, mpm3695_25 };
>
> +static u16 voltage_scale_loop_max_val[] = {
> + GENMASK(10, 0), /* mpq8785 */
> + GENMASK(9, 0), /* mpm82504 */
> + GENMASK(9, 0), /* mpm3695 */
> + GENMASK(11, 0), /* mpm3695_25 */
Use
[... ] = GENMASK()
as suggested.
> +};
> +
> static int mpq8785_identify(struct i2c_client *client,
> struct pmbus_driver_info *info)
> {
> @@ -99,6 +106,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)
> @@ -126,6 +135,18 @@ static int mpq8785_probe(struct i2c_client *client)
> return -ENODEV;
> }
>
> + if (!of_property_read_u32(dev->of_node,
s/of_property/device_property/ (and include linux/property.h) to make this
usable from non-devicetree systems.
Also, please swap this patch with the previous patch to address the concern
about patch order (i.e., introduce the property first and then add support
for the new chips).
Thanks,
Guenter
> + "mps,vout-fb-divider-ratio-permille",
> + &voltage_scale)) {
> + if (voltage_scale > voltage_scale_loop_max_val[chip_id])
> + return -EINVAL;
> +
> + ret = i2c_smbus_write_word_data(client, PMBUS_VOUT_SCALE_LOOP,
> + voltage_scale);
> + if (ret)
> + return ret;
> + }
> +
> return pmbus_do_probe(client, info);
> };
>
Powered by blists - more mailing lists