Skip to content

Commit cd38a0a

Browse files
t-8chsre
authored andcommitted
power: supply: mm8013: fix "not charging" detection
The charge_behaviours property is meant as a control-knob that can be changed by the user. Page 23 of [0] which documents the flag CHG_INH as follows: CHG_INH : Charge Inhibit When the current is more than or equal to charge threshold current, charge inhibit temperature (upper/lower limit) :1 charge permission temperature or the current is less than charge threshold current :0 So this is pure read-only information which is better represented as POWER_SUPPLY_STATUS_NOT_CHARGING. [0] https://product.minebeamitsumi.com/en/product/category/ics/battery/fuel_gauge/parts/download/__icsFiles/afieldfile/2023/07/12/1_download_01_12.pdf Signed-off-by: Thomas Weißschuh <[email protected]> Link: https://lore.kernel.org/r/20240303-power_supply-charge_behaviour_prop-v2-1-8ebb0a7c2409@weissschuh.net Fixes: e39257c ("power: supply: mm8013: Add more properties") Signed-off-by: Sebastian Reichel <[email protected]>
1 parent f107e6b commit cd38a0a

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

drivers/power/supply/mm8013.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ static int mm8013_checkdevice(struct mm8013_chip *chip)
7171

7272
static enum power_supply_property mm8013_battery_props[] = {
7373
POWER_SUPPLY_PROP_CAPACITY,
74-
POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR,
7574
POWER_SUPPLY_PROP_CHARGE_FULL,
7675
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
7776
POWER_SUPPLY_PROP_CHARGE_NOW,
@@ -103,16 +102,6 @@ static int mm8013_get_property(struct power_supply *psy,
103102

104103
val->intval = regval;
105104
break;
106-
case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR:
107-
ret = regmap_read(chip->regmap, REG_FLAGS, &regval);
108-
if (ret < 0)
109-
return ret;
110-
111-
if (regval & MM8013_FLAG_CHG_INH)
112-
val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE;
113-
else
114-
val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO;
115-
break;
116105
case POWER_SUPPLY_PROP_CHARGE_FULL:
117106
ret = regmap_read(chip->regmap, REG_FULL_CHARGE_CAPACITY, &regval);
118107
if (ret < 0)
@@ -187,6 +176,8 @@ static int mm8013_get_property(struct power_supply *psy,
187176

188177
if (regval & MM8013_FLAG_DSG)
189178
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
179+
else if (regval & MM8013_FLAG_CHG_INH)
180+
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
190181
else if (regval & MM8013_FLAG_CHG)
191182
val->intval = POWER_SUPPLY_STATUS_CHARGING;
192183
else if (regval & MM8013_FLAG_FC)

0 commit comments

Comments
 (0)