thinkpad_acpi: Battery quirk for Thinkpad 11e (4th gen)
I recently acquired a Thinkpad 11e 4th gen (Type 20HV, BIOS version R0KET36W, EC program R0KHT18W). I've put Debian Buster on it, with the 4.19 kernel, which gives the following errors in dmesg:
ACPI: \_SB_.PCI0.LPCB.EC__.HKEY: BCTG evaluated but flagged as error
thinkpad_acpi: Error probing battery 2
battery: error in extension, unloading: ThinkPad Battery Extension
I wanted to try using the battery charging thresholds, so I added an entry to the battery quirk table in thinkpad_acpi.c (patch given below), which allows the battery extension to load successfully.
Setting charge thresholds seems to basically work, but one thing worth mentioning is that charge_start_threshold and charge_stop_threshold appear to be tied together; AFAICT setting one also sets the other to the same value. The battery does seem to start charging whenever it falls below the common threshold, I have it set at 80% and it has kept the battery floating around 79%.
Battery status is reported correctly when charging or discharging; when charging has been suppressed because the battery level is above the threshold, then the status is reported as "Unknown".
drivers/platform/x86/thinkpad_acpi.c +1 -0
@@ -9619,6 +9619,7 @@ static const struct tpacpi_quirk batteryTPACPI_Q_LNV3 ('R' ,'0' ,'B' , true),/* Thinkpad 11e gen 3 */ TPACPI_Q_LNV3 ('R' ,'0' ,'C' , true),/* Thinkpad 13 */ TPACPI_Q_LNV3 ('R' ,'0' ,'J' , true),/* Thinkpad 13 gen 2 */ + TPACPI_Q_LNV3('R', '0', 'K', true), /* Thinkpad 11e gen 4 */ };static int __init tpacpi_battery_init (struct ibm_init_struct *ibm)
Quoted 6 lines · Ken Milmore
Setting charge thresholds seems to basically work, but one thing worth mentioning is that
charge_start_thresholdandcharge_stop_thresholdappear to be tied together; AFAICT setting one also sets the other to the same value. The battery does seem to start charging whenever it falls below the common threshold, I have it set at 80% and it has kept the battery floating around 79%.
I observe the same behavior on my Thinkpad 13. Maybe there is a bug in the driver, but it could also be a bug in the firmware.
drivers/platform/x86/thinkpad_acpi.c 2019-02-24 13:09:28.710982438 +0000 static const struct tpacpi_quirk battery · line 9622
Quoted 8 lines
diff -uprN
linux-source-4.19~/drivers/platform/x86/thinkpad_acpi.clinux-source-4.19/drivers/platform/x86/thinkpad_acpi.cdrivers/platform/x86/thinkpad_acpi.c 2019-02-24 13:09:28.710982438 +0000 renamed from drivers/platform/x86/thinkpad_acpi.c 2019-02-24 13:27:29.341331227 +0000 +1
-0@@ -9619,6 +9619,7 @@ static const struct tpacpi_quirk battery TPACPI_Q_LNV3('R', '0', 'B', true), /* Thinkpad 11e gen 3 */ TPACPI_Q_LNV3('R', '0', 'C', true), /* Thinkpad 13 */ TPACPI_Q_LNV3('R', '0', 'J', true), /* Thinkpad 13 gen 2 */ + TPACPI_Q_LNV3('R', '0', 'K', true), /* Thinkpad 11e gen 4 */
Personally, I would add the line below the 11e gen 3.
Quoted 3 lines
drivers/platform/x86/thinkpad_acpi.c 2019-02-24 13:09:28.710982438 +0000 renamed from drivers/platform/x86/thinkpad_acpi.c 2019-02-24 13:27:29.341331227 +0000 +0
-0}; static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)