thinkpad_acpi: Battery quirk for Thinkpad 11e (4th gen)

From: Ken Milmore
Date: Sun Feb 24 2019 - 10:01:43 EST


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".

diff -uprN linux-source-4.19~/drivers/platform/x86/thinkpad_acpi.c linux-source-4.19/drivers/platform/x86/thinkpad_acpi.c
--- linux-source-4.19~/drivers/platform/x86/thinkpad_acpi.c 2019-02-24 13:27:29.341331227 +0000
+++ linux-source-4.19/drivers/platform/x86/thinkpad_acpi.c 2019-02-24 13:09:28.710982438 +0000
@@ -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 */
};

static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)