Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <xc-racer2@live.ca>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Jonathan Bakker and committed by
Sebastian Reichel
5d809cb2 1a37a039

+22 -3
+22 -3
drivers/power/supply/max8998_charger.c
··· 23 23 static enum power_supply_property max8998_battery_props[] = { 24 24 POWER_SUPPLY_PROP_PRESENT, /* the presence of battery */ 25 25 POWER_SUPPLY_PROP_ONLINE, /* charger is active or not */ 26 + POWER_SUPPLY_PROP_STATUS, /* charger is charging/discharging/full */ 26 27 }; 27 28 28 29 /* Note that the charger control is done by a current regulator "CHARGER" */ ··· 50 49 ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg); 51 50 if (ret) 52 51 return ret; 53 - if (reg & (1 << 3)) 54 - val->intval = 0; 55 - else 52 + 53 + if (reg & (1 << 5)) 56 54 val->intval = 1; 55 + else 56 + val->intval = 0; 57 + 58 + break; 59 + case POWER_SUPPLY_PROP_STATUS: 60 + ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg); 61 + if (ret) 62 + return ret; 63 + 64 + if (!(reg & (1 << 5))) { 65 + val->intval = POWER_SUPPLY_STATUS_DISCHARGING; 66 + } else { 67 + if (reg & (1 << 6)) 68 + val->intval = POWER_SUPPLY_STATUS_FULL; 69 + else if (reg & (1 << 3)) 70 + val->intval = POWER_SUPPLY_STATUS_CHARGING; 71 + else 72 + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; 73 + } 57 74 break; 58 75 default: 59 76 return -EINVAL;