From: Pawel Dembicki <paweldembicki@gmail.com>
To: linux-hwmon@vger.kernel.org
Cc: Pawel Dembicki <paweldembicki@gmail.com>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Noah Wang <noahwang.wang@outlook.com>,
Michal Simek <michal.simek@amd.com>,
Naresh Solanki <naresh.solanki@9elements.com>,
Fabio Estevam <festevam@gmail.com>,
Grant Peltier <grantpeltier93@gmail.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Shen Lichuan <shenlichuan@vivo.com>,
Peter Zijlstra <peterz@infradead.org>,
Greg KH <gregkh@linuxfoundation.org>,
Charles Hsu <ythsu0511@gmail.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: [PATCH v2 4/5] hwmon: pmbus: mpq8785: Implement VOUT feedback resistor divider ratio configuration
Date: Fri, 9 May 2025 08:51:08 +0200 [thread overview]
Message-ID: <20250509065237.2392692-5-paweldembicki@gmail.com> (raw)
In-Reply-To: <20250509065237.2392692-1-paweldembicki@gmail.com>
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@gmail.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 */
+};
+
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,
+ "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);
};
--
2.43.0
next prev parent reply other threads:[~2025-05-09 6:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 6:51 [PATCH v2 0/5] hwmon: pmbus: Add support for MPM82504 and MPM3695 family Pawel Dembicki
2025-05-09 6:51 ` [PATCH v2 1/5] hwmon: pmbus: mpq8785: Prepare driver for multiple device support Pawel Dembicki
2025-05-09 7:03 ` Krzysztof Kozlowski
2025-05-09 7:41 ` Paweł Dembicki
2025-05-09 9:22 ` Krzysztof Kozlowski
2025-05-09 14:15 ` Guenter Roeck
2025-05-09 6:51 ` [PATCH v2 2/5] hwmon: pmbus: mpq8785: Add support for MPM82504 Pawel Dembicki
2025-05-09 13:54 ` Guenter Roeck
2025-05-09 6:51 ` [PATCH v2 3/5] hwmon: pmbus: mpq8785: Add support for MPM3695 family Pawel Dembicki
2025-05-09 7:06 ` Krzysztof Kozlowski
2025-05-09 6:51 ` Pawel Dembicki [this message]
2025-05-09 7:07 ` [PATCH v2 4/5] hwmon: pmbus: mpq8785: Implement VOUT feedback resistor divider ratio configuration Krzysztof Kozlowski
2025-05-09 13:26 ` Guenter Roeck
2025-05-09 6:51 ` [PATCH v2 5/5] dt-bindings: hwmon: Add bindings for mpq8785 driver Pawel Dembicki
2025-05-09 7:00 ` Krzysztof Kozlowski
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=20250509065237.2392692-5-paweldembicki@gmail.com \
--to=paweldembicki@gmail.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=grantpeltier93@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=michal.simek@amd.com \
--cc=naresh.solanki@9elements.com \
--cc=noahwang.wang@outlook.com \
--cc=peterz@infradead.org \
--cc=robh@kernel.org \
--cc=shenlichuan@vivo.com \
--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