1 From ad3d9c779b1f09f3f3a6fefd07af407c7bc7c9a7 Mon Sep 17 00:00:00 2001
2 From: Hans de Goede <hdegoede@redhat.com>
3 Date: Sat, 15 Apr 2023 20:23:40 +0200
4 Subject: power: supply: bq25890: Call power_supply_changed() after updating input current or voltage
6 From: Hans de Goede <hdegoede@redhat.com>
8 commit ad3d9c779b1f09f3f3a6fefd07af407c7bc7c9a7 upstream.
10 The bq25892 model relies on external charger-type detection and once
11 that is done the bq25890_charger code will update the input current
12 and if pumpexpress is used also the input voltage.
14 In this case, when the initial power_supply_changed() call is made
15 from the interrupt handler, the input settings are 5V/0.5A which
16 on many devices is not enough power to charge (while the device is on).
18 On many devices the fuel-gauge relies in its external_power_changed
19 callback to timely signal userspace about charging <-> discharging
20 status changes. Add a power_supply_changed() call after updating
21 the input current or voltage. This allows the fuel-gauge driver
22 to timely recheck if the battery is charging after the new input
23 settings have been applied and then it can immediately notify
26 Fixes: 48f45b094dbb ("power: supply: bq25890: Support higher charging voltages through Pump Express+ protocol")
27 Fixes: eab25b4f93aa ("power: supply: bq25890: On the bq25892 set the IINLIM based on external charger detection")
28 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
29 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 drivers/power/supply/bq25890_charger.c | 3 +++
33 1 file changed, 3 insertions(+)
35 --- a/drivers/power/supply/bq25890_charger.c
36 +++ b/drivers/power/supply/bq25890_charger.c
37 @@ -675,6 +675,7 @@ static void bq25890_charger_external_pow
40 bq25890_field_write(bq, F_IINLIM, input_current_limit);
41 + power_supply_changed(psy);
44 static int bq25890_get_chip_state(struct bq25890_device *bq,
45 @@ -973,6 +974,8 @@ static void bq25890_pump_express_work(st
46 dev_info(bq->dev, "Hi-voltage charging requested, input voltage is %d mV\n",
49 + power_supply_changed(bq->charger);
53 bq25890_field_write(bq, F_PUMPX_EN, 0);