hwmon: (pmbus) add VR12/VR13 mode support write paths
PATCH 1/1 hwmon: (pmbus) add VR12/VR13 mode support write paths
pmbus_core supported VR11/VR12/VR13 modes when reading VID-formatted registers, but the write path only supported VR11 translations. Add support for VR12 and VR13 to 'data2reg_vid' for translating these formats. This is the inverse of 'reg2data_vid'.
--- drivers/hwmon/pmbus/pmbus_core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +12 -2
@@ -845,9 +845,19 @@ static u16 pmbus_data2reg_direct(struct pmbus_data *data,static u16 pmbus_data2reg_vid (struct pmbus_data *data,struct pmbus_sensor *sensor,long val) { - val =clamp_val (val,500 ,1600 ); +switch (data->info->vrm_version) { +case vr11: + val =clamp_val (val,500 ,1600 ); +return 2 +DIV_ROUND_CLOSEST ((1600 - val) *100 ,625 ); +case vr12: + val =clamp_val (val,0 ,1520 ); +return ((val -250 ) /5 ) +1 ; +case vr13: + val =clamp_val (val,0 ,2500 ); +return ((val -500 ) /10 ) +1 ; + } -return 2 +DIV_ROUND_CLOSEST ((1600 - val) *100 ,625 ); +return 0 ; } static u16 pmbus_data2reg(struct pmbus_data *data,
Signature · 1 line
2.17.2 (Apple Git-113)
A message that is not in the archive (sent off-list or not yet received): [email protected]
---- On Tue, 01 Oct 2019 16:02:10 -0700 Guenter Roeck <[email protected]> wrote ----
Quoted 12 lines
drivers/hwmon/pmbus/pmbus_core.c static u16 pmbus_data2reg_direct(struct pmbus_data *data, · line 857
Quoted 11 lines
drivers/hwmon/pmbus/pmbus_core.c +10
-1- val =clamp_val (val,500 ,1600 ); +switch (data->info->vrm_version) { +case vr11: + val =clamp_val (val,500 ,1600 ); +return 2 +DIV_ROUND_CLOSEST ((1600 - val) *100 ,625 ); +case vr12: + val =clamp_val (val,0 ,1520 ); +return ((val -250 ) /5 ) +1 ; +case vr13: + val =clamp_val (val,0 ,2500 ); +return ((val -500 ) /10 ) +1 ;
Quoted 6 lines
Both vr12 and vr13 converts low values into negative values, which are then converted into more or less random register values. That can not be correct. The resulting register values must always be valid.
Guenter
Thanks for catching this. It may be as simple as me adjusting the lower bound on the clamp_val. I’ll check with one of the device specs and confirm the appropriate behavior on the lower bounds.