[PATCH] hwmon: (pmbus/lm25066) Fix coefficients and overcurrent limit selection

From: Potin Lai

Date: Wed Jun 10 2026 - 09:41:03 EST


Swap high setting and low setting coefficients in the lm25066_coeff
table for LM25056, LM25066, LM5064, LM5066, and LM5066i. The
coefficients were previously mapped incorrectly, resulting in inverted
current and power scaling.

Also, correct the overcurrent limit selection logic in probe.
Bit 4 of the DEVICE_SETUP register (LM25066_DEV_SETUP_CL) selects the
current limit range, but its active state differs depending on the
chip family:
- For lm5064, lm5066, and lm5066i, a set bit selects the low setting.
- For lm25056 and lm25066, a cleared bit selects the low setting.
The logic previously treated all chips the same, inverting the flag
status for lm25056 and lm25066.

Finally, dynamically assign the exponent (R) registers inside the
probe's low setting branches. This ensures that the proper exponent is
applied (e.g., for lm25056, high setting power exponent is -3, but
low setting power exponent is -4).

Signed-off-by: Potin Lai <potin.lai@xxxxxxxxxxxx>
---
drivers/hwmon/pmbus/lm25066.c | 96 +++++++++++++++++++++++--------------------
1 file changed, 52 insertions(+), 44 deletions(-)

diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index dd7275a67a0a..6b08f93801b9 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -60,25 +60,25 @@ static const struct __coeff lm25066_coeff[][PSC_NUM_CLASSES + 2] = {
.R = -2,
},
[PSC_CURRENT_IN] = {
- .m = 13797,
- .b = -1833,
+ .m = 6726,
+ .b = -537,
.R = -2,
},
[PSC_CURRENT_IN_L] = {
- .m = 6726,
- .b = -537,
+ .m = 13797,
+ .b = -1833,
.R = -2,
},
[PSC_POWER] = {
- .m = 5501,
- .b = -2908,
- .R = -3,
- },
- [PSC_POWER_L] = {
.m = 26882,
.b = -5646,
.R = -4,
},
+ [PSC_POWER_L] = {
+ .m = 5501,
+ .b = -2908,
+ .R = -3,
+ },
[PSC_TEMPERATURE] = {
.m = 1580,
.b = -14500,
@@ -97,23 +97,23 @@ static const struct __coeff lm25066_coeff[][PSC_NUM_CLASSES + 2] = {
.R = -2,
},
[PSC_CURRENT_IN] = {
- .m = 13661,
- .b = -5200,
+ .m = 6854,
+ .b = -3100,
.R = -2,
},
[PSC_CURRENT_IN_L] = {
- .m = 6854,
- .b = -3100,
+ .m = 13661,
+ .b = -5200,
.R = -2,
},
[PSC_POWER] = {
- .m = 736,
- .b = -3300,
+ .m = 369,
+ .b = -1900,
.R = -2,
},
[PSC_POWER_L] = {
- .m = 369,
- .b = -1900,
+ .m = 736,
+ .b = -3300,
.R = -2,
},
[PSC_TEMPERATURE] = {
@@ -132,23 +132,23 @@ static const struct __coeff lm25066_coeff[][PSC_NUM_CLASSES + 2] = {
.R = -2,
},
[PSC_CURRENT_IN] = {
- .m = 10742,
- .b = 1552,
+ .m = 5456,
+ .b = 2118,
.R = -2,
},
[PSC_CURRENT_IN_L] = {
- .m = 5456,
- .b = 2118,
+ .m = 10742,
+ .b = 1552,
.R = -2,
},
[PSC_POWER] = {
- .m = 1204,
- .b = 8524,
+ .m = 612,
+ .b = 11202,
.R = -3,
},
[PSC_POWER_L] = {
- .m = 612,
- .b = 11202,
+ .m = 1204,
+ .b = 8524,
.R = -3,
},
[PSC_TEMPERATURE] = {
@@ -167,23 +167,23 @@ static const struct __coeff lm25066_coeff[][PSC_NUM_CLASSES + 2] = {
.R = -2,
},
[PSC_CURRENT_IN] = {
- .m = 10753,
- .b = -1200,
+ .m = 5405,
+ .b = -600,
.R = -2,
},
[PSC_CURRENT_IN_L] = {
- .m = 5405,
- .b = -600,
+ .m = 10753,
+ .b = -1200,
.R = -2,
},
[PSC_POWER] = {
- .m = 1204,
- .b = -6000,
+ .m = 605,
+ .b = -8000,
.R = -3,
},
[PSC_POWER_L] = {
- .m = 605,
- .b = -8000,
+ .m = 1204,
+ .b = -6000,
.R = -3,
},
[PSC_TEMPERATURE] = {
@@ -202,23 +202,23 @@ static const struct __coeff lm25066_coeff[][PSC_NUM_CLASSES + 2] = {
.R = -2,
},
[PSC_CURRENT_IN] = {
- .m = 15076,
- .b = -504,
+ .m = 7645,
+ .b = 100,
.R = -2,
},
[PSC_CURRENT_IN_L] = {
- .m = 7645,
- .b = 100,
+ .m = 15076,
+ .b = -504,
.R = -2,
},
[PSC_POWER] = {
- .m = 1701,
- .b = -4000,
+ .m = 861,
+ .b = -965,
.R = -3,
},
[PSC_POWER_L] = {
- .m = 861,
- .b = -965,
+ .m = 1701,
+ .b = -4000,
.R = -3,
},
[PSC_TEMPERATURE] = {
@@ -468,6 +468,7 @@ static int lm25066_probe(struct i2c_client *client)
struct lm25066_data *data;
struct pmbus_driver_info *info;
const struct __coeff *coeff;
+ bool low_limit;

if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_READ_BYTE_DATA))
@@ -519,18 +520,25 @@ static int lm25066_probe(struct i2c_client *client)
info->m[PSC_VOLTAGE_OUT] = coeff[PSC_VOLTAGE_OUT].m;
info->b[PSC_VOLTAGE_OUT] = coeff[PSC_VOLTAGE_OUT].b;
info->R[PSC_VOLTAGE_OUT] = coeff[PSC_VOLTAGE_OUT].R;
- info->R[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].R;
- info->R[PSC_POWER] = coeff[PSC_POWER].R;
- if (config & LM25066_DEV_SETUP_CL) {
+ if (data->id == lm5064 || data->id == lm5066 || data->id == lm5066i)
+ low_limit = config & LM25066_DEV_SETUP_CL;
+ else
+ low_limit = !(config & LM25066_DEV_SETUP_CL);
+
+ if (low_limit) {
info->m[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN_L].m;
info->b[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN_L].b;
+ info->R[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN_L].R;
info->m[PSC_POWER] = coeff[PSC_POWER_L].m;
info->b[PSC_POWER] = coeff[PSC_POWER_L].b;
+ info->R[PSC_POWER] = coeff[PSC_POWER_L].R;
} else {
info->m[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].m;
info->b[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].b;
+ info->R[PSC_CURRENT_IN] = coeff[PSC_CURRENT_IN].R;
info->m[PSC_POWER] = coeff[PSC_POWER].m;
info->b[PSC_POWER] = coeff[PSC_POWER].b;
+ info->R[PSC_POWER] = coeff[PSC_POWER].R;
}

/*

---
base-commit: 05f7e89ab9731565d8a62e3b5d1ec206485eeb0b
change-id: 20260610-lm25066-driver-fix-ae435577fce1

Best regards,
--
Potin Lai <potin.lai@xxxxxxxxxxxx>