Skip to content

Instantly share code, notes, and snippets.

@linrunner
Last active September 12, 2024 15:25
Show Gist options
  • Save linrunner/b7e4454f91d1f8be4ee126b7da7379f2 to your computer and use it in GitHub Desktop.
Save linrunner/b7e4454f91d1f8be4ee126b7da7379f2 to your computer and use it in GitHub Desktop.

TLP 1.4 Test: Battery Care for ASUS Laptops

Read the overview document first.

Supported Features

ASUS laptops using the asus_wmi driver have a stop charge threshold ranging from 0% (threshold off) to 100%. The hardware behaviour is:

  1. Connected to the charger, charging stops when the charge level reaches the stop threshold

  2. If the charge level is higher than the stop threshold, the battery will not discharge automatically; it will only be discharged when the charger is removed i.e. the laptop runs on battery

When suitable hardware has been detected, tlp-stat -b shows:

+++ Battery Care
Plugin: asus
Supported features: charge threshold
Driver usage:
* natacpi (asus_wmi) = active (charge threshold)
Parameter value range:
* STOP_CHARGE_THRESH_BAT0/1: 0(off)..100(default)

+++ Battery Status: BAT0
...
/sys/class/power_supply/BAT0/charge_control_end_threshold   =    100 [%]
...

How it works

Battery charging is a process not controlled by TLP itself, but by the laptop's embedded controller (EC). This makes the process work even when switched off or no operating system is running. You cannot change the basic behavior, it is hard-coded into the EC firmware by the vendor. TLP just writes the charge threshold into the EC with the help of the kernel driver, the EC takes care of the rest.

Installation

Packages are provided at the download page.

Linux kernel 5.4 or higher required.

Test Cases

Important: please provide all terminal input and output from the test cases via an individual Gist and link it in your post below.

1. Configure and apply a charge stop threshold

Edit /etc/tlp.conf (or a config file of your choice under /etc/tlp.d/):

STOP_CHARGE_THRESH_BAT0="80"

Note: if necessary replace with your own value that suits the test case.

Enter the following commands in a terminal (as root or with sudo):

tlp start
tlp-stat -s -c -b

Verify that charge_control_end_threshold = 80.

2. Verify the charging process

  1. Let the laptop run on battery power until the charge level falls below the stop threshold by at least 10%
  2. Connect the charger and see if charging starts
  3. Verify that charging stops at 80% (or your configured value)

Enter the command (as root or with sudo):

tlp-stat -b

3. Change charge stop threshold manually

Enter the commands (as root or with sudo):

tlp setcharge 0 85
tlp-stat -b

Verify that charge_control_end_threshold = 85 and charging starts.

Notes:

  • If necessary replace 85 with a value higher than your first value chosen above
  • The first command argument '0' is a dummy for the start threshold not available on ASUS laptops

Enter the commands (as root or with sudo):

tlp setcharge
tlp-stat -b

Verify that charge_control_end_threshold = 80 and charging halts.

4. Disable stop threshold and return to full charge

Edit the config file used above and comment the parameter to disable it:

#STOP_CHARGE_THRESH_BAT0="80"

Enter the commands (as root or with sudo):

tlp fullcharge
tlp-stat -b

Verify that charge_control_end_threshold = 100 and the battery gets fully charged.

What else should I check?

  • A user has reported an ASUS laptop recognizing only discrete values 60, 80, 100; other values just being ignored by the hardware - can other users confirm this?
  • Are there ASUS laptops with more than one battery (tlp-stat -b should show)?
@linrunner
Copy link
Author

Beta 2 is out. Enjoy!

@linrunner
Copy link
Author

linrunner commented Sep 24, 2021

TLP 1.4 is released. Have fun and please keep testing!

@foxhoundsk
Copy link

Hi @linrunner, does /sys/class/power_supply/BAT0/charge_control_start_threshold not presenting means that the kernel (corresponding driver) can't recognize the EC so that it can't modify the threshold? Is it possible that the threshold is not modifiable for specific model?

I'm curious about the chance that we can reverse-engineer the EC to figure the way to set the threshold.

My laptop is ASUS X550JX, which is a circa 7-year-old model.

The output of TLP says:
https://gist.github.com/foxhoundsk/fcedcea96cd9e238ba7092f68643887b

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment