[PATCH] hwmon: ltc2990: support all measurement modes
Updated ltc2990 driver to support all possible measurement modes that the chip provides. Mode can be set through a device tree attribute or by writing to the "mode" sysfs attribute. Signed-off-by: Tom Levens--- .../devicetree/bindings/hwmon/ltc2990.txt | 15 + Documentation/hwmon/ltc2990| 25 ++- drivers/hwmon/Kconfig |7 +- drivers/hwmon/ltc2990.c| 268 +--- 4 files changed, 266 insertions(+), 49 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/ltc2990.txt diff --git a/Documentation/devicetree/bindings/hwmon/ltc2990.txt b/Documentation/devicetree/bindings/hwmon/ltc2990.txt new file mode 100644 index 000..0a17e8d --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/ltc2990.txt @@ -0,0 +1,15 @@ +ltc2990 + +Required properties: +- compatible: must be "lltc,ltc2990" +- reg: I2C slave address + +Optional properties: +- mode: measurement mode (0-7), see Documentation/hwmon/ltc2990 for details + +Example: +ltc2990@4c { + compatible = "lltc,ltc2990"; + mode = <7>; + reg = <0x4c>; +}; diff --git a/Documentation/hwmon/ltc2990 b/Documentation/hwmon/ltc2990 index c25211e..a97df88 100644 --- a/Documentation/hwmon/ltc2990 +++ b/Documentation/hwmon/ltc2990 @@ -8,6 +8,7 @@ Supported chips: Datasheet: http://www.linear.com/product/ltc2990 Author: Mike Looijmans +Tom Levens Description @@ -16,10 +17,8 @@ Description LTC2990 is a Quad I2C Voltage, Current and Temperature Monitor. The chip's inputs can measure 4 voltages, or two inputs together (1+2 and 3+4) can be combined to measure a differential voltage, which is typically used to -measure current through a series resistor, or a temperature. - -This driver currently uses the 2x differential mode only. In order to support -other modes, the driver will need to be expanded. +measure current through a series resistor, or a temperature with an external +diode. Usage Notes @@ -32,12 +31,20 @@ devices explicitly. Sysfs attributes +in0_input Voltage at Vcc pin in millivolt (range 2.5V to 5V) +temp1_input Internal chip temperature in millidegrees Celcius +mode Set the measurement mode (range 0 to 7) + +A subset of the following attributes are visible, depending on the programmed +measurement mode. + +in[1-4]_input Voltage at V[1-4] pin in millivolt +temp2_input External temperature sensor TR1 in millidegrees Celcius +temp3_input External temperature sensor TR2 in millidegrees Celcius +curr1_input Current in mA across V1-V2 assuming a 1mOhm sense resistor +curr2_input Current in mA across V3-V4 assuming a 1mOhm sense resistor + The "curr*_input" measurements actually report the voltage drop across the input pins in microvolts. This is equivalent to the current through a 1mOhm sense resistor. Divide the reported value by the actual sense resistor value in mOhm to get the actual value. - -in0_input Voltage at Vcc pin in millivolt (range 2.5V to 5V) -temp1_input Internal chip temperature in millidegrees Celcius -curr1_input Current in mA across v1-v2 assuming a 1mOhm sense resistor. -curr2_input Current in mA across v3-v4 assuming a 1mOhm sense resistor. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 45cef3d..f7096ca 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -699,15 +699,12 @@ config SENSORS_LTC2945 be called ltc2945. config SENSORS_LTC2990 - tristate "Linear Technology LTC2990 (current monitoring mode only)" + tristate "Linear Technology LTC2990" depends on I2C help If you say yes here you get support for Linear Technology LTC2990 I2C System Monitor. The LTC2990 supports a combination of voltage, - current and temperature monitoring, but in addition to the Vcc supply - voltage and chip temperature, this driver currently only supports - reading two currents by measuring two differential voltages across - series resistors. + current and temperature monitoring. This driver can also be built as a module. If so, the module will be called ltc2990. diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c index 8f8fe05..b6f910d 100644 --- a/drivers/hwmon/ltc2990.c +++ b/drivers/hwmon/ltc2990.c @@ -4,11 +4,10 @@ * Copyright (C) 2014 Topic Embedded Products * Author: Mike Looijmans * - * License: GPLv2 + * Copyright (C) 2016 European Organization for Nuclear Research (CERN) + * Author: Tom Levens * - * This driver assumes the chip is wired as a dual current monitor, and - * reports the voltage drop across two series resistors. It also reports - * the chip's internal temperature and Vcc power supply voltage. + * License: GPLv2 */ #include @@
Re: [PATCH] hwmon: ltc2990: support all measurement modes
On 11/16/2016 05:53 AM, Tom Levens wrote: Updated ltc2990 driver to support all possible measurement modes that the chip provides. Mode can be set through a device tree attribute or by writing to the "mode" sysfs attribute. Signed-off-by: Tom Levens--- .../devicetree/bindings/hwmon/ltc2990.txt | 15 + Documentation/hwmon/ltc2990| 25 ++- drivers/hwmon/Kconfig |7 +- drivers/hwmon/ltc2990.c| 268 +--- 4 files changed, 266 insertions(+), 49 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/ltc2990.txt diff --git a/Documentation/devicetree/bindings/hwmon/ltc2990.txt b/Documentation/devicetree/bindings/hwmon/ltc2990.txt new file mode 100644 index 000..0a17e8d --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/ltc2990.txt @@ -0,0 +1,15 @@ +ltc2990 + +Required properties: +- compatible: must be "lltc,ltc2990" +- reg: I2C slave address + +Optional properties: +- mode: measurement mode (0-7), see Documentation/hwmon/ltc2990 for details + This needs to be documented here. +Example: +ltc2990@4c { + compatible = "lltc,ltc2990"; + mode = <7>; + reg = <0x4c>; +}; Please submit as separate patch and copy devicetree maintainers for Ack. You'll probably want to specify valid modes and their impact. diff --git a/Documentation/hwmon/ltc2990 b/Documentation/hwmon/ltc2990 index c25211e..a97df88 100644 --- a/Documentation/hwmon/ltc2990 +++ b/Documentation/hwmon/ltc2990 @@ -8,6 +8,7 @@ Supported chips: Datasheet: http://www.linear.com/product/ltc2990 Author: Mike Looijmans +Tom Levens Description @@ -16,10 +17,8 @@ Description LTC2990 is a Quad I2C Voltage, Current and Temperature Monitor. The chip's inputs can measure 4 voltages, or two inputs together (1+2 and 3+4) can be combined to measure a differential voltage, which is typically used to -measure current through a series resistor, or a temperature. - -This driver currently uses the 2x differential mode only. In order to support -other modes, the driver will need to be expanded. +measure current through a series resistor, or a temperature with an external +diode. Usage Notes @@ -32,12 +31,20 @@ devices explicitly. Sysfs attributes +in0_input Voltage at Vcc pin in millivolt (range 2.5V to 5V) +temp1_input Internal chip temperature in millidegrees Celcius +mode Set the measurement mode (range 0 to 7) + The mode is determined by the hardware configuration. It does not make sense to have it user configurable. +A subset of the following attributes are visible, depending on the programmed +measurement mode. + +in[1-4]_input Voltage at V[1-4] pin in millivolt +temp2_input External temperature sensor TR1 in millidegrees Celcius +temp3_input External temperature sensor TR2 in millidegrees Celcius +curr1_input Current in mA across V1-V2 assuming a 1mOhm sense resistor +curr2_input Current in mA across V3-V4 assuming a 1mOhm sense resistor + The "curr*_input" measurements actually report the voltage drop across the input pins in microvolts. This is equivalent to the current through a 1mOhm sense resistor. Divide the reported value by the actual sense resistor value in mOhm to get the actual value. - -in0_input Voltage at Vcc pin in millivolt (range 2.5V to 5V) -temp1_input Internal chip temperature in millidegrees Celcius -curr1_input Current in mA across v1-v2 assuming a 1mOhm sense resistor. -curr2_input Current in mA across v3-v4 assuming a 1mOhm sense resistor. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 45cef3d..f7096ca 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -699,15 +699,12 @@ config SENSORS_LTC2945 be called ltc2945. config SENSORS_LTC2990 - tristate "Linear Technology LTC2990 (current monitoring mode only)" + tristate "Linear Technology LTC2990" depends on I2C help If you say yes here you get support for Linear Technology LTC2990 I2C System Monitor. The LTC2990 supports a combination of voltage, - current and temperature monitoring, but in addition to the Vcc supply - voltage and chip temperature, this driver currently only supports - reading two currents by measuring two differential voltages across - series resistors. + current and temperature monitoring. This driver can also be built as a module. If so, the module will be called ltc2990. diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c index 8f8fe05..b6f910d 100644 --- a/drivers/hwmon/ltc2990.c +++ b/drivers/hwmon/ltc2990.c @@ -4,11 +4,10 @@ * Copyright (C) 2014 Topic Embedded Products * Author: Mike Looijmans * - * License: GPLv2 + * Copyright (C) 2016 European Organization for