Skip to content

hwmon: (ina3221) Add support for channel summation disable

Steve Best requested to merge sfbest/centos-stream-9:RHEL-1899 into main

JIRA: https://issues.redhat.com/browse/RHEL-1899

Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=56673060

Tested: Did sanity sensors testing on (nvidia-jetson-agx-orin-05) system.

commit 7b64906c98fe503338066b97d3ff2dad65debf2b Author: Ninad Malwade nmalwade@nvidia.com Date: Fri Sep 29 11:36:49 2023 +0100

hwmon: (ina3221) Add support for channel summation disable

The INA3221 allows the Critical alert pin to be controlled by the
summation control function. This function adds the single
shunt-voltage conversions for the desired channels in order to compare
the combined sum to the programmed limit. The Shunt-Voltage Sum Limit
register contains the programmed value that is compared to the value in
the Shunt-Voltage Sum register in order to determine if the total summed
limit is exceeded. If the shunt-voltage sum limit value is exceeded, the
Critical alert pin pulls low.

For the summation limit to have a meaningful value, we have to use the
same shunt-resistor value on all included channels. Unless equal
shunt-resistor values are used for each channel, the summation control
function cannot be used and it is not enabled by the driver.

To address this, add support to disable the summation of specific
channels via device tree property "ti,summation-disable". The channel
which has this property would be excluded from the calculation of
summation control function.

For example, summation control function calculates Shunt-Voltage Sum as:

- input_shunt_voltage_summation = input_shunt_voltage_channel1
                                + input_shunt_voltage_channel2
                                + input_shunt_voltage_channel3

If we want the summation to only use channel1 and channel3, we can add
'ti,summation-disable' property in device tree node for channel2. Then
the calculation will skip channel2.

- input_shunt_voltage_summation = input_shunt_voltage_channel1
                                + input_shunt_voltage_channel3

Note that we only want the channel to be skipped for summation control
function rather than completely disabled. Therefore, even if we add the
property 'ti,summation-disable', the channel is still enabled and
functional.

Finally, create debugfs entries that display if summation is disabled
for each of the channels.

Signed-off-by: Rajkumar Kasirajan <rkasirajan@nvidia.com>
Signed-off-by: Ninad Malwade <nmalwade@nvidia.com>
Co-developed-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Link: https://lore.kernel.org/r/20230929103650.86074-4-jonathanh@nvidia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Signed-off-by: Steve Best sbest@redhat.com

Merge request reports