utils.c 22 KB

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