utils.c 21 KB

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