1 // SPDX-License-Identifier: GPL-2.0-only 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. 9 */ 10 11 #define pr_fmt(fmt) "ACPI: " fmt 12 13 #include <linux/acpi.h> 14 #include <linux/dmi.h> 15 #include <linux/pci.h> 16 #include <linux/platform_device.h> 17 #include <asm/cpu_device_id.h> 18 #include <asm/intel-family.h> 19 #include "../internal.h" 20 21 /* 22 * Some ACPI devices are hidden (status == 0x0) in recent BIOS-es because 23 * some recent Windows drivers bind to one device but poke at multiple 24 * devices at the same time, so the others get hidden. 25 * 26 * Some BIOS-es (temporarily) hide specific APCI devices to work around Windows 27 * driver bugs. We use DMI matching to match known cases of this. 28 * 29 * Likewise sometimes some not-actually present devices are sometimes 30 * reported as present, which may cause issues. 31 * 32 * We work around this by using the below quirk list to override the status 33 * reported by the _STA method with a fixed value (ACPI_STA_DEFAULT or 0). 34 * Note this MUST only be done for devices where this is safe. 35 * 36 * This status overriding is limited to specific CPU (SoC) models both to 37 * avoid potentially causing trouble on other models and because some HIDs 38 * are re-used on different SoCs for completely different devices. 39 */ 40 struct override_status_id { 41 struct acpi_device_id hid[2]; 42 struct x86_cpu_id cpu_ids[2]; 43 struct dmi_system_id dmi_ids[2]; /* Optional */ 44 const char *uid; 45 const char *path; 46 unsigned long long status; 47 }; 48 49 #define ENTRY(status, hid, uid, path, cpu_model, dmi...) { \ 50 { { hid, }, {} }, \ 51 { X86_MATCH_INTEL_FAM6_MODEL(cpu_model, NULL), {} }, \ 52 { { .matches = dmi }, {} }, \ 53 uid, \ 54 path, \ 55 status, \ 56 } 57 58 #define PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \ 59 ENTRY(ACPI_STA_DEFAULT, hid, uid, NULL, cpu_model, dmi) 60 61 #define NOT_PRESENT_ENTRY_HID(hid, uid, cpu_model, dmi...) \ 62 ENTRY(0, hid, uid, NULL, cpu_model, dmi) 63 64 #define PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \ 65 ENTRY(ACPI_STA_DEFAULT, "", NULL, path, cpu_model, dmi) 66 67 #define NOT_PRESENT_ENTRY_PATH(path, cpu_model, dmi...) \ 68 ENTRY(0, "", NULL, path, cpu_model, dmi) 69 70 static const struct override_status_id override_status_ids[] = { 71 /* 72 * Bay / Cherry Trail PWM directly poked by GPU driver in win10, 73 * but Linux uses a separate PWM driver, harmless if not used. 74 */ 75 PRESENT_ENTRY_HID("80860F09", "1", ATOM_SILVERMONT, {}), 76 PRESENT_ENTRY_HID("80862288", "1", ATOM_AIRMONT, {}), 77 78 /* The Xiaomi Mi Pad 2 uses PWM2 for touchkeys backlight control */ 79 PRESENT_ENTRY_HID("80862289", "2", ATOM_AIRMONT, { 80 DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"), 81 DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"), 82 }), 83 84 /* 85 * The INT0002 device is necessary to clear wakeup interrupt sources 86 * on Cherry Trail devices, without it we get nobody cared IRQ msgs. 87 */ 88 PRESENT_ENTRY_HID("INT0002", "1", ATOM_AIRMONT, {}), 89 /* 90 * On the Dell Venue 11 Pro 7130 and 7139, the DSDT hides 91 * the touchscreen ACPI device until a certain time 92 * after _SB.PCI0.GFX0.LCD.LCD1._ON gets called has passed 93 * *and* _STA has been called at least 3 times since. 94 */ 95 PRESENT_ENTRY_HID("SYNA7500", "1", HASWELL_L, { 96 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 97 DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7130"), 98 }), 99 PRESENT_ENTRY_HID("SYNA7500", "1", HASWELL_L, { 100 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 101 DMI_MATCH(DMI_PRODUCT_NAME, "Venue 11 Pro 7139"), 102 }), 103 104 /* 105 * The GPD win BIOS dated 20170221 has disabled the accelerometer, the 106 * drivers sometimes cause crashes under Windows and this is how the 107 * manufacturer has solved this :| The DMI match may not seem unique, 108 * but it is. In the 67000+ DMI decode dumps from linux-hardware.org 109 * only 116 have board_vendor set to "AMI Corporation" and of those 116 110 * only the GPD win and pocket entries' board_name is "Default string". 111 * 112 * Unfortunately the GPD pocket also uses these strings and its BIOS 113 * was copy-pasted from the GPD win, so it has a disabled KIOX000A 114 * node which we should not enable, thus we also check the BIOS date. 115 */ 116 PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { 117 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 118 DMI_MATCH(DMI_BOARD_NAME, "Default string"), 119 DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 120 DMI_MATCH(DMI_BIOS_DATE, "02/21/2017") 121 }), 122 PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { 123 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 124 DMI_MATCH(DMI_BOARD_NAME, "Default string"), 125 DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 126 DMI_MATCH(DMI_BIOS_DATE, "03/20/2017") 127 }), 128 PRESENT_ENTRY_HID("KIOX000A", "1", ATOM_AIRMONT, { 129 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 130 DMI_MATCH(DMI_BOARD_NAME, "Default string"), 131 DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), 132 DMI_MATCH(DMI_BIOS_DATE, "05/25/2017") 133 }), 134 135 /* 136 * The GPD win/pocket have a PCI wifi card, but its DSDT has the SDIO 137 * mmc controller enabled and that has a child-device which _PS3 138 * method sets a GPIO causing the PCI wifi card to turn off. 139 * See above remark about uniqueness of the DMI match. 140 */ 141 NOT_PRESENT_ENTRY_PATH("\\_SB_.PCI0.SDHB.BRC1", ATOM_AIRMONT, { 142 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 143 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"), 144 DMI_EXACT_MATCH(DMI_BOARD_SERIAL, "Default string"), 145 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Default string"), 146 }), 147 148 /* 149 * The LSM303D on the Lenovo Yoga Tablet 2 series is present 150 * as both ACCL0001 and MAGN0001. As we can only ever register an 151 * i2c client for one of them, ignore MAGN0001. 152 */ 153 NOT_PRESENT_ENTRY_HID("MAGN0001", "1", ATOM_SILVERMONT, { 154 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 155 DMI_MATCH(DMI_PRODUCT_FAMILY, "YOGATablet2"), 156 }), 157 }; 158 159 bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *status) 160 { 161 bool ret = false; 162 unsigned int i; 163 164 for (i = 0; i < ARRAY_SIZE(override_status_ids); i++) { 165 if (!x86_match_cpu(override_status_ids[i].cpu_ids)) 166 continue; 167 168 if (override_status_ids[i].dmi_ids[0].matches[0].slot && 169 !dmi_check_system(override_status_ids[i].dmi_ids)) 170 continue; 171 172 if (override_status_ids[i].path) { 173 struct acpi_buffer path = { ACPI_ALLOCATE_BUFFER, NULL }; 174 bool match; 175 176 if (acpi_get_name(adev->handle, ACPI_FULL_PATHNAME, &path)) 177 continue; 178 179 match = strcmp((char *)path.pointer, override_status_ids[i].path) == 0; 180 kfree(path.pointer); 181 182 if (!match) 183 continue; 184 } else { 185 if (acpi_match_device_ids(adev, override_status_ids[i].hid)) 186 continue; 187 188 if (!adev->pnp.unique_id || 189 strcmp(adev->pnp.unique_id, override_status_ids[i].uid)) 190 continue; 191 } 192 193 *status = override_status_ids[i].status; 194 ret = true; 195 break; 196 } 197 198 return ret; 199 } 200 201 /* 202 * AMD systems from Renoir onwards *require* that the NVME controller 203 * is put into D3 over a Modern Standby / suspend-to-idle cycle. 204 * 205 * This is "typically" accomplished using the `StorageD3Enable` 206 * property in the _DSD that is checked via the `acpi_storage_d3` function 207 * but some OEM systems still don't have it in their BIOS. 208 * 209 * The Microsoft documentation for StorageD3Enable mentioned that Windows has 210 * a hardcoded allowlist for D3 support as well as a registry key to override 211 * the BIOS, which has been used for these cases. 212 * 213 * This allows quirking on Linux in a similar fashion. 214 * 215 * Cezanne systems shouldn't *normally* need this as the BIOS includes 216 * StorageD3Enable. But for two reasons we have added it. 217 * 1) The BIOS on a number of Dell systems have ambiguity 218 * between the same value used for _ADR on ACPI nodes GPP1.DEV0 and GPP1.NVME. 219 * GPP1.NVME is needed to get StorageD3Enable node set properly. 220 * https://bugzilla.kernel.org/show_bug.cgi?id=216440 221 * https://bugzilla.kernel.org/show_bug.cgi?id=216773 222 * https://bugzilla.kernel.org/show_bug.cgi?id=217003 223 * 2) On at least one HP system StorageD3Enable is missing on the second NVME 224 * disk in the system. 225 * 3) On at least one HP Rembrandt system StorageD3Enable is missing on the only 226 * NVME device. 227 */ 228 bool force_storage_d3(void) 229 { 230 if (!cpu_feature_enabled(X86_FEATURE_ZEN)) 231 return false; 232 return acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0; 233 } 234 235 /* 236 * x86 ACPI boards which ship with only Android as their factory image usually 237 * declare a whole bunch of bogus I2C devices in their ACPI tables and sometimes 238 * there are issues with serdev devices on these boards too, e.g. the resource 239 * points to the wrong serdev_controller. 240 * 241 * Instantiating I2C / serdev devs for these bogus devs causes various issues, 242 * e.g. GPIO/IRQ resource conflicts because sometimes drivers do bind to them. 243 * The Android x86 kernel fork shipped on these devices has some special code 244 * to remove the bogus I2C clients (and AFAICT serdevs are ignored completely). 245 * 246 * The acpi_quirk_skip_*_enumeration() functions below are used by the I2C or 247 * serdev code to skip instantiating any I2C or serdev devs on broken boards. 248 * 249 * In case of I2C an exception is made for HIDs on the i2c_acpi_known_good_ids 250 * list. These are known to always be correct (and in case of the audio-codecs 251 * the drivers heavily rely on the codec being enumerated through ACPI). 252 * 253 * Note these boards typically do actually have I2C and serdev devices, 254 * just different ones then the ones described in their DSDT. The devices 255 * which are actually present are manually instantiated by the 256 * drivers/platform/x86/x86-android-tablets.c kernel module. 257 */ 258 #define ACPI_QUIRK_SKIP_I2C_CLIENTS BIT(0) 259 #define ACPI_QUIRK_UART1_SKIP BIT(1) 260 #define ACPI_QUIRK_UART1_TTY_UART2_SKIP BIT(2) 261 #define ACPI_QUIRK_PNP_UART1_SKIP BIT(3) 262 #define ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY BIT(4) 263 #define ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY BIT(5) 264 #define ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS BIT(6) 265 266 static const struct dmi_system_id acpi_quirk_skip_dmi_ids[] = { 267 /* 268 * 1. Devices with only the skip / don't-skip AC and battery quirks, 269 * sorted alphabetically. 270 */ 271 { 272 /* ECS EF20EA, AXP288 PMIC but uses separate fuel-gauge */ 273 .matches = { 274 DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"), 275 }, 276 .driver_data = (void *)ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY 277 }, 278 { 279 /* Lenovo Ideapad Miix 320, AXP288 PMIC, separate fuel-gauge */ 280 .matches = { 281 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 282 DMI_MATCH(DMI_PRODUCT_NAME, "80XF"), 283 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"), 284 }, 285 .driver_data = (void *)ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY 286 }, 287 288 /* 289 * 2. Devices which also have the skip i2c/serdev quirks and which 290 * need the x86-android-tablets module to properly work. 291 * Sorted alphabetically. 292 */ 293 #if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS) 294 { 295 /* Acer Iconia One 7 B1-750 */ 296 .matches = { 297 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), 298 DMI_MATCH(DMI_PRODUCT_NAME, "VESPA2"), 299 }, 300 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 301 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY | 302 ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS), 303 }, 304 { 305 /* Acer Iconia One 8 A1-840 (non FHD version) */ 306 .matches = { 307 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), 308 DMI_MATCH(DMI_PRODUCT_NAME, "BayTrail"), 309 /* Above strings are too generic also match BIOS date */ 310 DMI_MATCH(DMI_BIOS_DATE, "04/01/2014"), 311 }, 312 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 313 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY | 314 ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS), 315 }, 316 { 317 /* Asus ME176C tablet */ 318 .matches = { 319 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 320 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"), 321 }, 322 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 323 ACPI_QUIRK_UART1_TTY_UART2_SKIP | 324 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY | 325 ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS), 326 }, 327 { 328 /* Asus TF103C transformer 2-in-1 */ 329 .matches = { 330 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 331 DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"), 332 }, 333 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 334 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY | 335 ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS), 336 }, 337 { 338 /* Lenovo Yoga Book X90F/L */ 339 .matches = { 340 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), 341 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"), 342 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"), 343 }, 344 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 345 ACPI_QUIRK_UART1_SKIP | 346 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY | 347 ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS), 348 }, 349 { 350 /* Lenovo Yoga Tablet 2 1050F/L */ 351 .matches = { 352 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."), 353 DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"), 354 DMI_MATCH(DMI_BOARD_NAME, "BYT-T FFD8"), 355 /* Partial match on beginning of BIOS version */ 356 DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"), 357 }, 358 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 359 ACPI_QUIRK_PNP_UART1_SKIP | 360 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 361 }, 362 { 363 /* Lenovo Yoga Tab 3 Pro X90F */ 364 .matches = { 365 DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), 366 DMI_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"), 367 DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"), 368 }, 369 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 370 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 371 }, 372 { 373 /* Medion Lifetab S10346 */ 374 .matches = { 375 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 376 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), 377 /* Way too generic, also match on BIOS data */ 378 DMI_MATCH(DMI_BIOS_DATE, "10/22/2015"), 379 }, 380 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 381 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 382 }, 383 { 384 /* Nextbook Ares 8 (BYT version)*/ 385 .matches = { 386 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), 387 DMI_MATCH(DMI_PRODUCT_NAME, "M890BAP"), 388 }, 389 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 390 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY | 391 ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS), 392 }, 393 { 394 /* Nextbook Ares 8A (CHT version)*/ 395 .matches = { 396 DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), 397 DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"), 398 DMI_MATCH(DMI_BIOS_VERSION, "M882"), 399 }, 400 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 401 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 402 }, 403 { 404 /* Vexia Edu Atla 10 tablet 9V version */ 405 .matches = { 406 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 407 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), 408 /* Above strings are too generic, also match on BIOS date */ 409 DMI_MATCH(DMI_BIOS_DATE, "08/25/2014"), 410 }, 411 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 412 ACPI_QUIRK_UART1_SKIP | 413 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY | 414 ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS), 415 }, 416 { 417 /* Whitelabel (sold as various brands) TM800A550L */ 418 .matches = { 419 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), 420 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), 421 /* Above strings are too generic, also match on BIOS version */ 422 DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"), 423 }, 424 .driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS | 425 ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY), 426 }, 427 #endif 428 {} 429 }; 430 431 #if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS) 432 static const struct acpi_device_id i2c_acpi_known_good_ids[] = { 433 { "10EC5640", 0 }, /* RealTek ALC5640 audio codec */ 434 { "10EC5651", 0 }, /* RealTek ALC5651 audio codec */ 435 { "INT33F4", 0 }, /* X-Powers AXP288 PMIC */ 436 { "INT33F5", 0 }, /* TI Dollar Cove PMIC */ 437 { "INT33FD", 0 }, /* Intel Crystal Cove PMIC */ 438 { "INT34D3", 0 }, /* Intel Whiskey Cove PMIC */ 439 { "NPCE69A", 0 }, /* Asus Transformer keyboard dock */ 440 {} 441 }; 442 443 bool acpi_quirk_skip_i2c_client_enumeration(struct acpi_device *adev) 444 { 445 const struct dmi_system_id *dmi_id; 446 long quirks; 447 448 dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids); 449 if (!dmi_id) 450 return false; 451 452 quirks = (unsigned long)dmi_id->driver_data; 453 if (!(quirks & ACPI_QUIRK_SKIP_I2C_CLIENTS)) 454 return false; 455 456 return acpi_match_device_ids(adev, i2c_acpi_known_good_ids); 457 } 458 EXPORT_SYMBOL_GPL(acpi_quirk_skip_i2c_client_enumeration); 459 460 static int acpi_dmi_skip_serdev_enumeration(struct device *controller_parent, bool *skip) 461 { 462 struct acpi_device *adev = ACPI_COMPANION(controller_parent); 463 const struct dmi_system_id *dmi_id; 464 long quirks = 0; 465 u64 uid = 0; 466 467 dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids); 468 if (!dmi_id) 469 return 0; 470 471 quirks = (unsigned long)dmi_id->driver_data; 472 473 /* uid is left at 0 on errors and 0 is not a valid UART UID */ 474 acpi_dev_uid_to_integer(adev, &uid); 475 476 /* For PCI UARTs without an UID */ 477 if (!uid && dev_is_pci(controller_parent)) { 478 struct pci_dev *pdev = to_pci_dev(controller_parent); 479 480 /* 481 * Devfn values for PCI UARTs on Bay Trail SoCs, which are 482 * the only devices where this fallback is necessary. 483 */ 484 if (pdev->devfn == PCI_DEVFN(0x1e, 3)) 485 uid = 1; 486 else if (pdev->devfn == PCI_DEVFN(0x1e, 4)) 487 uid = 2; 488 } 489 490 if (!uid) 491 return 0; 492 493 if (!dev_is_platform(controller_parent) && !dev_is_pci(controller_parent)) { 494 /* PNP enumerated UARTs */ 495 if ((quirks & ACPI_QUIRK_PNP_UART1_SKIP) && uid == 1) 496 *skip = true; 497 498 return 0; 499 } 500 501 if ((quirks & ACPI_QUIRK_UART1_SKIP) && uid == 1) 502 *skip = true; 503 504 if (quirks & ACPI_QUIRK_UART1_TTY_UART2_SKIP) { 505 if (uid == 1) 506 return -ENODEV; /* Create tty cdev instead of serdev */ 507 508 if (uid == 2) 509 *skip = true; 510 } 511 512 return 0; 513 } 514 515 bool acpi_quirk_skip_gpio_event_handlers(void) 516 { 517 const struct dmi_system_id *dmi_id; 518 long quirks; 519 520 dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids); 521 if (!dmi_id) 522 return false; 523 524 quirks = (unsigned long)dmi_id->driver_data; 525 return (quirks & ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS); 526 } 527 EXPORT_SYMBOL_GPL(acpi_quirk_skip_gpio_event_handlers); 528 #else 529 static int acpi_dmi_skip_serdev_enumeration(struct device *controller_parent, bool *skip) 530 { 531 return 0; 532 } 533 #endif 534 535 int acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *skip) 536 { 537 *skip = false; 538 539 return acpi_dmi_skip_serdev_enumeration(controller_parent, skip); 540 } 541 EXPORT_SYMBOL_GPL(acpi_quirk_skip_serdev_enumeration); 542 543 /* Lists of PMIC ACPI HIDs with an (often better) native charger driver */ 544 static const struct { 545 const char *hid; 546 int hrv; 547 } acpi_skip_ac_and_battery_pmic_ids[] = { 548 { "INT33F4", -1 }, /* X-Powers AXP288 PMIC */ 549 { "INT34D3", 3 }, /* Intel Cherrytrail Whiskey Cove PMIC */ 550 }; 551 552 bool acpi_quirk_skip_acpi_ac_and_battery(void) 553 { 554 const struct dmi_system_id *dmi_id; 555 long quirks = 0; 556 int i; 557 558 dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids); 559 if (dmi_id) 560 quirks = (unsigned long)dmi_id->driver_data; 561 562 if (quirks & ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY) 563 return true; 564 565 if (quirks & ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY) 566 return false; 567 568 for (i = 0; i < ARRAY_SIZE(acpi_skip_ac_and_battery_pmic_ids); i++) { 569 if (acpi_dev_present(acpi_skip_ac_and_battery_pmic_ids[i].hid, "1", 570 acpi_skip_ac_and_battery_pmic_ids[i].hrv)) { 571 pr_info_once("found native %s PMIC, skipping ACPI AC and battery devices\n", 572 acpi_skip_ac_and_battery_pmic_ids[i].hid); 573 return true; 574 } 575 } 576 577 return false; 578 } 579 EXPORT_SYMBOL_GPL(acpi_quirk_skip_acpi_ac_and_battery); 580 581 /* This section provides a workaround for a specific x86 system 582 * which requires disabling of mwait to work correctly. 583 */ 584 static int __init acpi_proc_quirk_set_no_mwait(const struct dmi_system_id *id) 585 { 586 pr_notice("%s detected - disabling mwait for CPU C-states\n", 587 id->ident); 588 boot_option_idle_override = IDLE_NOMWAIT; 589 return 0; 590 } 591 592 static const struct dmi_system_id acpi_proc_quirk_mwait_dmi_table[] __initconst = { 593 { 594 .callback = acpi_proc_quirk_set_no_mwait, 595 .ident = "Extensa 5220", 596 .matches = { 597 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), 598 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), 599 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"), 600 DMI_MATCH(DMI_BOARD_NAME, "Columbia"), 601 }, 602 .driver_data = NULL, 603 }, 604 {} 605 }; 606 607 void __init acpi_proc_quirk_mwait_check(void) 608 { 609 /* 610 * Check whether the system is DMI table. If yes, OSPM 611 * should not use mwait for CPU-states. 612 */ 613 dmi_check_system(acpi_proc_quirk_mwait_dmi_table); 614 } 615