diff options
author | Hans de Goede <hdegoede@redhat.com> | 2017-12-26 13:59:11 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2018-01-09 17:41:39 +0100 |
commit | 2b5a4b4bf2224f4f6b6631091bd51cb08d3094be (patch) | |
tree | 106d05c3511243dc552c9129b0e5c4a37c1c2c60 /drivers/power/supply/pda_power.c | |
parent | power: reset: account for const type of of_device_id.data (diff) | |
download | linux-2b5a4b4bf2224f4f6b6631091bd51cb08d3094be.tar.xz linux-2b5a4b4bf2224f4f6b6631091bd51cb08d3094be.zip |
power: supply: axp288_fuel_gauge: Rework get_status()
Relying on the (dis)charge current reporting for reporting FULL back to
userspace does not work really well and often leads to the reported status
getting stuck at e.g. 98/99% (the fuelgauge is not perfect) for hours.
What happens is that when the battery is full the axp288 keeps charging it
with a very low current. Until it is really really full and once really
really full, some inaccuracies in the adc lead to it then sometimes
reporting a small discharging rate, even though an external pwr source is
used. So we end up with a status of "charging" for hours after the battery
is actually already full and sometimes this then flip-flops to discharging.
This commit fixes this by first checking if a valid Vbus is present and if
it is present using the fuel-gauge's reported percentage to check for a
full battery.
This commit also changes how get_status() determines if the battery is
charging or discharging when not reporting it as full. We still use the
current direction for this, but instead of reading 4 extra registers for
this (2 16 bit regs), simplify things by using the current-direction bit
in the power-status register, which already gets read anyways.
This also reduces the amount of i2c reads to 1 when on battery and 2
when a valid Vbus is present.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers/power/supply/pda_power.c')
0 files changed, 0 insertions, 0 deletions