summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZev Weiss <zev@bewilderbeest.net>2021-09-28 12:22:41 +0300
committerJoel Stanley <joel@jms.id.au>2021-11-01 09:42:38 +0300
commitb40e40b32a5a3fcda9d83ac505fafecee76ee5f5 (patch)
tree7d4ca6ef043b095c4d6e722ecc1e72258f51a9d4
parenta3749c686d1dbf8e0e33c86ada22ec70f3d64f31 (diff)
downloadlinux-b40e40b32a5a3fcda9d83ac505fafecee76ee5f5.tar.xz
hwmon: (pmbus/lm25066) Support configurable sense resistor values
The appropriate mantissa values for the lm25066 family's direct-format current and power readings are a function of the sense resistor employed between the SENSE and VIN pins of the chip. Instead of assuming that resistance is always the same 1mOhm as used in the datasheet, allow it to be configured via a device-tree property ("shunt-resistor-micro-ohms"). Signed-off-by: Zev Weiss <zev@bewilderbeest.net> Link: https://lore.kernel.org/r/20210928092242.30036-8-zev@bewilderbeest.net [groeck: Fixed checkpatch warnings] Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Joel Stanley <joel@jms.id.au>
-rw-r--r--drivers/hwmon/pmbus/lm25066.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
index 7dc5ffeab77d..8402b41520eb 100644
--- a/drivers/hwmon/pmbus/lm25066.c
+++ b/drivers/hwmon/pmbus/lm25066.c
@@ -458,6 +458,7 @@ MODULE_DEVICE_TABLE(of, lm25066_of_match);
static int lm25066_probe(struct i2c_client *client)
{
int config;
+ u32 shunt;
struct lm25066_data *data;
struct pmbus_driver_info *info;
const struct __coeff *coeff;
@@ -534,6 +535,16 @@ static int lm25066_probe(struct i2c_client *client)
info->b[PSC_POWER] = coeff[PSC_POWER].b;
}
+ /*
+ * Values in the TI datasheets are normalized for a 1mOhm sense
+ * resistor; assume that unless DT specifies a value explicitly.
+ */
+ if (of_property_read_u32(client->dev.of_node, "shunt-resistor-micro-ohms", &shunt))
+ shunt = 1000;
+
+ info->m[PSC_CURRENT_IN] = info->m[PSC_CURRENT_IN] * shunt / 1000;
+ info->m[PSC_POWER] = info->m[PSC_POWER] * shunt / 1000;
+
return pmbus_do_probe(client, info);
}