blob: f22f23933063b7e57072bb8606b849be74c1639b [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Hans de Goedeb7ecf662017-04-21 12:47:40 +02002/*
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 Goedeb7ecf662017-04-21 12:47:40 +02009 */
10
11#include <linux/acpi.h>
Hans de Goede3b6a70b2017-07-09 21:05:12 +020012#include <linux/dmi.h>
Hans de Goedeb7ecf662017-04-21 12:47:40 +020013#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 Goede3b6a70b2017-07-09 21:05:12 +020021 *
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 Goedeb7ecf662017-04-21 12:47:40 +020025 * 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 */
33struct always_present_id {
34 struct acpi_device_id hid[2];
35 struct x86_cpu_id cpu_ids[2];
Hans de Goede3b6a70b2017-07-09 21:05:12 +020036 struct dmi_system_id dmi_ids[2]; /* Optional */
Hans de Goedeb7ecf662017-04-21 12:47:40 +020037 const char *uid;
38};
39
Thomas Gleixnere36cf2f2020-03-20 14:13:53 +010040#define X86_MATCH(model) X86_MATCH_INTEL_FAM6_MODEL(model, NULL)
Hans de Goedeb7ecf662017-04-21 12:47:40 +020041
Hans de Goede3b6a70b2017-07-09 21:05:12 +020042#define ENTRY(hid, uid, cpu_models, dmi...) { \
Hans de Goedeb7ecf662017-04-21 12:47:40 +020043 { { hid, }, {} }, \
44 { cpu_models, {} }, \
Hans de Goede3b6a70b2017-07-09 21:05:12 +020045 { { .matches = dmi }, {} }, \
Hans de Goedeb7ecf662017-04-21 12:47:40 +020046 uid, \
47}
48
49static 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 Gleixnere36cf2f2020-03-20 14:13:53 +010054 ENTRY("80860F09", "1", X86_MATCH(ATOM_SILVERMONT), {}),
55 ENTRY("80862288", "1", X86_MATCH(ATOM_AIRMONT), {}),
Yauhen Kharuzhyff6cdfd2019-02-09 13:06:12 +030056
57 /* Lenovo Yoga Book uses PWM2 for keyboard backlight control */
Thomas Gleixnere36cf2f2020-03-20 14:13:53 +010058 ENTRY("80862289", "2", X86_MATCH(ATOM_AIRMONT), {
Yauhen Kharuzhyff6cdfd2019-02-09 13:06:12 +030059 DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9"),
60 }),
Hans de Goede753a4482017-04-21 12:47:41 +020061 /*
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 Gleixnere36cf2f2020-03-20 14:13:53 +010065 ENTRY("INT0002", "1", X86_MATCH(ATOM_AIRMONT), {}),
Hans de Goedeb5cc1692017-07-09 21:05:13 +020066 /*
Tristian Celestin72a361a2018-06-09 18:18:06 -040067 * 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 Goedeb5cc1692017-07-09 21:05:13 +020071 */
Thomas Gleixnere36cf2f2020-03-20 14:13:53 +010072 ENTRY("SYNA7500", "1", X86_MATCH(HASWELL_L), {
Hans de Goedeb5cc1692017-07-09 21:05:13 +020073 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
74 DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"),
75 }),
Thomas Gleixnere36cf2f2020-03-20 14:13:53 +010076 ENTRY("SYNA7500", "1", X86_MATCH(HASWELL_L), {
Tristian Celestin72a361a2018-06-09 18:18:06 -040077 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
78 DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"),
79 }),
80
Hans de Goede906dc282017-07-09 21:05:14 +020081 /*
Hans de Goede1c3b44c2017-10-19 13:23:21 +020082 * The GPD win BIOS dated 20170221 has disabled the accelerometer, the
Hans de Goede906dc282017-07-09 21:05:14 +020083 * 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 Goede1c3b44c2017-10-19 13:23:21 +020087 *
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 Goede906dc282017-07-09 21:05:14 +020091 */
Thomas Gleixnere36cf2f2020-03-20 14:13:53 +010092 ENTRY("KIOX000A", "1", X86_MATCH(ATOM_AIRMONT), {
Hans de Goede906dc282017-07-09 21:05:14 +020093 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 Goede1c3b44c2017-10-19 13:23:21 +020096 DMI_MATCH(DMI_BIOS_DATE, "02/21/2017")
97 }),
Thomas Gleixnere36cf2f2020-03-20 14:13:53 +010098 ENTRY("KIOX000A", "1", X86_MATCH(ATOM_AIRMONT), {
Hans de Goede1c3b44c2017-10-19 13:23:21 +020099 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 Goede906dc282017-07-09 21:05:14 +0200102 DMI_MATCH(DMI_BIOS_DATE, "03/20/2017")
103 }),
Thomas Gleixnere36cf2f2020-03-20 14:13:53 +0100104 ENTRY("KIOX000A", "1", X86_MATCH(ATOM_AIRMONT), {
Hans de Goede1c3b44c2017-10-19 13:23:21 +0200105 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 Goedeb7ecf662017-04-21 12:47:40 +0200110};
111
112bool acpi_device_always_present(struct acpi_device *adev)
113{
Hans de Goedeb7ecf662017-04-21 12:47:40 +0200114 bool ret = false;
115 unsigned int i;
116
Hans de Goedeb7ecf662017-04-21 12:47:40 +0200117 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 Goede3b6a70b2017-07-09 21:05:12 +0200128 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 Goedeb7ecf662017-04-21 12:47:40 +0200132 ret = true;
133 break;
134 }
Hans de Goedeb7ecf662017-04-21 12:47:40 +0200135
136 return ret;
137}
Mario Limonciello6485fc12021-06-09 13:40:18 -0500138
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 */
153static 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
159bool force_storage_d3(void)
160{
161 return x86_match_cpu(storage_d3_cpu_ids);
162}