* [PATCH hwmon 1/1] hwmon: (pmbus) Fix sensors readouts for MPS Multi-phase mp2888 controller
@ 2022-09-29 12:16 Oleksandr Shamray
2022-10-02 15:07 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Oleksandr Shamray @ 2022-09-29 12:16 UTC (permalink / raw)
To: linux; +Cc: linux-hwmon, vadimp, Oleksandr Shamray
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="y", Size: 2851 bytes --]
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: e4db7719d037 ("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>
---
drivers/hwmon/pmbus/mp2888.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/pmbus/mp2888.c b/drivers/hwmon/pmbus/mp2888.c
index 8ecd4adfef40..529eb3c95bb6 100644
--- a/drivers/hwmon/pmbus/mp2888.c
+++ b/drivers/hwmon/pmbus/mp2888.c
@@ -109,7 +109,7 @@ mp2888_read_phase(struct i2c_client *client, struct mp2888_data *data, int page,
* - Kcs is the DrMOS current sense gain of power stage, which is obtained from the
* register MP2888_MFR_VR_CONFIG1, bits 13-12 with the following selection of DrMOS
* (data->curr_sense_gain):
- * 00b - 5µA/A, 01b - 8.5µA/A, 10b - 9.7µA/A, 11b - 10µA/A.
+ * 00b - 8.5µA/A, 01b - 9.7µA/A, 1b - 10µA/A, 11b - 5µA/A.
* - Rcs is the internal phase current sense resistor. This parameter depends on hardware
* assembly. By default it is set to 1kΩ. In case of different assembly, user should
* 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,
* because sampling of current occurrence of bit weight has a big deviation, especially for
* light load.
*/
- ret = DIV_ROUND_CLOSEST(ret * 100 - 9800, data->curr_sense_gain);
- ret = (data->phase_curr_resolution) ? ret * 2 : ret;
+ ret = DIV_ROUND_CLOSEST(ret * 200 - 19600, data->curr_sense_gain);
/* Scale according to total current resolution. */
- ret = (data->total_curr_resolution) ? ret * 8 : ret * 4;
+ ret = (data->total_curr_resolution) ? ret * 2 : ret;
return ret;
}
@@ -212,7 +211,7 @@ static int mp2888_read_word_data(struct i2c_client *client, int page, int phase,
ret = pmbus_read_word_data(client, page, phase, reg);
if (ret < 0)
return ret;
- ret = data->total_curr_resolution ? ret * 2 : ret;
+ ret = data->total_curr_resolution ? ret : DIV_ROUND_CLOSEST(ret, 2);
break;
case PMBUS_POUT_OP_WARN_LIMIT:
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,
* set 1. Actual power is reported with 0.5W or 1W respectively resolution. Scaling
* is needed to match both.
*/
- ret = data->total_curr_resolution ? ret * 4 : ret * 2;
+ ret = data->total_curr_resolution ? ret * 2 : ret;
break;
/*
* The below registers are not implemented by device or implemented not according to the
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH hwmon 1/1] hwmon: (pmbus) Fix sensors readouts for MPS Multi-phase mp2888 controller
2022-09-29 12:16 [PATCH hwmon 1/1] hwmon: (pmbus) Fix sensors readouts for MPS Multi-phase mp2888 controller Oleksandr Shamray
@ 2022-10-02 15:07 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2022-10-02 15:07 UTC (permalink / raw)
To: Oleksandr Shamray; +Cc: linux-hwmon, vadimp
On Thu, Sep 29, 2022 at 03:16:42PM +0300, Oleksandr Shamray wrote:
> 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: e4db7719d037 ("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>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/pmbus/mp2888.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/mp2888.c b/drivers/hwmon/pmbus/mp2888.c
> index 8ecd4adfef40..529eb3c95bb6 100644
> --- a/drivers/hwmon/pmbus/mp2888.c
> +++ b/drivers/hwmon/pmbus/mp2888.c
> @@ -109,7 +109,7 @@ mp2888_read_phase(struct i2c_client *client, struct mp2888_data *data, int page,
> * - Kcs is the DrMOS current sense gain of power stage, which is obtained from the
> * register MP2888_MFR_VR_CONFIG1, bits 13-12 with the following selection of DrMOS
> * (data->curr_sense_gain):
> - * 00b - 5µA/A, 01b - 8.5µA/A, 10b - 9.7µA/A, 11b - 10µA/A.
> + * 00b - 8.5µA/A, 01b - 9.7µA/A, 1b - 10µA/A, 11b - 5µA/A.
> * - Rcs is the internal phase current sense resistor. This parameter depends on hardware
> * assembly. By default it is set to 1kΩ. In case of different assembly, user should
> * 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,
> * because sampling of current occurrence of bit weight has a big deviation, especially for
> * light load.
> */
> - ret = DIV_ROUND_CLOSEST(ret * 100 - 9800, data->curr_sense_gain);
> - ret = (data->phase_curr_resolution) ? ret * 2 : ret;
> + ret = DIV_ROUND_CLOSEST(ret * 200 - 19600, data->curr_sense_gain);
> /* Scale according to total current resolution. */
> - ret = (data->total_curr_resolution) ? ret * 8 : ret * 4;
> + ret = (data->total_curr_resolution) ? ret * 2 : ret;
> return ret;
> }
>
> @@ -212,7 +211,7 @@ static int mp2888_read_word_data(struct i2c_client *client, int page, int phase,
> ret = pmbus_read_word_data(client, page, phase, reg);
> if (ret < 0)
> return ret;
> - ret = data->total_curr_resolution ? ret * 2 : ret;
> + ret = data->total_curr_resolution ? ret : DIV_ROUND_CLOSEST(ret, 2);
> break;
> case PMBUS_POUT_OP_WARN_LIMIT:
> 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,
> * set 1. Actual power is reported with 0.5W or 1W respectively resolution. Scaling
> * is needed to match both.
> */
> - ret = data->total_curr_resolution ? ret * 4 : ret * 2;
> + ret = data->total_curr_resolution ? ret * 2 : ret;
> break;
> /*
> * The below registers are not implemented by device or implemented not according to the
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-02 15:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-29 12:16 [PATCH hwmon 1/1] hwmon: (pmbus) Fix sensors readouts for MPS Multi-phase mp2888 controller Oleksandr Shamray
2022-10-02 15:07 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox