Commit dccfae6d4f4c2cfa1fdc3bf55755fcad02184b99

Authored by Hans de Goede
Committed by Rafael J. Wysocki
1 parent bc39fbcf9c

ACPI / battery: Add a blacklist with PMIC ACPI HIDs with a native battery driver

On some systems we have a native PMIC driver which provides battery
monitoring, while the ACPI battery driver is broken on these systems
due to bad DSDTs or because we do not support the proprietary and
undocumented ACPI opregions these ACPI battery devices rely on
(e.g. BMOP opregion).

This leads to there being 2 battery power_supply-s registed like this:

~$ acpi
Battery 0: Charging, 84%, 00:49:39 until charged
Battery 1: Unknown, 0%, rate information unavailable

Even if the ACPI battery where to function fine (which on systems
where we have a native PMIC driver it often doesn't) we still do not
want to export the same battery to userspace twice.

This commit adds a blacklist with PMIC ACPI HIDs for which we've a
native battery driver and makes the ACPI battery driver not register
itself when a PMIC on this list is present.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=194811
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Showing 1 changed file with 14 additions and 0 deletions Side-by-side Diff

drivers/acpi/battery.c
... ... @@ -94,6 +94,11 @@
94 94  
95 95 MODULE_DEVICE_TABLE(acpi, battery_device_ids);
96 96  
  97 +/* Lists of PMIC ACPI HIDs with an (often better) native battery driver */
  98 +static const char * const acpi_battery_blacklist[] = {
  99 + "INT33F4", /* X-Powers AXP288 PMIC */
  100 +};
  101 +
97 102 enum {
98 103 ACPI_BATTERY_ALARM_PRESENT,
99 104 ACPI_BATTERY_XINFO_PRESENT,
100 105  
... ... @@ -1316,7 +1321,16 @@
1316 1321  
1317 1322 static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
1318 1323 {
  1324 + unsigned int i;
1319 1325 int result;
  1326 +
  1327 + for (i = 0; i < ARRAY_SIZE(acpi_battery_blacklist); i++)
  1328 + if (acpi_dev_present(acpi_battery_blacklist[i], "1", -1)) {
  1329 + pr_info(PREFIX ACPI_BATTERY_DEVICE_NAME
  1330 + ": found native %s PMIC, not loading\n",
  1331 + acpi_battery_blacklist[i]);
  1332 + return;
  1333 + }
1320 1334  
1321 1335 dmi_check_system(bat_dmi_table);
1322 1336