OSDN Git Service

power: supply: bq24190_charger: Delay applying charge_type changes when OTG 5V Vbus...
authorHans de Goede <hdegoede@redhat.com>
Sat, 12 Feb 2022 16:48:17 +0000 (17:48 +0100)
committerSebastian Reichel <sre@kernel.org>
Fri, 25 Feb 2022 19:08:02 +0000 (20:08 +0100)
commitd69fc86aca7eda7bd7405c16f35f260c154e14e3
treeae66679a7b1fff605f68225e2377e92efe6a574c
parentf7731754fdce33dad19be746f647d6ac47c5d695
power: supply: bq24190_charger: Delay applying charge_type changes when OTG 5V Vbus boost is on

Recently userspace has started switching power_supply class devices with
a charge_type psy-property between fast and trickle charge mode, see:
https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/85

Before this patch bq24190_charger_set_charge_type() would unconditionally
write charging or none to the BQ24190_REG_POC_CHG_CONFIG bits, replacing
the otg setting of those bits when the OTG 5V Vbus boost converter was on,
turning the 5V Vbus off, removing the power from any attached peripherals.

This fixes this by keeping track of otg_vbus_enabled and the requested
charger_type settings and when otg_vbus_enabled is true, delay applying
the charger_type until the 5V boost converter is turned off.

Cc: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/bq24190_charger.c