summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2016-03-21 21:31:08 +1030
committerJoel Stanley <joel@jms.id.au>2016-03-21 22:45:51 +1030
commitdd13a2c59d1221f8dd7ca3eb61b587a652c32d8f (patch)
treec53a2b43b6086774490fdc5bfcda0bc8487ec735
parent5fbf374af9fc88bc15a21cde9055f2503c43ab50 (diff)
downloadtalos-obmc-linux-dd13a2c59d1221f8dd7ca3eb61b587a652c32d8f.tar.gz
talos-obmc-linux-dd13a2c59d1221f8dd7ca3eb61b587a652c32d8f.zip
hwmon/adm1275: Support sense resistor parameter from dt
Allow a system to specify the value of an external sense resistor in the device tree. Signed-off-by: Joel Stanley <joel@jms.id.au>
-rw-r--r--Documentation/devicetree/bindings/hwmon/adm1275.txt19
-rw-r--r--drivers/hwmon/pmbus/adm1275.c11
2 files changed, 28 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/hwmon/adm1275.txt b/Documentation/devicetree/bindings/hwmon/adm1275.txt
new file mode 100644
index 000000000000..abfba34e91ba
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/adm1275.txt
@@ -0,0 +1,19 @@
+adm1275 temperature sensor
+--------------------------
+
+Required property:
+
+ - compatible: "adi,adm1278"
+ - reg: i2c device address
+
+Optional property:
+
+- sense-resistor: external sense resistor value in milliOhms
+
+Example:
+
+sensor {
+ reg = <0x11>;
+ compatible = "adi,adm1278";
+ sense-resistor = < 100 >
+}
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
index 1476a127dbdb..a5534e40f4b1 100644
--- a/drivers/hwmon/pmbus/adm1275.c
+++ b/drivers/hwmon/pmbus/adm1275.c
@@ -364,6 +364,7 @@ static int adm1275_probe(struct i2c_client *client,
u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1];
int config, device_config;
int ret;
+ u32 r_sense = 1;
struct pmbus_driver_info *info;
struct adm1275_data *data;
const struct i2c_device_id *mid;
@@ -418,6 +419,12 @@ static int adm1275_probe(struct i2c_client *client,
if (!data)
return -ENOMEM;
+ ret = of_property_read_u32(client->dev.of_node, "sense-resistor",
+ &r_sense);
+ if (!ret)
+ dev_notice(&client->dev, "using r_sense from dt %d\n",
+ r_sense);
+
data->id = mid->driver_data;
info = &data->info;
@@ -591,12 +598,12 @@ static int adm1275_probe(struct i2c_client *client,
info->R[PSC_VOLTAGE_OUT] = coefficients[voindex].R;
}
if (cindex >= 0) {
- info->m[PSC_CURRENT_OUT] = coefficients[cindex].m;
+ info->m[PSC_CURRENT_OUT] = coefficients[cindex].m * r_sense;
info->b[PSC_CURRENT_OUT] = coefficients[cindex].b;
info->R[PSC_CURRENT_OUT] = coefficients[cindex].R;
}
if (pindex >= 0) {
- info->m[PSC_POWER] = coefficients[pindex].m;
+ info->m[PSC_POWER] = coefficients[pindex].m * r_sense;
info->b[PSC_POWER] = coefficients[pindex].b;
info->R[PSC_POWER] = coefficients[pindex].R;
}
OpenPOWER on IntegriCloud