• Ninad Malwade's avatar
    hwmon: (ina3221) Add support for channel summation disable · 7b64906c
    Ninad Malwade authored
    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: default avatarRajkumar Kasirajan <rkasirajan@nvidia.com>
    Signed-off-by: default avatarNinad Malwade <nmalwade@nvidia.com>
    Co-developed-by: default avatarJon Hunter <jonathanh@nvidia.com>
    Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
    Link: https://lore.kernel.org/r/20230929103650.86074-4-jonathanh@nvidia.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    7b64906c
ina3221.c 27.3 KB