diff options
author | Tony Lindgren <tony@atomide.com> | 2021-01-10 21:53:57 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2021-01-14 23:42:42 +0100 |
commit | 2071236b8519673a276ecbf7f60a6f7da7e5cd8a (patch) | |
tree | b26d66e593f1d532f353b2c9751dd954907ae735 /drivers/power/supply/cpcap-battery.c | |
parent | 6ddcec581fdc1b9026dd1996b9f8b834c11d868f (diff) | |
download | linux-2071236b8519673a276ecbf7f60a6f7da7e5cd8a.tar.bz2 |
power: supply: cpcap-charger: Provide state updates for battery from charger
We want to have the battery update it's status when the charge is done,
and when the charger is disconnected. Otherwise the battery does not know
when it's full unless there's a userspace app polling the battery status.
To do this, we add supplied_to handling to cpcap-battery, and implement
power_supply_changed() for cpcap-charger. When cpcap-charger calls
power_supply_changed(), cpcap-battery will update it's status.
Let's also use new_state variable for the POWER_SUPPLY_STATUS_CHARGING
case to have unified handling for the switch.
Cc: Arthur Demchenkov <spinal.by@gmail.com>
Cc: Carl Philipp Klemm <philipp@uvos.xyz>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power/supply/cpcap-battery.c')
-rw-r--r-- | drivers/power/supply/cpcap-battery.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cpcap-battery.c index 283f7e0c1d54..4ec0c8d1a356 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -416,6 +416,18 @@ static int cpcap_battery_update_status(struct cpcap_battery_ddata *ddata) return 0; } +/* + * Update battery status when cpcap-charger calls power_supply_changed(). + * This allows us to detect battery full condition before the charger + * disconnects. + */ +static void cpcap_battery_external_power_changed(struct power_supply *psy) +{ + union power_supply_propval prop; + + power_supply_get_property(psy, POWER_SUPPLY_PROP_STATUS, &prop); +} + static enum power_supply_property cpcap_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, @@ -914,6 +926,7 @@ static int cpcap_battery_probe(struct platform_device *pdev) psy_desc->get_property = cpcap_battery_get_property; psy_desc->set_property = cpcap_battery_set_property; psy_desc->property_is_writeable = cpcap_battery_property_is_writeable; + psy_desc->external_power_changed = cpcap_battery_external_power_changed; psy_cfg.of_node = pdev->dev.of_node; psy_cfg.drv_data = ddata; |