1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2b7ecf663SHans de Goede /* 3b7ecf663SHans de Goede * X86 ACPI Utility Functions 4b7ecf663SHans de Goede * 5b7ecf663SHans de Goede * Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com> 6b7ecf663SHans de Goede * 7b7ecf663SHans de Goede * Based on various non upstream patches to support the CHT Whiskey Cove PMIC: 8b7ecf663SHans de Goede * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. 9b7ecf663SHans de Goede */ 10b7ecf663SHans de Goede 1157a18322SHans de Goede #define pr_fmt(fmt) "ACPI: " fmt 1257a18322SHans de Goede 13b7ecf663SHans de Goede #include <linux/acpi.h> 143b6a70beSHans de Goede #include <linux/dmi.h> 1535f9e773SHans de Goede #include <linux/platform_device.h> 16b7ecf663SHans de Goede #include <asm/cpu_device_id.h> 17b7ecf663SHans de Goede #include <asm/intel-family.h> 18b7ecf663SHans de Goede #include "../internal.h" 19b7ecf663SHans de Goede 20b7ecf663SHans de Goede /* 21b7ecf663SHans de Goede * Some ACPI devices are hidden (status == 0x0) in recent BIOS-es because 22b7ecf663SHans de Goede * some recent Windows drivers bind to one device but poke at multiple 23b7ecf663SHans de Goede * devices at the same time, so the others get hidden. 243b6a70beSHans de Goede * 253b6a70beSHans de Goede * Some BIOS-es (temporarily) hide specific APCI devices to work around Windows 263b6a70beSHans de Goede * driver bugs. We use DMI matching to match known cases of this. 273b6a70beSHans de Goede * 281a68b346SHans de Goede * Likewise sometimes some not-actually present devices are sometimes 291a68b346SHans de Goede * reported as present, which may cause issues. 30b7ecf663SHans de Goede * 311a68b346SHans de Goede * We work around this by using the below quirk list to override the status 321a68b346SHans de Goede * reported by the _STA method with a fixed value (ACPI_STA_DEFAULT or 0). 331a68b346SHans de Goede * Note this MUST only be done for devices where this is safe. 341a68b346SHans de Goede * 351a68b346SHans de Goede * This status overriding is limited to specific CPU (SoC) models both to 361a68b346SHans de Goede * avoid potentially causing trouble on other models and because some HIDs 371a68b346SHans de Goede * are re-used on different SoCs for completely different devices. 38b7ecf663SHans de Goede */ 391a68b346SHans de Goede struct override_status_id { 40b7ecf663SHans de Goede struct acpi_device_id hid[2]; 41b7ecf663SHans de Goede struct x86_cpu_id cpu_ids[2]; 423b6a70beSHans de Goede struct dmi_system_id dmi_ids[2]; /* Optional */ 43b7ecf663SHans de Goede const char *uid; 44ba46e42eSHans de Goede const char *path; 451a68b346SHans de Goede unsigned long long status; 46b7ecf663SHans de Goede }; 47b7ecf663SHans de Goede 48ba46e42eSHans de Goede #define ENTRY(status, hid, uid, path, cpu_model, dmi...) { \ 49b7ecf663SHans de Goede { { hid, }, {} }, \ 501a68b346SHans de Goede { X86_MATCH_INTEL_FAM6_MODEL(cpu_model, NULL), {} }, \ 513b6a70beSHans de Goede { { .matches = dmi }, {} }, \ 52b7ecf663SHans de Goede uid, \ 53ba46e42eSHans de Goede path, \ 541a68b346SHans de Goede status, \ 55b7ecf663SHans de Goede } 56b7ecf663SHans de Goede 571a68b346SHans de Goede #define PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \ 58ba46e42eSHans de Goede ENTRY(ACPI_STA_DEFAULT, hid, uid, NULL, cpu_model, dmi) 591a68b346SHans de Goede 601a68b346SHans de Goede #define NOT_PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \ 61ba46e42eSHans de Goede ENTRY(0, hid, uid, NULL, cpu_model, dmi) 62ba46e42eSHans de Goede 63ba46e42eSHans de Goede #define PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \ 64ba46e42eSHans de Goede ENTRY(ACPI_STA_DEFAULT, "", NULL, path, cpu_model, dmi) 65ba46e42eSHans de Goede 66ba46e42eSHans de Goede #define NOT_PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \ 67ba46e42eSHans de Goede ENTRY(0, "", NULL, path, cpu_model, dmi) 681a68b346SHans de Goede 691a68b346SHans de Goede static const struct override_status_id override_status_ids[] = { 70b7ecf663SHans de Goede /* 71b7ecf663SHans de Goede * Bay / Cherry Trail PWM directly poked by GPU driver in win10, 72b7ecf663SHans de Goede * but Linux uses a separate PWM driver, harmless if not used. 73b7ecf663SHans de Goede */ 741a68b346SHans de Goede PRESENT_ENTRY_HID("80860F09", "1", ATOM_SILVERMONT, {}), 751a68b346SHans de Goede PRESENT_ENTRY_HID("80862288", "1", ATOM_AIRMONT, {}), 76ff6cdfd7SYauhen Kharuzhy 77b72cd8e0SHans de Goede /* The Xiaomi Mi Pad 2 uses PWM2 for touchkeys backlight control */ 78b72cd8e0SHans de Goede PRESENT_ENTRY_HID("80862289", "2", ATOM_AIRMONT, { 79b72cd8e0SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"), 80b72cd8e0SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"), 81b72cd8e0SHans de Goede }), 82b72cd8e0SHans de Goede 83753a448cSHans de Goede /* 84753a448cSHans de Goede * The INT0002 device is necessary to clear wakeup interrupt sources 85753a448cSHans de Goede * on Cherry Trail devices, without it we get nobody cared IRQ msgs. 86753a448cSHans de Goede */ 871a68b346SHans de Goede PRESENT_ENTRY_HID("INT0002", "1", ATOM_AIRMONT, {}), 88b5cc1699SHans de Goede /* 8972a361a5STristian Celestin * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides 9072a361a5STristian Celestin * the touchscreen ACPI device until a certain time 9172a361a5STristian Celestin * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed 9272a361a5STristian Celestin * *and* _STA has been called at least 3 times since. 93b5cc1699SHans de Goede */ 941a68b346SHans de Goede PRESENT_ENTRY_HID("SYNA7500", "1", HASWELL_L, { 95b5cc1699SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 96b5cc1699SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"), 97b5cc1699SHans de Goede }), 981a68b346SHans de Goede PRESENT_ENTRY_HID("SYNA7500", "1", HASWELL_L, { 9972a361a5STristian Celestin DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 10072a361a5STristian Celestin DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"), 10172a361a5STristian Celestin }), 10272a361a5STristian Celestin 103906dc284SHans de Goede /* 1041c3b44c0SHans de Goede * The GPD win BIOS dated 20170221 has disabled the accelerometer, the 105906dc284SHans de Goede * drivers sometimes cause crashes under Windows and this is how the 10657d2dbf7SHans de Goede * manufacturer has solved this :| The DMI match may not seem unique, 10757d2dbf7SHans de Goede * but it is. In the 67000+ DMI decode dumps from linux-hardware.org 10857d2dbf7SHans de Goede * only 116 have board_vendor set to "AMI Corporation" and of those 116 10957d2dbf7SHans de Goede * only the GPD win and pocket entries' board_name is "Default string". 1101c3b44c0SHans de Goede * 1111c3b44c0SHans de Goede * Unfortunately the GPD pocket also uses these strings and its BIOS 1121c3b44c0SHans de Goede * was copy-pasted from the GPD win, so it has a disabled KIOX000A 1131c3b44c0SHans de Goede * node which we should not enable, thus we also check the BIOS date. 114906dc284SHans de Goede */ 1151a68b346SHans de Goede PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { 116906dc284SHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 117906dc284SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Default string"), 118906dc284SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 1191c3b44c0SHans de Goede DMI_MATCH(DMI_BIOS_DATE, "02/21/2017") 1201c3b44c0SHans de Goede }), 1211a68b346SHans de Goede PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { 1221c3b44c0SHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 1231c3b44c0SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Default string"), 1241c3b44c0SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 125906dc284SHans de Goede DMI_MATCH(DMI_BIOS_DATE, "03/20/2017") 126906dc284SHans de Goede }), 1271a68b346SHans de Goede PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { 1281c3b44c0SHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 1291c3b44c0SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Default string"), 1301c3b44c0SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 1311c3b44c0SHans de Goede DMI_MATCH(DMI_BIOS_DATE, "05/25/2017") 1321c3b44c0SHans de Goede }), 13357d2dbf7SHans de Goede 13457d2dbf7SHans de Goede /* 13557d2dbf7SHans de Goede * The GPD win/pocket have a PCI wifi card, but its DSDT has the SDIO 13657d2dbf7SHans de Goede * mmc controller enabled and that has a child-device which _PS3 13757d2dbf7SHans de Goede * method sets a GPIO causing the PCI wifi card to turn off. 13857d2dbf7SHans de Goede * See above remark about uniqueness of the DMI match. 13957d2dbf7SHans de Goede */ 14057d2dbf7SHans de Goede NOT_PRESENT_ENTRY_PATH("\\_SB_.PCI0.SDHB.BRC1", ATOM_AIRMONT, { 14157d2dbf7SHans de Goede DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 14257d2dbf7SHans de Goede DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"), 14357d2dbf7SHans de Goede DMI_EXACT_MATCH(DMI_BOARD_SERIAL, "Default string"), 14457d2dbf7SHans de Goede DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"), 14557d2dbf7SHans de Goede }), 146b7ecf663SHans de Goede }; 147b7ecf663SHans de Goede 1481a68b346SHans de Goede bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *status) 149b7ecf663SHans de Goede { 150b7ecf663SHans de Goede bool ret = false; 151b7ecf663SHans de Goede unsigned int i; 152b7ecf663SHans de Goede 1531a68b346SHans de Goede for (i = 0; i < ARRAY_SIZE(override_status_ids); i++) { 1541a68b346SHans de Goede if (!x86_match_cpu(override_status_ids[i].cpu_ids)) 155b7ecf663SHans de Goede continue; 156b7ecf663SHans de Goede 1571a68b346SHans de Goede if (override_status_ids[i].dmi_ids[0].matches[0].slot && 1581a68b346SHans de Goede !dmi_check_system(override_status_ids[i].dmi_ids)) 1593b6a70beSHans de Goede continue; 1603b6a70beSHans de Goede 161ba46e42eSHans de Goede if (override_status_ids[i].path) { 162ba46e42eSHans de Goede struct acpi_buffer path = { ACPI_ALLOCATE_BUFFER, NULL }; 163ba46e42eSHans de Goede bool match; 164ba46e42eSHans de Goede 165ba46e42eSHans de Goede if (acpi_get_name(adev->handle, ACPI_FULL_PATHNAME, &path)) 166ba46e42eSHans de Goede continue; 167ba46e42eSHans de Goede 168ba46e42eSHans de Goede match = strcmp((char *)path.pointer, override_status_ids[i].path) == 0; 169ba46e42eSHans de Goede kfree(path.pointer); 170ba46e42eSHans de Goede 171ba46e42eSHans de Goede if (!match) 172ba46e42eSHans de Goede continue; 173ba46e42eSHans de Goede } else { 174ba46e42eSHans de Goede if (acpi_match_device_ids(adev, override_status_ids[i].hid)) 175ba46e42eSHans de Goede continue; 176ba46e42eSHans de Goede 177ba46e42eSHans de Goede if (!adev->pnp.unique_id || 178ba46e42eSHans de Goede strcmp(adev->pnp.unique_id, override_status_ids[i].uid)) 179ba46e42eSHans de Goede continue; 180ba46e42eSHans de Goede } 181ba46e42eSHans de Goede 1821a68b346SHans de Goede *status = override_status_ids[i].status; 183b7ecf663SHans de Goede ret = true; 184b7ecf663SHans de Goede break; 185b7ecf663SHans de Goede } 186b7ecf663SHans de Goede 187b7ecf663SHans de Goede return ret; 188b7ecf663SHans de Goede } 1896485fc18SMario Limonciello 1906485fc18SMario Limonciello /* 1916485fc18SMario Limonciello * AMD systems from Renoir and Lucienne *require* that the NVME controller 1926485fc18SMario Limonciello * is put into D3 over a Modern Standby / suspend-to-idle cycle. 1936485fc18SMario Limonciello * 1946485fc18SMario Limonciello * This is "typically" accomplished using the `StorageD3Enable` 1956485fc18SMario Limonciello * property in the _DSD that is checked via the `acpi_storage_d3` function 1966485fc18SMario Limonciello * but this property was introduced after many of these systems launched 1976485fc18SMario Limonciello * and most OEM systems don't have it in their BIOS. 1986485fc18SMario Limonciello * 1996485fc18SMario Limonciello * The Microsoft documentation for StorageD3Enable mentioned that Windows has 2006485fc18SMario Limonciello * a hardcoded allowlist for D3 support, which was used for these platforms. 2016485fc18SMario Limonciello * 2026485fc18SMario Limonciello * This allows quirking on Linux in a similar fashion. 2036485fc18SMario Limonciello */ 2046485fc18SMario Limonciello static const struct x86_cpu_id storage_d3_cpu_ids[] = { 2056485fc18SMario Limonciello X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 96, NULL), /* Renoir */ 2066485fc18SMario Limonciello X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 104, NULL), /* Lucienne */ 2076485fc18SMario Limonciello {} 2086485fc18SMario Limonciello }; 2096485fc18SMario Limonciello 2106485fc18SMario Limonciello bool force_storage_d3(void) 2116485fc18SMario Limonciello { 2126485fc18SMario Limonciello return x86_match_cpu(storage_d3_cpu_ids); 2136485fc18SMario Limonciello } 21435f9e773SHans de Goede 21535f9e773SHans de Goede /* 21635f9e773SHans de Goede * x86 ACPI boards which ship with only Android as their factory image usually 21735f9e773SHans de Goede * declare a whole bunch of bogus I2C devices in their ACPI tables and sometimes 21835f9e773SHans de Goede * there are issues with serdev devices on these boards too, e.g. the resource 21935f9e773SHans de Goede * points to the wrong serdev_controller. 22035f9e773SHans de Goede * 22135f9e773SHans de Goede * Instantiating I2C / serdev devs for these bogus devs causes various issues, 22235f9e773SHans de Goede * e.g. GPIO/IRQ resource conflicts because sometimes drivers do bind to them. 22335f9e773SHans de Goede * The Android x86 kernel fork shipped on these devices has some special code 22435f9e773SHans de Goede * to remove the bogus I2C clients (and AFAICT serdevs are ignored completely). 22535f9e773SHans de Goede * 22635f9e773SHans de Goede * The acpi_quirk_skip_*_enumeration() functions below are used by the I2C or 22735f9e773SHans de Goede * serdev code to skip instantiating any I2C or serdev devs on broken boards. 22835f9e773SHans de Goede * 22935f9e773SHans de Goede * In case of I2C an exception is made for HIDs on the i2c_acpi_known_good_ids 23035f9e773SHans de Goede * list. These are known to always be correct (and in case of the audio-codecs 23135f9e773SHans de Goede * the drivers heavily rely on the codec being enumerated through ACPI). 23235f9e773SHans de Goede * 23335f9e773SHans de Goede * Note these boards typically do actually have I2C and serdev devices, 23435f9e773SHans de Goede * just different ones then the ones described in their DSDT. The devices 23535f9e773SHans de Goede * which are actually present are manually instantiated by the 23635f9e773SHans de Goede * drivers/platform/x86/x86-android-tablets.c kernel module. 23735f9e773SHans de Goede */ 23835f9e773SHans de Goede #define ACPI_QUIRK_SKIP_I2C_CLIENTS BIT(0) 23935f9e773SHans de Goede #define ACPI_QUIRK_UART1_TTY_UART2_SKIP BIT(1) 24057a18322SHans de Goede #define ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY BIT(2) 24157a18322SHans de Goede #define ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY BIT(3) 24235f9e773SHans de Goede 24357a18322SHans de Goede static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = { 24457a18322SHans de Goede /* 24557a18322SHans de Goede * 1. Devices with only the skip / don't-skip AC and battery quirks, 24657a18322SHans de Goede * sorted alphabetically. 24757a18322SHans de Goede */ 24857a18322SHans de Goede { 24957a18322SHans de Goede /* ECS EF20EA, AXP288 PMIC but uses separate fuel-gauge */ 25057a18322SHans de Goede .matches = { 25157a18322SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"), 25257a18322SHans de Goede }, 25357a18322SHans de Goede .driver_data = (void *)ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY 25457a18322SHans de Goede }, 25557a18322SHans de Goede { 25657a18322SHans de Goede /* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */ 25757a18322SHans de Goede .matches = { 25857a18322SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 25957a18322SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "80XF"), 26057a18322SHans de Goede DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"), 26157a18322SHans de Goede }, 26257a18322SHans de Goede .driver_data = (void *)ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY 26357a18322SHans de Goede }, 26457a18322SHans de Goede 26557a18322SHans de Goede /* 26657a18322SHans de Goede * 2. Devices which also have the skip i2c/serdev quirks and which 26757a18322SHans de Goede * need the x86-android-tablets module to properly work. 26857a18322SHans de Goede */ 26957a18322SHans de Goede #if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS) 27035f9e773SHans de Goede { 27135f9e773SHans de Goede .matches = { 27235f9e773SHans de Goede DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 27335f9e773SHans de Goede DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"), 27435f9e773SHans de Goede }, 27535f9e773SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 2761b15b698SHans de Goede ACPI_QUIRK_UART1_TTY_UART2_SKIP | 2771b15b698SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 27835f9e773SHans de Goede }, 27935f9e773SHans de Goede { 28035f9e773SHans de Goede .matches = { 28135f9e773SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 28235f9e773SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"), 28335f9e773SHans de Goede }, 2841b15b698SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 2851b15b698SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 28635f9e773SHans de Goede }, 28735f9e773SHans de Goede { 288*f38312c9SHans de Goede /* Nextbook Ares 8 */ 289*f38312c9SHans de Goede .matches = { 290*f38312c9SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), 291*f38312c9SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "M890BAP"), 292*f38312c9SHans de Goede }, 293*f38312c9SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 294*f38312c9SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 295*f38312c9SHans de Goede }, 296*f38312c9SHans de Goede { 29735f9e773SHans de Goede /* Whitelabel (sold as various brands) TM800A550L */ 29835f9e773SHans de Goede .matches = { 29935f9e773SHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 30035f9e773SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), 30135f9e773SHans de Goede /* Above strings are too generic, also match on BIOS version */ 30235f9e773SHans de Goede DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"), 30335f9e773SHans de Goede }, 3041b15b698SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 3051b15b698SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 30635f9e773SHans de Goede }, 30757a18322SHans de Goede #endif 30835f9e773SHans de Goede {} 30935f9e773SHans de Goede }; 31035f9e773SHans de Goede 31157a18322SHans de Goede #if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS) 31235f9e773SHans de Goede static const struct acpi_device_id i2c_acpi_known_good_ids[] = { 31335f9e773SHans de Goede { "10EC5640", 0 }, /* RealTek ALC5640 audio codec */ 31435f9e773SHans de Goede { "INT33F4", 0 }, /* X-Powers AXP288 PMIC */ 31535f9e773SHans de Goede { "INT33FD", 0 }, /* Intel Crystal Cove PMIC */ 31635f9e773SHans de Goede { "NPCE69A", 0 }, /* Asus Transformer keyboard dock */ 31735f9e773SHans de Goede {} 31835f9e773SHans de Goede }; 31935f9e773SHans de Goede 32035f9e773SHans de Goede bool acpi_quirk_skip_i2c_client_enumeration(struct acpi_device *adev) 32135f9e773SHans de Goede { 32235f9e773SHans de Goede const struct dmi_system_id *dmi_id; 32335f9e773SHans de Goede long quirks; 32435f9e773SHans de Goede 32557a18322SHans de Goede dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids); 32635f9e773SHans de Goede if (!dmi_id) 32735f9e773SHans de Goede return false; 32835f9e773SHans de Goede 32935f9e773SHans de Goede quirks = (unsigned long)dmi_id->driver_data; 33035f9e773SHans de Goede if (!(quirks & ACPI_QUIRK_SKIP_I2C_CLIENTS)) 33135f9e773SHans de Goede return false; 33235f9e773SHans de Goede 33335f9e773SHans de Goede return acpi_match_device_ids(adev, i2c_acpi_known_good_ids); 33435f9e773SHans de Goede } 33535f9e773SHans de Goede EXPORT_SYMBOL_GPL(acpi_quirk_skip_i2c_client_enumeration); 33635f9e773SHans de Goede 33735f9e773SHans de Goede int acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *skip) 33835f9e773SHans de Goede { 33935f9e773SHans de Goede struct acpi_device *adev = ACPI_COMPANION(controller_parent); 34035f9e773SHans de Goede const struct dmi_system_id *dmi_id; 34135f9e773SHans de Goede long quirks = 0; 34235f9e773SHans de Goede 34335f9e773SHans de Goede *skip = false; 34435f9e773SHans de Goede 34535f9e773SHans de Goede /* !dev_is_platform() to not match on PNP enumerated debug UARTs */ 34635f9e773SHans de Goede if (!adev || !adev->pnp.unique_id || !dev_is_platform(controller_parent)) 34735f9e773SHans de Goede return 0; 34835f9e773SHans de Goede 34957a18322SHans de Goede dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids); 35035f9e773SHans de Goede if (dmi_id) 35135f9e773SHans de Goede quirks = (unsigned long)dmi_id->driver_data; 35235f9e773SHans de Goede 35335f9e773SHans de Goede if (quirks & ACPI_QUIRK_UART1_TTY_UART2_SKIP) { 35435f9e773SHans de Goede if (!strcmp(adev->pnp.unique_id, "1")) 35535f9e773SHans de Goede return -ENODEV; /* Create tty cdev instead of serdev */ 35635f9e773SHans de Goede 35735f9e773SHans de Goede if (!strcmp(adev->pnp.unique_id, "2")) 35835f9e773SHans de Goede *skip = true; 35935f9e773SHans de Goede } 36035f9e773SHans de Goede 36135f9e773SHans de Goede return 0; 36235f9e773SHans de Goede } 36335f9e773SHans de Goede EXPORT_SYMBOL_GPL(acpi_quirk_skip_serdev_enumeration); 36435f9e773SHans de Goede #endif 36557a18322SHans de Goede 36657a18322SHans de Goede /* Lists of PMIC ACPI HIDs with an (often better) native charger driver */ 36757a18322SHans de Goede static const struct { 36857a18322SHans de Goede const char *hid; 36957a18322SHans de Goede int hrv; 37057a18322SHans de Goede } acpi_skip_ac_and_battery_pmic_ids[] = { 37157a18322SHans de Goede { "INT33F4", -1 }, /* X-Powers AXP288 PMIC */ 37257a18322SHans de Goede { "INT34D3", 3 }, /* Intel Cherrytrail Whiskey Cove PMIC */ 37357a18322SHans de Goede }; 37457a18322SHans de Goede 37557a18322SHans de Goede bool acpi_quirk_skip_acpi_ac_and_battery(void) 37657a18322SHans de Goede { 37757a18322SHans de Goede const struct dmi_system_id *dmi_id; 37857a18322SHans de Goede long quirks = 0; 37957a18322SHans de Goede int i; 38057a18322SHans de Goede 38157a18322SHans de Goede dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids); 38257a18322SHans de Goede if (dmi_id) 38357a18322SHans de Goede quirks = (unsigned long)dmi_id->driver_data; 38457a18322SHans de Goede 38557a18322SHans de Goede if (quirks & ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY) 38657a18322SHans de Goede return true; 38757a18322SHans de Goede 38857a18322SHans de Goede if (quirks & ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY) 38957a18322SHans de Goede return false; 39057a18322SHans de Goede 39157a18322SHans de Goede for (i = 0; i < ARRAY_SIZE(acpi_skip_ac_and_battery_pmic_ids); i++) { 39257a18322SHans de Goede if (acpi_dev_present(acpi_skip_ac_and_battery_pmic_ids[i].hid, "1", 39357a18322SHans de Goede acpi_skip_ac_and_battery_pmic_ids[i].hrv)) { 39457a18322SHans de Goede pr_info_once("found native %s PMIC, skipping ACPI AC and battery devices\n", 39557a18322SHans de Goede acpi_skip_ac_and_battery_pmic_ids[i].hid); 39657a18322SHans de Goede return true; 39757a18322SHans de Goede } 39857a18322SHans de Goede } 39957a18322SHans de Goede 40057a18322SHans de Goede return false; 40157a18322SHans de Goede } 40257a18322SHans de Goede EXPORT_SYMBOL_GPL(acpi_quirk_skip_acpi_ac_and_battery); 403