Re: [PATCH] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips
On Mon, Sep 23, 2019 at 07:29:48PM +, Tremblay, Eric wrote: > Add driver for Texas Instruments TMP512/513 sensor chips. > > TI's TMP512/513 are I2C/SMBus system monitor chips. These chips > monitor the supply voltage, supply current, power consumption and > provide one local and up to three (TMP513) remote temperature sensors. > > It has been tested using a TI TMP513 development kit (TMP513EVM) > Not a complete review, and sorry for the late reply. > Signed-off-by: Eric Tremblay > --- > .../devicetree/bindings/hwmon/tmp513.txt | 24 + > Documentation/hwmon/tmp513.rst| 118 +++ > MAINTAINERS | 7 + > drivers/hwmon/Kconfig | 10 + > drivers/hwmon/Makefile| 1 + > drivers/hwmon/tmp513.c| 910 ++ > 6 files changed, 1070 insertions(+) > create mode 100644 Documentation/devicetree/bindings/hwmon/tmp513.txt > create mode 100644 Documentation/hwmon/tmp513.rst > create mode 100644 drivers/hwmon/tmp513.c > > diff --git a/Documentation/devicetree/bindings/hwmon/tmp513.txt > b/Documentation/devicetree/bindings/hwmon/tmp513.txt > new file mode 100644 > index ..9f6498607736 > --- /dev/null > +++ b/Documentation/devicetree/bindings/hwmon/tmp513.txt > @@ -0,0 +1,24 @@ > +TMP513 system monitor sensor > +- > + > +Requires node properties: > +- compatible: one of > + "ti,tmp512" > + "ti,tmp513" > +- reg : the I2C address of the device. This is 0x5c, 0x5d, 0x5e, or 0x5f. > +- shunt-resistor-mohm : The shunt resistor value in mohm. > + > +Optional properties: > +- bus-voltage-range: 32V or 16V, default to 32V. > +- pga-gain: The gain value for the PGA function. This is 8, 4, 2 or 1. > Default to 8. > +- max-expected-current-ma: Maximum current value that is expected. Default > to max value. > + > +Example: > + tmp513@5c { > + compatible = "ti,tmp513"; > + reg = <0x5C>; > + shunt-resistor-mohm = <330>; We commonly have shunt resistor values in uOhm since sometimes fractions of mOhm are used. > + bus-voltage-range = <32>; > + pga-gain = <8>; > + max-expected-current-ma = <100>; > + }; > diff --git a/Documentation/hwmon/tmp513.rst b/Documentation/hwmon/tmp513.rst > new file mode 100644 > index ..adc99e79287b > --- /dev/null > +++ b/Documentation/hwmon/tmp513.rst > @@ -0,0 +1,118 @@ > +Kernel driver tmp513 > + > + > +Supported chips: > + > + * Texas Instruments TMP512 > + > +Prefix: 'tmp512' > + > +Datasheet: http://www.ti.com/lit/ds/symlink/tmp512.pdf > + > + * Texas Instruments TMP513 > + > +Prefix: 'tmp513' > + > +Datasheet: http://www.ti.com/lit/ds/symlink/tmp513.pdf > + > +Authors: > + > + Eric Tremblay > + > +Description > +--- > + > +This driver implements support for Texas Instruments TMP512, and TMP513 > +temperature and power supply sensor chips. These chips implement one > +local and up to three (TMP513) temperature sensor. The chips also implement > +power supply monitoring such as shunt voltage, shunt current, bus voltage > +and power consumption. > + > +The temperatures are measured in degrees Celsius with a range of > +-40 to + 125 degress Celcius with a resolution of 0.0625 degree C. > +The nfactor of the diode can by configured on each channel and a > +global hysteresis value for the alarms can be set. > + > +The driver exports the temperature values via the following sysfs files: > + > +**temp[1-4]_input** > + > +**temp[1-4]_crit** > + > +**temp[1-4]_crit_alarm** > + > +**temp[1-4]_nfactor** > + This is a nonstandard attribute. As outlined in Documentation/hwmon/submitting-patches.rst, please provide a rationale why this needs to be confiurable at runtime (vs. devicetree). > +**temp_hyst** > + > +The shunt voltage is measured in micro volts. There are four configurable > +range: 320mV, 160mV, 80mV and 40mV all of them with a resolution of 10 uV. > +The range depends on the pga gain specified in the device tree > +with "pga-gain" (default to 8). The range will be equal to pga gain > +multiply by 40mV. > + > +The driver exports the shunt voltage values via the following sysFs files: > + > +**in0_input** > + > +**in0_lcrit** > + > +**in0_lcrit_alarm** > + > +**in0_crit** > + > +**in0_crit_alarm** > + > +The bus voltage is measured in milli volts. There are two configuable > +range: 32V and 16V both with a resolution of 4mV. It can be configured in the > +device tree with "bus-voltage-range" (default to 32V); > + > +The driver exports the bus voltage values via the following sysFs files: > + > +**in0_input** > + > +**in0_lcrit** > + > +**in0_lcrit_alarm** > + > +**in0_crit** > + > +**in0_crit_alarm** > + > +The power and the currents range and resolution depends on the calibration > +register value. Those values are calculate by the
[PATCH] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips
Add driver for Texas Instruments TMP512/513 sensor chips. TI's TMP512/513 are I2C/SMBus system monitor chips. These chips monitor the supply voltage, supply current, power consumption and provide one local and up to three (TMP513) remote temperature sensors. It has been tested using a TI TMP513 development kit (TMP513EVM) Signed-off-by: Eric Tremblay --- .../devicetree/bindings/hwmon/tmp513.txt | 24 + Documentation/hwmon/tmp513.rst| 118 +++ MAINTAINERS | 7 + drivers/hwmon/Kconfig | 10 + drivers/hwmon/Makefile| 1 + drivers/hwmon/tmp513.c| 910 ++ 6 files changed, 1070 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/tmp513.txt create mode 100644 Documentation/hwmon/tmp513.rst create mode 100644 drivers/hwmon/tmp513.c diff --git a/Documentation/devicetree/bindings/hwmon/tmp513.txt b/Documentation/devicetree/bindings/hwmon/tmp513.txt new file mode 100644 index ..9f6498607736 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/tmp513.txt @@ -0,0 +1,24 @@ +TMP513 system monitor sensor +- + +Requires node properties: +- compatible: one of + "ti,tmp512" + "ti,tmp513" +- reg : the I2C address of the device. This is 0x5c, 0x5d, 0x5e, or 0x5f. +- shunt-resistor-mohm : The shunt resistor value in mohm. + +Optional properties: +- bus-voltage-range: 32V or 16V, default to 32V. +- pga-gain: The gain value for the PGA function. This is 8, 4, 2 or 1. Default to 8. +- max-expected-current-ma: Maximum current value that is expected. Default to max value. + +Example: + tmp513@5c { + compatible = "ti,tmp513"; + reg = <0x5C>; + shunt-resistor-mohm = <330>; + bus-voltage-range = <32>; + pga-gain = <8>; + max-expected-current-ma = <100>; + }; diff --git a/Documentation/hwmon/tmp513.rst b/Documentation/hwmon/tmp513.rst new file mode 100644 index ..adc99e79287b --- /dev/null +++ b/Documentation/hwmon/tmp513.rst @@ -0,0 +1,118 @@ +Kernel driver tmp513 + + +Supported chips: + + * Texas Instruments TMP512 + +Prefix: 'tmp512' + +Datasheet: http://www.ti.com/lit/ds/symlink/tmp512.pdf + + * Texas Instruments TMP513 + +Prefix: 'tmp513' + +Datasheet: http://www.ti.com/lit/ds/symlink/tmp513.pdf + +Authors: + + Eric Tremblay + +Description +--- + +This driver implements support for Texas Instruments TMP512, and TMP513 +temperature and power supply sensor chips. These chips implement one +local and up to three (TMP513) temperature sensor. The chips also implement +power supply monitoring such as shunt voltage, shunt current, bus voltage +and power consumption. + +The temperatures are measured in degrees Celsius with a range of +-40 to + 125 degress Celcius with a resolution of 0.0625 degree C. +The nfactor of the diode can by configured on each channel and a +global hysteresis value for the alarms can be set. + +The driver exports the temperature values via the following sysfs files: + +**temp[1-4]_input** + +**temp[1-4]_crit** + +**temp[1-4]_crit_alarm** + +**temp[1-4]_nfactor** + +**temp_hyst** + +The shunt voltage is measured in micro volts. There are four configurable +range: 320mV, 160mV, 80mV and 40mV all of them with a resolution of 10 uV. +The range depends on the pga gain specified in the device tree +with "pga-gain" (default to 8). The range will be equal to pga gain +multiply by 40mV. + +The driver exports the shunt voltage values via the following sysFs files: + +**in0_input** + +**in0_lcrit** + +**in0_lcrit_alarm** + +**in0_crit** + +**in0_crit_alarm** + +The bus voltage is measured in milli volts. There are two configuable +range: 32V and 16V both with a resolution of 4mV. It can be configured in the +device tree with "bus-voltage-range" (default to 32V); + +The driver exports the bus voltage values via the following sysFs files: + +**in0_input** + +**in0_lcrit** + +**in0_lcrit_alarm** + +**in0_crit** + +**in0_crit_alarm** + +The power and the currents range and resolution depends on the calibration +register value. Those values are calculate by the hardware using those +formula: + +Current = (ShuntVoltage * CalibrationRegister) / 4096 +Power = (Current * BusVoltage) / 5000 + +The driver exports the current and power values via the following sysFs files: + +**curr0_input** + +**power1_input** + +**power1_crit** + +**power1_crit_alarm** + +The calibration process follow the procedure of the datasheet (without overflow) +and depend on the shunt resistor value, needed in the device tree "shunt-resistor-mohm". +It also depends on the pga gain and the maximum expected current, also specified from +the device tree "max-expected-current-ma". If not specified it default to the maximum +possible current