Commit 5d809cb2 authored by Jonathan Bakker's avatar Jonathan Bakker Committed by Sebastian Reichel

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: default avatarJonathan Bakker <xc-racer2@live.ca>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 1a37a039
......@@ -23,6 +23,7 @@ struct max8998_battery_data {
static enum power_supply_property max8998_battery_props[] = {
POWER_SUPPLY_PROP_PRESENT, /* the presence of battery */
POWER_SUPPLY_PROP_ONLINE, /* charger is active or not */
POWER_SUPPLY_PROP_STATUS, /* charger is charging/discharging/full */
};
/* 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,
ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg);
if (ret)
return ret;
if (reg & (1 << 3))
val->intval = 0;
else
if (reg & (1 << 5))
val->intval = 1;
else
val->intval = 0;
break;
case POWER_SUPPLY_PROP_STATUS:
ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg);
if (ret)
return ret;
if (!(reg & (1 << 5))) {
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
} else {
if (reg & (1 << 6))
val->intval = POWER_SUPPLY_STATUS_FULL;
else if (reg & (1 << 3))
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
}
break;
default:
return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment