Add support for INA3221 Triple Current/Voltage Monitors
Subsystems (2)
v5 cover Add support for INA3221 Triple Current/Voltage Monitors
Hello all,
This series adds support for the INA3221 Triple Current/Voltage Monitor.
Changes from v4:
- Drop DT support, will be added by Laxman in followup patches
Changes from v3:
- minor fixups from comments
- rebased on v4.7-rc1
Changes from v2:
- changed alarms to work on current
- added of_match_table
- other small fixups/typos
Changes from v1:
- rearranged and renumbered sysfs enteries
- added reading alert bits to sysfs
- removed internal power calculation
- added DT setting of shunt resistors
- various other minor fixups
Thanks,
Andrew
Andrew F. Davis (1):
hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Documentation/hwmon/ina3221 | 35 ++++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/ina3221.c | 446 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 493 insertions(+) create mode 100644 Documentation/hwmon/ina3221 create mode 100644 drivers/hwmon/ina3221.c
Signature · 1 line
2.8.3
PATCH v5 1/1 hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Add support for the the INA3221 26v capable, Triple channel, Bi-Directional, Zero-Drift, Low-/High-Side, Current/Voltage Monitor with I2C interface.
--- Documentation/hwmon/ina3221 | 35 ++++ drivers/hwmon/Kconfig | 11 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/ina3221.c | 446 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 493 insertions(+) create mode 100644 Documentation/hwmon/ina3221 create mode 100644 drivers/hwmon/ina3221.c
Documentation/hwmon/ina3221 new file +35 -0
@@ -0,0 +1,35 @@ +Kernel driver ina3221 +===================== + +Supported chips: + * Texas Instruments INA3221 + Prefix: 'ina3221' + Addresses: I2C 0x40 - 0x43 + Datasheet: Publicly available at the Texas Instruments website + http://www.ti.com/ + +Author: Andrew F. Davis <[email protected]> + +Description +----------- + +The Texas Instruments INA3221 monitors voltage, current, and power on the high +side of up to three D.C. power supplies. The INA3221 monitors both shunt drop +and supply voltage, with programmable conversion times and averaging, current +and power are calculated host-side from these. + +Sysfs entries +------------- + +in[123]_input Bus voltage(mV) channels +curr[123]_input Current(mA) measurement channels +shunt[123]_resistor Shunt resistance(uOhm) channels +curr[123]_crit Critical alert current(mA) setting, activates the + corresponding alarm when the respective current + is above this value +curr[123]_crit_alarm Critical alert current limit exceeded +curr[123]_max Warning alert current(mA) setting, activates the + corresponding alarm when the respective current + average is above this value. +curr[123]_max_alarm Warning alert current limit exceeded +in[456]_input Shunt voltage(uV) for channels 1, 2, and 3 respectively
drivers/hwmon/Kconfig +11 -0
@@ -1514,6 +1514,17 @@ config SENSORS_INA2XX This driver can also be built as a module. If so, the module will be called ina2xx. +config SENSORS_INA3221 + tristate "Texas Instruments INA3221 Triple Power Monitor" + depends on I2C + select REGMAP_I2C + help + If you say yes here you get support for the TI INA3221 Triple Power + Monitor. + + This driver can also be built as a module. If so, the module + will be called ina3221. + config SENSORS_TC74 tristate "Microchip TC74" depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -77,6 +77,7 @@ obj-$(CONFIG_SENSORS_IBMPOWERNV)+= ibmpowernv.o obj-$(CONFIG_SENSORS_IIO_HWMON) += iio_hwmon.o obj-$(CONFIG_SENSORS_INA209) += ina209.o obj-$(CONFIG_SENSORS_INA2XX) += ina2xx.o +obj-$(CONFIG_SENSORS_INA3221) += ina3221.o obj-$(CONFIG_SENSORS_IT87) += it87.o obj-$(CONFIG_SENSORS_JC42) += jc42.o obj-$(CONFIG_SENSORS_JZ4740) += jz4740-hwmon.o
drivers/hwmon/ina3221.c new file +446 -0
446 lines not on this page · raw message
Signature · 1 line
2.8.3
Re: [PATCH v5 1/1] hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Quoted 5 lines · Andrew F. Davis
Add support for the the INA3221 26v capable, Triple channel, Bi-Directional, Zero-Drift, Low-/High-Side, Current/Voltage Monitor with I2C interface.
Signed-off-by Andrew F. Davis <[email protected]>
Applied to -next.
Can you by any chance send me a register dump ? I would like to write module test code for the chip.
Thanks,
Guenter
Re: [PATCH v5 1/1] hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Andrew F. Davis
Add support for the the INA3221 26v capable, Triple channel, Bi-Directional, Zero-Drift, Low-/High-Side, Current/Voltage Monitor with I2C interface.
Quoted 7 lines
Quoted 1 line
Signed-off-by Andrew F. Davis <[email protected]>Applied to -next.
Can you by any chance send me a register dump ? I would like to write module test code for the chip.
No problem:
# i2cdump -y 2 0x48
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 18 16 80 00 08 7f 80 7f 80 00 00 00 00 00 00 00 ???.?????.......
10: e0 00 00 f0 00 00 03 00 00 7f 00 00 00 00 00 00 ?..?..?..?......
20: 7f 0a 01 00 00 XX 00 00 00 00 0e 00 00 00 40 00 ???..X....?...@.
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 ..............U.Guenter Roeck
maintainerRe: [PATCH v5 1/1] hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Hi Andrew,
Quoted 27 lines · Andrew F. Davis
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Andrew F. Davis
Add support for the the INA3221 26v capable, Triple channel, Bi-Directional, Zero-Drift, Low-/High-Side, Current/Voltage Monitor with I2C interface.
Quoted 7 lines
Quoted 1 line
Signed-off-by Andrew F. Davis <[email protected]>Applied to -next.
Can you by any chance send me a register dump ? I would like to write module test code for the chip.
No problem:
# i2cdump -y 2 0x48 No size specified (using byte-data access) 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: 18 16 80 00 08 7f 80 7f 80 00 00 00 00 00 00 00 ???.?????....... 10: e0 00 00 f0 00 00 03 00 00 7f 00 00 00 00 00 00 ?..?..?..?...... 20: 7f 0a 01 00 00 XX 00 00 00 00 0e 00 00 00 40 00 ???..X....?...@. 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Quoted 8 lines
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 ..............U.
The chip registers are 16 bit. Can you repeat the command using the "w" option ?
Thanks,
Guenter
Re: [PATCH v5 1/1] hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Quoted 4 lines · Guenter Roeck
The chip registers are 16 bit. Can you repeat the command using the "w" option ?
# i2cdump -y 2 0x40 w
0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f
00: 2771 0000 0000 0000 0000 0000 0000 f87f
08: f87f f87f f87f f87f f87f 0000 fe7f 0300
10: 1027 2823 ffff ffff ffff ffff ffff ffff
18: ffff ffff XXXX f8f8 ffff ffff 4954 2032
20: 2771 0000 0000 0000 0000 0000 0000 f87f
28: f87f f87f f87f f87f f87f 0000 fe7f 0300
30: 1027 2823 ffff ffff ffff ffff ffff ffff
38: ffff ffff XXXX f8f8 ffff ffff 4954 2032
40: 2771 0000 0000 0000 0000 0000 0000 f87f
48: f87f f87f f87f f87f f87f 0000 fe7f 0300
50: 1027 2823 ffff ffff ffff ffff ffff ffff
58: ffff ffff XXXX f8f8 ffff ffff 4954 2032
60: 2771 0000 0000 0000 0000 0000 0000 f87f
68: f87f f87f f87f f87f f87f 0000 fe7f 0300
70: 1027 2823 ffff ffff ffff ffff ffff ffff
78: ffff ffff XXXX f8f8 ffff ffff 4954 2032
80: 2771 0000 0000 0000 0000 0000 0000 f87f
88: f87f f87f f87f f87f f87f 0000 fe7f 0300
90: 1027 2823 ffff ffff ffff ffff ffff ffff
98: ffff ffff XXXX f8f8 ffff ffff 4954 2032
a0: 2771 0000 0000 0000 0000 0000 0000 f87f
a8: f87f f87f f87f f87f f87f 0000 fe7f 0300
b0: 1027 2823 ffff ffff ffff ffff ffff ffff
b8: ffff ffff XXXX f8f8 ffff ffff 4954 2032
c0: 2771 0000 0000 0000 0000 0000 0000 f87f
c8: f87f f87f f87f f87f f87f 0000 fe7f 0300
d0: 1027 2823 ffff ffff ffff ffff ffff ffff
d8: ffff ffff XXXX f8f8 ffff ffff 4954 2032
e0: 2771 0000 0000 0000 0000 0000 0000 f87f
e8: f87f f87f f87f f87f f87f 0000 fe7f 0300
f0: 1027 2823 ffff ffff ffff ffff ffff ffff
f8: ffff ffff XXXX f8f8 ffff ffff 4954 2032Guenter Roeck
maintainerRe: [PATCH v5 1/1] hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Quoted 32 lines · Andrew F. Davis
Quoted 4 lines · Guenter Roeck
The chip registers are 16 bit. Can you repeat the command using the "w" option ?
# i2cdump -y 2 0x40 w 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f 00: 2771 0000 0000 0000 0000 0000 0000 f87f 08: f87f f87f f87f f87f f87f 0000 fe7f 0300 10: 1027 2823 ffff ffff ffff ffff ffff ffff 18: ffff ffff XXXX f8f8 ffff ffff 4954 2032 20: 2771 0000 0000 0000 0000 0000 0000 f87f 28: f87f f87f f87f f87f f87f 0000 fe7f 0300 30: 1027 2823 ffff ffff ffff ffff ffff ffff 38: ffff ffff XXXX f8f8 ffff ffff 4954 2032 40: 2771 0000 0000 0000 0000 0000 0000 f87f 48: f87f f87f f87f f87f f87f 0000 fe7f 0300 50: 1027 2823 ffff ffff ffff ffff ffff ffff 58: ffff ffff XXXX f8f8 ffff ffff 4954 2032 60: 2771 0000 0000 0000 0000 0000 0000 f87f 68: f87f f87f f87f f87f f87f 0000 fe7f 0300 70: 1027 2823 ffff ffff ffff ffff ffff ffff 78: ffff ffff XXXX f8f8 ffff ffff 4954 2032 80: 2771 0000 0000 0000 0000 0000 0000 f87f 88: f87f f87f f87f f87f f87f 0000 fe7f 0300 90: 1027 2823 ffff ffff ffff ffff ffff ffff 98: ffff ffff XXXX f8f8 ffff ffff 4954 2032 a0: 2771 0000 0000 0000 0000 0000 0000 f87f a8: f87f f87f f87f f87f f87f 0000 fe7f 0300 b0: 1027 2823 ffff ffff ffff ffff ffff ffff b8: ffff ffff XXXX f8f8 ffff ffff 4954 2032
Quoted 8 lines
c0: 2771 0000 0000 0000 0000 0000 0000 f87f c8: f87f f87f f87f f87f f87f 0000 fe7f 0300 d0: 1027 2823 ffff ffff ffff ffff ffff ffff d8: ffff ffff XXXX f8f8 ffff ffff 4954 2032 e0: 2771 0000 0000 0000 0000 0000 0000 f87f e8: f87f f87f f87f f87f f87f 0000 fe7f 0300 f0: 1027 2823 ffff ffff ffff ffff ffff ffff f8: ffff ffff XXXX f8f8 ffff ffff 4954 2032
Thanks a lot!
Guenter
Re: [PATCH v5 1/1] hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Quoted 42 lines · Guenter Roeck
Quoted 32 lines · Andrew F. Davis
Quoted 4 lines · Guenter Roeck
The chip registers are 16 bit. Can you repeat the command using the "w" option ?
# i2cdump -y 2 0x40 w 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f 00: 2771 0000 0000 0000 0000 0000 0000 f87f 08: f87f f87f f87f f87f f87f 0000 fe7f 0300 10: 1027 2823 ffff ffff ffff ffff ffff ffff 18: ffff ffff XXXX f8f8 ffff ffff 4954 2032 20: 2771 0000 0000 0000 0000 0000 0000 f87f 28: f87f f87f f87f f87f f87f 0000 fe7f 0300 30: 1027 2823 ffff ffff ffff ffff ffff ffff 38: ffff ffff XXXX f8f8 ffff ffff 4954 2032 40: 2771 0000 0000 0000 0000 0000 0000 f87f 48: f87f f87f f87f f87f f87f 0000 fe7f 0300 50: 1027 2823 ffff ffff ffff ffff ffff ffff 58: ffff ffff XXXX f8f8 ffff ffff 4954 2032 60: 2771 0000 0000 0000 0000 0000 0000 f87f 68: f87f f87f f87f f87f f87f 0000 fe7f 0300 70: 1027 2823 ffff ffff ffff ffff ffff ffff 78: ffff ffff XXXX f8f8 ffff ffff 4954 2032 80: 2771 0000 0000 0000 0000 0000 0000 f87f 88: f87f f87f f87f f87f f87f 0000 fe7f 0300 90: 1027 2823 ffff ffff ffff ffff ffff ffff 98: ffff ffff XXXX f8f8 ffff ffff 4954 2032 a0: 2771 0000 0000 0000 0000 0000 0000 f87f a8: f87f f87f f87f f87f f87f 0000 fe7f 0300 b0: 1027 2823 ffff ffff ffff ffff ffff ffff b8: ffff ffff XXXX f8f8 ffff ffff 4954 2032Quoted 8 lines
c0: 2771 0000 0000 0000 0000 0000 0000 f87f c8: f87f f87f f87f f87f f87f 0000 fe7f 0300 d0: 1027 2823 ffff ffff ffff ffff ffff ffff d8: ffff ffff XXXX f8f8 ffff ffff 4954 2032 e0: 2771 0000 0000 0000 0000 0000 0000 f87f e8: f87f f87f f87f f87f f87f 0000 fe7f 0300 f0: 1027 2823 ffff ffff ffff ffff ffff ffff f8: ffff ffff XXXX f8f8 ffff ffff 4954 2032
Quoted 2 lines
Thanks a lot!
Feel free to completely ignore the first register dump I sent, I did it for the wrong device anyway :).
I had just gotten done reading this:
https://lkml.org/lkml/2015/12/10/459
and accidentally got EVMs confused did the test for the TMP461, but it does look like on startup register 0x16 can be used to differentiate the parts, if the TMP461 hadn't gone into a different driver.
Andrew
Guenter Roeck
maintainerRe: [PATCH v5 1/1] hwmon: Add support for INA3221 Triple Current/Voltage Monitors
Quoted 46 lines · Andrew F. Davis
Quoted 42 lines · Guenter Roeck
Quoted 32 lines · Andrew F. Davis
Quoted 4 lines · Guenter Roeck
The chip registers are 16 bit. Can you repeat the command using the "w" option ?
# i2cdump -y 2 0x40 w 0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f 00: 2771 0000 0000 0000 0000 0000 0000 f87f 08: f87f f87f f87f f87f f87f 0000 fe7f 0300 10: 1027 2823 ffff ffff ffff ffff ffff ffff 18: ffff ffff XXXX f8f8 ffff ffff 4954 2032 20: 2771 0000 0000 0000 0000 0000 0000 f87f 28: f87f f87f f87f f87f f87f 0000 fe7f 0300 30: 1027 2823 ffff ffff ffff ffff ffff ffff 38: ffff ffff XXXX f8f8 ffff ffff 4954 2032 40: 2771 0000 0000 0000 0000 0000 0000 f87f 48: f87f f87f f87f f87f f87f 0000 fe7f 0300 50: 1027 2823 ffff ffff ffff ffff ffff ffff 58: ffff ffff XXXX f8f8 ffff ffff 4954 2032 60: 2771 0000 0000 0000 0000 0000 0000 f87f 68: f87f f87f f87f f87f f87f 0000 fe7f 0300 70: 1027 2823 ffff ffff ffff ffff ffff ffff 78: ffff ffff XXXX f8f8 ffff ffff 4954 2032 80: 2771 0000 0000 0000 0000 0000 0000 f87f 88: f87f f87f f87f f87f f87f 0000 fe7f 0300 90: 1027 2823 ffff ffff ffff ffff ffff ffff 98: ffff ffff XXXX f8f8 ffff ffff 4954 2032 a0: 2771 0000 0000 0000 0000 0000 0000 f87f a8: f87f f87f f87f f87f f87f 0000 fe7f 0300 b0: 1027 2823 ffff ffff ffff ffff ffff ffff b8: ffff ffff XXXX f8f8 ffff ffff 4954 2032Quoted 8 lines
c0: 2771 0000 0000 0000 0000 0000 0000 f87f c8: f87f f87f f87f f87f f87f 0000 fe7f 0300 d0: 1027 2823 ffff ffff ffff ffff ffff ffff d8: ffff ffff XXXX f8f8 ffff ffff 4954 2032 e0: 2771 0000 0000 0000 0000 0000 0000 f87f e8: f87f f87f f87f f87f f87f 0000 fe7f 0300 f0: 1027 2823 ffff ffff ffff ffff ffff ffff f8: ffff ffff XXXX f8f8 ffff ffff 4954 2032Quoted 2 lines
Thanks a lot!
Quoted 9 lines
Feel free to completely ignore the first register dump I sent, I did it for the wrong device anyway :).
I had just gotten done reading this:
https://lkml.org/lkml/2015/12/10/459
and accidentally got EVMs confused did the test for the TMP461, but it does look like on startup register0x16can be used to differentiate the parts, if the TMP461 hadn't gone into a different driver.
Good catch.
That makes me wonder if we should move tmp461 support to the lm90 driver. What do you think ? Problem is that tmp461 will be auto-detected as tmp451 by the lm90 driver, which is less than perfect.
My test script for ina3221 only accepts a single value - 16380 - for the limit registers. Seems odd. I'll have to look into it some more.
Guenter