diff options
-rw-r--r-- | Documentation/devicetree/bindings/i2c/ina2xx.txt | 22 | ||||
-rw-r--r-- | Documentation/hwmon/ina2xx | 4 | ||||
-rw-r--r-- | drivers/hwmon/ina2xx.c | 5 |
3 files changed, 30 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/i2c/ina2xx.txt b/Documentation/devicetree/bindings/i2c/ina2xx.txt new file mode 100644 index 000000000000..a2ad85d7e747 --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/ina2xx.txt | |||
@@ -0,0 +1,22 @@ | |||
1 | ina2xx properties | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: Must be one of the following: | ||
5 | - "ti,ina219" for ina219 | ||
6 | - "ti,ina220" for ina220 | ||
7 | - "ti,ina226" for ina226 | ||
8 | - "ti,ina230" for ina230 | ||
9 | - reg: I2C address | ||
10 | |||
11 | Optional properties: | ||
12 | |||
13 | - shunt-resistor | ||
14 | Shunt resistor value in micro-Ohm | ||
15 | |||
16 | Example: | ||
17 | |||
18 | ina220@44 { | ||
19 | compatible = "ti,ina220"; | ||
20 | reg = <0x44>; | ||
21 | shunt-resistor = <1000>; | ||
22 | }; | ||
diff --git a/Documentation/hwmon/ina2xx b/Documentation/hwmon/ina2xx index 03444f9d833f..4223c2d3b508 100644 --- a/Documentation/hwmon/ina2xx +++ b/Documentation/hwmon/ina2xx | |||
@@ -44,4 +44,6 @@ The INA226 monitors both a shunt voltage drop and bus supply voltage. | |||
44 | The INA230 is a high or low side current shunt and power monitor with an I2C | 44 | The INA230 is a high or low side current shunt and power monitor with an I2C |
45 | interface. The INA230 monitors both a shunt voltage drop and bus supply voltage. | 45 | interface. The INA230 monitors both a shunt voltage drop and bus supply voltage. |
46 | 46 | ||
47 | The shunt value in micro-ohms can be set via platform data. | 47 | The shunt value in micro-ohms can be set via platform data or device tree. |
48 | Please refer to the Documentation/devicetree/bindings/i2c/ina2xx.txt for bindings | ||
49 | if the device tree is used. | ||
diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index 4958b2f89dce..d917a2d8c30f 100644 --- a/drivers/hwmon/ina2xx.c +++ b/drivers/hwmon/ina2xx.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/hwmon.h> | 34 | #include <linux/hwmon.h> |
35 | #include <linux/hwmon-sysfs.h> | 35 | #include <linux/hwmon-sysfs.h> |
36 | #include <linux/jiffies.h> | 36 | #include <linux/jiffies.h> |
37 | #include <linux/of.h> | ||
37 | 38 | ||
38 | #include <linux/platform_data/ina2xx.h> | 39 | #include <linux/platform_data/ina2xx.h> |
39 | 40 | ||
@@ -221,6 +222,7 @@ static int ina2xx_probe(struct i2c_client *client, | |||
221 | struct ina2xx_data *data; | 222 | struct ina2xx_data *data; |
222 | struct ina2xx_platform_data *pdata; | 223 | struct ina2xx_platform_data *pdata; |
223 | int ret; | 224 | int ret; |
225 | u32 val; | ||
224 | long shunt = 10000; /* default shunt value 10mOhms */ | 226 | long shunt = 10000; /* default shunt value 10mOhms */ |
225 | 227 | ||
226 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) | 228 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) |
@@ -234,6 +236,9 @@ static int ina2xx_probe(struct i2c_client *client, | |||
234 | pdata = | 236 | pdata = |
235 | (struct ina2xx_platform_data *)client->dev.platform_data; | 237 | (struct ina2xx_platform_data *)client->dev.platform_data; |
236 | shunt = pdata->shunt_uohms; | 238 | shunt = pdata->shunt_uohms; |
239 | } else if (!of_property_read_u32(client->dev.of_node, | ||
240 | "shunt-resistor", &val)) { | ||
241 | shunt = val; | ||
237 | } | 242 | } |
238 | 243 | ||
239 | if (shunt <= 0) | 244 | if (shunt <= 0) |