Skip to content

Commit 9838011

Browse files
macromorgansre
authored andcommitted
power: supply: axp20x_battery: Fix fault handling for AXP717
Correct the fault handling for the AXP717 by changing the i2c write from regmap_update_bits() to regmap_write_bits(). The update bits function does not work properly on a RW1C register where we must write a 1 back to an existing register to clear it. Additionally, as part of this testing I confirmed the behavior of errors reappearing, so remove comment about assumptions. Fixes: 6625767 ("power: supply: axp20x_battery: add support for AXP717") Signed-off-by: Chris Morgan <macromorgan@hotmail.com> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20250131231455.153447-2-macroalpha82@gmail.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 64dd6ed commit 9838011

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

drivers/power/supply/axp20x_battery.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,9 @@ static int axp717_battery_get_prop(struct power_supply *psy,
466466

467467
/*
468468
* If a fault is detected it must also be cleared; if the
469-
* condition persists it should reappear (This is an
470-
* assumption, it's actually not documented). A restart was
471-
* not sufficient to clear the bit in testing despite the
472-
* register listed as POR.
469+
* condition persists it should reappear. A restart was not
470+
* sufficient to clear the bit in testing despite the register
471+
* listed as POR.
473472
*/
474473
case POWER_SUPPLY_PROP_HEALTH:
475474
ret = regmap_read(axp20x_batt->regmap, AXP717_PMU_FAULT,
@@ -480,26 +479,26 @@ static int axp717_battery_get_prop(struct power_supply *psy,
480479
switch (reg & AXP717_BATT_PMU_FAULT_MASK) {
481480
case AXP717_BATT_UVLO_2_5V:
482481
val->intval = POWER_SUPPLY_HEALTH_DEAD;
483-
regmap_update_bits(axp20x_batt->regmap,
484-
AXP717_PMU_FAULT,
485-
AXP717_BATT_UVLO_2_5V,
486-
AXP717_BATT_UVLO_2_5V);
482+
regmap_write_bits(axp20x_batt->regmap,
483+
AXP717_PMU_FAULT,
484+
AXP717_BATT_UVLO_2_5V,
485+
AXP717_BATT_UVLO_2_5V);
487486
return 0;
488487

489488
case AXP717_BATT_OVER_TEMP:
490489
val->intval = POWER_SUPPLY_HEALTH_HOT;
491-
regmap_update_bits(axp20x_batt->regmap,
492-
AXP717_PMU_FAULT,
493-
AXP717_BATT_OVER_TEMP,
494-
AXP717_BATT_OVER_TEMP);
490+
regmap_write_bits(axp20x_batt->regmap,
491+
AXP717_PMU_FAULT,
492+
AXP717_BATT_OVER_TEMP,
493+
AXP717_BATT_OVER_TEMP);
495494
return 0;
496495

497496
case AXP717_BATT_UNDER_TEMP:
498497
val->intval = POWER_SUPPLY_HEALTH_COLD;
499-
regmap_update_bits(axp20x_batt->regmap,
500-
AXP717_PMU_FAULT,
501-
AXP717_BATT_UNDER_TEMP,
502-
AXP717_BATT_UNDER_TEMP);
498+
regmap_write_bits(axp20x_batt->regmap,
499+
AXP717_PMU_FAULT,
500+
AXP717_BATT_UNDER_TEMP,
501+
AXP717_BATT_UNDER_TEMP);
503502
return 0;
504503

505504
default:

0 commit comments

Comments
 (0)