Skip to content

Commit b325d35

Browse files
robimarkogroeck
authored andcommitted
hwmon: (tps23861) set current shunt value
TPS23861 has a configuration bit for setting of the current shunt value used on the board. Its bit 0 of the General Mask 1 register. According to the datasheet bit values are: 0 for 255 mOhm (Default) 1 for 250 mOhm So, configure the bit before registering the hwmon device according to the value passed in the DTS or default one if none is passed. This caused potentially reading slightly skewed values due to max current value being 1.02A when 250mOhm shunt is used instead of 1.0A when 255mOhm is used. Fixes: fff7b8a ("hwmon: add Texas Instruments TPS23861 driver") Signed-off-by: Robert Marko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent fb8543f commit b325d35

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/hwmon/tps23861.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999
#define POWER_ENABLE 0x19
100100
#define TPS23861_NUM_PORTS 4
101101

102+
#define TPS23861_GENERAL_MASK_1 0x17
103+
#define TPS23861_CURRENT_SHUNT_MASK BIT(0)
104+
102105
#define TEMPERATURE_LSB 652 /* 0.652 degrees Celsius */
103106
#define VOLTAGE_LSB 3662 /* 3.662 mV */
104107
#define SHUNT_RESISTOR_DEFAULT 255000 /* 255 mOhm */
@@ -561,6 +564,15 @@ static int tps23861_probe(struct i2c_client *client)
561564
else
562565
data->shunt_resistor = SHUNT_RESISTOR_DEFAULT;
563566

567+
if (data->shunt_resistor == SHUNT_RESISTOR_DEFAULT)
568+
regmap_clear_bits(data->regmap,
569+
TPS23861_GENERAL_MASK_1,
570+
TPS23861_CURRENT_SHUNT_MASK);
571+
else
572+
regmap_set_bits(data->regmap,
573+
TPS23861_GENERAL_MASK_1,
574+
TPS23861_CURRENT_SHUNT_MASK);
575+
564576
hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name,
565577
data, &tps23861_chip_info,
566578
NULL);

0 commit comments

Comments
 (0)