Skip to content

Commit 5d809cb

Browse files
xc-racer99sre
authored andcommitted
power: supply: max8998_charger: Correct ONLINE and add STATUS props
The ONLINE prop should be when the charger is present (ie able to charge), however, it was for when it was actually charging or not. Instead, add the STATUS prop to show whether charging is actually going on or not. The magic numbers have been ported from a downstream kernel for the SGH-T959V. Signed-off-by: Jonathan Bakker <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 1a37a03 commit 5d809cb

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

drivers/power/supply/max8998_charger.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct max8998_battery_data {
2323
static enum power_supply_property max8998_battery_props[] = {
2424
POWER_SUPPLY_PROP_PRESENT, /* the presence of battery */
2525
POWER_SUPPLY_PROP_ONLINE, /* charger is active or not */
26+
POWER_SUPPLY_PROP_STATUS, /* charger is charging/discharging/full */
2627
};
2728

2829
/* Note that the charger control is done by a current regulator "CHARGER" */
@@ -49,10 +50,28 @@ static int max8998_battery_get_property(struct power_supply *psy,
4950
ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg);
5051
if (ret)
5152
return ret;
52-
if (reg & (1 << 3))
53-
val->intval = 0;
54-
else
53+
54+
if (reg & (1 << 5))
5555
val->intval = 1;
56+
else
57+
val->intval = 0;
58+
59+
break;
60+
case POWER_SUPPLY_PROP_STATUS:
61+
ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg);
62+
if (ret)
63+
return ret;
64+
65+
if (!(reg & (1 << 5))) {
66+
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
67+
} else {
68+
if (reg & (1 << 6))
69+
val->intval = POWER_SUPPLY_STATUS_FULL;
70+
else if (reg & (1 << 3))
71+
val->intval = POWER_SUPPLY_STATUS_CHARGING;
72+
else
73+
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
74+
}
5675
break;
5776
default:
5877
return -EINVAL;

0 commit comments

Comments
 (0)