Re: [PATCH] hwmon: (pmbus) add VR12/VR13 mode support write paths

2019-10-01 Thread Patrick Williams
 On Tue, 01 Oct 2019 16:02:10 -0700 Guenter Roeck  
wrote 
 
 > > -val = clamp_val(val, 500, 1600); 
 > > +switch (data->info->vrm_version) { 
 > > +case vr11: 
 > > +val = clamp_val(val, 500, 1600); 
 > > +return 2 + DIV_ROUND_CLOSEST((1600 - val) * 100, 625); 
 > > +case vr12: 
 > > +val = clamp_val(val, 0, 1520); 
 > > +return ((val - 250) / 5) + 1; 
 > > +case vr13: 
 > > +val = clamp_val(val, 0, 2500); 
 > > +return ((val - 500) / 10) + 1; 
 >  
 > Both vr12 and vr13 converts low values into negative values, 
 > which are then converted into more or less random register 
 > values. That can not be correct. The resulting register values 
 > must always be valid. 
 >  
 > Guenter 

Thanks for catching this.  It may be as simple as me adjusting the lower
bound on the clamp_val.  I’ll check with one of the device specs and
confirm the appropriate behavior on the lower bounds.



Re: [PATCH v2 2/2] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips

2019-10-01 Thread Guenter Roeck
On Tue, Oct 01, 2019 at 09:36:30PM +, Tremblay, Eric wrote:
> > On Tue, Oct 01, 2019 at 05:50:32PM +, Tremblay, Eric wrote:
> > > hwmon: Add DT bindings for TMP513 driver
> > >
> > > Signed-off-by: Eric Tremblay 
> > > ---
> > >  .../devicetree/bindings/hwmon/tmp513.txt  | 33 +++
> > >  1 file changed, 33 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/hwmon/tmp513.txt
> > >
> > > diff --git a/Documentation/devicetree/bindings/hwmon/tmp513.txt
> > > b/Documentation/devicetree/bindings/hwmon/tmp513.txt
> > > new file mode 100644
> > > index ..0f61793cbf2f
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/hwmon/tmp513.txt
> > > @@ -0,0 +1,33 @@
> > > +TMP513 system monitor sensor
> > > +-
> > > +
> > > +Require 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-uohm : The shunt resistor value in uOhm.
> > > +
> > > +Optional properties:
> > > +- bus-voltage-range: 32V or 16V, default to 32V.
> > > +- max-expected-current-ma: Maximum expected current value. Default to 
> > > max possible value.
> > > +- pga-gain: The gain value for the PGA function. This is 8, 4, 2 or 1. 
> > > Default to 8.
> > > +- temp_2_nfactor: nFactor for remote channel 1. Value according to Table 
> > > 11 in datasheet.
> > > +- temp_3_nfactor: nFactor for remote channel 2. Value according to Table 
> > > 11 in datasheet.
> > > +- temp_4_nfactor: nFactor for remote channel 3. Value according to Table 
> > > 11 in datasheet,
> > > +   TMP513 only.
> > > +- temp_hysteresis: Hystereris for temperature limits.
> > 
> > There is a standard sysfs attribute for hysteresis values, and I assume 
> > this is one parameter that users might want to change at
> > runtime. Why not use it ?
> 
> In those sensors, the hysteresis setting is global to all channels. Is it 
> still a standard sysfs attribute in that case ? If yes, should I name it
> temp_crit_hyst to show that is a global parameter ?

That is the case for many chips. The most common solution is to support
the attribute for all channels and make only the first channel writeable.
When doing that, add a note to the documentation indicating that writing
one attribute affects all attributes.

temp_crit_hyst doesn't help because it is non-standard and the "sensors"
command won't see it.

Guenter

> > 
> > > +
> > > +Example:
> > > + tmp513@5c {
> > > +   compatible = "ti,tmp513";
> > > +   reg = <0x5C>;
> > > +   shunt-resistor-uohm = <330>;
> > > +   bus-voltage-range = <32>;
> > > +   pga-gain = <8>;
> > > +   max-expected-current-ma = <100>;
> > > +   temp_2_nfactor = <0x01>;
> > > +   temp_3_nfactor = <0x02>;
> > > +   temp_4_nfactor = <0x03>;
> > > +   temp_hysteresis = <5>;
> > > + };
> > > --
> > > 2.17.1
> > >


Re: ABI for these two registers?

2019-10-01 Thread Nicolin Chen
Hello Guenter,

It's been nearly three weeks. Would it be possible for you to
provide some advice on my latest questions? I'd like to write
code and submit changes once ABI is confirmed...

Thank you!

On Thu, Sep 12, 2019 at 05:12:38PM -0700, Nicolin Chen wrote:

> > > > > > Datasheet: http://www.ti.com/lit/ds/symlink/ina3221.pdf
> > > > > > (At page 32, chapter 8.6.2.14 and 8.6.2.15)
> > > > > > 
> > > > > > I have two registers that I need to expose to user space:
> > > > > > Shunt-Voltage-Sum and Shunt-Voltage-Limit registers
> > > > > > 
> > > > > > Right now in[123]_input of INA3221 are for voltage channels
> > > > > > while in[456]_input are for Shunt voltage channels.
> > > > > > 
> > > > > > So can I just use in7_input and in7_crit for them?
> > > > > > 
> > > > > Doesn't Shunt-Voltage-Limit apply to in[456]_input ?
> > > > > If so, the limit should be attached to those.
> > > > 
> > > > The initial patch of ina3221 driver applied Shunt-Voltage-Limits,
> > > > being named as "Critical Alert Limit Registers" in the datasheet,
> > > > to curr[123]_crit, corresponding to curr[123] and in[456]_input.
> > > > 
> > > > And this Shunt-Voltage-Limit-Sum is more related to the reading
> > > > from Shunt-Voltage-Sum, which we just agreed it to be in7_input.
> > > > 
> > > You didn't say Shunt-Voltage-Limit-Sum earlier. You said
> > 
> > Ahright...it's my fault. Sorry.
> > 
> > > Shunt-Voltage-Limit. I would agree that Shunt-Voltage-Limit-Sum is
> > > associated with Shunt-Voltage-Sum, but, again, that is not what you
> > > said earlier. Confused :-(
> > 
> > So, those two should be in7_input and in7_crit?
> 
> And a couple of more questions upon it:
> 
> 1) There are 3 control bits for the summation of this
>shunt-voltage-sum register to enable corresponding
>input channels. But in7_enable only allows users to
>en/disable all three channels at the same time. So
>how should I attach three enable bits using ABI?
>Or should I create a device-specific sysfs node?
> 
> 2) We have a requirement of providing current-sum and
>current-limit-sum nodes, for use cases where those
>enabled channels use same value shunt resistors.
>It's similar to provide curr[1-3]_crit by dividing
>shunt[123]_resistor from in[456]_input. So could I
>deploy curr4_input and curr4_crit nodes for this
>requirement?


RE: [PATCH v2 2/2] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips

2019-10-01 Thread Tremblay, Eric
> On Tue, Oct 01, 2019 at 05:50:32PM +, Tremblay, Eric wrote:
> > hwmon: Add DT bindings for TMP513 driver
> >
> > Signed-off-by: Eric Tremblay 
> > ---
> >  .../devicetree/bindings/hwmon/tmp513.txt  | 33 +++
> >  1 file changed, 33 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/hwmon/tmp513.txt
> >
> > diff --git a/Documentation/devicetree/bindings/hwmon/tmp513.txt
> > b/Documentation/devicetree/bindings/hwmon/tmp513.txt
> > new file mode 100644
> > index ..0f61793cbf2f
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/hwmon/tmp513.txt
> > @@ -0,0 +1,33 @@
> > +TMP513 system monitor sensor
> > +-
> > +
> > +Require 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-uohm : The shunt resistor value in uOhm.
> > +
> > +Optional properties:
> > +- bus-voltage-range: 32V or 16V, default to 32V.
> > +- max-expected-current-ma: Maximum expected current value. Default to max 
> > possible value.
> > +- pga-gain: The gain value for the PGA function. This is 8, 4, 2 or 1. 
> > Default to 8.
> > +- temp_2_nfactor: nFactor for remote channel 1. Value according to Table 
> > 11 in datasheet.
> > +- temp_3_nfactor: nFactor for remote channel 2. Value according to Table 
> > 11 in datasheet.
> > +- temp_4_nfactor: nFactor for remote channel 3. Value according to Table 
> > 11 in datasheet,
> > + TMP513 only.
> > +- temp_hysteresis: Hystereris for temperature limits.
> 
> There is a standard sysfs attribute for hysteresis values, and I assume this 
> is one parameter that users might want to change at
> runtime. Why not use it ?

In those sensors, the hysteresis setting is global to all channels. Is it still 
a standard sysfs attribute in that case ? If yes, should I name it
temp_crit_hyst to show that is a global parameter ?
> 
> > +
> > +Example:
> > +   tmp513@5c {
> > + compatible = "ti,tmp513";
> > + reg = <0x5C>;
> > + shunt-resistor-uohm = <330>;
> > + bus-voltage-range = <32>;
> > + pga-gain = <8>;
> > + max-expected-current-ma = <100>;
> > + temp_2_nfactor = <0x01>;
> > + temp_3_nfactor = <0x02>;
> > + temp_4_nfactor = <0x03>;
> > + temp_hysteresis = <5>;
> > +   };
> > --
> > 2.17.1
> >


Re: [PATCH v2 2/2] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips

2019-10-01 Thread Guenter Roeck
On Tue, Oct 01, 2019 at 05:50:32PM +, Tremblay, Eric wrote:
> hwmon: Add DT bindings for TMP513 driver
> 
> Signed-off-by: Eric Tremblay 
> ---
>  .../devicetree/bindings/hwmon/tmp513.txt  | 33 +++
>  1 file changed, 33 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/hwmon/tmp513.txt
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/tmp513.txt 
> b/Documentation/devicetree/bindings/hwmon/tmp513.txt
> new file mode 100644
> index ..0f61793cbf2f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/hwmon/tmp513.txt
> @@ -0,0 +1,33 @@
> +TMP513 system monitor sensor
> +-
> +
> +Require 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-uohm : The shunt resistor value in uOhm.
> +
> +Optional properties:
> +- bus-voltage-range: 32V or 16V, default to 32V.
> +- max-expected-current-ma: Maximum expected current value. Default to max 
> possible value.
> +- pga-gain: The gain value for the PGA function. This is 8, 4, 2 or 1. 
> Default to 8.
> +- temp_2_nfactor: nFactor for remote channel 1. Value according to Table 11 
> in datasheet.
> +- temp_3_nfactor: nFactor for remote channel 2. Value according to Table 11 
> in datasheet.
> +- temp_4_nfactor: nFactor for remote channel 3. Value according to Table 11 
> in datasheet,
> +   TMP513 only.
> +- temp_hysteresis: Hystereris for temperature limits.

There is a standard sysfs attribute for hysteresis values, and I assume this
is one parameter that users might want to change at runtime. Why not use it ?

> +
> +Example:
> + tmp513@5c {
> +   compatible = "ti,tmp513";
> +   reg = <0x5C>;
> +   shunt-resistor-uohm = <330>;
> +   bus-voltage-range = <32>;
> +   pga-gain = <8>;
> +   max-expected-current-ma = <100>;
> +   temp_2_nfactor = <0x01>;
> +   temp_3_nfactor = <0x02>;
> +   temp_4_nfactor = <0x03>;
> +   temp_hysteresis = <5>;
> + };
> -- 
> 2.17.1
> 


Re: [PATCH v2 1/2] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips

2019-10-01 Thread Guenter Roeck
On Tue, Oct 01, 2019 at 05:49:52PM +, Tremblay, Eric wrote:
> hwmon: Add driver for Texas Instruments TMP512/513 sensor
> 
> 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 
> ---
>  Documentation/hwmon/tmp513.rst |  98 
>  MAINTAINERS|   7 +
>  drivers/hwmon/Kconfig  |  10 +
>  drivers/hwmon/Makefile |   1 +
>  drivers/hwmon/tmp513.c | 800 +
>  5 files changed, 916 insertions(+)
>  create mode 100644 Documentation/hwmon/tmp513.rst
>  create mode 100644 drivers/hwmon/tmp513.c
> 
> diff --git a/Documentation/hwmon/tmp513.rst b/Documentation/hwmon/tmp513.rst
> new file mode 100644
> index ..3ba6f6f14220
> --- /dev/null
> +++ b/Documentation/hwmon/tmp513.rst
> @@ -0,0 +1,98 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +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 sensors. 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 driver exports the temperature values via the following sysfs files:
> +
> +**temp[1-4]_input**
> +
> +**temp[1-4]_crit**
> +
> +**temp[1-4]_crit_alarm**
> +
> +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 depending on the pga gain.
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 296de2b51c83..1d13e5be6661 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -16369,6 +16369,13 @@ S:   Maintained
>  F:   Documentation/hwmon/tmp401.rst
>  F:   drivers/hwmon/tmp401.c
>  
> +TMP513 HARDWARE MONITOR DRIVER
> +M:   Eric Tremblay 
> +L:   linux-hwmon@vger.kernel.org
> +S:   Maintained
> +F:   Documentation/hwmon/tmp513.rst
> +F:   drivers/hwmon/tmp513.c
> +
>  TMPFS (SHMEM FILESYSTEM)
>  M:   Hugh Dickins 
>  L:   linux...@kvack.org
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index 13a6b4afb4b3..926e3c98dbdf 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -1709,6 +1709,16 @@ config SENSORS_TMP421
> This driver can also be built as a module. If so, the module
> will be called tmp421.
>  
> +config SENSORS_TMP513
> + tristate "Texas Instruments TMP513 and compatibles"
> + depends on I2C
> + help
> +   If you say yes here you get support for Texas Instruments TMP512,
> +   and TMP513 temperature and power supply 

[PATCH v2 2/2] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips

2019-10-01 Thread Tremblay, Eric
hwmon: Add DT bindings for TMP513 driver

Signed-off-by: Eric Tremblay 
---
 .../devicetree/bindings/hwmon/tmp513.txt  | 33 +++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/tmp513.txt

diff --git a/Documentation/devicetree/bindings/hwmon/tmp513.txt 
b/Documentation/devicetree/bindings/hwmon/tmp513.txt
new file mode 100644
index ..0f61793cbf2f
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/tmp513.txt
@@ -0,0 +1,33 @@
+TMP513 system monitor sensor
+-
+
+Require 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-uohm : The shunt resistor value in uOhm.
+
+Optional properties:
+- bus-voltage-range: 32V or 16V, default to 32V.
+- max-expected-current-ma: Maximum expected current value. Default to max 
possible value.
+- pga-gain: The gain value for the PGA function. This is 8, 4, 2 or 1. Default 
to 8.
+- temp_2_nfactor: nFactor for remote channel 1. Value according to Table 11 in 
datasheet.
+- temp_3_nfactor: nFactor for remote channel 2. Value according to Table 11 in 
datasheet.
+- temp_4_nfactor: nFactor for remote channel 3. Value according to Table 11 in 
datasheet,
+ TMP513 only.
+- temp_hysteresis: Hystereris for temperature limits.
+
+Example:
+   tmp513@5c {
+ compatible = "ti,tmp513";
+ reg = <0x5C>;
+ shunt-resistor-uohm = <330>;
+ bus-voltage-range = <32>;
+ pga-gain = <8>;
+ max-expected-current-ma = <100>;
+ temp_2_nfactor = <0x01>;
+ temp_3_nfactor = <0x02>;
+ temp_4_nfactor = <0x03>;
+ temp_hysteresis = <5>;
+   };
-- 
2.17.1



[PATCH v2 1/2] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips

2019-10-01 Thread Tremblay, Eric
hwmon: Add driver for Texas Instruments TMP512/513 sensor

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 
---
 Documentation/hwmon/tmp513.rst |  98 
 MAINTAINERS|   7 +
 drivers/hwmon/Kconfig  |  10 +
 drivers/hwmon/Makefile |   1 +
 drivers/hwmon/tmp513.c | 800 +
 5 files changed, 916 insertions(+)
 create mode 100644 Documentation/hwmon/tmp513.rst
 create mode 100644 drivers/hwmon/tmp513.c

diff --git a/Documentation/hwmon/tmp513.rst b/Documentation/hwmon/tmp513.rst
new file mode 100644
index ..3ba6f6f14220
--- /dev/null
+++ b/Documentation/hwmon/tmp513.rst
@@ -0,0 +1,98 @@
+.. SPDX-License-Identifier: GPL-2.0
+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 sensors. 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 driver exports the temperature values via the following sysfs files:
+
+**temp[1-4]_input**
+
+**temp[1-4]_crit**
+
+**temp[1-4]_crit_alarm**
+
+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 depending on the pga gain.
diff --git a/MAINTAINERS b/MAINTAINERS
index 296de2b51c83..1d13e5be6661 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16369,6 +16369,13 @@ S: Maintained
 F: Documentation/hwmon/tmp401.rst
 F: drivers/hwmon/tmp401.c
 
+TMP513 HARDWARE MONITOR DRIVER
+M: Eric Tremblay 
+L: linux-hwmon@vger.kernel.org
+S: Maintained
+F: Documentation/hwmon/tmp513.rst
+F: drivers/hwmon/tmp513.c
+
 TMPFS (SHMEM FILESYSTEM)
 M: Hugh Dickins 
 L: linux...@kvack.org
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 13a6b4afb4b3..926e3c98dbdf 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1709,6 +1709,16 @@ config SENSORS_TMP421
  This driver can also be built as a module. If so, the module
  will be called tmp421.
 
+config SENSORS_TMP513
+   tristate "Texas Instruments TMP513 and compatibles"
+   depends on I2C
+   help
+ If you say yes here you get support for Texas Instruments TMP512,
+ and TMP513 temperature and power supply sensor chips.
+
+ This driver can also be built as a module. If so, the module
+ will be called tmp513.
+
 config SENSORS_VEXPRESS
tristate "Versatile Express"
depends on VEXPRESS_CONFIG
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 40c036ea45e6..762642291914 100644
--- a/drivers/hwmon/Makefile

[PATCH v2 0/2] hwmon: Add driver for Texas Instruments TMP512/513 sensor chips

2019-10-01 Thread Tremblay, Eric
Version two of the driver for Texas Instruments TMP512/513 sensors.

Thank you very much for version one review. I reworked the driver
based on the comments left on the first version.

Main changes from version 1:
- Use the with_info API instead of sysfs attributes.
- Remove non-standard attributes and raw value.
- Move settings that were non-standard attributes to
  device tree, update documentation as well.
- Fix coding style issues

Eric Tremblay (2):
  Add driver for Texas Instruments TMP512/513 sensor chips.
  Add DT bindings for TMP513 driver

 .../devicetree/bindings/hwmon/tmp513.txt  |  33 +
 Documentation/hwmon/tmp513.rst|  98 +++
 MAINTAINERS   |   7 +
 drivers/hwmon/Kconfig |  10 +
 drivers/hwmon/Makefile|   1 +
 drivers/hwmon/tmp513.c| 800 ++
 6 files changed, 949 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/tmp513.txt
 create mode 100644 Documentation/hwmon/tmp513.rst
 create mode 100644 drivers/hwmon/tmp513.c

-- 
2.17.1







[PATCH] hwmon: (pmbus) add VR12/VR13 mode support write paths

2019-10-01 Thread Patrick Williams
pmbus_core supported VR11/VR12/VR13 modes when reading
VID-formatted registers, but the write path only supported
VR11 translations.  Add support for VR12 and VR13 to
'data2reg_vid' for translating these formats.  This is the
inverse of 'reg2data_vid'.

Signed-off-by: Patrick Williams 
---
 drivers/hwmon/pmbus/pmbus_core.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 8470097907bc..f0d696552142 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -845,9 +845,19 @@ static u16 pmbus_data2reg_direct(struct pmbus_data *data,
 static u16 pmbus_data2reg_vid(struct pmbus_data *data,
  struct pmbus_sensor *sensor, long val)
 {
-   val = clamp_val(val, 500, 1600);
+   switch (data->info->vrm_version) {
+   case vr11:
+   val = clamp_val(val, 500, 1600);
+   return 2 + DIV_ROUND_CLOSEST((1600 - val) * 100, 625);
+   case vr12:
+   val = clamp_val(val, 0, 1520);
+   return ((val - 250) / 5) + 1;
+   case vr13:
+   val = clamp_val(val, 0, 2500);
+   return ((val - 500) / 10) + 1;
+   }
 
-   return 2 + DIV_ROUND_CLOSEST((1600 - val) * 100, 625);
+   return 0;
 }
 
 static u16 pmbus_data2reg(struct pmbus_data *data,
-- 
2.17.2 (Apple Git-113)