diff options
| author | Csókás, Bence <csokas.bence@prolan.hu> | 2024-11-19 21:07:38 +0300 |
|---|---|---|
| committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2024-12-05 03:07:08 +0300 |
| commit | 667e11374f4e4c85452d1a4f6f3fe0640991abd8 (patch) | |
| tree | 59692dc3912dd970a199ecab0f53c2181bdd6d9c | |
| parent | ee7300da80db325af4ddaf2127984f8fb561bc00 (diff) | |
| download | linux-667e11374f4e4c85452d1a4f6f3fe0640991abd8.tar.xz | |
power: ip5xxx_power: Fall back to Charge End bit if status register is absent
On parts where there is no status register, check the Charge End
bit to set charging/not charging status. Fullness, trickle charge
status, discharging etc. cannot be determined from just this bit.
Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
Link: https://lore.kernel.org/r/20241119180741.2237692-6-csokas.bence@prolan.hu
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
| -rw-r--r-- | drivers/power/supply/ip5xxx_power.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c index 2c4d338574d7..24b437cb8793 100644 --- a/drivers/power/supply/ip5xxx_power.c +++ b/drivers/power/supply/ip5xxx_power.c @@ -270,6 +270,19 @@ static int ip5xxx_battery_get_status(struct ip5xxx *ip5xxx, int *val) unsigned int rval; int ret; + if (!ip5xxx->regs.charger.status) { + // Fall-back to Charging Ended bit + ret = ip5xxx_read(ip5xxx, ip5xxx->regs.charger.chg_end, &rval); + if (ret) + return ret; + + if (rval == ip5xxx->chg_end_inverted) + *val = POWER_SUPPLY_STATUS_CHARGING; + else + *val = POWER_SUPPLY_STATUS_NOT_CHARGING; + return 0; + } + ret = ip5xxx_read(ip5xxx, ip5xxx->regs.charger.status, &rval); if (ret) return ret; |
