diff options
author | Hans de Goede <hdegoede@redhat.com> | 2022-02-06 19:35:38 +0100 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.com> | 2022-02-11 19:08:34 +0100 |
commit | 5e8c1dc78ccf37fc804df5415a8426ca9d19d51a (patch) | |
tree | 4dbb644bd56c3e5b6d7aaa6631ccdc1f760c93f0 /drivers | |
parent | c76787b0d8d2b8660e880d17fbe6fac22e8d35f5 (diff) | |
download | linux-5e8c1dc78ccf37fc804df5415a8426ca9d19d51a.tar.bz2 |
power: supply: bq24190_charger: Turn off 5V boost regulator on shutdown
Turn off the 5V boost regulator on shutdown, there are 3 reasons for
doing this:
1. It drains he battery if left on
2. If left on the device will not charge when plugged into a charger
3. If left on and the powered peripheral attached to a Type-C port is
removed before the next boot, then the Type-C port-controller will
see VBus being present while nothing is attached confusing the
TCPM state-machine.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/supply/bq24190_charger.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index a1c957a26f07..7414830a70e4 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c @@ -497,10 +497,8 @@ static ssize_t bq24190_sysfs_store(struct device *dev, } #endif -#ifdef CONFIG_REGULATOR -static int bq24190_set_charge_mode(struct regulator_dev *dev, u8 val) +static int bq24190_set_charge_mode(struct bq24190_dev_info *bdi, u8 val) { - struct bq24190_dev_info *bdi = rdev_get_drvdata(dev); int ret; ret = pm_runtime_get_sync(bdi->dev); @@ -520,14 +518,17 @@ static int bq24190_set_charge_mode(struct regulator_dev *dev, u8 val) return ret; } +#ifdef CONFIG_REGULATOR static int bq24190_vbus_enable(struct regulator_dev *dev) { - return bq24190_set_charge_mode(dev, BQ24190_REG_POC_CHG_CONFIG_OTG); + return bq24190_set_charge_mode(rdev_get_drvdata(dev), + BQ24190_REG_POC_CHG_CONFIG_OTG); } static int bq24190_vbus_disable(struct regulator_dev *dev) { - return bq24190_set_charge_mode(dev, BQ24190_REG_POC_CHG_CONFIG_CHARGE); + return bq24190_set_charge_mode(rdev_get_drvdata(dev), + BQ24190_REG_POC_CHG_CONFIG_CHARGE); } static int bq24190_vbus_is_enabled(struct regulator_dev *dev) @@ -1870,6 +1871,14 @@ static int bq24190_remove(struct i2c_client *client) return 0; } +static void bq24190_shutdown(struct i2c_client *client) +{ + struct bq24190_dev_info *bdi = i2c_get_clientdata(client); + + /* Turn off 5V boost regulator on shutdown */ + bq24190_set_charge_mode(bdi, BQ24190_REG_POC_CHG_CONFIG_CHARGE); +} + static __maybe_unused int bq24190_runtime_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -1980,6 +1989,7 @@ MODULE_DEVICE_TABLE(of, bq24190_of_match); static struct i2c_driver bq24190_driver = { .probe = bq24190_probe, .remove = bq24190_remove, + .shutdown = bq24190_shutdown, .id_table = bq24190_i2c_ids, .driver = { .name = "bq24190-charger", |