Commit 1a32ebb2 authored by Jouke Witteveen's avatar Jouke Witteveen Committed by Andy Shevchenko

platform/x86: thinkpad_acpi: Support battery quirk

Some Thinkpads have a single battery, but expose it as BAT1. Use the quirks
engine to force these machines into always addressing the primary battery.
Without this, the battery name would resolve to the non-existent secondary
battery and ACPI calls would fail.
Signed-off-by: default avatarJouke Witteveen <j.witteveen@gmail.com>
Acked-by: default avatarHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent 846a416b
...@@ -335,6 +335,7 @@ static struct { ...@@ -335,6 +335,7 @@ static struct {
u32 second_fan:1; u32 second_fan:1;
u32 beep_needs_two_args:1; u32 beep_needs_two_args:1;
u32 mixer_no_level_control:1; u32 mixer_no_level_control:1;
u32 battery_force_primary:1;
u32 input_device_registered:1; u32 input_device_registered:1;
u32 platform_drv_registered:1; u32 platform_drv_registered:1;
u32 platform_drv_attrs_registered:1; u32 platform_drv_attrs_registered:1;
...@@ -343,7 +344,6 @@ static struct { ...@@ -343,7 +344,6 @@ static struct {
u32 sensors_pdev_attrs_registered:1; u32 sensors_pdev_attrs_registered:1;
u32 hotkey_poll_active:1; u32 hotkey_poll_active:1;
u32 has_adaptive_kbd:1; u32 has_adaptive_kbd:1;
u32 battery:1;
} tp_features; } tp_features;
static struct { static struct {
...@@ -471,6 +471,12 @@ do { \ ...@@ -471,6 +471,12 @@ do { \
.ec = TPACPI_MATCH_ANY, \ .ec = TPACPI_MATCH_ANY, \
.quirks = (__quirk) } .quirks = (__quirk) }
#define TPACPI_Q_LNV3(__id1, __id2, __id3, __quirk) \
{ .vendor = PCI_VENDOR_ID_LENOVO, \
.bios = TPID3(__id1, __id2, __id3), \
.ec = TPACPI_MATCH_ANY, \
.quirks = (__quirk) }
#define TPACPI_QEC_LNV(__id1, __id2, __quirk) \ #define TPACPI_QEC_LNV(__id1, __id2, __quirk) \
{ .vendor = PCI_VENDOR_ID_LENOVO, \ { .vendor = PCI_VENDOR_ID_LENOVO, \
.bios = TPACPI_MATCH_ANY, \ .bios = TPACPI_MATCH_ANY, \
...@@ -9423,7 +9429,8 @@ static int tpacpi_battery_probe(int battery) ...@@ -9423,7 +9429,8 @@ static int tpacpi_battery_probe(int battery)
static int tpacpi_battery_get_id(const char *battery_name) static int tpacpi_battery_get_id(const char *battery_name)
{ {
if (strcmp(battery_name, "BAT0") == 0) if (strcmp(battery_name, "BAT0") == 0 ||
tp_features.battery_force_primary)
return BAT_PRIMARY; return BAT_PRIMARY;
if (strcmp(battery_name, "BAT1") == 0) if (strcmp(battery_name, "BAT1") == 0)
return BAT_SECONDARY; return BAT_SECONDARY;
...@@ -9599,8 +9606,20 @@ static struct acpi_battery_hook battery_hook = { ...@@ -9599,8 +9606,20 @@ static struct acpi_battery_hook battery_hook = {
/* Subdriver init/exit */ /* Subdriver init/exit */
static const struct tpacpi_quirk battery_quirk_table[] __initconst = {
/*
* Individual addressing is broken on models that expose the
* primary battery as BAT1.
*/
TPACPI_Q_LNV3('R', '0', 'C', true), /* Thinkpad 13 */
};
static int __init tpacpi_battery_init(struct ibm_init_struct *ibm) static int __init tpacpi_battery_init(struct ibm_init_struct *ibm)
{ {
tp_features.battery_force_primary = tpacpi_check_quirks(
battery_quirk_table,
ARRAY_SIZE(battery_quirk_table));
battery_hook_register(&battery_hook); battery_hook_register(&battery_hook);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment