Repository navigation
Description
With the battery charge limit at 100%, Battery Extender disabled and no charge thresholds from the host, no sustainer is set, and the EC charges whenever the battery asks for current. A full battery asks again as soon as its charge drops by a percent, so on AC it is topped up over and over and stays between 99% and 100%, as Framework documents for the first 5 days on AC, and connecting AC with the charge at 97% charges it to full as well. Most laptops charge a full battery again only once it is a few percent below full, which users here asked for as well (Battery Charging Hysteresis Support, Add battery charging limit START), and #63 works on avoiding such mini-cycles too.
I know about Battery Extender, which lowers the charge after some days on AC, but I keep it disabled: it sets its own range in the sustainer, which replaces the charge thresholds which Linux sets there. I use GNOME's Preserve Battery Health instead, whose thresholds hold the battery between min % and max % while the laptop is docked. When I need a full battery, I turn them off, and then the behavior above applies.
Patch (commit, and setting it to 95 for azalea and lilac): a new CONFIG_BATT_RECHARGE_PERCENTAGE (PLATFORM_EC_BATT_RECHARGE_PERCENTAGE in Kconfig, 0 by default, which keeps the current behavior). While no sustainer is set, sustain_battery_soc() switches to CHARGE_CONTROL_IDLE once the battery is full, and when AC is connected or the host disables the sustainer with the charge at the percentage or above it, and back to CHARGE_CONTROL_NORMAL once the charge falls below the percentage. The battery counts as full when calc_is_full() says so, because the display soc can stay below 100% with a full battery. The EC changes only NORMAL and the IDLE which it set itself, so a mode which the host sets, to inhibit the charge or to discharge the battery, stays. Whenever a sustainer is set, by the host, the BIOS charge limit or Battery Extender, the sustainer decides as before. make run-sbs_charging has a new test for it. The hold always uses IDLE and has no variant with EC_CHARGE_CONTROL_FLAG_NO_IDLE, so a board with problems in IDLE (#63) would need one.
On a Laptop 13 Pro with the AMD Ryzen AI 300 Series mainboard, with 95%: a full battery stayed in IDLE on AC for 7.5 hours, also after two forced discharges by the host which took it to 99%. The charge was kept when AC was connected at 95.4% and when Linux turned its thresholds off at 96%, and connecting AC at 93.9% charged the battery to full.
Three things which came up with it:
- A host which disables the sustainer with the charge at 95% or more makes the EC keep the charge. The
cros_charge_controldriver of Linux 7.0 does that when it loads at boot, so a reboot during a top-up above 95% ends the top-up. - In IDLE without the sustainer, Framework's code in
update_dynamic_battery_info()reports the battery as charging, because it clearsEC_BATT_FLAG_CHARGINGonly when the sustainer is enabled, and the battery's current of about zero counts as charging. With the hold, Linux reported "Charging" at 0 W. This commit reports a battery in IDLE on AC as neither charging nor discharging, which also covers Linux'scharge_behaviour=inhibit-charge. - On AC,
update_dynamic_battery_info()reports the remaining capacity of a battery whose gauge flags it as fully charged as its full capacity, and the battery as discharging from 99.5% on. The gauge keeps the flag until the charge falls well below full, so with the charge held at 96% Linux showed 100%, and plugging AC in made the displayed charge jump from 95.4% to 100%. The display soc, which the sustainer and this hold compare with their limits, read 100% as well. My branch removes both, so Linux sees the remaining capacity as the gauge reports it, which right after a full charge can be a little below 100%. That is a matter of taste, but with a hold it matters more, because the battery spends its time near full instead of at it.
I can open a pull request against fwk-lilac-27116 if this is wanted.
Activity