]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hwmon: (pmbus/lm25066) Fix PMBus coefficients for LM5064/5066/5066i
authorPotin Lai <potin.lai.pt@gmail.com>
Thu, 11 Jun 2026 05:46:18 +0000 (13:46 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 11 Jun 2026 11:30:34 +0000 (04:30 -0700)
Swap the high setting and low setting coefficients in the lm25066_coeff
table for LM5064, LM5066, and LM5066i. The coefficients were previously
mapped incorrectly, resulting in inverted current and power scaling.

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

Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
Link: https://lore.kernel.org/r/20260611-lm25066-driver-fix-v3-1-9d7d4b4e253d@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/lm25066.c

index 0f7df7e2c9c5bac2b87ac47743240950235807e8..2be50cf1bbdea566f294c7f5faa92cdd5edf1110 100644 (file)
@@ -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] = {
@@ -519,18 +519,20 @@ 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) {
                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;
        }
 
        /*