Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 1 | /* |
| 2 | * X86 ACPI Utility Functions |
| 3 | * |
| 4 | * Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com> |
| 5 | * |
| 6 | * Based on various non upstream patches to support the CHT Whiskey Cove PMIC: |
| 7 | * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/acpi.h> |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 15 | #include <linux/dmi.h> |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 16 | #include <asm/cpu_device_id.h> |
| 17 | #include <asm/intel-family.h> |
| 18 | #include "../internal.h" |
| 19 | |
| 20 | /* |
| 21 | * Some ACPI devices are hidden (status == 0x0) in recent BIOS-es because |
| 22 | * some recent Windows drivers bind to one device but poke at multiple |
| 23 | * devices at the same time, so the others get hidden. |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 24 | * |
| 25 | * Some BIOS-es (temporarily) hide specific APCI devices to work around Windows |
| 26 | * driver bugs. We use DMI matching to match known cases of this. |
| 27 | * |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 28 | * We work around this by always reporting ACPI_STA_DEFAULT for these |
| 29 | * devices. Note this MUST only be done for devices where this is safe. |
| 30 | * |
| 31 | * This forcing of devices to be present is limited to specific CPU (SoC) |
| 32 | * models both to avoid potentially causing trouble on other models and |
| 33 | * because some HIDs are re-used on different SoCs for completely |
| 34 | * different devices. |
| 35 | */ |
| 36 | struct always_present_id { |
| 37 | struct acpi_device_id hid[2]; |
| 38 | struct x86_cpu_id cpu_ids[2]; |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 39 | struct dmi_system_id dmi_ids[2]; /* Optional */ |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 40 | const char *uid; |
| 41 | }; |
| 42 | |
| 43 | #define ICPU(model) { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, } |
| 44 | |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 45 | #define ENTRY(hid, uid, cpu_models, dmi...) { \ |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 46 | { { hid, }, {} }, \ |
| 47 | { cpu_models, {} }, \ |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 48 | { { .matches = dmi }, {} }, \ |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 49 | uid, \ |
| 50 | } |
| 51 | |
| 52 | static const struct always_present_id always_present_ids[] = { |
| 53 | /* |
| 54 | * Bay / Cherry Trail PWM directly poked by GPU driver in win10, |
| 55 | * but Linux uses a separate PWM driver, harmless if not used. |
| 56 | */ |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 57 | ENTRY("80860F09", "1", ICPU(INTEL_FAM6_ATOM_SILVERMONT1), {}), |
| 58 | ENTRY("80862288", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {}), |
Hans de Goede | 753a448 | 2017-04-21 12:47:41 +0200 | [diff] [blame] | 59 | /* |
| 60 | * The INT0002 device is necessary to clear wakeup interrupt sources |
| 61 | * on Cherry Trail devices, without it we get nobody cared IRQ msgs. |
| 62 | */ |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 63 | ENTRY("INT0002", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {}), |
Hans de Goede | b5cc169 | 2017-07-09 21:05:13 +0200 | [diff] [blame] | 64 | /* |
Tristian Celestin | 72a361a | 2018-06-09 18:18:06 -0400 | [diff] [blame^] | 65 | * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides |
| 66 | * the touchscreen ACPI device until a certain time |
| 67 | * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed |
| 68 | * *and* _STA has been called at least 3 times since. |
Hans de Goede | b5cc169 | 2017-07-09 21:05:13 +0200 | [diff] [blame] | 69 | */ |
| 70 | ENTRY("SYNA7500", "1", ICPU(INTEL_FAM6_HASWELL_ULT), { |
| 71 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 72 | DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"), |
| 73 | }), |
Tristian Celestin | 72a361a | 2018-06-09 18:18:06 -0400 | [diff] [blame^] | 74 | ENTRY("SYNA7500", "1", ICPU(INTEL_FAM6_HASWELL_ULT), { |
| 75 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
| 76 | DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"), |
| 77 | }), |
| 78 | |
Hans de Goede | 906dc28 | 2017-07-09 21:05:14 +0200 | [diff] [blame] | 79 | /* |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 80 | * The GPD win BIOS dated 20170221 has disabled the accelerometer, the |
Hans de Goede | 906dc28 | 2017-07-09 21:05:14 +0200 | [diff] [blame] | 81 | * drivers sometimes cause crashes under Windows and this is how the |
| 82 | * manufacturer has solved this :| Note that the the DMI data is less |
| 83 | * generic then it seems, a board_vendor of "AMI Corporation" is quite |
| 84 | * rare and a board_name of "Default String" also is rare. |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 85 | * |
| 86 | * Unfortunately the GPD pocket also uses these strings and its BIOS |
| 87 | * was copy-pasted from the GPD win, so it has a disabled KIOX000A |
| 88 | * 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] | 89 | */ |
| 90 | ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), { |
| 91 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 92 | DMI_MATCH(DMI_BOARD_NAME, "Default string"), |
| 93 | DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 94 | DMI_MATCH(DMI_BIOS_DATE, "02/21/2017") |
| 95 | }), |
| 96 | ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), { |
| 97 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 98 | DMI_MATCH(DMI_BOARD_NAME, "Default string"), |
| 99 | DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), |
Hans de Goede | 906dc28 | 2017-07-09 21:05:14 +0200 | [diff] [blame] | 100 | DMI_MATCH(DMI_BIOS_DATE, "03/20/2017") |
| 101 | }), |
Hans de Goede | 1c3b44c | 2017-10-19 13:23:21 +0200 | [diff] [blame] | 102 | ENTRY("KIOX000A", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), { |
| 103 | DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), |
| 104 | DMI_MATCH(DMI_BOARD_NAME, "Default string"), |
| 105 | DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), |
| 106 | DMI_MATCH(DMI_BIOS_DATE, "05/25/2017") |
| 107 | }), |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | bool acpi_device_always_present(struct acpi_device *adev) |
| 111 | { |
| 112 | u32 *status = (u32 *)&adev->status; |
| 113 | u32 old_status = *status; |
| 114 | bool ret = false; |
| 115 | unsigned int i; |
| 116 | |
| 117 | /* acpi_match_device_ids checks status, so set it to default */ |
| 118 | *status = ACPI_STA_DEFAULT; |
| 119 | for (i = 0; i < ARRAY_SIZE(always_present_ids); i++) { |
| 120 | if (acpi_match_device_ids(adev, always_present_ids[i].hid)) |
| 121 | continue; |
| 122 | |
| 123 | if (!adev->pnp.unique_id || |
| 124 | strcmp(adev->pnp.unique_id, always_present_ids[i].uid)) |
| 125 | continue; |
| 126 | |
| 127 | if (!x86_match_cpu(always_present_ids[i].cpu_ids)) |
| 128 | continue; |
| 129 | |
Hans de Goede | 3b6a70b | 2017-07-09 21:05:12 +0200 | [diff] [blame] | 130 | if (always_present_ids[i].dmi_ids[0].matches[0].slot && |
| 131 | !dmi_check_system(always_present_ids[i].dmi_ids)) |
| 132 | continue; |
| 133 | |
Hans de Goede | b7ecf66 | 2017-04-21 12:47:40 +0200 | [diff] [blame] | 134 | if (old_status != ACPI_STA_DEFAULT) /* Log only once */ |
| 135 | dev_info(&adev->dev, |
| 136 | "Device [%s] is in always present list\n", |
| 137 | adev->pnp.bus_id); |
| 138 | |
| 139 | ret = true; |
| 140 | break; |
| 141 | } |
| 142 | *status = old_status; |
| 143 | |
| 144 | return ret; |
| 145 | } |