[PATCH v1 5/9] power: supply: max17042_battery: Keep only critical alerts during suspend
From: Vincent Cloutier
Date: Mon Apr 06 2026 - 17:01:00 EST
From: Vincent Cloutier <vincent@xxxxxxxxxxx>
Disable MAX17055 dSOCi while the system is suspended so state-of-charge changes do not wake the system repeatedly. Leave SALRT armed for the critical low-battery threshold and restore runtime alert handling on resume.
Signed-off-by: Vincent Cloutier <vincent@xxxxxxxxxxx>
---
drivers/power/supply/max17042_battery.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 09bb1babb0d6..b93fedf183b1 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -903,6 +903,16 @@ static void max17042_enable_soc_alerts(struct max17042_chip *chip)
max17042_set_soc_threshold(chip, 1);
}
+static void max17042_suspend_soc_alerts(struct max17042_chip *chip)
+{
+ if (chip->chip_type != MAXIM_DEVICE_TYPE_MAX17055)
+ return;
+
+ regmap_update_bits(chip->regmap, MAX17055_Config2,
+ CFG2_DSOCI_BIT_ENBL, 0);
+ max17042_set_critical_soc_threshold(chip);
+}
+
static irqreturn_t max17042_thread_handler(int id, void *dev)
{
struct max17042_chip *chip = dev;
@@ -1220,6 +1230,7 @@ static int max17042_suspend(struct device *dev)
*/
if (chip->irq) {
disable_irq(chip->irq);
+ max17042_suspend_soc_alerts(chip);
enable_irq_wake(chip->irq);
}
@@ -1233,8 +1244,8 @@ static int max17042_resume(struct device *dev)
if (chip->irq) {
disable_irq_wake(chip->irq);
enable_irq(chip->irq);
- /* re-program the SOC thresholds to 1% change */
- max17042_set_soc_threshold(chip, 1);
+ /* re-arm runtime SOC alerts */
+ max17042_enable_soc_alerts(chip);
}
return 0;
--
2.53.0