rickysarraf / laptop-mode-tools

Power Savings tool for Linux
https://www.researchut.com/tags/laptop-mode-tools/
GNU General Public License v2.0
550 stars 47 forks source link

Thikpad charge thresholds #173

Closed rickysarraf closed 2 years ago

rickysarraf commented 2 years ago

Describe the bug Explore charge threshold feature on the ThinkPad.

rrs@priyasi:.../tmp$ sudo ./tpacpi-bat.pl -v -s FD 1  1
Call    : \_SB.PCI0.LPC0.EC0.HKEY.BDSS 0x101
Response: 0x0
20:27 ♒ ॐ ♅ ♄ ⛢     ☺ 😄    
rrs@priyasi:.../tmp$ sudo ./tpacpi-bat.pl -v -s FD 1  1 1
Call    : \_SB.PCI0.LPC0.EC0.HKEY.BDSS 0x103
Response: 0x80000000
20:28 ♒ ॐ ♅ ♄ ⛢     ☺ 😄    

Notes:

rickysarraf commented 2 years ago

On a ThinkPad T14 Gen2 with Linux 5.15, one can directly write the thresholds to sysfs, which I wrote through exec-modules

Like:

rrs@priyasi:.../BAT0$ for x in charge_*; do echo $x; cat $x; done
charge_control_end_threshold
90
charge_control_start_threshold
60
charge_start_threshold
60
charge_stop_threshold
90
22:14 ♒ ॐ ♅ ♄ ⛢     ☺ 😄    
rrs@priyasi:.../BAT0$ pwd
/sys/class/power_supply/BAT0
22:14 ♒ ॐ ♅ ♄ ⛢     ☺ 😄    

Note to self: Is this all enough ? Is there any additional trigger required to trigger the charge disconnect ? Any events ? Not sure if the thresholds are in effect when the trip point reaches.

rickysarraf commented 2 years ago

tpacpi-bat and acpi_call (out-of-tree kernel module) are not really needed on (modern) ThinkPads that are supported through the thinkpad-acpi.ko in-tree kernel module.

As for machines supported by thinkpad-acpi.ko (including T14 Gen2), there's nothing much to do than just writing the values in sysfs.

So good job on part of thinkpad-acpi and there's nothing much to do here. Closing.

rickysarraf commented 2 years ago

On a ThinkPad T14 Gen2 with Linux 5.15, one can directly write the thresholds to sysfs, which I wrote through exec-modules

Note to self: Is this all enough ? Is there any additional trigger required to trigger the charge disconnect ? Any events ? Not sure if the thresholds are in effect when the trip point reaches.

To answer my question, nothing is really needed to be done. The ThinkPad EC is in control of the AC charge connect/disconnect. The kernel sysfs is only used to write the charge threshold; nothing more.

Also to note is that: Start Threshold: 60 and Stop Threshold: 90 means:

rickysarraf commented 2 years ago

On a ThinkPad T14 Gen2 with Linux 5.15, one can directly write the thresholds to sysfs, which I wrote through exec-modules Note to self: Is this all enough ? Is there any additional trigger required to trigger the charge disconnect ? Any events ? Not sure if the thresholds are in effect when the trip point reaches.

To answer my question, nothing is really needed to be done. The ThinkPad EC is in control of the AC charge connect/disconnect. The kernel sysfs is only used to write the charge threshold; nothing more.

Also to note is that: Start Threshold: 60 and Stop Threshold: 90 means:

* That when on AC, charge will not go beyond `90`

* And also that when on AC, charge will not go on battery (and discharge to `60`), once it reaches `90`.

Another important bit: