Skip to content

Commit 525dd5a

Browse files
sholeksandrgroeck
authored andcommitted
hwmon: (pmbus/mp2888) Fix sensors readouts for MPS Multi-phase mp2888 controller
Fix scale factors for reading MPS Multi-phase mp2888 controller. Fixed sensors: - PIN/POUT: based on vendor documentation, set bscale factor 0.5W/LSB - IOUT: based on vendor documentation, set scale factor 0.25 A/LSB Fixes: e4db771 ("hwmon: (pmbus) Add support for MPS Multi-phase mp2888 controller") Signed-off-by: Oleksandr Shamray <oleksandrs@nvidia.com> Reviewed-by: Vadim Pasternak <vadimp@nvidia.com> Link: https://lore.kernel.org/r/20220929121642.63051-1-oleksandrs@nvidia.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 1793bed commit 525dd5a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/hwmon/pmbus/mp2888.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct mp2888_data {
3434
int curr_sense_gain;
3535
};
3636

37-
#define to_mp2888_data(x) container_of(x, struct mp2888_data, info)
37+
#define to_mp2888_data(x) container_of(x, struct mp2888_data, info)
3838

3939
static int mp2888_read_byte_data(struct i2c_client *client, int page, int reg)
4040
{
@@ -109,7 +109,7 @@ mp2888_read_phase(struct i2c_client *client, struct mp2888_data *data, int page,
109109
* - Kcs is the DrMOS current sense gain of power stage, which is obtained from the
110110
* register MP2888_MFR_VR_CONFIG1, bits 13-12 with the following selection of DrMOS
111111
* (data->curr_sense_gain):
112-
* 00b - 5µA/A, 01b - 8.5µA/A, 10b - 9.7µA/A, 11b - 10µA/A.
112+
* 00b - 8.5µA/A, 01b - 9.7µA/A, 1b - 10µA/A, 11b - 5µA/A.
113113
* - Rcs is the internal phase current sense resistor. This parameter depends on hardware
114114
* assembly. By default it is set to 1kΩ. In case of different assembly, user should
115115
* scale this parameter by dividing it by Rcs.
@@ -118,10 +118,9 @@ mp2888_read_phase(struct i2c_client *client, struct mp2888_data *data, int page,
118118
* because sampling of current occurrence of bit weight has a big deviation, especially for
119119
* light load.
120120
*/
121-
ret = DIV_ROUND_CLOSEST(ret * 100 - 9800, data->curr_sense_gain);
122-
ret = (data->phase_curr_resolution) ? ret * 2 : ret;
121+
ret = DIV_ROUND_CLOSEST(ret * 200 - 19600, data->curr_sense_gain);
123122
/* Scale according to total current resolution. */
124-
ret = (data->total_curr_resolution) ? ret * 8 : ret * 4;
123+
ret = (data->total_curr_resolution) ? ret * 2 : ret;
125124
return ret;
126125
}
127126

@@ -212,7 +211,7 @@ static int mp2888_read_word_data(struct i2c_client *client, int page, int phase,
212211
ret = pmbus_read_word_data(client, page, phase, reg);
213212
if (ret < 0)
214213
return ret;
215-
ret = data->total_curr_resolution ? ret * 2 : ret;
214+
ret = data->total_curr_resolution ? ret : DIV_ROUND_CLOSEST(ret, 2);
216215
break;
217216
case PMBUS_POUT_OP_WARN_LIMIT:
218217
ret = pmbus_read_word_data(client, page, phase, reg);
@@ -223,7 +222,7 @@ static int mp2888_read_word_data(struct i2c_client *client, int page, int phase,
223222
* set 1. Actual power is reported with 0.5W or 1W respectively resolution. Scaling
224223
* is needed to match both.
225224
*/
226-
ret = data->total_curr_resolution ? ret * 4 : ret * 2;
225+
ret = data->total_curr_resolution ? ret * 2 : ret;
227226
break;
228227
/*
229228
* The below registers are not implemented by device or implemented not according to the

0 commit comments

Comments
 (0)