From: wenswang@yeah.net
To: linux@roeck-us.net
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
Wensheng Wang <wenswang@yeah.net>
Subject: [PATCH] hwmon: mp2925: add vid offset for vid mode
Date: Tue, 6 Jan 2026 14:13:48 +0800 [thread overview]
Message-ID: <20260106061348.170509-1-wenswang@yeah.net> (raw)
From: Wensheng Wang <wenswang@yeah.net>
In vid mode, the mp2925 vout telemetry has 49 vid step offset, add
vid offset for this.
Signed-off-by: Wensheng Wang <wenswang@yeah.net>
---
drivers/hwmon/pmbus/mp2925.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/pmbus/mp2925.c b/drivers/hwmon/pmbus/mp2925.c
index 6bebd6023021..ad094842cf2d 100644
--- a/drivers/hwmon/pmbus/mp2925.c
+++ b/drivers/hwmon/pmbus/mp2925.c
@@ -40,6 +40,7 @@
struct mp2925_data {
struct pmbus_driver_info info;
int vout_scale[MP2925_PAGE_NUM];
+ int vid_offset[MP2925_PAGE_NUM];
};
#define to_mp2925_data(x) container_of(x, struct mp2925_data, info)
@@ -94,8 +95,15 @@ static int mp2925_read_word_data(struct i2c_client *client, int page, int phase,
if (ret < 0)
return ret;
- ret = DIV_ROUND_CLOSEST((ret & GENMASK(11, 0)) * data->vout_scale[page],
- MP2925_VOUT_DIV);
+ /*
+ * In vid mode, the MP2925 vout telemetry has 49 vid step offset, but
+ * PMBUS_VOUT_OV_FAULT_LIMIT and PMBUS_VOUT_UV_FAULT_LIMIT do not take
+ * this into consideration, its resolution is 1.95mV/LSB, as a result,
+ * format[PSC_VOLTAGE_OUT] can not be set to vid directly. Adding extra
+ * vid_offset variable for vout telemetry.
+ */
+ ret = DIV_ROUND_CLOSEST(((ret & GENMASK(11, 0)) + data->vid_offset[page]) *
+ data->vout_scale[page], MP2925_VOUT_DIV);
break;
case PMBUS_VOUT_OV_FAULT_LIMIT:
case PMBUS_VOUT_UV_FAULT_LIMIT:
@@ -231,10 +239,21 @@ mp2925_identify_vout_scale(struct i2c_client *client, struct pmbus_driver_info *
data->vout_scale[page] = 2560;
else
data->vout_scale[page] = 5120;
+
+ /*
+ * In vid mode, the MP2925 vout telemetry has 49 vid step offset, but
+ * PMBUS_VOUT_OV_FAULT_LIMIT and PMBUS_VOUT_UV_FAULT_LIMIT do not take
+ * this into consideration, its resolution is 1.95mV/LSB, as a result,
+ * format[PSC_VOLTAGE_OUT] can not be set to vid directly. Adding extra
+ * vid_offset variable for vout telemetry.
+ */
+ data->vid_offset[page] = 49;
} else if (FIELD_GET(GENMASK(4, 4), ret)) {
data->vout_scale[page] = 1;
+ data->vid_offset[page] = 0;
} else {
data->vout_scale[page] = 512;
+ data->vid_offset[page] = 0;
}
return 0;
--
2.25.1
next reply other threads:[~2026-01-06 6:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 6:13 wenswang [this message]
2026-01-12 21:22 ` Guenter Roeck
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=20260106061348.170509-1-wenswang@yeah.net \
--to=wenswang@yeah.net \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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®