Commit 98380110 authored by Chris Morgan's avatar Chris Morgan Committed by Sebastian Reichel
Browse files

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: 66257670 ("power: supply: axp20x_battery: add support for AXP717")
Signed-off-by: default avatarChris Morgan <macromorgan@hotmail.com>
Reviewed-by: default avatarChen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/r/20250131231455.153447-2-macroalpha82@gmail.com


Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 64dd6edf
Loading
Loading
Loading
Loading
+15 −16
Original line number Diff line number Diff line
@@ -466,10 +466,9 @@ static int axp717_battery_get_prop(struct power_supply *psy,

	/*
	 * If a fault is detected it must also be cleared; if the
	 * condition persists it should reappear (This is an
	 * assumption, it's actually not documented). A restart was
	 * not sufficient to clear the bit in testing despite the
	 * register listed as POR.
	 * condition persists it should reappear. A restart was not
	 * sufficient to clear the bit in testing despite the register
	 * listed as POR.
	 */
	case POWER_SUPPLY_PROP_HEALTH:
		ret = regmap_read(axp20x_batt->regmap, AXP717_PMU_FAULT,
@@ -480,7 +479,7 @@ static int axp717_battery_get_prop(struct power_supply *psy,
		switch (reg & AXP717_BATT_PMU_FAULT_MASK) {
		case AXP717_BATT_UVLO_2_5V:
			val->intval = POWER_SUPPLY_HEALTH_DEAD;
			regmap_update_bits(axp20x_batt->regmap,
			regmap_write_bits(axp20x_batt->regmap,
					  AXP717_PMU_FAULT,
					  AXP717_BATT_UVLO_2_5V,
					  AXP717_BATT_UVLO_2_5V);
@@ -488,7 +487,7 @@ static int axp717_battery_get_prop(struct power_supply *psy,

		case AXP717_BATT_OVER_TEMP:
			val->intval = POWER_SUPPLY_HEALTH_HOT;
			regmap_update_bits(axp20x_batt->regmap,
			regmap_write_bits(axp20x_batt->regmap,
					  AXP717_PMU_FAULT,
					  AXP717_BATT_OVER_TEMP,
					  AXP717_BATT_OVER_TEMP);
@@ -496,7 +495,7 @@ static int axp717_battery_get_prop(struct power_supply *psy,

		case AXP717_BATT_UNDER_TEMP:
			val->intval = POWER_SUPPLY_HEALTH_COLD;
			regmap_update_bits(axp20x_batt->regmap,
			regmap_write_bits(axp20x_batt->regmap,
					  AXP717_PMU_FAULT,
					  AXP717_BATT_UNDER_TEMP,
					  AXP717_BATT_UNDER_TEMP);