Charge levels configurable from KDE userspace

Which Linux distro are you using?Gentoo
Which kernel are you using? 6.14.7, plasma 6.3.90 ( aka plasma 6.4 beta 1)
Which BIOS version are you using? BIOS 03.03 03/10/2025
Which Framework Laptop 13 model are you using? AMD Ryzen AI 9 HX 370

Powerdevil reports
org.kde.powerdevil.chargethresholdhelper.getthreshold failed "Charge thresholds are not supported by the kernel for this hardware"

Will charge levels be added to the/a kernel driver? I understand framewrok-system exists, but integration into desktop features through standard APIs would be nice.

Thanks.

Where/how do you configure the charge level in plasma? I have never seen that option anywhere.

I think this is supposed to appear if the system supports it

I believe this is done through sysfs knobs, as reported by tlp-stat:

/sys/class/power_supply/BAT1/charge_control_start_threshold = (not available) 
/sys/class/power_supply/BAT1/charge_control_end_threshold   = (not available) 
/sys/class/power_supply/BAT1/charge_behaviour               = (not available) 

oh that’s so cool! I never knew that was there. I found it there as well just now. Adjusted it from 80 up to 85% and sure enough, it worked!

I kinda wish it was adjustable down in the tray icon but I have systemd timers set up to change it anyway and that works for me. While I’m working, plugged in all day, it’s at 80%. Then an hour before I get off work I have a timer to set it to 100% for gaming or moving around the house on battery. This method works great for me.

1 Like

framework laptop? Not strix point I suppose…

Ahh yeah, I’m on the 16.

Cool, that means it probably will come in the future to strix point.

This is what adds the sysfs location on mine. I assume you have probably installed it as well but it just doesn’t work for you yet:

It adds the /sys/class/power_supply/BAT1/charge_control_end_threshold which seems to be used by the kde settings app. When I unload this kernel module, that charge limit option completely disappears.

You should still be able to use the ectool command to set the levels. That’s what I use in my systemd timers and testing a moment ago shows it still works whether this additional kernel module is loaded or not.

Oh, I didn’t know about this.
On Gentoo not compatible with 6.14. Fix seems easy, but not for today…

If you are on 6.14, you should have access to the cros_charge_control module already. You may need to configure it ti enable probe_with_fwk_charge_control.

If your distributor is not packaging that module, file a bug on them.

Here in 2025, you no longer need my framework-laptop-kmod driver. :slight_smile:

1 Like

This is not working for me on 6.15.0-rc4. And I can not find any documentation anywhere that mentiones how to set probe_with_fwk_charge_control. I tried “true” and “1” and neither did anything to enable charge control. Your kernel module is the only one that works.

Could you offer any pointers?

cros_charge_control is loaded (mainline version), /sys/class/power_supply/BAT1/ doesn’t contain any threshold files.
probe_with_fwk_charge_control doesn’t seem to change anything. Haven’t rebooted, just rmmod/modprobe

Can either of you share your kernel logs? dmesg.

Hey DHowett, I just got off work and have more time to look in to this (and reboot). When I checked, dmesg had some errors about being unable to get the device because of the “framework_laptop” module taking it. Even after unloading “framework_laptop” module it still failed to work. So I commented out the load, blacklisted it, and rebooted.

Works now!

# ls -l /sys/class/power_supply/BAT1/*thre*
-rw-r--r-- 1 root root 4096 May 19 17:59 /sys/class/power_supply/BAT1/charge_control_end_threshold
-rw-r--r-- 1 root root 4096 May 19 17:58 /sys/class/power_supply/BAT1/charge_control_start_threshold

Thanks for the pointer. Can the github readme for that module be updated to inform of its obsolescence?

Also, looks like it probably doesn’t work for serafean as is.

EDIT: And for any who try this out. Setting this is required for it to work:
/etc/modprobe.d/cros_charge_control.conf

options cros_charge_control probe_with_fwk_charge_control=1

Hi, can’t share complete dmesg, 1.5mb is too big for pastebins, so grepped:

# dmesg | grep -i cros
[    2.482602] Timer migration: 2 hierarchy levels; 8 children per group; 2 crossnode level
[   40.828104] Adding 67108860k swap on /dev/zram0.  Priority:100 extents:1 across:67108860k SS
[   40.851330] cros_ec_lpcs FRMWC004:00: loaded with quirks 00000001
[   40.875569] cros_ec_lpcs FRMWC004:00: Chrome EC device registered
# lsmod | grep -i cros
cros_charge_control    16384  0
leds_cros_ec           12288  0
cros_ec_sysfs          12288  0
cros_ec_chardev        12288  0
gpio_cros_ec           12288  0
cros_ec_hwmon          12288  0
led_class_multicolor    12288  1 leds_cros_ec
cros_kbd_led_backlight    12288  0
cros_ec_dev            16384  0
cros_ec_lpcs           20480  0
cros_ec                16384  1 cros_ec_lpcs

# ls /sys/class/power_supply/BAT1/*thre*
No such file

Another update: it seems that setting the charge level in BIOS doesn’t do anything either… ACPI reports charged to 100%.

When using cros_charge_control, don’t use the BIOS settings or ectool. They are not compatible.
This is the whole reason the module parameter is needed.

I haven’t yet managed to convince the laptop to limit the charge.

The bios options are set, but don’t appear to do anything.
cros_charge_control module doesn’t load automatically at boot, loading it manually with or without probe_with_fwk_charge_control doesn’t do anything. Not even a line in dmesg. lsmod output shows it as loaded though.
The only idea I have now is if the battery management somehow falls into a default ACPI handler, but I’m out of my depth here…

here is the full dmesg of current boot.

What is the output of ectool inventory?
Maybe you need mfd: cros_ec: Separate charge-control probing from USB-PD

2 Likes

Yes, the kernel patch did the trick. At first

cros-charge-control cros-charge-control.6.auto: Framework charge control detected, preventing load

then reloading with probe_with_fwk_charge_control, and I have the threshold sysfs files, and UI in powerdevil.
Now I’ll test whether it actually works.

Got ectool binary from here

EC supported features:
1   : Flash support
2   : Direct Fan power management support
3   : Keyboard backlight support
5   : LED support
7   : Keyboard support
9   : BIOS Port 80h access support
10  : Thermal management support
13  : Host event support
14  : GPIO support
15  : I2C controller support
16  : Charger support
17  : Simple Battery support
18  : Smart Battery support
25  : Temporary secure vstore support
32  : Unified wake masks for LPC/eSPI support
33  : 64-bit host events support
34  : Execute code in RAM support
41  : TCPMv2 Type-C commands support