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