Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 2 | /* |
| 3 | * X86 ACPI Utility Functions |
| 4 | * |
| 5 | * Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com> |
| 6 | * |
| 7 | * Based on various non upstream patches to support the CHT Whiskey Cove PMIC: |
| 8 | * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <linux/acpi.h> |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 12 | #include <linux/dmi.h> |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 13 | #include <asm/cpu_device_id.h> |
| 14 | #include <asm/intel-family.h> |
| 15 | #include "../internal.h" |
| 16 | |
| 17 | /* |
| 18 | * Some ACPI devices are hidden (status == 0x0) in recent BIOS-es because |
| 19 | * some recent Windows drivers bind to one device but poke at multiple |
| 20 | * devices at the same time, so the others get hidden. |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 21 | * |
| 22 | * Some BIOS-es (temporarily) hide specific APCI devices to work around Windows |
| 23 | * driver bugs. We use DMI matching to match known cases of this. |
| 24 | * |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 25 | * We work around this by always reporting ACPI_STA_DEFAULT for these |
| 26 | * devices. Note this MUST only be done for devices where this is safe. |
| 27 | * |
| 28 | * This forcing of devices to be present is limited to specific CPU (SoC) |
| 29 | * models both to avoid potentially causing trouble on other models and |
| 30 | * because some HIDs are re-used on different SoCs for completely |
| 31 | * different devices. |
| 32 | */ |
| 33 | struct always_present_id { |
| 34 | struct acpi_device_id hid[2]; |
| 35 | struct x86_cpu_id cpu_ids[2]; |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 36 | struct dmi_system_id dmi_ids[2]; /* Optional */ |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 37 | const char *uid; |
| 38 | }; |
| 39 | |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 40 | #define X86_MATCH(model) X86_MATCH_INTEL_FAM6_MODEL(model, NULL) |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 41 | |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 42 | #define ENTRY(hid, uid, cpu_models, dmi...) { \ |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 43 | { { hid, }, {} }, \ |
| 44 | { cpu_models, {} }, \ |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 45 | { { .matches = dmi }, {} }, \ |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 46 | uid, \ |
| 47 | } |
| 48 | |
| 49 | static const struct always_present_id always_present_ids[] = { |
| 50 | /* |
| 51 | * Bay / Cherry Trail PWM directly poked by GPU driver in win10, |
| 52 | * but Linux uses a separate PWM driver, harmless if not used. |
| 53 | */ |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 54 | ENTRY("80860F09", "1", X86_MATCH(ATOM_SILVERMONT), {}), |
| 55 | ENTRY("80862288", "1", X86_MATCH(ATOM_AIRMONT), {}), |
Yauhen Kharuzhy | ff6cdfd | 2019-02-09 13:06:12 +0300 | [diff] [blame] | 56 | |
| 57 | /* Lenovo Yoga Book uses PWM2 for keyboard backlight control */ |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 58 | ENTRY("80862289", "2", X86_MATCH(ATOM_AIRMONT), { |
Yauhen Kharuzhy | ff6cdfd | 2019-02-09 13:06:12 +0300 | [diff] [blame] | 59 | DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9"), |
| 60 | }), |
Hans de Goede | 753a448 | 2017-04-21 12:47:41 +0200 | [diff] [blame] | 61 | /* |
| 62 | * The INT0002 device is necessary to clear wakeup interrupt sources |
| 63 | * on Cherry Trail devices, without it we get nobody cared IRQ msgs. |
| 64 | */ |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 65 | ENTRY("INT0002", "1", X86_MATCH(ATOM_AIRMONT), {}), |
Hans de Goede | b5cc169 | 2017-07-09 21:05:13 +0200 | [diff] [blame] | 66 | /* |
Tristian Celestin | 72a361a | 2018-06-09 18:18:06 -0400 | [diff] [blame] | 67 | * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides |
| 68 | * the touchscreen ACPI device until a certain time |
| 69 | * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed |
| 70 | * *and* _STA has been called at least 3 times since. |
Hans de Goede | b5cc169 | 2017-07-09 21:05:13 +0200 | [diff] [blame] | 71 | */ |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 72 | ENTRY("SYNA7500", "1", X86_MATCH(HASWELL_L), { |
Hans de Goede | b5cc169 | 2017-07-09 21:05:13 +0200 | [diff] [blame] | 73 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 74 | DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"), |
| 75 | }), |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 76 | ENTRY("SYNA7500", "1", X86_MATCH(HASWELL_L), { |
Tristian Celestin | 72a361a | 2018-06-09 18:18:06 -0400 | [diff] [blame] | 77 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 78 | DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"), |
| 79 | }), |
| 80 | |
Hans de Goede | 906dc28 | 2017-07-09 21:05:14 +0200 | [diff] [blame] | 81 | /* |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 82 | * The GPD win BIOS dated 20170221 has disabled the accelerometer, the |
Hans de Goede | 906dc28 | 2017-07-09 21:05:14 +0200 | [diff] [blame] | 83 | * drivers sometimes cause crashes under Windows and this is how the |
| 84 | * manufacturer has solved this :| Note that the the DMI data is less |
| 85 | * generic then it seems, a board_vendor of "AMI Corporation" is quite |
| 86 | * rare and a board_name of "Default String" also is rare. |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 87 | * |
| 88 | * Unfortunately the GPD pocket also uses these strings and its BIOS |
| 89 | * was copy-pasted from the GPD win, so it has a disabled KIOX000A |
| 90 | * node which we should not enable, thus we also check the BIOS date. |
Hans de Goede | 906dc28 | 2017-07-09 21:05:14 +0200 | [diff] [blame] | 91 | */ |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 92 | ENTRY("KIOX000A", "1", X86_MATCH(ATOM_AIRMONT), { |
Hans de Goede | 906dc28 | 2017-07-09 21:05:14 +0200 | [diff] [blame] | 93 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 94 | DMI_MATCH(DMI_BOARD_NAME, "Default string"), |
| 95 | DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 96 | DMI_MATCH(DMI_BIOS_DATE, "02/21/2017") |
| 97 | }), |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 98 | ENTRY("KIOX000A", "1", X86_MATCH(ATOM_AIRMONT), { |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 99 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 100 | DMI_MATCH(DMI_BOARD_NAME, "Default string"), |
| 101 | DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), |
Hans de Goede | 906dc28 | 2017-07-09 21:05:14 +0200 | [diff] [blame] | 102 | DMI_MATCH(DMI_BIOS_DATE, "03/20/2017") |
| 103 | }), |
Thomas Gleixner | e36cf2f | 2020-03-20 14:13:53 +0100 | [diff] [blame] | 104 | ENTRY("KIOX000A", "1", X86_MATCH(ATOM_AIRMONT), { |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 105 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 106 | DMI_MATCH(DMI_BOARD_NAME, "Default string"), |
| 107 | DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), |
| 108 | DMI_MATCH(DMI_BIOS_DATE, "05/25/2017") |
| 109 | }), |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | bool acpi_device_always_present(struct acpi_device *adev) |
| 113 | { |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 114 | bool ret = false; |
| 115 | unsigned int i; |
| 116 | |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 117 | for (i = 0; i < ARRAY_SIZE(always_present_ids); i++) { |
| 118 | if (acpi_match_device_ids(adev, always_present_ids[i].hid)) |
| 119 | continue; |
| 120 | |
| 121 | if (!adev->pnp.unique_id || |
| 122 | strcmp(adev->pnp.unique_id, always_present_ids[i].uid)) |
| 123 | continue; |
| 124 | |
| 125 | if (!x86_match_cpu(always_present_ids[i].cpu_ids)) |
| 126 | continue; |
| 127 | |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 128 | if (always_present_ids[i].dmi_ids[0].matches[0].slot && |
| 129 | !dmi_check_system(always_present_ids[i].dmi_ids)) |
| 130 | continue; |
| 131 | |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 132 | ret = true; |
| 133 | break; |
| 134 | } |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 135 | |
| 136 | return ret; |
| 137 | } |
Mario Limonciello | 6485fc1 | 2021-06-09 13:40:18 -0500 | [diff] [blame] | 138 | |
| 139 | /* |
| 140 | * AMD systems from Renoir and Lucienne *require* that the NVME controller |
| 141 | * is put into D3 over a Modern Standby / suspend-to-idle cycle. |
| 142 | * |
| 143 | * This is "typically" accomplished using the `StorageD3Enable` |
| 144 | * property in the _DSD that is checked via the `acpi_storage_d3` function |
| 145 | * but this property was introduced after many of these systems launched |
| 146 | * and most OEM systems don't have it in their BIOS. |
| 147 | * |
| 148 | * The Microsoft documentation for StorageD3Enable mentioned that Windows has |
| 149 | * a hardcoded allowlist for D3 support, which was used for these platforms. |
| 150 | * |
| 151 | * This allows quirking on Linux in a similar fashion. |
| 152 | */ |
| 153 | static const struct x86_cpu_id storage_d3_cpu_ids[] = { |
| 154 | X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 96, NULL), /* Renoir */ |
| 155 | X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 104, NULL), /* Lucienne */ |
| 156 | {} |
| 157 | }; |
| 158 | |
| 159 | bool force_storage_d3(void) |
| 160 | { |
| 161 | return x86_match_cpu(storage_d3_cpu_ids); |
| 162 | } |