power: supply: axp288_charger: Do not stop + restart charging at boot
authorHans de Goede <hdegoede@redhat.com>
Tue, 26 Dec 2017 12:58:59 +0000 (13:58 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.co.uk>
Mon, 8 Jan 2018 17:38:56 +0000 (18:38 +0100)
commitd8e651953595403eb3504c1306135c24f243c7d9
tree5d8d942673ab675eb93cf208efd785c731a45f62
parentbaf61639b808307bd6e5be27e5cbef9cc3acd80e
power: supply: axp288_charger: Do not stop + restart charging at boot

Before this commit we were relying solely on the extcon interface for
cable detection, including to determine if a cable providing vbus is
connected at all. This caused us to turn off charging at boot, because
when we run the initial state processing the axp288-extcon driver is still
running charger-type detection most of the time, so all charger cable
types read as disconnected when we run the initial state processing.

This commit reworks the axp288_charger_extcon_evt_worker flow to use the
VBUS_VALID bit from the PWR_INPUT_STATUS register to determine if we
should turn charging on/off. Note this is the same bit as we use for the
online property.

If VBUS_VALID is set, but the extcon code has not completed the charger
type detection yet, we now simply bail leaving things as configured by
the BIOS (we will get a notifier call when the extcon code is done and
reschedule the axp288_charger_extcon_evt_worker).

The extcon code is the only one to trigger the worker (outside of the
initial run) and we can rely on it to only call us if things have changed,
so while we are completely refactoring axp288_charger_extcon_evt_worker,
also remove the code to check if the state has changed.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
drivers/power/supply/axp288_charger.c