Skip to content

Instantly share code, notes, and snippets.

@linrunner
Last active February 28, 2024 17:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linrunner/fee8feeb079efc03001d9f3671146298 to your computer and use it in GitHub Desktop.
Save linrunner/fee8feeb079efc03001d9f3671146298 to your computer and use it in GitHub Desktop.

TLP 1.4 Test: Battery Care for LG Gram Laptops

Read the overview document first.

Supported Features

LG Gram laptops using the lg_laptop driver have a feature called 'battery care limit', basically a fixed stop charge threshold at 80%. 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: lg
Supported features: charge threshold
Driver usage:
* vendor (lg_laptop) = active (charge threshold)
Parameter value range:
* STOP_CHARGE_THRESH_BAT0: 80(on), 100(off) -- battery care limit

/sys/devices/platform/lg-laptop/battery_care_limit          = 80 [%]

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 4.20 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 enable battery care limit

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

STOP_CHARGE_THRESH_BAT0="80"

Connect the charger.

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

tlp start
tlp-stat -s -c -b

Verify that battery_care_limit = 80.

2. Verify the charging process

  1. Let the laptop run on battery power until the charge level falls below at least 70%
  2. Connect the charger and see if charging starts
  3. Verify that charging stops at 80%

Enter the command (as root or with sudo):

tlp-stat -b

3. Disable battery care limit and return to full charge

Edit the config file used above:

STOP_CHARGE_THRESH_BAT0="100"

Enter the commands (as root or with sudo):

tlp fullcharge
tlp-stat -b

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

What else should I check?

  • Are there LG Gram laptops with more than one battery (tlp-stat -b should show)?
@linrunner
Copy link
Author

TLP 1.4 is released. Have fun!

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