xref: /openbmc/linux/drivers/acpi/x86/utils.c (revision 8ad09ddc63ace3950ac43db6fbfe25b40f589dd6)
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 	 */
292 #if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS)
293 	{
294 		/* Acer Iconia One 7 B1-750 */
295 		.matches = {
296 			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
297 			DMI_MATCH(DMI_PRODUCT_NAME, "VESPA2"),
298 		},
299 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
300 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
301 					ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
302 	},
303 	{
304 		.matches = {
305 			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
306 			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"),
307 		},
308 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
309 					ACPI_QUIRK_UART1_TTY_UART2_SKIP |
310 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
311 					ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
312 	},
313 	{
314 		/* Lenovo Yoga Book X90F/L */
315 		.matches = {
316 			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
317 			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"),
318 			DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"),
319 		},
320 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
321 					ACPI_QUIRK_UART1_SKIP |
322 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
323 					ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
324 	},
325 	{
326 		.matches = {
327 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
328 			DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"),
329 		},
330 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
331 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
332 					ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
333 	},
334 	{
335 		/* Lenovo Yoga Tablet 2 1050F/L */
336 		.matches = {
337 			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
338 			DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"),
339 			DMI_MATCH(DMI_BOARD_NAME, "BYT-T FFD8"),
340 			/* Partial match on beginning of BIOS version */
341 			DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"),
342 		},
343 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
344 					ACPI_QUIRK_PNP_UART1_SKIP |
345 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
346 	},
347 	{
348 		/* Lenovo Yoga Tab 3 Pro X90F */
349 		.matches = {
350 			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
351 			DMI_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"),
352 			DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
353 		},
354 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
355 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
356 	},
357 	{
358 		/* Medion Lifetab S10346 */
359 		.matches = {
360 			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
361 			DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
362 			/* Way too generic, also match on BIOS data */
363 			DMI_MATCH(DMI_BIOS_DATE, "10/22/2015"),
364 		},
365 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
366 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
367 	},
368 	{
369 		/* Nextbook Ares 8 (BYT version)*/
370 		.matches = {
371 			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
372 			DMI_MATCH(DMI_PRODUCT_NAME, "M890BAP"),
373 		},
374 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
375 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
376 					ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
377 	},
378 	{
379 		/* Nextbook Ares 8A (CHT version)*/
380 		.matches = {
381 			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
382 			DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"),
383 			DMI_MATCH(DMI_BIOS_VERSION, "M882"),
384 		},
385 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
386 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
387 	},
388 	{
389 		/* Vexia Edu Atla 10 tablet 9V version */
390 		.matches = {
391 			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
392 			DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
393 			/* Above strings are too generic, also match on BIOS date */
394 			DMI_MATCH(DMI_BIOS_DATE, "08/25/2014"),
395 		},
396 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
397 					ACPI_QUIRK_UART1_SKIP |
398 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY |
399 					ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS),
400 	},
401 	{
402 		/* Whitelabel (sold as various brands) TM800A550L */
403 		.matches = {
404 			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
405 			DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
406 			/* Above strings are too generic, also match on BIOS version */
407 			DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"),
408 		},
409 		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
410 					ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY),
411 	},
412 #endif
413 	{}
414 };
415 
416 #if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS)
417 static const struct acpi_device_id i2c_acpi_known_good_ids[] = {
418 	{ "10EC5640", 0 }, /* RealTek ALC5640 audio codec */
419 	{ "10EC5651", 0 }, /* RealTek ALC5651 audio codec */
420 	{ "INT33F4", 0 },  /* X-Powers AXP288 PMIC */
421 	{ "INT33FD", 0 },  /* Intel Crystal Cove PMIC */
422 	{ "INT34D3", 0 },  /* Intel Whiskey Cove PMIC */
423 	{ "NPCE69A", 0 },  /* Asus Transformer keyboard dock */
424 	{}
425 };
426 
427 bool acpi_quirk_skip_i2c_client_enumeration(struct acpi_device *adev)
428 {
429 	const struct dmi_system_id *dmi_id;
430 	long quirks;
431 
432 	dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
433 	if (!dmi_id)
434 		return false;
435 
436 	quirks = (unsigned long)dmi_id->driver_data;
437 	if (!(quirks & ACPI_QUIRK_SKIP_I2C_CLIENTS))
438 		return false;
439 
440 	return acpi_match_device_ids(adev, i2c_acpi_known_good_ids);
441 }
442 EXPORT_SYMBOL_GPL(acpi_quirk_skip_i2c_client_enumeration);
443 
444 static int acpi_dmi_skip_serdev_enumeration(struct device *controller_parent, bool *skip)
445 {
446 	struct acpi_device *adev = ACPI_COMPANION(controller_parent);
447 	const struct dmi_system_id *dmi_id;
448 	long quirks = 0;
449 	u64 uid = 0;
450 
451 	dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
452 	if (!dmi_id)
453 		return 0;
454 
455 	quirks = (unsigned long)dmi_id->driver_data;
456 
457 	/* uid is left at 0 on errors and 0 is not a valid UART UID */
458 	acpi_dev_uid_to_integer(adev, &uid);
459 
460 	/* For PCI UARTs without an UID */
461 	if (!uid && dev_is_pci(controller_parent)) {
462 		struct pci_dev *pdev = to_pci_dev(controller_parent);
463 
464 		/*
465 		 * Devfn values for PCI UARTs on Bay Trail SoCs, which are
466 		 * the only devices where this fallback is necessary.
467 		 */
468 		if (pdev->devfn == PCI_DEVFN(0x1e, 3))
469 			uid = 1;
470 		else if (pdev->devfn == PCI_DEVFN(0x1e, 4))
471 			uid = 2;
472 	}
473 
474 	if (!uid)
475 		return 0;
476 
477 	if (!dev_is_platform(controller_parent) && !dev_is_pci(controller_parent)) {
478 		/* PNP enumerated UARTs */
479 		if ((quirks & ACPI_QUIRK_PNP_UART1_SKIP) && uid == 1)
480 			*skip = true;
481 
482 		return 0;
483 	}
484 
485 	if ((quirks & ACPI_QUIRK_UART1_SKIP) && uid == 1)
486 		*skip = true;
487 
488 	if (quirks & ACPI_QUIRK_UART1_TTY_UART2_SKIP) {
489 		if (uid == 1)
490 			return -ENODEV; /* Create tty cdev instead of serdev */
491 
492 		if (uid == 2)
493 			*skip = true;
494 	}
495 
496 	return 0;
497 }
498 
499 bool acpi_quirk_skip_gpio_event_handlers(void)
500 {
501 	const struct dmi_system_id *dmi_id;
502 	long quirks;
503 
504 	dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
505 	if (!dmi_id)
506 		return false;
507 
508 	quirks = (unsigned long)dmi_id->driver_data;
509 	return (quirks & ACPI_QUIRK_SKIP_GPIO_EVENT_HANDLERS);
510 }
511 EXPORT_SYMBOL_GPL(acpi_quirk_skip_gpio_event_handlers);
512 #else
513 static int acpi_dmi_skip_serdev_enumeration(struct device *controller_parent, bool *skip)
514 {
515 	return 0;
516 }
517 #endif
518 
519 int acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *skip)
520 {
521 	*skip = false;
522 
523 	return acpi_dmi_skip_serdev_enumeration(controller_parent, skip);
524 }
525 EXPORT_SYMBOL_GPL(acpi_quirk_skip_serdev_enumeration);
526 
527 /* Lists of PMIC ACPI HIDs with an (often better) native charger driver */
528 static const struct {
529 	const char *hid;
530 	int hrv;
531 } acpi_skip_ac_and_battery_pmic_ids[] = {
532 	{ "INT33F4", -1 }, /* X-Powers AXP288 PMIC */
533 	{ "INT34D3",  3 }, /* Intel Cherrytrail Whiskey Cove PMIC */
534 };
535 
536 bool acpi_quirk_skip_acpi_ac_and_battery(void)
537 {
538 	const struct dmi_system_id *dmi_id;
539 	long quirks = 0;
540 	int i;
541 
542 	dmi_id = dmi_first_match(acpi_quirk_skip_dmi_ids);
543 	if (dmi_id)
544 		quirks = (unsigned long)dmi_id->driver_data;
545 
546 	if (quirks & ACPI_QUIRK_SKIP_ACPI_AC_AND_BATTERY)
547 		return true;
548 
549 	if (quirks & ACPI_QUIRK_USE_ACPI_AC_AND_BATTERY)
550 		return false;
551 
552 	for (i = 0; i < ARRAY_SIZE(acpi_skip_ac_and_battery_pmic_ids); i++) {
553 		if (acpi_dev_present(acpi_skip_ac_and_battery_pmic_ids[i].hid, "1",
554 				     acpi_skip_ac_and_battery_pmic_ids[i].hrv)) {
555 			pr_info_once("found native %s PMIC, skipping ACPI AC and battery devices\n",
556 				     acpi_skip_ac_and_battery_pmic_ids[i].hid);
557 			return true;
558 		}
559 	}
560 
561 	return false;
562 }
563 EXPORT_SYMBOL_GPL(acpi_quirk_skip_acpi_ac_and_battery);
564 
565 /* This section provides a workaround for a specific x86 system
566  * which requires disabling of mwait to work correctly.
567  */
568 static int __init acpi_proc_quirk_set_no_mwait(const struct dmi_system_id *id)
569 {
570 	pr_notice("%s detected - disabling mwait for CPU C-states\n",
571 		  id->ident);
572 	boot_option_idle_override = IDLE_NOMWAIT;
573 	return 0;
574 }
575 
576 static const struct dmi_system_id acpi_proc_quirk_mwait_dmi_table[] __initconst = {
577 	{
578 		.callback = acpi_proc_quirk_set_no_mwait,
579 		.ident = "Extensa 5220",
580 		.matches =  {
581 			DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
582 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
583 			DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
584 			DMI_MATCH(DMI_BOARD_NAME, "Columbia"),
585 		},
586 		.driver_data = NULL,
587 	},
588 	{}
589 };
590 
591 void __init acpi_proc_quirk_mwait_check(void)
592 {
593 	/*
594 	 * Check whether the system is DMI table. If yes, OSPM
595 	 * should not use mwait for CPU-states.
596 	 */
597 	dmi_check_system(acpi_proc_quirk_mwait_dmi_table);
598 }
599