resource.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * drivers/acpi/resource.c - ACPI device resources interpretation.
  4. *
  5. * Copyright (C) 2012, Intel Corp.
  6. * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  7. *
  8. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. *
  10. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. */
  12. #include <linux/acpi.h>
  13. #include <linux/device.h>
  14. #include <linux/export.h>
  15. #include <linux/ioport.h>
  16. #include <linux/slab.h>
  17. #include <linux/irq.h>
  18. #include <linux/dmi.h>
  19. #include <linux/string_choices.h>
  20. #ifdef CONFIG_X86
  21. #define valid_IRQ(i) (((i) != 0) && ((i) != 2))
  22. static inline bool acpi_iospace_resource_valid(struct resource *res)
  23. {
  24. /* On X86 IO space is limited to the [0 - 64K] IO port range */
  25. return res->end < 0x10003;
  26. }
  27. #else
  28. #define valid_IRQ(i) (true)
  29. /*
  30. * ACPI IO descriptors on arches other than X86 contain MMIO CPU physical
  31. * addresses mapping IO space in CPU physical address space, IO space
  32. * resources can be placed anywhere in the 64-bit physical address space.
  33. */
  34. static inline bool
  35. acpi_iospace_resource_valid(struct resource *res) { return true; }
  36. #endif
  37. #if IS_ENABLED(CONFIG_ACPI_GENERIC_GSI)
  38. static inline bool is_gsi(struct acpi_resource_extended_irq *ext_irq)
  39. {
  40. return ext_irq->resource_source.string_length == 0 &&
  41. ext_irq->producer_consumer == ACPI_CONSUMER;
  42. }
  43. #else
  44. static inline bool is_gsi(struct acpi_resource_extended_irq *ext_irq)
  45. {
  46. return true;
  47. }
  48. #endif
  49. static bool acpi_dev_resource_len_valid(u64 start, u64 end, u64 len, bool io)
  50. {
  51. u64 reslen = end - start + 1;
  52. /*
  53. * CHECKME: len might be required to check versus a minimum
  54. * length as well. 1 for io is fine, but for memory it does
  55. * not make any sense at all.
  56. * Note: some BIOSes report incorrect length for ACPI address space
  57. * descriptor, so remove check of 'reslen == len' to avoid regression.
  58. */
  59. if (len && reslen && start <= end)
  60. return true;
  61. pr_debug("ACPI: invalid or unassigned resource %s [%016llx - %016llx] length [%016llx]\n",
  62. io ? "io" : "mem", start, end, len);
  63. return false;
  64. }
  65. static void acpi_dev_memresource_flags(struct resource *res, u64 len,
  66. u8 write_protect)
  67. {
  68. res->flags = IORESOURCE_MEM;
  69. if (!acpi_dev_resource_len_valid(res->start, res->end, len, false))
  70. res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;
  71. if (write_protect == ACPI_READ_WRITE_MEMORY)
  72. res->flags |= IORESOURCE_MEM_WRITEABLE;
  73. }
  74. static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len,
  75. u8 write_protect)
  76. {
  77. res->start = start;
  78. res->end = start + len - 1;
  79. acpi_dev_memresource_flags(res, len, write_protect);
  80. }
  81. /**
  82. * acpi_dev_resource_memory - Extract ACPI memory resource information.
  83. * @ares: Input ACPI resource object.
  84. * @res: Output generic resource object.
  85. *
  86. * Check if the given ACPI resource object represents a memory resource and
  87. * if that's the case, use the information in it to populate the generic
  88. * resource object pointed to by @res.
  89. *
  90. * Return:
  91. * 1) false with res->flags setting to zero: not the expected resource type
  92. * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
  93. * 3) true: valid assigned resource
  94. */
  95. bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)
  96. {
  97. struct acpi_resource_memory24 *memory24;
  98. struct acpi_resource_memory32 *memory32;
  99. struct acpi_resource_fixed_memory32 *fixed_memory32;
  100. switch (ares->type) {
  101. case ACPI_RESOURCE_TYPE_MEMORY24:
  102. memory24 = &ares->data.memory24;
  103. acpi_dev_get_memresource(res, memory24->minimum << 8,
  104. memory24->address_length << 8,
  105. memory24->write_protect);
  106. break;
  107. case ACPI_RESOURCE_TYPE_MEMORY32:
  108. memory32 = &ares->data.memory32;
  109. acpi_dev_get_memresource(res, memory32->minimum,
  110. memory32->address_length,
  111. memory32->write_protect);
  112. break;
  113. case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
  114. fixed_memory32 = &ares->data.fixed_memory32;
  115. acpi_dev_get_memresource(res, fixed_memory32->address,
  116. fixed_memory32->address_length,
  117. fixed_memory32->write_protect);
  118. break;
  119. default:
  120. res->flags = 0;
  121. return false;
  122. }
  123. return !(res->flags & IORESOURCE_DISABLED);
  124. }
  125. EXPORT_SYMBOL_GPL(acpi_dev_resource_memory);
  126. static void acpi_dev_ioresource_flags(struct resource *res, u64 len,
  127. u8 io_decode, u8 translation_type)
  128. {
  129. res->flags = IORESOURCE_IO;
  130. if (!acpi_dev_resource_len_valid(res->start, res->end, len, true))
  131. res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;
  132. if (!acpi_iospace_resource_valid(res))
  133. res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;
  134. if (io_decode == ACPI_DECODE_16)
  135. res->flags |= IORESOURCE_IO_16BIT_ADDR;
  136. if (translation_type == ACPI_SPARSE_TRANSLATION)
  137. res->flags |= IORESOURCE_IO_SPARSE;
  138. }
  139. static void acpi_dev_get_ioresource(struct resource *res, u64 start, u64 len,
  140. u8 io_decode)
  141. {
  142. res->start = start;
  143. res->end = start + len - 1;
  144. acpi_dev_ioresource_flags(res, len, io_decode, 0);
  145. }
  146. /**
  147. * acpi_dev_resource_io - Extract ACPI I/O resource information.
  148. * @ares: Input ACPI resource object.
  149. * @res: Output generic resource object.
  150. *
  151. * Check if the given ACPI resource object represents an I/O resource and
  152. * if that's the case, use the information in it to populate the generic
  153. * resource object pointed to by @res.
  154. *
  155. * Return:
  156. * 1) false with res->flags setting to zero: not the expected resource type
  157. * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
  158. * 3) true: valid assigned resource
  159. */
  160. bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)
  161. {
  162. struct acpi_resource_io *io;
  163. struct acpi_resource_fixed_io *fixed_io;
  164. switch (ares->type) {
  165. case ACPI_RESOURCE_TYPE_IO:
  166. io = &ares->data.io;
  167. acpi_dev_get_ioresource(res, io->minimum,
  168. io->address_length,
  169. io->io_decode);
  170. break;
  171. case ACPI_RESOURCE_TYPE_FIXED_IO:
  172. fixed_io = &ares->data.fixed_io;
  173. acpi_dev_get_ioresource(res, fixed_io->address,
  174. fixed_io->address_length,
  175. ACPI_DECODE_10);
  176. break;
  177. default:
  178. res->flags = 0;
  179. return false;
  180. }
  181. return !(res->flags & IORESOURCE_DISABLED);
  182. }
  183. EXPORT_SYMBOL_GPL(acpi_dev_resource_io);
  184. static bool acpi_decode_space(struct resource_win *win,
  185. struct acpi_resource_address *addr,
  186. struct acpi_address64_attribute *attr)
  187. {
  188. u8 iodec = attr->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16;
  189. bool wp = addr->info.mem.write_protect;
  190. u64 len = attr->address_length;
  191. u64 start, end, offset = 0;
  192. struct resource *res = &win->res;
  193. /*
  194. * Filter out invalid descriptor according to ACPI Spec 5.0, section
  195. * 6.4.3.5 Address Space Resource Descriptors.
  196. */
  197. if ((addr->min_address_fixed != addr->max_address_fixed && len) ||
  198. (addr->min_address_fixed && addr->max_address_fixed && !len))
  199. pr_debug("ACPI: Invalid address space min_addr_fix %d, max_addr_fix %d, len %llx\n",
  200. addr->min_address_fixed, addr->max_address_fixed, len);
  201. /*
  202. * For bridges that translate addresses across the bridge,
  203. * translation_offset is the offset that must be added to the
  204. * address on the secondary side to obtain the address on the
  205. * primary side. Non-bridge devices must list 0 for all Address
  206. * Translation offset bits.
  207. */
  208. if (addr->producer_consumer == ACPI_PRODUCER)
  209. offset = attr->translation_offset;
  210. else if (attr->translation_offset)
  211. pr_debug("ACPI: translation_offset(%lld) is invalid for non-bridge device.\n",
  212. attr->translation_offset);
  213. start = attr->minimum + offset;
  214. end = attr->maximum + offset;
  215. win->offset = offset;
  216. res->start = start;
  217. res->end = end;
  218. if (sizeof(resource_size_t) < sizeof(u64) &&
  219. (offset != win->offset || start != res->start || end != res->end)) {
  220. pr_warn("acpi resource window ([%#llx-%#llx] ignored, not CPU addressable)\n",
  221. attr->minimum, attr->maximum);
  222. return false;
  223. }
  224. switch (addr->resource_type) {
  225. case ACPI_MEMORY_RANGE:
  226. acpi_dev_memresource_flags(res, len, wp);
  227. if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
  228. res->flags |= IORESOURCE_PREFETCH;
  229. break;
  230. case ACPI_IO_RANGE:
  231. acpi_dev_ioresource_flags(res, len, iodec,
  232. addr->info.io.translation_type);
  233. break;
  234. case ACPI_BUS_NUMBER_RANGE:
  235. res->flags = IORESOURCE_BUS;
  236. break;
  237. default:
  238. return false;
  239. }
  240. if (addr->producer_consumer == ACPI_PRODUCER)
  241. res->flags |= IORESOURCE_WINDOW;
  242. return !(res->flags & IORESOURCE_DISABLED);
  243. }
  244. /**
  245. * acpi_dev_resource_address_space - Extract ACPI address space information.
  246. * @ares: Input ACPI resource object.
  247. * @win: Output generic resource object.
  248. *
  249. * Check if the given ACPI resource object represents an address space resource
  250. * and if that's the case, use the information in it to populate the generic
  251. * resource object pointed to by @win.
  252. *
  253. * Return:
  254. * 1) false with win->res.flags setting to zero: not the expected resource type
  255. * 2) false with IORESOURCE_DISABLED in win->res.flags: valid unassigned
  256. * resource
  257. * 3) true: valid assigned resource
  258. */
  259. bool acpi_dev_resource_address_space(struct acpi_resource *ares,
  260. struct resource_win *win)
  261. {
  262. struct acpi_resource_address64 addr;
  263. win->res.flags = 0;
  264. if (ACPI_FAILURE(acpi_resource_to_address64(ares, &addr)))
  265. return false;
  266. return acpi_decode_space(win, (struct acpi_resource_address *)&addr,
  267. &addr.address);
  268. }
  269. EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space);
  270. /**
  271. * acpi_dev_resource_ext_address_space - Extract ACPI address space information.
  272. * @ares: Input ACPI resource object.
  273. * @win: Output generic resource object.
  274. *
  275. * Check if the given ACPI resource object represents an extended address space
  276. * resource and if that's the case, use the information in it to populate the
  277. * generic resource object pointed to by @win.
  278. *
  279. * Return:
  280. * 1) false with win->res.flags setting to zero: not the expected resource type
  281. * 2) false with IORESOURCE_DISABLED in win->res.flags: valid unassigned
  282. * resource
  283. * 3) true: valid assigned resource
  284. */
  285. bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
  286. struct resource_win *win)
  287. {
  288. struct acpi_resource_extended_address64 *ext_addr;
  289. win->res.flags = 0;
  290. if (ares->type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64)
  291. return false;
  292. ext_addr = &ares->data.ext_address64;
  293. return acpi_decode_space(win, (struct acpi_resource_address *)ext_addr,
  294. &ext_addr->address);
  295. }
  296. EXPORT_SYMBOL_GPL(acpi_dev_resource_ext_address_space);
  297. /**
  298. * acpi_dev_irq_flags - Determine IRQ resource flags.
  299. * @triggering: Triggering type as provided by ACPI.
  300. * @polarity: Interrupt polarity as provided by ACPI.
  301. * @shareable: Whether or not the interrupt is shareable.
  302. * @wake_capable: Wake capability as provided by ACPI.
  303. */
  304. unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable, u8 wake_capable)
  305. {
  306. unsigned long flags;
  307. if (triggering == ACPI_LEVEL_SENSITIVE)
  308. flags = polarity == ACPI_ACTIVE_LOW ?
  309. IORESOURCE_IRQ_LOWLEVEL : IORESOURCE_IRQ_HIGHLEVEL;
  310. else
  311. flags = polarity == ACPI_ACTIVE_LOW ?
  312. IORESOURCE_IRQ_LOWEDGE : IORESOURCE_IRQ_HIGHEDGE;
  313. if (shareable == ACPI_SHARED)
  314. flags |= IORESOURCE_IRQ_SHAREABLE;
  315. if (wake_capable == ACPI_WAKE_CAPABLE)
  316. flags |= IORESOURCE_IRQ_WAKECAPABLE;
  317. return flags | IORESOURCE_IRQ;
  318. }
  319. EXPORT_SYMBOL_GPL(acpi_dev_irq_flags);
  320. /**
  321. * acpi_dev_get_irq_type - Determine irq type.
  322. * @triggering: Triggering type as provided by ACPI.
  323. * @polarity: Interrupt polarity as provided by ACPI.
  324. */
  325. unsigned int acpi_dev_get_irq_type(int triggering, int polarity)
  326. {
  327. switch (polarity) {
  328. case ACPI_ACTIVE_LOW:
  329. return triggering == ACPI_EDGE_SENSITIVE ?
  330. IRQ_TYPE_EDGE_FALLING :
  331. IRQ_TYPE_LEVEL_LOW;
  332. case ACPI_ACTIVE_HIGH:
  333. return triggering == ACPI_EDGE_SENSITIVE ?
  334. IRQ_TYPE_EDGE_RISING :
  335. IRQ_TYPE_LEVEL_HIGH;
  336. case ACPI_ACTIVE_BOTH:
  337. if (triggering == ACPI_EDGE_SENSITIVE)
  338. return IRQ_TYPE_EDGE_BOTH;
  339. fallthrough;
  340. default:
  341. return IRQ_TYPE_NONE;
  342. }
  343. }
  344. EXPORT_SYMBOL_GPL(acpi_dev_get_irq_type);
  345. /*
  346. * DMI matches for boards where the DSDT specifies the kbd IRQ as
  347. * level active-low and using the override changes this to rising edge,
  348. * stopping the keyboard from working.
  349. */
  350. static const struct dmi_system_id irq1_level_low_skip_override[] = {
  351. {
  352. /* MEDION P15651 */
  353. .matches = {
  354. DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
  355. DMI_MATCH(DMI_BOARD_NAME, "M15T"),
  356. },
  357. },
  358. {
  359. /* MEDION S17405 */
  360. .matches = {
  361. DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
  362. DMI_MATCH(DMI_BOARD_NAME, "M17T"),
  363. },
  364. },
  365. {
  366. /* MEDION S17413 */
  367. .matches = {
  368. DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
  369. DMI_MATCH(DMI_BOARD_NAME, "M1xA"),
  370. },
  371. },
  372. {
  373. /* Asus Vivobook K3402ZA */
  374. .matches = {
  375. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  376. DMI_MATCH(DMI_BOARD_NAME, "K3402ZA"),
  377. },
  378. },
  379. {
  380. /* Asus Vivobook K3502ZA */
  381. .matches = {
  382. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  383. DMI_MATCH(DMI_BOARD_NAME, "K3502ZA"),
  384. },
  385. },
  386. {
  387. /* Asus Vivobook S5402ZA */
  388. .matches = {
  389. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  390. DMI_MATCH(DMI_BOARD_NAME, "S5402ZA"),
  391. },
  392. },
  393. {
  394. /* Asus Vivobook S5602ZA */
  395. .matches = {
  396. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  397. DMI_MATCH(DMI_BOARD_NAME, "S5602ZA"),
  398. },
  399. },
  400. {
  401. /* Asus Vivobook X1404VAP */
  402. .matches = {
  403. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  404. DMI_MATCH(DMI_BOARD_NAME, "X1404VAP"),
  405. },
  406. },
  407. {
  408. /* Asus Vivobook X1504VAP */
  409. .matches = {
  410. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  411. DMI_MATCH(DMI_BOARD_NAME, "X1504VAP"),
  412. },
  413. },
  414. {
  415. /* Asus Vivobook X1704VAP */
  416. .matches = {
  417. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  418. DMI_MATCH(DMI_BOARD_NAME, "X1704VAP"),
  419. },
  420. },
  421. {
  422. /* Asus ExpertBook B1402C* */
  423. .matches = {
  424. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  425. DMI_MATCH(DMI_BOARD_NAME, "B1402C"),
  426. },
  427. },
  428. {
  429. /* Asus ExpertBook B1502C* */
  430. .matches = {
  431. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  432. DMI_MATCH(DMI_BOARD_NAME, "B1502C"),
  433. },
  434. },
  435. {
  436. /* Asus ExpertBook B2402 (B2402CBA / B2402FBA / B2402CVA / B2402FVA) */
  437. .matches = {
  438. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  439. DMI_MATCH(DMI_BOARD_NAME, "B2402"),
  440. },
  441. },
  442. {
  443. /* Asus ExpertBook B2502 (B2502CBA / B2502FBA / B2502CVA / B2502FVA) */
  444. .matches = {
  445. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  446. DMI_MATCH(DMI_BOARD_NAME, "B2502"),
  447. },
  448. },
  449. {
  450. /* Asus Vivobook Go E1404GA* */
  451. .matches = {
  452. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  453. DMI_MATCH(DMI_BOARD_NAME, "E1404GA"),
  454. },
  455. },
  456. {
  457. /* Asus Vivobook E1504GA* */
  458. .matches = {
  459. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  460. DMI_MATCH(DMI_BOARD_NAME, "E1504GA"),
  461. },
  462. },
  463. {
  464. /* Asus Vivobook Pro N6506M* */
  465. .matches = {
  466. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  467. DMI_MATCH(DMI_BOARD_NAME, "N6506M"),
  468. },
  469. },
  470. {
  471. /* Asus Vivobook Pro N6506CU* */
  472. .matches = {
  473. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
  474. DMI_MATCH(DMI_BOARD_NAME, "N6506CU"),
  475. },
  476. },
  477. {
  478. /* LG Electronics 17U70P */
  479. .matches = {
  480. DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
  481. DMI_MATCH(DMI_BOARD_NAME, "17U70P"),
  482. },
  483. },
  484. {
  485. /* LG Electronics 16T90SP */
  486. .matches = {
  487. DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
  488. DMI_MATCH(DMI_BOARD_NAME, "16T90SP"),
  489. },
  490. },
  491. {
  492. /* JWIPC JVC9100 */
  493. .matches = {
  494. DMI_MATCH(DMI_BOARD_NAME, "JVC9100"),
  495. },
  496. },
  497. { }
  498. };
  499. /*
  500. * DMI matches for AMD Zen boards where the DSDT specifies the kbd IRQ
  501. * as falling edge and this must be overridden to rising edge,
  502. * to have a working keyboard.
  503. */
  504. static const struct dmi_system_id irq1_edge_low_force_override[] = {
  505. {
  506. /* MECHREVO Jiaolong17KS Series GM7XG0M */
  507. .matches = {
  508. DMI_MATCH(DMI_BOARD_NAME, "GM7XG0M"),
  509. },
  510. },
  511. {
  512. /* XMG APEX 17 (M23) */
  513. .matches = {
  514. DMI_MATCH(DMI_BOARD_NAME, "GMxBGxx"),
  515. },
  516. },
  517. {
  518. /* TongFang GMxRGxx/XMG CORE 15 (M22)/TUXEDO Stellaris 15 Gen4 AMD */
  519. .matches = {
  520. DMI_MATCH(DMI_BOARD_NAME, "GMxRGxx"),
  521. },
  522. },
  523. {
  524. /* TongFang GMxXGxx/TUXEDO Polaris 15 Gen5 AMD */
  525. .matches = {
  526. DMI_MATCH(DMI_BOARD_NAME, "GMxXGxx"),
  527. },
  528. },
  529. {
  530. /* TongFang GMxXGxX/TUXEDO Polaris 15 Gen5 AMD */
  531. .matches = {
  532. DMI_MATCH(DMI_BOARD_NAME, "GMxXGxX"),
  533. },
  534. },
  535. {
  536. /* TongFang GMxXGxx sold as Eluktronics Inc. RP-15 */
  537. .matches = {
  538. DMI_MATCH(DMI_SYS_VENDOR, "Eluktronics Inc."),
  539. DMI_MATCH(DMI_BOARD_NAME, "RP-15"),
  540. },
  541. },
  542. {
  543. .matches = {
  544. DMI_MATCH(DMI_SYS_VENDOR, "Eluktronics Inc."),
  545. DMI_MATCH(DMI_BOARD_NAME, "MECH-17"),
  546. },
  547. },
  548. {
  549. /* TongFang GM6XGxX/TUXEDO Stellaris 16 Gen5 AMD */
  550. .matches = {
  551. DMI_MATCH(DMI_BOARD_NAME, "GM6XGxX"),
  552. },
  553. },
  554. {
  555. /* MAINGEAR Vector Pro 2 15 */
  556. .matches = {
  557. DMI_MATCH(DMI_SYS_VENDOR, "Micro Electronics Inc"),
  558. DMI_MATCH(DMI_PRODUCT_NAME, "MG-VCP2-15A3070T"),
  559. }
  560. },
  561. {
  562. /* MAINGEAR Vector Pro 2 17 */
  563. .matches = {
  564. DMI_MATCH(DMI_SYS_VENDOR, "Micro Electronics Inc"),
  565. DMI_MATCH(DMI_PRODUCT_NAME, "MG-VCP2-17A3070T"),
  566. },
  567. },
  568. {
  569. /* TongFang GM6BGEQ / PCSpecialist Elimina Pro 16 M, RTX 3050 */
  570. .matches = {
  571. DMI_MATCH(DMI_BOARD_NAME, "GM6BGEQ"),
  572. },
  573. },
  574. {
  575. /* TongFang GM6BG5Q, RTX 4050 */
  576. .matches = {
  577. DMI_MATCH(DMI_BOARD_NAME, "GM6BG5Q"),
  578. },
  579. },
  580. {
  581. /* TongFang GM6BG0Q / PCSpecialist Elimina Pro 16 M, RTX 4060 */
  582. .matches = {
  583. DMI_MATCH(DMI_BOARD_NAME, "GM6BG0Q"),
  584. },
  585. },
  586. {
  587. /* Infinity E15-5A165-BM */
  588. .matches = {
  589. DMI_MATCH(DMI_BOARD_NAME, "GM5RG1E0009COM"),
  590. },
  591. },
  592. {
  593. /* Infinity E15-5A305-1M */
  594. .matches = {
  595. DMI_MATCH(DMI_BOARD_NAME, "GM5RGEE0016COM"),
  596. },
  597. },
  598. {
  599. /* Lunnen Ground 15 / AMD Ryzen 5 5500U */
  600. .matches = {
  601. DMI_MATCH(DMI_SYS_VENDOR, "Lunnen"),
  602. DMI_MATCH(DMI_BOARD_NAME, "LLL5DAW"),
  603. },
  604. },
  605. {
  606. /* Lunnen Ground 16 / AMD Ryzen 7 5800U */
  607. .matches = {
  608. DMI_MATCH(DMI_SYS_VENDOR, "Lunnen"),
  609. DMI_MATCH(DMI_BOARD_NAME, "LL6FA"),
  610. },
  611. },
  612. {
  613. /* MAIBENBEN X577 */
  614. .matches = {
  615. DMI_MATCH(DMI_SYS_VENDOR, "MAIBENBEN"),
  616. DMI_MATCH(DMI_BOARD_NAME, "X577"),
  617. },
  618. },
  619. {
  620. /* Maibenben X565 */
  621. .matches = {
  622. DMI_MATCH(DMI_SYS_VENDOR, "MAIBENBEN"),
  623. DMI_MATCH(DMI_BOARD_NAME, "X565"),
  624. },
  625. },
  626. {
  627. /* TongFang GXxHRXx/TUXEDO InfinityBook Pro Gen9 AMD */
  628. .matches = {
  629. DMI_MATCH(DMI_BOARD_NAME, "GXxHRXx"),
  630. },
  631. },
  632. {
  633. /* TongFang GMxHGxx/TUXEDO Stellaris Slim Gen1 AMD */
  634. .matches = {
  635. DMI_MATCH(DMI_BOARD_NAME, "GMxHGxx"),
  636. },
  637. },
  638. {
  639. /* MACHENIKE L16P/L16P */
  640. .matches = {
  641. DMI_MATCH(DMI_SYS_VENDOR, "MACHENIKE"),
  642. DMI_MATCH(DMI_BOARD_NAME, "L16P"),
  643. },
  644. },
  645. {
  646. /*
  647. * TongFang GM5HG0A in case of the SKIKK Vanaheim relabel the
  648. * board-name is changed, so check OEM strings instead. Note
  649. * OEM string matches are always exact matches.
  650. * https://bugzilla.kernel.org/show_bug.cgi?id=219614
  651. */
  652. .matches = {
  653. DMI_EXACT_MATCH(DMI_OEM_STRING, "GM5HG0A"),
  654. },
  655. },
  656. { }
  657. };
  658. struct irq_override_cmp {
  659. const struct dmi_system_id *system;
  660. unsigned char irq;
  661. unsigned char triggering;
  662. unsigned char polarity;
  663. unsigned char shareable;
  664. bool override;
  665. };
  666. static const struct irq_override_cmp override_table[] = {
  667. { irq1_level_low_skip_override, 1, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 0, false },
  668. { irq1_level_low_skip_override, 10, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 1, false },
  669. { irq1_level_low_skip_override, 11, ACPI_LEVEL_SENSITIVE, ACPI_ACTIVE_LOW, 1, false },
  670. { irq1_edge_low_force_override, 1, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_LOW, 1, true },
  671. };
  672. static bool acpi_dev_irq_override(u32 gsi, u8 triggering, u8 polarity,
  673. u8 shareable)
  674. {
  675. int i;
  676. for (i = 0; i < ARRAY_SIZE(override_table); i++) {
  677. const struct irq_override_cmp *entry = &override_table[i];
  678. if (entry->irq == gsi &&
  679. entry->triggering == triggering &&
  680. entry->polarity == polarity &&
  681. entry->shareable == shareable &&
  682. dmi_check_system(entry->system))
  683. return entry->override;
  684. }
  685. #ifdef CONFIG_X86
  686. /*
  687. * Always use the MADT override info, except for the i8042 PS/2 ctrl
  688. * IRQs (1 and 12). For these the DSDT IRQ settings should sometimes
  689. * be used otherwise PS/2 keyboards / mice will not work.
  690. */
  691. if (gsi != 1 && gsi != 12)
  692. return true;
  693. /* If the override comes from an INT_SRC_OVR MADT entry, honor it. */
  694. if (acpi_int_src_ovr[gsi])
  695. return true;
  696. /*
  697. * IRQ override isn't needed on modern AMD Zen systems and
  698. * this override breaks active low IRQs on AMD Ryzen 6000 and
  699. * newer systems. Skip it.
  700. */
  701. if (boot_cpu_has(X86_FEATURE_ZEN))
  702. return false;
  703. #endif
  704. return true;
  705. }
  706. static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
  707. u8 triggering, u8 polarity, u8 shareable,
  708. u8 wake_capable, bool check_override)
  709. {
  710. int irq, p, t;
  711. if (!valid_IRQ(gsi)) {
  712. irqresource_disabled(res, gsi);
  713. return;
  714. }
  715. /*
  716. * In IO-APIC mode, use overridden attribute. Two reasons:
  717. * 1. BIOS bug in DSDT
  718. * 2. BIOS uses IO-APIC mode Interrupt Source Override
  719. *
  720. * We do this only if we are dealing with IRQ() or IRQNoFlags()
  721. * resource (the legacy ISA resources). With modern ACPI 5 devices
  722. * using extended IRQ descriptors we take the IRQ configuration
  723. * from _CRS directly.
  724. */
  725. if (check_override &&
  726. acpi_dev_irq_override(gsi, triggering, polarity, shareable) &&
  727. !acpi_get_override_irq(gsi, &t, &p)) {
  728. u8 trig = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
  729. u8 pol = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
  730. if (triggering != trig || polarity != pol) {
  731. pr_warn("ACPI: IRQ %d override to %s%s, %s%s\n", gsi,
  732. t ? "level" : "edge",
  733. trig == triggering ? "" : "(!)",
  734. str_low_high(p),
  735. pol == polarity ? "" : "(!)");
  736. triggering = trig;
  737. polarity = pol;
  738. }
  739. }
  740. res->flags = acpi_dev_irq_flags(triggering, polarity, shareable, wake_capable);
  741. irq = acpi_register_gsi(NULL, gsi, triggering, polarity);
  742. if (irq >= 0) {
  743. res->start = irq;
  744. res->end = irq;
  745. } else {
  746. irqresource_disabled(res, gsi);
  747. }
  748. }
  749. /**
  750. * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information.
  751. * @ares: Input ACPI resource object.
  752. * @index: Index into the array of GSIs represented by the resource.
  753. * @res: Output generic resource object.
  754. *
  755. * Check if the given ACPI resource object represents an interrupt resource
  756. * and @index does not exceed the resource's interrupt count (true is returned
  757. * in that case regardless of the results of the other checks)). If that's the
  758. * case, register the GSI corresponding to @index from the array of interrupts
  759. * represented by the resource and populate the generic resource object pointed
  760. * to by @res accordingly. If the registration of the GSI is not successful,
  761. * IORESOURCE_DISABLED will be set it that object's flags.
  762. *
  763. * Return:
  764. * 1) false with res->flags setting to zero: not the expected resource type
  765. * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
  766. * 3) true: valid assigned resource
  767. */
  768. bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
  769. struct resource *res)
  770. {
  771. struct acpi_resource_irq *irq;
  772. struct acpi_resource_extended_irq *ext_irq;
  773. switch (ares->type) {
  774. case ACPI_RESOURCE_TYPE_IRQ:
  775. /*
  776. * Per spec, only one interrupt per descriptor is allowed in
  777. * _CRS, but some firmware violates this, so parse them all.
  778. */
  779. irq = &ares->data.irq;
  780. if (index >= irq->interrupt_count) {
  781. irqresource_disabled(res, 0);
  782. return false;
  783. }
  784. acpi_dev_get_irqresource(res, irq->interrupts[index],
  785. irq->triggering, irq->polarity,
  786. irq->shareable, irq->wake_capable,
  787. true);
  788. break;
  789. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  790. ext_irq = &ares->data.extended_irq;
  791. if (index >= ext_irq->interrupt_count) {
  792. irqresource_disabled(res, 0);
  793. return false;
  794. }
  795. if (is_gsi(ext_irq))
  796. acpi_dev_get_irqresource(res, ext_irq->interrupts[index],
  797. ext_irq->triggering, ext_irq->polarity,
  798. ext_irq->shareable, ext_irq->wake_capable,
  799. false);
  800. else
  801. irqresource_disabled(res, 0);
  802. break;
  803. default:
  804. res->flags = 0;
  805. return false;
  806. }
  807. return true;
  808. }
  809. EXPORT_SYMBOL_GPL(acpi_dev_resource_interrupt);
  810. /**
  811. * acpi_dev_free_resource_list - Free resource from %acpi_dev_get_resources().
  812. * @list: The head of the resource list to free.
  813. */
  814. void acpi_dev_free_resource_list(struct list_head *list)
  815. {
  816. resource_list_free(list);
  817. }
  818. EXPORT_SYMBOL_GPL(acpi_dev_free_resource_list);
  819. struct res_proc_context {
  820. struct list_head *list;
  821. int (*preproc)(struct acpi_resource *, void *);
  822. void *preproc_data;
  823. int count;
  824. int error;
  825. };
  826. static acpi_status acpi_dev_new_resource_entry(struct resource_win *win,
  827. struct res_proc_context *c)
  828. {
  829. struct resource_entry *rentry;
  830. rentry = resource_list_create_entry(NULL, 0);
  831. if (!rentry) {
  832. c->error = -ENOMEM;
  833. return AE_NO_MEMORY;
  834. }
  835. *rentry->res = win->res;
  836. rentry->offset = win->offset;
  837. resource_list_add_tail(rentry, c->list);
  838. c->count++;
  839. return AE_OK;
  840. }
  841. static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,
  842. void *context)
  843. {
  844. struct res_proc_context *c = context;
  845. struct resource_win win;
  846. struct resource *res = &win.res;
  847. int i;
  848. if (c->preproc) {
  849. int ret;
  850. ret = c->preproc(ares, c->preproc_data);
  851. if (ret < 0) {
  852. c->error = ret;
  853. return AE_ABORT_METHOD;
  854. } else if (ret > 0) {
  855. return AE_OK;
  856. }
  857. }
  858. memset(&win, 0, sizeof(win));
  859. if (acpi_dev_resource_memory(ares, res)
  860. || acpi_dev_resource_io(ares, res)
  861. || acpi_dev_resource_address_space(ares, &win)
  862. || acpi_dev_resource_ext_address_space(ares, &win))
  863. return acpi_dev_new_resource_entry(&win, c);
  864. for (i = 0; acpi_dev_resource_interrupt(ares, i, res); i++) {
  865. acpi_status status;
  866. status = acpi_dev_new_resource_entry(&win, c);
  867. if (ACPI_FAILURE(status))
  868. return status;
  869. }
  870. return AE_OK;
  871. }
  872. static int __acpi_dev_get_resources(struct acpi_device *adev,
  873. struct list_head *list,
  874. int (*preproc)(struct acpi_resource *, void *),
  875. void *preproc_data, char *method)
  876. {
  877. struct res_proc_context c;
  878. acpi_status status;
  879. if (!adev || !adev->handle || !list_empty(list))
  880. return -EINVAL;
  881. if (!acpi_has_method(adev->handle, method))
  882. return 0;
  883. c.list = list;
  884. c.preproc = preproc;
  885. c.preproc_data = preproc_data;
  886. c.count = 0;
  887. c.error = 0;
  888. status = acpi_walk_resources(adev->handle, method,
  889. acpi_dev_process_resource, &c);
  890. if (ACPI_FAILURE(status)) {
  891. acpi_dev_free_resource_list(list);
  892. return c.error ? c.error : -EIO;
  893. }
  894. return c.count;
  895. }
  896. /**
  897. * acpi_dev_get_resources - Get current resources of a device.
  898. * @adev: ACPI device node to get the resources for.
  899. * @list: Head of the resultant list of resources (must be empty).
  900. * @preproc: The caller's preprocessing routine.
  901. * @preproc_data: Pointer passed to the caller's preprocessing routine.
  902. *
  903. * Evaluate the _CRS method for the given device node and process its output by
  904. * (1) executing the @preproc() routine provided by the caller, passing the
  905. * resource pointer and @preproc_data to it as arguments, for each ACPI resource
  906. * returned and (2) converting all of the returned ACPI resources into struct
  907. * resource objects if possible. If the return value of @preproc() in step (1)
  908. * is different from 0, step (2) is not applied to the given ACPI resource and
  909. * if that value is negative, the whole processing is aborted and that value is
  910. * returned as the final error code.
  911. *
  912. * The resultant struct resource objects are put on the list pointed to by
  913. * @list, that must be empty initially, as members of struct resource_entry
  914. * objects. Callers of this routine should use %acpi_dev_free_resource_list() to
  915. * free that list.
  916. *
  917. * The number of resources in the output list is returned on success, an error
  918. * code reflecting the error condition is returned otherwise.
  919. */
  920. int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
  921. int (*preproc)(struct acpi_resource *, void *),
  922. void *preproc_data)
  923. {
  924. return __acpi_dev_get_resources(adev, list, preproc, preproc_data,
  925. METHOD_NAME__CRS);
  926. }
  927. EXPORT_SYMBOL_GPL(acpi_dev_get_resources);
  928. static int is_memory(struct acpi_resource *ares, void *not_used)
  929. {
  930. struct resource_win win;
  931. struct resource *res = &win.res;
  932. memset(&win, 0, sizeof(win));
  933. if (acpi_dev_filter_resource_type(ares, IORESOURCE_MEM))
  934. return 1;
  935. return !(acpi_dev_resource_memory(ares, res)
  936. || acpi_dev_resource_address_space(ares, &win)
  937. || acpi_dev_resource_ext_address_space(ares, &win));
  938. }
  939. /**
  940. * acpi_dev_get_dma_resources - Get current DMA resources of a device.
  941. * @adev: ACPI device node to get the resources for.
  942. * @list: Head of the resultant list of resources (must be empty).
  943. *
  944. * Evaluate the _DMA method for the given device node and process its
  945. * output.
  946. *
  947. * The resultant struct resource objects are put on the list pointed to
  948. * by @list, that must be empty initially, as members of struct
  949. * resource_entry objects. Callers of this routine should use
  950. * %acpi_dev_free_resource_list() to free that list.
  951. *
  952. * The number of resources in the output list is returned on success,
  953. * an error code reflecting the error condition is returned otherwise.
  954. */
  955. int acpi_dev_get_dma_resources(struct acpi_device *adev, struct list_head *list)
  956. {
  957. return __acpi_dev_get_resources(adev, list, is_memory, NULL,
  958. METHOD_NAME__DMA);
  959. }
  960. EXPORT_SYMBOL_GPL(acpi_dev_get_dma_resources);
  961. /**
  962. * acpi_dev_get_memory_resources - Get current memory resources of a device.
  963. * @adev: ACPI device node to get the resources for.
  964. * @list: Head of the resultant list of resources (must be empty).
  965. *
  966. * This is a helper function that locates all memory type resources of @adev
  967. * with acpi_dev_get_resources().
  968. *
  969. * The number of resources in the output list is returned on success, an error
  970. * code reflecting the error condition is returned otherwise.
  971. */
  972. int acpi_dev_get_memory_resources(struct acpi_device *adev, struct list_head *list)
  973. {
  974. return acpi_dev_get_resources(adev, list, is_memory, NULL);
  975. }
  976. EXPORT_SYMBOL_GPL(acpi_dev_get_memory_resources);
  977. /**
  978. * acpi_dev_filter_resource_type - Filter ACPI resource according to resource
  979. * types
  980. * @ares: Input ACPI resource object.
  981. * @types: Valid resource types of IORESOURCE_XXX
  982. *
  983. * This is a helper function to support acpi_dev_get_resources(), which filters
  984. * ACPI resource objects according to resource types.
  985. */
  986. int acpi_dev_filter_resource_type(struct acpi_resource *ares,
  987. unsigned long types)
  988. {
  989. unsigned long type = 0;
  990. switch (ares->type) {
  991. case ACPI_RESOURCE_TYPE_MEMORY24:
  992. case ACPI_RESOURCE_TYPE_MEMORY32:
  993. case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
  994. type = IORESOURCE_MEM;
  995. break;
  996. case ACPI_RESOURCE_TYPE_IO:
  997. case ACPI_RESOURCE_TYPE_FIXED_IO:
  998. type = IORESOURCE_IO;
  999. break;
  1000. case ACPI_RESOURCE_TYPE_IRQ:
  1001. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  1002. type = IORESOURCE_IRQ;
  1003. break;
  1004. case ACPI_RESOURCE_TYPE_DMA:
  1005. case ACPI_RESOURCE_TYPE_FIXED_DMA:
  1006. type = IORESOURCE_DMA;
  1007. break;
  1008. case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
  1009. type = IORESOURCE_REG;
  1010. break;
  1011. case ACPI_RESOURCE_TYPE_ADDRESS16:
  1012. case ACPI_RESOURCE_TYPE_ADDRESS32:
  1013. case ACPI_RESOURCE_TYPE_ADDRESS64:
  1014. case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
  1015. if (ares->data.address.resource_type == ACPI_MEMORY_RANGE)
  1016. type = IORESOURCE_MEM;
  1017. else if (ares->data.address.resource_type == ACPI_IO_RANGE)
  1018. type = IORESOURCE_IO;
  1019. else if (ares->data.address.resource_type ==
  1020. ACPI_BUS_NUMBER_RANGE)
  1021. type = IORESOURCE_BUS;
  1022. break;
  1023. default:
  1024. break;
  1025. }
  1026. return (type & types) ? 0 : 1;
  1027. }
  1028. EXPORT_SYMBOL_GPL(acpi_dev_filter_resource_type);
  1029. static int acpi_dev_consumes_res(struct acpi_device *adev, struct resource *res)
  1030. {
  1031. struct list_head resource_list;
  1032. struct resource_entry *rentry;
  1033. int ret, found = 0;
  1034. INIT_LIST_HEAD(&resource_list);
  1035. ret = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
  1036. if (ret < 0)
  1037. return 0;
  1038. list_for_each_entry(rentry, &resource_list, node) {
  1039. if (resource_contains(rentry->res, res)) {
  1040. found = 1;
  1041. break;
  1042. }
  1043. }
  1044. acpi_dev_free_resource_list(&resource_list);
  1045. return found;
  1046. }
  1047. static acpi_status acpi_res_consumer_cb(acpi_handle handle, u32 depth,
  1048. void *context, void **ret)
  1049. {
  1050. struct resource *res = context;
  1051. struct acpi_device **consumer = (struct acpi_device **) ret;
  1052. struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
  1053. if (!adev)
  1054. return AE_OK;
  1055. if (acpi_dev_consumes_res(adev, res)) {
  1056. *consumer = adev;
  1057. return AE_CTRL_TERMINATE;
  1058. }
  1059. return AE_OK;
  1060. }
  1061. /**
  1062. * acpi_resource_consumer - Find the ACPI device that consumes @res.
  1063. * @res: Resource to search for.
  1064. *
  1065. * Search the current resource settings (_CRS) of every ACPI device node
  1066. * for @res. If we find an ACPI device whose _CRS includes @res, return
  1067. * it. Otherwise, return NULL.
  1068. */
  1069. struct acpi_device *acpi_resource_consumer(struct resource *res)
  1070. {
  1071. struct acpi_device *consumer = NULL;
  1072. acpi_get_devices(NULL, acpi_res_consumer_cb, res, (void **) &consumer);
  1073. return consumer;
  1074. }