]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hwmon: (ina2xx) Set alert latch
authorGuenter Roeck <linux@roeck-us.net>
Tue, 23 Jul 2024 23:17:02 +0000 (16:17 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 30 Aug 2024 15:34:23 +0000 (08:34 -0700)
Alerts should only be cleared after reported, not immediately after the
alert condition has been cleared. Set the latch enable bit to keep alerts
latched until the alert register has been read from the chip.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina2xx.c

index a9e3b23445b448fdbea320557bcb2ea63c198647..98338b7e74376da0f923a7d9024ed7c616e3dca4 100644 (file)
@@ -67,6 +67,7 @@
 
 #define INA226_READ_AVG(reg)           FIELD_GET(INA226_AVG_RD_MASK, reg)
 
+#define INA226_ALERT_LATCH_ENABLE      BIT(0)
 #define INA226_ALERT_POLARITY          BIT(1)
 
 /* bit number of alert functions in Mask/Enable Register */
@@ -640,8 +641,10 @@ static int ina2xx_init(struct device *dev, struct ina2xx_data *data)
        if (data->chip == ina226) {
                bool active_high = device_property_read_bool(dev, "ti,alert-polarity-active-high");
 
-               regmap_update_bits(regmap, INA226_MASK_ENABLE, INA226_ALERT_POLARITY,
-                                  FIELD_PREP(INA226_ALERT_POLARITY, active_high));
+               regmap_update_bits(regmap, INA226_MASK_ENABLE,
+                                  INA226_ALERT_LATCH_ENABLE | INA226_ALERT_POLARITY,
+                                  INA226_ALERT_LATCH_ENABLE |
+                                               FIELD_PREP(INA226_ALERT_POLARITY, active_high));
        }
 
        /*