Expanding battery charge control support in Linux
Posted on ma 04 augustus 2025 in kernel
Since GNOME 48, users can now preserve their battery health directly from GNOME Settings. Currently, this feature only works on laptops that support both start and end charge thresholds, such as ThinkPads. Ideally, we’d like to support every laptop with any form of charge threshold control but that isn't always discoverable for UPower.
In a UPower issue discussing broader laptop support, the creator of the GNOME Battery Health Charging extension provided an excellent summary of the various kernel APIs used for battery preservation. These approaches can be grouped as follows:
- Charge start/end threshold can be set
- Fixed end threshold (ie. 80/100)
- Boolean toggle with a custom sysfs entry (ie. conservation_mode (ideapad))
- Customizable end threshold (ie. 60-100)
The first option is already handled by UPower, and while looking at the options
my colleague Hans de Goede mentioned that Dell laptops can only set a custom
start/end threshold when the charge_type
property of the battery is set to
Custom
. The charge_type
property also has a Long Life
option which fits
our the "boolean toggle" and 80/100 fixed end threshold so this seems like a
good candidate for UPower to use to enable battery conservation mode. However
the charge_type
property does not advertise what properties it supports, so
userspace has to try to write to it and handle a possible -EINVAL
.
Discussing this with Hans de Goede let to a new charge_types property to be added to the kernel. Reading this new property shows the supported and selected value(s):
Fast [Standard] "Long Life"
The patch series landed in 6.14 and Dell was the first laptop to support this new property. To expand support to other laptops I would have to get my hands dirty but not before reading up on the new power supply extension API by Thomas Weißschuh. This new API makes it quite trivial to add charge_behaviour, charge_control_* and charge_types properties to a x86 platform driver.
With that knowledge these custom API's can be converted to charge_types
:
- /sys/bus/platform/devices/VPC2004:*/conservation_mode
- /sys/devices/platform/samsung/battery_life_extender
- /sys/devices/platform/lg-laptop/battery_care_limit
- Panasonic's
eco_mode
Acquiring an test Lenovo ideapad laptop was easy and only cost me € 45, using the new
charge_types
API in a power_supply extension required a small
patch.
After that landed in 6.16, the ideapad platform driver was converted to the new charge_types API in this
patch. In my local hackerspace
I found someone to test the Samsung conversion patch and submitted it for review.
The Ideapad/Samsung patches are merged in Linux 6.17.
If anyone reading this has a device (LG/Panasonic) which has not yet been ported to
charge_types
and is happy to test kernel patches feel free to reach out to me
via email. Older laptops with an eco_mode such as the MSI Wind U100 (2008) and
Sony vaio's with battery_care_limit should probably not be ported as they are
quite old and 32 bit.
Additionally in the future the out of tree Acer wmi battery driver will hopefully be upstreamed now that the kernel has a charge_types
API to support this driver.
For UPower support, my colleague Kate Hsuan has been extending
upower to
support battery charge conservation support on Dell laptops. And support for
setting charge_types
to Long Life
when a user wants to preserve battery
health in this merge
request.
All of this work should enable more laptops to be able to enable battery charge conservation in GNOME settings.