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>
155a4688dbSHans de Goede #include <linux/pci.h>
1635f9e773SHans de Goede #include <linux/platform_device.h>
17b7ecf663SHans de Goede #include <asm/cpu_device_id.h>
18b7ecf663SHans de Goede #include <asm/intel-family.h>
19b7ecf663SHans de Goede #include "../internal.h"
20b7ecf663SHans de Goede
21b7ecf663SHans de Goede /*
22b7ecf663SHans de Goede * Some ACPI devices are hidden (status == 0x0) in recent BIOS-es because
23b7ecf663SHans de Goede * some recent Windows drivers bind to one device but poke at multiple
24b7ecf663SHans de Goede * devices at the same time, so the others get hidden.
253b6a70beSHans de Goede *
263b6a70beSHans de Goede * Some BIOS-es (temporarily) hide specific APCI devices to work around Windows
273b6a70beSHans de Goede * driver bugs. We use DMI matching to match known cases of this.
283b6a70beSHans de Goede *
291a68b346SHans de Goede * Likewise sometimes some not-actually present devices are sometimes
301a68b346SHans de Goede * reported as present, which may cause issues.
31b7ecf663SHans de Goede *
321a68b346SHans de Goede * We work around this by using the below quirk list to override the status
331a68b346SHans de Goede * reported by the _STA method with a fixed value (ACPI_STA_DEFAULT or 0).
341a68b346SHans de Goede * Note this MUST only be done for devices where this is safe.
351a68b346SHans de Goede *
361a68b346SHans de Goede * This status overriding is limited to specific CPU (SoC) models both to
371a68b346SHans de Goede * avoid potentially causing trouble on other models and because some HIDs
381a68b346SHans de Goede * are re-used on different SoCs for completely different devices.
39b7ecf663SHans de Goede */
401a68b346SHans de Goede struct override_status_id {
41b7ecf663SHans de Goede struct acpi_device_id hid[2];
42b7ecf663SHans de Goede struct x86_cpu_id cpu_ids[2];
433b6a70beSHans de Goede struct dmi_system_id dmi_ids[2]; /* Optional */
44b7ecf663SHans de Goede const char *uid;
45ba46e42eSHans de Goede const char *path;
461a68b346SHans de Goede unsigned long long status;
47b7ecf663SHans de Goede };
48b7ecf663SHans de Goede
49ba46e42eSHans de Goede #define ENTRY(status, hid, uid, path, cpu_model, dmi...) { \
50b7ecf663SHans de Goede { { hid, }, {} }, \
511a68b346SHans de Goede { X86_MATCH_INTEL_FAM6_MODEL(cpu_model, NULL), {} }, \
523b6a70beSHans de Goede { { .matches = dmi }, {} }, \
53b7ecf663SHans de Goede uid, \
54ba46e42eSHans de Goede path, \
551a68b346SHans de Goede status, \
56b7ecf663SHans de Goede }
57b7ecf663SHans de Goede
581a68b346SHans de Goede #define PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \
59ba46e42eSHans de Goede ENTRY(ACPI_STA_DEFAULT, hid, uid, NULL, cpu_model, dmi)
601a68b346SHans de Goede
611a68b346SHans de Goede #define NOT_PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \
62ba46e42eSHans de Goede ENTRY(0, hid, uid, NULL, cpu_model, dmi)
63ba46e42eSHans de Goede
64ba46e42eSHans de Goede #define PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \
65ba46e42eSHans de Goede ENTRY(ACPI_STA_DEFAULT, "", NULL, path, cpu_model, dmi)
66ba46e42eSHans de Goede
67ba46e42eSHans de Goede #define NOT_PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \
68ba46e42eSHans de Goede ENTRY(0, "", NULL, path, cpu_model, dmi)
691a68b346SHans de Goede
701a68b346SHans de Goede static const struct override_status_id override_status_ids[] = {
71b7ecf663SHans de Goede /*
72b7ecf663SHans de Goede * Bay / Cherry Trail PWM directly poked by GPU driver in win10,
73b7ecf663SHans de Goede * but Linux uses a separate PWM driver, harmless if not used.
74b7ecf663SHans de Goede */
751a68b346SHans de Goede PRESENT_ENTRY_HID("80860F09", "1", ATOM_SILVERMONT, {}),
761a68b346SHans de Goede PRESENT_ENTRY_HID("80862288", "1", ATOM_AIRMONT, {}),
77ff6cdfd7SYauhen Kharuzhy
78b72cd8e0SHans de Goede /* The Xiaomi Mi Pad 2 uses PWM2 for touchkeys backlight control */
79b72cd8e0SHans de Goede PRESENT_ENTRY_HID("80862289", "2", ATOM_AIRMONT, {
80b72cd8e0SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"),
81b72cd8e0SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"),
82b72cd8e0SHans de Goede }),
83b72cd8e0SHans de Goede
84753a448cSHans de Goede /*
85753a448cSHans de Goede * The INT0002 device is necessary to clear wakeup interrupt sources
86753a448cSHans de Goede * on Cherry Trail devices, without it we get nobody cared IRQ msgs.
87753a448cSHans de Goede */
881a68b346SHans de Goede PRESENT_ENTRY_HID("INT0002", "1", ATOM_AIRMONT, {}),
89b5cc1699SHans de Goede /*
9072a361a5STristian Celestin * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides
9172a361a5STristian Celestin * the touchscreen ACPI device until a certain time
9272a361a5STristian Celestin * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed
9372a361a5STristian Celestin * *and* _STA has been called at least 3 times since.
94b5cc1699SHans de Goede */
951a68b346SHans de Goede PRESENT_ENTRY_HID("SYNA7500", "1", HASWELL_L, {
96b5cc1699SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
97b5cc1699SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"),
98b5cc1699SHans de Goede }),
991a68b346SHans de Goede PRESENT_ENTRY_HID("SYNA7500", "1", HASWELL_L, {
10072a361a5STristian Celestin DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
10172a361a5STristian Celestin DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"),
10272a361a5STristian Celestin }),
10372a361a5STristian Celestin
104906dc284SHans de Goede /*
1051c3b44c0SHans de Goede * The GPD win BIOS dated 20170221 has disabled the accelerometer, the
106906dc284SHans de Goede * drivers sometimes cause crashes under Windows and this is how the
10757d2dbf7SHans de Goede * manufacturer has solved this :| The DMI match may not seem unique,
10857d2dbf7SHans de Goede * but it is. In the 67000+ DMI decode dumps from linux-hardware.org
10957d2dbf7SHans de Goede * only 116 have board_vendor set to "AMI Corporation" and of those 116
11057d2dbf7SHans de Goede * only the GPD win and pocket entries' board_name is "Default string".
1111c3b44c0SHans de Goede *
1121c3b44c0SHans de Goede * Unfortunately the GPD pocket also uses these strings and its BIOS
1131c3b44c0SHans de Goede * was copy-pasted from the GPD win, so it has a disabled KIOX000A
1141c3b44c0SHans de Goede * node which we should not enable, thus we also check the BIOS date.
115906dc284SHans de Goede */
1161a68b346SHans de Goede PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, {
117906dc284SHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
118906dc284SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Default string"),
119906dc284SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
1201c3b44c0SHans de Goede DMI_MATCH(DMI_BIOS_DATE, "02/21/2017")
1211c3b44c0SHans de Goede }),
1221a68b346SHans de Goede PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, {
1231c3b44c0SHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
1241c3b44c0SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Default string"),
1251c3b44c0SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
126906dc284SHans de Goede DMI_MATCH(DMI_BIOS_DATE, "03/20/2017")
127906dc284SHans de Goede }),
1281a68b346SHans de Goede PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, {
1291c3b44c0SHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
1301c3b44c0SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Default string"),
1311c3b44c0SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
1321c3b44c0SHans de Goede DMI_MATCH(DMI_BIOS_DATE, "05/25/2017")
1331c3b44c0SHans de Goede }),
13457d2dbf7SHans de Goede
13557d2dbf7SHans de Goede /*
13657d2dbf7SHans de Goede * The GPD win/pocket have a PCI wifi card, but its DSDT has the SDIO
13757d2dbf7SHans de Goede * mmc controller enabled and that has a child-device which _PS3
13857d2dbf7SHans de Goede * method sets a GPIO causing the PCI wifi card to turn off.
13957d2dbf7SHans de Goede * See above remark about uniqueness of the DMI match.
14057d2dbf7SHans de Goede */
14157d2dbf7SHans de Goede NOT_PRESENT_ENTRY_PATH("\\_SB_.PCI0.SDHB.BRC1", ATOM_AIRMONT, {
14257d2dbf7SHans de Goede DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
14357d2dbf7SHans de Goede DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"),
14457d2dbf7SHans de Goede DMI_EXACT_MATCH(DMI_BOARD_SERIAL, "Default string"),
14557d2dbf7SHans de Goede DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"),
14657d2dbf7SHans de Goede }),
14761711941SMarius Hoch
14861711941SMarius Hoch /*
14961711941SMarius Hoch * The LSM303D on the Lenovo Yoga Tablet 2 series is present
15061711941SMarius Hoch * as both ACCL0001 and MAGN0001. As we can only ever register an
15161711941SMarius Hoch * i2c client for one of them, ignore MAGN0001.
15261711941SMarius Hoch */
15361711941SMarius Hoch NOT_PRESENT_ENTRY_HID("MAGN0001", "1", ATOM_SILVERMONT, {
15461711941SMarius Hoch DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
15561711941SMarius Hoch DMI_MATCH(DMI_PRODUCT_FAMILY, "YOGATablet2"),
15661711941SMarius Hoch }),
157b7ecf663SHans de Goede };
158b7ecf663SHans de Goede
acpi_device_override_status(struct acpi_device * adev,unsigned long long * status)1591a68b346SHans de Goede bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *status)
160b7ecf663SHans de Goede {
161b7ecf663SHans de Goede bool ret = false;
162b7ecf663SHans de Goede unsigned int i;
163b7ecf663SHans de Goede
1641a68b346SHans de Goede for (i = 0; i < ARRAY_SIZE(override_status_ids); i++) {
1651a68b346SHans de Goede if (!x86_match_cpu(override_status_ids[i].cpu_ids))
166b7ecf663SHans de Goede continue;
167b7ecf663SHans de Goede
1681a68b346SHans de Goede if (override_status_ids[i].dmi_ids[0].matches[0].slot &&
1691a68b346SHans de Goede !dmi_check_system(override_status_ids[i].dmi_ids))
1703b6a70beSHans de Goede continue;
1713b6a70beSHans de Goede
172ba46e42eSHans de Goede if (override_status_ids[i].path) {
173ba46e42eSHans de Goede struct acpi_buffer path = { ACPI_ALLOCATE_BUFFER, NULL };
174ba46e42eSHans de Goede bool match;
175ba46e42eSHans de Goede
176ba46e42eSHans de Goede if (acpi_get_name(adev->handle, ACPI_FULL_PATHNAME, &path))
177ba46e42eSHans de Goede continue;
178ba46e42eSHans de Goede
179ba46e42eSHans de Goede match = strcmp((char *)path.pointer, override_status_ids[i].path) == 0;
180ba46e42eSHans de Goede kfree(path.pointer);
181ba46e42eSHans de Goede
182ba46e42eSHans de Goede if (!match)
183ba46e42eSHans de Goede continue;
184ba46e42eSHans de Goede } else {
185ba46e42eSHans de Goede if (acpi_match_device_ids(adev, override_status_ids[i].hid))
186ba46e42eSHans de Goede continue;
187ba46e42eSHans de Goede
188ba46e42eSHans de Goede if (!adev->pnp.unique_id ||
189ba46e42eSHans de Goede strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
190ba46e42eSHans de Goede continue;
191ba46e42eSHans de Goede }
192ba46e42eSHans de Goede
1931a68b346SHans de Goede *status = override_status_ids[i].status;
194b7ecf663SHans de Goede ret = true;
195b7ecf663SHans de Goede break;
196b7ecf663SHans de Goede }
197b7ecf663SHans de Goede
198b7ecf663SHans de Goede return ret;
199b7ecf663SHans de Goede }
2006485fc18SMario Limonciello
2016485fc18SMario Limonciello /*
202fd880577SMario Limonciello * AMD systems from Renoir onwards *require* that the NVME controller
2036485fc18SMario Limonciello * is put into D3 over a Modern Standby / suspend-to-idle cycle.
2046485fc18SMario Limonciello *
2056485fc18SMario Limonciello * This is "typically" accomplished using the `StorageD3Enable`
2066485fc18SMario Limonciello * property in the _DSD that is checked via the `acpi_storage_d3` function
207fd880577SMario Limonciello * but some OEM systems still don't have it in their BIOS.
2086485fc18SMario Limonciello *
2096485fc18SMario Limonciello * The Microsoft documentation for StorageD3Enable mentioned that Windows has
210fd880577SMario Limonciello * a hardcoded allowlist for D3 support as well as a registry key to override
211fd880577SMario Limonciello * the BIOS, which has been used for these cases.
2126485fc18SMario Limonciello *
2136485fc18SMario Limonciello * This allows quirking on Linux in a similar fashion.
214e2a56364SMario Limonciello *
215e2a56364SMario Limonciello * Cezanne systems shouldn't *normally* need this as the BIOS includes
216e2a56364SMario Limonciello * StorageD3Enable. But for two reasons we have added it.
217e2a56364SMario Limonciello * 1) The BIOS on a number of Dell systems have ambiguity
218e2a56364SMario Limonciello * between the same value used for _ADR on ACPI nodes GPP1.DEV0 and GPP1.NVME.
219e2a56364SMario Limonciello * GPP1.NVME is needed to get StorageD3Enable node set properly.
220e2a56364SMario Limonciello * https://bugzilla.kernel.org/show_bug.cgi?id=216440
221e2a56364SMario Limonciello * https://bugzilla.kernel.org/show_bug.cgi?id=216773
222e2a56364SMario Limonciello * https://bugzilla.kernel.org/show_bug.cgi?id=217003
223e2a56364SMario Limonciello * 2) On at least one HP system StorageD3Enable is missing on the second NVME
224fd880577SMario Limonciello * disk in the system.
225fd880577SMario Limonciello * 3) On at least one HP Rembrandt system StorageD3Enable is missing on the only
226fd880577SMario Limonciello * NVME device.
2276485fc18SMario Limonciello */
force_storage_d3(void)2286485fc18SMario Limonciello bool force_storage_d3(void)
2296485fc18SMario Limonciello {
230fd880577SMario Limonciello if (!cpu_feature_enabled(X86_FEATURE_ZEN))
231fd880577SMario Limonciello return false;
232fd880577SMario Limonciello return acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0;
2336485fc18SMario Limonciello }
23435f9e773SHans de Goede
23535f9e773SHans de Goede /*
23635f9e773SHans de Goede * x86 ACPI boards which ship with only Android as their factory image usually
23735f9e773SHans de Goede * declare a whole bunch of bogus I2C devices in their ACPI tables and sometimes
23835f9e773SHans de Goede * there are issues with serdev devices on these boards too, e.g. the resource
23935f9e773SHans de Goede * points to the wrong serdev_controller.
24035f9e773SHans de Goede *
24135f9e773SHans de Goede * Instantiating I2C / serdev devs for these bogus devs causes various issues,
24235f9e773SHans de Goede * e.g. GPIO/IRQ resource conflicts because sometimes drivers do bind to them.
24335f9e773SHans de Goede * The Android x86 kernel fork shipped on these devices has some special code
24435f9e773SHans de Goede * to remove the bogus I2C clients (and AFAICT serdevs are ignored completely).
24535f9e773SHans de Goede *
24635f9e773SHans de Goede * The acpi_quirk_skip_*_enumeration() functions below are used by the I2C or
24735f9e773SHans de Goede * serdev code to skip instantiating any I2C or serdev devs on broken boards.
24835f9e773SHans de Goede *
24935f9e773SHans de Goede * In case of I2C an exception is made for HIDs on the i2c_acpi_known_good_ids
25035f9e773SHans de Goede * list. These are known to always be correct (and in case of the audio-codecs
25135f9e773SHans de Goede * the drivers heavily rely on the codec being enumerated through ACPI).
25235f9e773SHans de Goede *
25335f9e773SHans de Goede * Note these boards typically do actually have I2C and serdev devices,
25435f9e773SHans de Goede * just different ones then the ones described in their DSDT. The devices
25535f9e773SHans de Goede * which are actually present are manually instantiated by the
25635f9e773SHans de Goede * drivers/platform/x86/x86-android-tablets.c kernel module.
25735f9e773SHans de Goede */
25835f9e773SHans de Goede #define ACPI_QUIRK_SKIP_I2C_CLIENTS BIT(0)
259f91280f3SHans de Goede #define ACPI_QUIRK_UART1_SKIP BIT(1)
260f91280f3SHans de Goede #define ACPI_QUIRK_UART1_TTY_UART2_SKIP BIT(2)
2612d42aaceSHans de Goede #define ACPI_QUIRK_PNP_UART1_SKIP BIT(3)
2622d42aaceSHans de Goede #define ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY BIT(4)
2632d42aaceSHans de Goede #define ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY BIT(5)
2642d42aaceSHans de Goede #define ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS BIT(6)
26535f9e773SHans de Goede
26657a18322SHans de Goede static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = {
26757a18322SHans de Goede /*
26857a18322SHans de Goede * 1. Devices with only the skip / don't-skip AC and battery quirks,
26957a18322SHans de Goede * sorted alphabetically.
27057a18322SHans de Goede */
27157a18322SHans de Goede {
27257a18322SHans de Goede /* ECS EF20EA, AXP288 PMIC but uses separate fuel-gauge */
27357a18322SHans de Goede .matches = {
27457a18322SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
27557a18322SHans de Goede },
27657a18322SHans de Goede .driver_data = (void *)ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY
27757a18322SHans de Goede },
27857a18322SHans de Goede {
27957a18322SHans de Goede /* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */
28057a18322SHans de Goede .matches = {
28157a18322SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
28257a18322SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "80XF"),
28357a18322SHans de Goede DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
28457a18322SHans de Goede },
28557a18322SHans de Goede .driver_data = (void *)ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY
28657a18322SHans de Goede },
28757a18322SHans de Goede
28857a18322SHans de Goede /*
28957a18322SHans de Goede * 2. Devices which also have the skip i2c/serdev quirks and which
29057a18322SHans de Goede * need the x86-android-tablets module to properly work.
291*ec1208b1SHans de Goede * Sorted alphabetically.
29257a18322SHans de Goede */
29357a18322SHans de Goede #if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS)
29435f9e773SHans de Goede {
295a5cb0695SHans de Goede /* Acer Iconia One 7 B1-750 */
296a5cb0695SHans de Goede .matches = {
297a5cb0695SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
298a5cb0695SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "VESPA2"),
299a5cb0695SHans de Goede },
300a5cb0695SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
301a5cb0695SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
302a5cb0695SHans de Goede ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
303a5cb0695SHans de Goede },
304a5cb0695SHans de Goede {
305353bc143SHans de Goede /* Acer Iconia One 8 A1-840 (non FHD version) */
306353bc143SHans de Goede .matches = {
307353bc143SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
308353bc143SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "BayTrail"),
309353bc143SHans de Goede /* Above strings are too generic also match BIOS date */
310353bc143SHans de Goede DMI_MATCH(DMI_BIOS_DATE, "04/01/2014"),
311353bc143SHans de Goede },
312353bc143SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
313353bc143SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
314353bc143SHans de Goede ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
315353bc143SHans de Goede },
316353bc143SHans de Goede {
317*ec1208b1SHans de Goede /* Asus ME176C tablet */
31835f9e773SHans de Goede .matches = {
31935f9e773SHans de Goede DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
32035f9e773SHans de Goede DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"),
32135f9e773SHans de Goede },
32235f9e773SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
3231b15b698SHans de Goede ACPI_QUIRK_UART1_TTY_UART2_SKIP |
3245adc4093SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
3255adc4093SHans de Goede ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
32635f9e773SHans de Goede },
32735f9e773SHans de Goede {
328*ec1208b1SHans de Goede /* Asus TF103C transformer 2-in-1 */
329*ec1208b1SHans de Goede .matches = {
330*ec1208b1SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
331*ec1208b1SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"),
332*ec1208b1SHans de Goede },
333*ec1208b1SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
334*ec1208b1SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
335*ec1208b1SHans de Goede ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
336*ec1208b1SHans de Goede },
337*ec1208b1SHans de Goede {
3381a1e7540SHans de Goede /* Lenovo Yoga Book X90F/L */
3391a1e7540SHans de Goede .matches = {
3401a1e7540SHans de Goede DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
3411a1e7540SHans de Goede DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"),
3421a1e7540SHans de Goede DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"),
3431a1e7540SHans de Goede },
3441a1e7540SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
345f91280f3SHans de Goede ACPI_QUIRK_UART1_SKIP |
3461a1e7540SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
3471a1e7540SHans de Goede ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
3481a1e7540SHans de Goede },
3491a1e7540SHans de Goede {
350fe820db3SHans de Goede /* Lenovo Yoga Tablet 2 1050F/L */
3514fecb1e9SHans de Goede .matches = {
3524fecb1e9SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
3534fecb1e9SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"),
3544fecb1e9SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "BYT-T FFD8"),
3554fecb1e9SHans de Goede /* Partial match on beginning of BIOS version */
3564fecb1e9SHans de Goede DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"),
3574fecb1e9SHans de Goede },
3584fecb1e9SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
3592d42aaceSHans de Goede ACPI_QUIRK_PNP_UART1_SKIP |
3604fecb1e9SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
3614fecb1e9SHans de Goede },
3624fecb1e9SHans de Goede {
363fe820db3SHans de Goede /* Lenovo Yoga Tab 3 Pro X90F */
364fe820db3SHans de Goede .matches = {
365fe820db3SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
366fe820db3SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"),
367fe820db3SHans de Goede DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
368fe820db3SHans de Goede },
369fe820db3SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
370fe820db3SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
371fe820db3SHans de Goede },
372fe820db3SHans de Goede {
373ecc6aaabSHans de Goede /* Medion Lifetab S10346 */
374ecc6aaabSHans de Goede .matches = {
375ecc6aaabSHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
376ecc6aaabSHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
377ecc6aaabSHans de Goede /* Way too generic, also match on BIOS data */
378ecc6aaabSHans de Goede DMI_MATCH(DMI_BIOS_DATE, "10/22/2015"),
379ecc6aaabSHans de Goede },
380ecc6aaabSHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
381ecc6aaabSHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
382ecc6aaabSHans de Goede },
383ecc6aaabSHans de Goede {
38469d6b376SHans de Goede /* Nextbook Ares 8 (BYT version)*/
385f38312c9SHans de Goede .matches = {
386f38312c9SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
387f38312c9SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "M890BAP"),
388f38312c9SHans de Goede },
389f38312c9SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
3905adc4093SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
3915adc4093SHans de Goede ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
392f38312c9SHans de Goede },
393f38312c9SHans de Goede {
39469d6b376SHans de Goede /* Nextbook Ares 8A (CHT version)*/
39569d6b376SHans de Goede .matches = {
39669d6b376SHans de Goede DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
39769d6b376SHans de Goede DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
39869d6b376SHans de Goede DMI_MATCH(DMI_BIOS_VERSION, "M882"),
39969d6b376SHans de Goede },
40069d6b376SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
40169d6b376SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
40269d6b376SHans de Goede },
40369d6b376SHans de Goede {
4045a4688dbSHans de Goede /* Vexia Edu Atla 10 tablet 9V version */
4055a4688dbSHans de Goede .matches = {
4065a4688dbSHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
4075a4688dbSHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
4085a4688dbSHans de Goede /* Above strings are too generic, also match on BIOS date */
4095a4688dbSHans de Goede DMI_MATCH(DMI_BIOS_DATE, "08/25/2014"),
4105a4688dbSHans de Goede },
4115a4688dbSHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
4125a4688dbSHans de Goede ACPI_QUIRK_UART1_SKIP |
4135a4688dbSHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
4145a4688dbSHans de Goede ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
4155a4688dbSHans de Goede },
4165a4688dbSHans de Goede {
41735f9e773SHans de Goede /* Whitelabel (sold as various brands) TM800A550L */
41835f9e773SHans de Goede .matches = {
41935f9e773SHans de Goede DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
42035f9e773SHans de Goede DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
42135f9e773SHans de Goede /* Above strings are too generic, also match on BIOS version */
42235f9e773SHans de Goede DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"),
42335f9e773SHans de Goede },
4241b15b698SHans de Goede .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
4251b15b698SHans de Goede ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
42635f9e773SHans de Goede },
42757a18322SHans de Goede #endif
42835f9e773SHans de Goede {}
42935f9e773SHans de Goede };
43035f9e773SHans de Goede
43157a18322SHans de Goede #if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS)
43235f9e773SHans de Goede static const struct acpi_device_id i2c_acpi_known_good_ids[] = {
43335f9e773SHans de Goede { "10EC5640", 0 }, /* RealTek ALC5640 audio codec */
43469d6b376SHans de Goede { "10EC5651", 0 }, /* RealTek ALC5651 audio codec */
43535f9e773SHans de Goede { "INT33F4", 0 }, /* X-Powers AXP288 PMIC */
436353bc143SHans de Goede { "INT33F5", 0 }, /* TI Dollar Cove PMIC */
43735f9e773SHans de Goede { "INT33FD", 0 }, /* Intel Crystal Cove PMIC */
438fe820db3SHans de Goede { "INT34D3", 0 }, /* Intel Whiskey Cove PMIC */
43935f9e773SHans de Goede { "NPCE69A", 0 }, /* Asus Transformer keyboard dock */
44035f9e773SHans de Goede {}
44135f9e773SHans de Goede };
44235f9e773SHans de Goede
acpi_quirk_skip_i2c_client_enumeration(struct acpi_device * adev)44335f9e773SHans de Goede bool acpi_quirk_skip_i2c_client_enumeration(struct acpi_device *adev)
44435f9e773SHans de Goede {
44535f9e773SHans de Goede const struct dmi_system_id *dmi_id;
44635f9e773SHans de Goede long quirks;
44735f9e773SHans de Goede
44857a18322SHans de Goede dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
44935f9e773SHans de Goede if (!dmi_id)
45035f9e773SHans de Goede return false;
45135f9e773SHans de Goede
45235f9e773SHans de Goede quirks = (unsigned long)dmi_id->driver_data;
45335f9e773SHans de Goede if (!(quirks & ACPI_QUIRK_SKIP_I2C_CLIENTS))
45435f9e773SHans de Goede return false;
45535f9e773SHans de Goede
45635f9e773SHans de Goede return acpi_match_device_ids(adev, i2c_acpi_known_good_ids);
45735f9e773SHans de Goede }
45835f9e773SHans de Goede EXPORT_SYMBOL_GPL(acpi_quirk_skip_i2c_client_enumeration);
45935f9e773SHans de Goede
acpi_dmi_skip_serdev_enumeration(struct device * controller_parent,bool * skip)460a217b613SHans de Goede static int acpi_dmi_skip_serdev_enumeration(struct device *controller_parent, bool *skip)
46135f9e773SHans de Goede {
46235f9e773SHans de Goede struct acpi_device *adev = ACPI_COMPANION(controller_parent);
46335f9e773SHans de Goede const struct dmi_system_id *dmi_id;
46435f9e773SHans de Goede long quirks = 0;
4655a4688dbSHans de Goede u64 uid = 0;
466197a5aeaSAndy Shevchenko
46757a18322SHans de Goede dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
4685a4688dbSHans de Goede if (!dmi_id)
4695a4688dbSHans de Goede return 0;
4705a4688dbSHans de Goede
47135f9e773SHans de Goede quirks = (unsigned long)dmi_id->driver_data;
47235f9e773SHans de Goede
4735a4688dbSHans de Goede /* uid is left at 0 on errors and 0 is not a valid UART UID */
4745a4688dbSHans de Goede acpi_dev_uid_to_integer(adev, &uid);
4755a4688dbSHans de Goede
4765a4688dbSHans de Goede /* For PCI UARTs without an UID */
4775a4688dbSHans de Goede if (!uid && dev_is_pci(controller_parent)) {
4785a4688dbSHans de Goede struct pci_dev *pdev = to_pci_dev(controller_parent);
4795a4688dbSHans de Goede
4805a4688dbSHans de Goede /*
4815a4688dbSHans de Goede * Devfn values for PCI UARTs on Bay Trail SoCs, which are
4825a4688dbSHans de Goede * the only devices where this fallback is necessary.
4835a4688dbSHans de Goede */
4845a4688dbSHans de Goede if (pdev->devfn == PCI_DEVFN(0x1e, 3))
4855a4688dbSHans de Goede uid = 1;
4865a4688dbSHans de Goede else if (pdev->devfn == PCI_DEVFN(0x1e, 4))
4875a4688dbSHans de Goede uid = 2;
4885a4688dbSHans de Goede }
4895a4688dbSHans de Goede
4905a4688dbSHans de Goede if (!uid)
4915a4688dbSHans de Goede return 0;
4925a4688dbSHans de Goede
4935a4688dbSHans de Goede if (!dev_is_platform(controller_parent) && !dev_is_pci(controller_parent)) {
4942d42aaceSHans de Goede /* PNP enumerated UARTs */
4952d42aaceSHans de Goede if ((quirks & ACPI_QUIRK_PNP_UART1_SKIP) && uid == 1)
4962d42aaceSHans de Goede *skip = true;
4972d42aaceSHans de Goede
4982d42aaceSHans de Goede return 0;
4992d42aaceSHans de Goede }
5002d42aaceSHans de Goede
501f91280f3SHans de Goede if ((quirks & ACPI_QUIRK_UART1_SKIP) && uid == 1)
502f91280f3SHans de Goede *skip = true;
503f91280f3SHans de Goede
50435f9e773SHans de Goede if (quirks & ACPI_QUIRK_UART1_TTY_UART2_SKIP) {
505197a5aeaSAndy Shevchenko if (uid == 1)
50635f9e773SHans de Goede return -ENODEV; /* Create tty cdev instead of serdev */
50735f9e773SHans de Goede
508197a5aeaSAndy Shevchenko if (uid == 2)
50935f9e773SHans de Goede *skip = true;
51035f9e773SHans de Goede }
51135f9e773SHans de Goede
51235f9e773SHans de Goede return 0;
51335f9e773SHans de Goede }
5145adc4093SHans de Goede
acpi_quirk_skip_gpio_event_handlers(void)5155adc4093SHans de Goede bool acpi_quirk_skip_gpio_event_handlers(void)
5165adc4093SHans de Goede {
5175adc4093SHans de Goede const struct dmi_system_id *dmi_id;
5185adc4093SHans de Goede long quirks;
5195adc4093SHans de Goede
5205adc4093SHans de Goede dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
5215adc4093SHans de Goede if (!dmi_id)
5225adc4093SHans de Goede return false;
5235adc4093SHans de Goede
5245adc4093SHans de Goede quirks = (unsigned long)dmi_id->driver_data;
5255adc4093SHans de Goede return (quirks & ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS);
5265adc4093SHans de Goede }
5275adc4093SHans de Goede EXPORT_SYMBOL_GPL(acpi_quirk_skip_gpio_event_handlers);
528a217b613SHans de Goede #else
acpi_dmi_skip_serdev_enumeration(struct device * controller_parent,bool * skip)529a217b613SHans de Goede static int acpi_dmi_skip_serdev_enumeration(struct device *controller_parent, bool *skip)
530a217b613SHans de Goede {
531a217b613SHans de Goede return 0;
532a217b613SHans de Goede }
53335f9e773SHans de Goede #endif
53457a18322SHans de Goede
acpi_quirk_skip_serdev_enumeration(struct device * controller_parent,bool * skip)535a217b613SHans de Goede int acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *skip)
536a217b613SHans de Goede {
537a217b613SHans de Goede *skip = false;
538a217b613SHans de Goede
539a217b613SHans de Goede return acpi_dmi_skip_serdev_enumeration(controller_parent, skip);
540a217b613SHans de Goede }
541a217b613SHans de Goede EXPORT_SYMBOL_GPL(acpi_quirk_skip_serdev_enumeration);
542a217b613SHans de Goede
54357a18322SHans de Goede /* Lists of PMIC ACPI HIDs with an (often better) native charger driver */
54457a18322SHans de Goede static const struct {
54557a18322SHans de Goede const char *hid;
54657a18322SHans de Goede int hrv;
54757a18322SHans de Goede } acpi_skip_ac_and_battery_pmic_ids[] = {
54857a18322SHans de Goede { "INT33F4", -1 }, /* X-Powers AXP288 PMIC */
54957a18322SHans de Goede { "INT34D3", 3 }, /* Intel Cherrytrail Whiskey Cove PMIC */
55057a18322SHans de Goede };
55157a18322SHans de Goede
acpi_quirk_skip_acpi_ac_and_battery(void)55257a18322SHans de Goede bool acpi_quirk_skip_acpi_ac_and_battery(void)
55357a18322SHans de Goede {
55457a18322SHans de Goede const struct dmi_system_id *dmi_id;
55557a18322SHans de Goede long quirks = 0;
55657a18322SHans de Goede int i;
55757a18322SHans de Goede
55857a18322SHans de Goede dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
55957a18322SHans de Goede if (dmi_id)
56057a18322SHans de Goede quirks = (unsigned long)dmi_id->driver_data;
56157a18322SHans de Goede
56257a18322SHans de Goede if (quirks & ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY)
56357a18322SHans de Goede return true;
56457a18322SHans de Goede
56557a18322SHans de Goede if (quirks & ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY)
56657a18322SHans de Goede return false;
56757a18322SHans de Goede
56857a18322SHans de Goede for (i = 0; i < ARRAY_SIZE(acpi_skip_ac_and_battery_pmic_ids); i++) {
56957a18322SHans de Goede if (acpi_dev_present(acpi_skip_ac_and_battery_pmic_ids[i].hid, "1",
57057a18322SHans de Goede acpi_skip_ac_and_battery_pmic_ids[i].hrv)) {
57157a18322SHans de Goede pr_info_once("found native %s PMIC, skipping ACPI AC and battery devices\n",
57257a18322SHans de Goede acpi_skip_ac_and_battery_pmic_ids[i].hid);
57357a18322SHans de Goede return true;
57457a18322SHans de Goede }
57557a18322SHans de Goede }
57657a18322SHans de Goede
57757a18322SHans de Goede return false;
57857a18322SHans de Goede }
57957a18322SHans de Goede EXPORT_SYMBOL_GPL(acpi_quirk_skip_acpi_ac_and_battery);
5800a0e2ea6SMichal Wilczynski
5810a0e2ea6SMichal Wilczynski /* This section provides a workaround for a specific x86 system
5820a0e2ea6SMichal Wilczynski * which requires disabling of mwait to work correctly.
5830a0e2ea6SMichal Wilczynski */
acpi_proc_quirk_set_no_mwait(const struct dmi_system_id * id)5840a0e2ea6SMichal Wilczynski static int __init acpi_proc_quirk_set_no_mwait(const struct dmi_system_id *id)
5850a0e2ea6SMichal Wilczynski {
5860a0e2ea6SMichal Wilczynski pr_notice("%s detected - disabling mwait for CPU C-states\n",
5870a0e2ea6SMichal Wilczynski id->ident);
5880a0e2ea6SMichal Wilczynski boot_option_idle_override = IDLE_NOMWAIT;
5890a0e2ea6SMichal Wilczynski return 0;
5900a0e2ea6SMichal Wilczynski }
5910a0e2ea6SMichal Wilczynski
5920a0e2ea6SMichal Wilczynski static const struct dmi_system_id acpi_proc_quirk_mwait_dmi_table[] __initconst = {
5930a0e2ea6SMichal Wilczynski {
5940a0e2ea6SMichal Wilczynski .callback = acpi_proc_quirk_set_no_mwait,
5950a0e2ea6SMichal Wilczynski .ident = "Extensa 5220",
5960a0e2ea6SMichal Wilczynski .matches = {
5970a0e2ea6SMichal Wilczynski DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
5980a0e2ea6SMichal Wilczynski DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
5990a0e2ea6SMichal Wilczynski DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
6000a0e2ea6SMichal Wilczynski DMI_MATCH(DMI_BOARD_NAME, "Columbia"),
6010a0e2ea6SMichal Wilczynski },
6020a0e2ea6SMichal Wilczynski .driver_data = NULL,
6030a0e2ea6SMichal Wilczynski },
6040a0e2ea6SMichal Wilczynski {}
6050a0e2ea6SMichal Wilczynski };
6060a0e2ea6SMichal Wilczynski
acpi_proc_quirk_mwait_check(void)6070a0e2ea6SMichal Wilczynski void __init acpi_proc_quirk_mwait_check(void)
6080a0e2ea6SMichal Wilczynski {
6090a0e2ea6SMichal Wilczynski /*
6100a0e2ea6SMichal Wilczynski * Check whether the system is DMI table. If yes, OSPM
6110a0e2ea6SMichal Wilczynski * should not use mwait for CPU-states.
6120a0e2ea6SMichal Wilczynski */
6130a0e2ea6SMichal Wilczynski dmi_check_system(acpi_proc_quirk_mwait_dmi_table);
6140a0e2ea6SMichal Wilczynski }
615