resource.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /*
  2. * drivers/acpi/resource.c - ACPI device resources interpretation.
  3. *
  4. * Copyright (C) 2012, Intel Corp.
  5. * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. */
  20. #include <linux/acpi.h>
  21. #include <linux/device.h>
  22. #include <linux/export.h>
  23. #include <linux/ioport.h>
  24. #include <linux/slab.h>
  25. #ifdef CONFIG_X86
  26. #define valid_IRQ(i) (((i) != 0) && ((i) != 2))
  27. #else
  28. #define valid_IRQ(i) (true)
  29. #endif
  30. static bool acpi_dev_resource_len_valid(u64 start, u64 end, u64 len, bool io)
  31. {
  32. u64 reslen = end - start + 1;
  33. /*
  34. * CHECKME: len might be required to check versus a minimum
  35. * length as well. 1 for io is fine, but for memory it does
  36. * not make any sense at all.
  37. * Note: some BIOSes report incorrect length for ACPI address space
  38. * descriptor, so remove check of 'reslen == len' to avoid regression.
  39. */
  40. if (len && reslen && start <= end)
  41. return true;
  42. pr_debug("ACPI: invalid or unassigned resource %s [%016llx - %016llx] length [%016llx]\n",
  43. io ? "io" : "mem", start, end, len);
  44. return false;
  45. }
  46. static void acpi_dev_memresource_flags(struct resource *res, u64 len,
  47. u8 write_protect)
  48. {
  49. res->flags = IORESOURCE_MEM;
  50. if (!acpi_dev_resource_len_valid(res->start, res->end, len, false))
  51. res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;
  52. if (write_protect == ACPI_READ_WRITE_MEMORY)
  53. res->flags |= IORESOURCE_MEM_WRITEABLE;
  54. }
  55. static void acpi_dev_get_memresource(struct resource *res, u64 start, u64 len,
  56. u8 write_protect)
  57. {
  58. res->start = start;
  59. res->end = start + len - 1;
  60. acpi_dev_memresource_flags(res, len, write_protect);
  61. }
  62. /**
  63. * acpi_dev_resource_memory - Extract ACPI memory resource information.
  64. * @ares: Input ACPI resource object.
  65. * @res: Output generic resource object.
  66. *
  67. * Check if the given ACPI resource object represents a memory resource and
  68. * if that's the case, use the information in it to populate the generic
  69. * resource object pointed to by @res.
  70. *
  71. * Return:
  72. * 1) false with res->flags setting to zero: not the expected resource type
  73. * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
  74. * 3) true: valid assigned resource
  75. */
  76. bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res)
  77. {
  78. struct acpi_resource_memory24 *memory24;
  79. struct acpi_resource_memory32 *memory32;
  80. struct acpi_resource_fixed_memory32 *fixed_memory32;
  81. switch (ares->type) {
  82. case ACPI_RESOURCE_TYPE_MEMORY24:
  83. memory24 = &ares->data.memory24;
  84. acpi_dev_get_memresource(res, memory24->minimum << 8,
  85. memory24->address_length << 8,
  86. memory24->write_protect);
  87. break;
  88. case ACPI_RESOURCE_TYPE_MEMORY32:
  89. memory32 = &ares->data.memory32;
  90. acpi_dev_get_memresource(res, memory32->minimum,
  91. memory32->address_length,
  92. memory32->write_protect);
  93. break;
  94. case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
  95. fixed_memory32 = &ares->data.fixed_memory32;
  96. acpi_dev_get_memresource(res, fixed_memory32->address,
  97. fixed_memory32->address_length,
  98. fixed_memory32->write_protect);
  99. break;
  100. default:
  101. res->flags = 0;
  102. return false;
  103. }
  104. return !(res->flags & IORESOURCE_DISABLED);
  105. }
  106. EXPORT_SYMBOL_GPL(acpi_dev_resource_memory);
  107. static void acpi_dev_ioresource_flags(struct resource *res, u64 len,
  108. u8 io_decode)
  109. {
  110. res->flags = IORESOURCE_IO;
  111. if (!acpi_dev_resource_len_valid(res->start, res->end, len, true))
  112. res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;
  113. if (res->end >= 0x10003)
  114. res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET;
  115. if (io_decode == ACPI_DECODE_16)
  116. res->flags |= IORESOURCE_IO_16BIT_ADDR;
  117. }
  118. static void acpi_dev_get_ioresource(struct resource *res, u64 start, u64 len,
  119. u8 io_decode)
  120. {
  121. res->start = start;
  122. res->end = start + len - 1;
  123. acpi_dev_ioresource_flags(res, len, io_decode);
  124. }
  125. /**
  126. * acpi_dev_resource_io - Extract ACPI I/O resource information.
  127. * @ares: Input ACPI resource object.
  128. * @res: Output generic resource object.
  129. *
  130. * Check if the given ACPI resource object represents an I/O resource and
  131. * if that's the case, use the information in it to populate the generic
  132. * resource object pointed to by @res.
  133. *
  134. * Return:
  135. * 1) false with res->flags setting to zero: not the expected resource type
  136. * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
  137. * 3) true: valid assigned resource
  138. */
  139. bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)
  140. {
  141. struct acpi_resource_io *io;
  142. struct acpi_resource_fixed_io *fixed_io;
  143. switch (ares->type) {
  144. case ACPI_RESOURCE_TYPE_IO:
  145. io = &ares->data.io;
  146. acpi_dev_get_ioresource(res, io->minimum,
  147. io->address_length,
  148. io->io_decode);
  149. break;
  150. case ACPI_RESOURCE_TYPE_FIXED_IO:
  151. fixed_io = &ares->data.fixed_io;
  152. acpi_dev_get_ioresource(res, fixed_io->address,
  153. fixed_io->address_length,
  154. ACPI_DECODE_10);
  155. break;
  156. default:
  157. res->flags = 0;
  158. return false;
  159. }
  160. return !(res->flags & IORESOURCE_DISABLED);
  161. }
  162. EXPORT_SYMBOL_GPL(acpi_dev_resource_io);
  163. static bool acpi_decode_space(struct resource_win *win,
  164. struct acpi_resource_address *addr,
  165. struct acpi_address64_attribute *attr)
  166. {
  167. u8 iodec = attr->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16;
  168. bool wp = addr->info.mem.write_protect;
  169. u64 len = attr->address_length;
  170. u64 start, end, offset = 0;
  171. struct resource *res = &win->res;
  172. /*
  173. * Filter out invalid descriptor according to ACPI Spec 5.0, section
  174. * 6.4.3.5 Address Space Resource Descriptors.
  175. */
  176. if ((addr->min_address_fixed != addr->max_address_fixed && len) ||
  177. (addr->min_address_fixed && addr->max_address_fixed && !len))
  178. pr_debug("ACPI: Invalid address space min_addr_fix %d, max_addr_fix %d, len %llx\n",
  179. addr->min_address_fixed, addr->max_address_fixed, len);
  180. /*
  181. * For bridges that translate addresses across the bridge,
  182. * translation_offset is the offset that must be added to the
  183. * address on the secondary side to obtain the address on the
  184. * primary side. Non-bridge devices must list 0 for all Address
  185. * Translation offset bits.
  186. */
  187. if (addr->producer_consumer == ACPI_PRODUCER)
  188. offset = attr->translation_offset;
  189. else if (attr->translation_offset)
  190. pr_debug("ACPI: translation_offset(%lld) is invalid for non-bridge device.\n",
  191. attr->translation_offset);
  192. start = attr->minimum + offset;
  193. end = attr->maximum + offset;
  194. win->offset = offset;
  195. res->start = start;
  196. res->end = end;
  197. if (sizeof(resource_size_t) < sizeof(u64) &&
  198. (offset != win->offset || start != res->start || end != res->end)) {
  199. pr_warn("acpi resource window ([%#llx-%#llx] ignored, not CPU addressable)\n",
  200. attr->minimum, attr->maximum);
  201. return false;
  202. }
  203. switch (addr->resource_type) {
  204. case ACPI_MEMORY_RANGE:
  205. acpi_dev_memresource_flags(res, len, wp);
  206. break;
  207. case ACPI_IO_RANGE:
  208. acpi_dev_ioresource_flags(res, len, iodec);
  209. break;
  210. case ACPI_BUS_NUMBER_RANGE:
  211. res->flags = IORESOURCE_BUS;
  212. break;
  213. default:
  214. return false;
  215. }
  216. if (addr->producer_consumer == ACPI_PRODUCER)
  217. res->flags |= IORESOURCE_WINDOW;
  218. if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
  219. res->flags |= IORESOURCE_PREFETCH;
  220. return !(res->flags & IORESOURCE_DISABLED);
  221. }
  222. /**
  223. * acpi_dev_resource_address_space - Extract ACPI address space information.
  224. * @ares: Input ACPI resource object.
  225. * @win: Output generic resource object.
  226. *
  227. * Check if the given ACPI resource object represents an address space resource
  228. * and if that's the case, use the information in it to populate the generic
  229. * resource object pointed to by @win.
  230. *
  231. * Return:
  232. * 1) false with win->res.flags setting to zero: not the expected resource type
  233. * 2) false with IORESOURCE_DISABLED in win->res.flags: valid unassigned
  234. * resource
  235. * 3) true: valid assigned resource
  236. */
  237. bool acpi_dev_resource_address_space(struct acpi_resource *ares,
  238. struct resource_win *win)
  239. {
  240. struct acpi_resource_address64 addr;
  241. win->res.flags = 0;
  242. if (ACPI_FAILURE(acpi_resource_to_address64(ares, &addr)))
  243. return false;
  244. return acpi_decode_space(win, (struct acpi_resource_address *)&addr,
  245. &addr.address);
  246. }
  247. EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space);
  248. /**
  249. * acpi_dev_resource_ext_address_space - Extract ACPI address space information.
  250. * @ares: Input ACPI resource object.
  251. * @win: Output generic resource object.
  252. *
  253. * Check if the given ACPI resource object represents an extended address space
  254. * resource and if that's the case, use the information in it to populate the
  255. * generic resource object pointed to by @win.
  256. *
  257. * Return:
  258. * 1) false with win->res.flags setting to zero: not the expected resource type
  259. * 2) false with IORESOURCE_DISABLED in win->res.flags: valid unassigned
  260. * resource
  261. * 3) true: valid assigned resource
  262. */
  263. bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
  264. struct resource_win *win)
  265. {
  266. struct acpi_resource_extended_address64 *ext_addr;
  267. win->res.flags = 0;
  268. if (ares->type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64)
  269. return false;
  270. ext_addr = &ares->data.ext_address64;
  271. return acpi_decode_space(win, (struct acpi_resource_address *)ext_addr,
  272. &ext_addr->address);
  273. }
  274. EXPORT_SYMBOL_GPL(acpi_dev_resource_ext_address_space);
  275. /**
  276. * acpi_dev_irq_flags - Determine IRQ resource flags.
  277. * @triggering: Triggering type as provided by ACPI.
  278. * @polarity: Interrupt polarity as provided by ACPI.
  279. * @shareable: Whether or not the interrupt is shareable.
  280. */
  281. unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable)
  282. {
  283. unsigned long flags;
  284. if (triggering == ACPI_LEVEL_SENSITIVE)
  285. flags = polarity == ACPI_ACTIVE_LOW ?
  286. IORESOURCE_IRQ_LOWLEVEL : IORESOURCE_IRQ_HIGHLEVEL;
  287. else
  288. flags = polarity == ACPI_ACTIVE_LOW ?
  289. IORESOURCE_IRQ_LOWEDGE : IORESOURCE_IRQ_HIGHEDGE;
  290. if (shareable == ACPI_SHARED)
  291. flags |= IORESOURCE_IRQ_SHAREABLE;
  292. return flags | IORESOURCE_IRQ;
  293. }
  294. EXPORT_SYMBOL_GPL(acpi_dev_irq_flags);
  295. static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi)
  296. {
  297. res->start = gsi;
  298. res->end = gsi;
  299. res->flags = IORESOURCE_IRQ | IORESOURCE_DISABLED | IORESOURCE_UNSET;
  300. }
  301. static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,
  302. u8 triggering, u8 polarity, u8 shareable,
  303. bool legacy)
  304. {
  305. int irq, p, t;
  306. if (!valid_IRQ(gsi)) {
  307. acpi_dev_irqresource_disabled(res, gsi);
  308. return;
  309. }
  310. /*
  311. * In IO-APIC mode, use overrided attribute. Two reasons:
  312. * 1. BIOS bug in DSDT
  313. * 2. BIOS uses IO-APIC mode Interrupt Source Override
  314. *
  315. * We do this only if we are dealing with IRQ() or IRQNoFlags()
  316. * resource (the legacy ISA resources). With modern ACPI 5 devices
  317. * using extended IRQ descriptors we take the IRQ configuration
  318. * from _CRS directly.
  319. */
  320. if (legacy && !acpi_get_override_irq(gsi, &t, &p)) {
  321. u8 trig = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
  322. u8 pol = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
  323. if (triggering != trig || polarity != pol) {
  324. pr_warning("ACPI: IRQ %d override to %s, %s\n", gsi,
  325. t ? "level" : "edge", p ? "low" : "high");
  326. triggering = trig;
  327. polarity = pol;
  328. }
  329. }
  330. res->flags = acpi_dev_irq_flags(triggering, polarity, shareable);
  331. irq = acpi_register_gsi(NULL, gsi, triggering, polarity);
  332. if (irq >= 0) {
  333. res->start = irq;
  334. res->end = irq;
  335. } else {
  336. acpi_dev_irqresource_disabled(res, gsi);
  337. }
  338. }
  339. /**
  340. * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information.
  341. * @ares: Input ACPI resource object.
  342. * @index: Index into the array of GSIs represented by the resource.
  343. * @res: Output generic resource object.
  344. *
  345. * Check if the given ACPI resource object represents an interrupt resource
  346. * and @index does not exceed the resource's interrupt count (true is returned
  347. * in that case regardless of the results of the other checks)). If that's the
  348. * case, register the GSI corresponding to @index from the array of interrupts
  349. * represented by the resource and populate the generic resource object pointed
  350. * to by @res accordingly. If the registration of the GSI is not successful,
  351. * IORESOURCE_DISABLED will be set it that object's flags.
  352. *
  353. * Return:
  354. * 1) false with res->flags setting to zero: not the expected resource type
  355. * 2) false with IORESOURCE_DISABLED in res->flags: valid unassigned resource
  356. * 3) true: valid assigned resource
  357. */
  358. bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,
  359. struct resource *res)
  360. {
  361. struct acpi_resource_irq *irq;
  362. struct acpi_resource_extended_irq *ext_irq;
  363. switch (ares->type) {
  364. case ACPI_RESOURCE_TYPE_IRQ:
  365. /*
  366. * Per spec, only one interrupt per descriptor is allowed in
  367. * _CRS, but some firmware violates this, so parse them all.
  368. */
  369. irq = &ares->data.irq;
  370. if (index >= irq->interrupt_count) {
  371. acpi_dev_irqresource_disabled(res, 0);
  372. return false;
  373. }
  374. acpi_dev_get_irqresource(res, irq->interrupts[index],
  375. irq->triggering, irq->polarity,
  376. irq->sharable, true);
  377. break;
  378. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  379. ext_irq = &ares->data.extended_irq;
  380. if (index >= ext_irq->interrupt_count) {
  381. acpi_dev_irqresource_disabled(res, 0);
  382. return false;
  383. }
  384. acpi_dev_get_irqresource(res, ext_irq->interrupts[index],
  385. ext_irq->triggering, ext_irq->polarity,
  386. ext_irq->sharable, false);
  387. break;
  388. default:
  389. res->flags = 0;
  390. return false;
  391. }
  392. return true;
  393. }
  394. EXPORT_SYMBOL_GPL(acpi_dev_resource_interrupt);
  395. /**
  396. * acpi_dev_free_resource_list - Free resource from %acpi_dev_get_resources().
  397. * @list: The head of the resource list to free.
  398. */
  399. void acpi_dev_free_resource_list(struct list_head *list)
  400. {
  401. resource_list_free(list);
  402. }
  403. EXPORT_SYMBOL_GPL(acpi_dev_free_resource_list);
  404. struct res_proc_context {
  405. struct list_head *list;
  406. int (*preproc)(struct acpi_resource *, void *);
  407. void *preproc_data;
  408. int count;
  409. int error;
  410. };
  411. static acpi_status acpi_dev_new_resource_entry(struct resource_win *win,
  412. struct res_proc_context *c)
  413. {
  414. struct resource_entry *rentry;
  415. rentry = resource_list_create_entry(NULL, 0);
  416. if (!rentry) {
  417. c->error = -ENOMEM;
  418. return AE_NO_MEMORY;
  419. }
  420. *rentry->res = win->res;
  421. rentry->offset = win->offset;
  422. resource_list_add_tail(rentry, c->list);
  423. c->count++;
  424. return AE_OK;
  425. }
  426. static acpi_status acpi_dev_process_resource(struct acpi_resource *ares,
  427. void *context)
  428. {
  429. struct res_proc_context *c = context;
  430. struct resource_win win;
  431. struct resource *res = &win.res;
  432. int i;
  433. if (c->preproc) {
  434. int ret;
  435. ret = c->preproc(ares, c->preproc_data);
  436. if (ret < 0) {
  437. c->error = ret;
  438. return AE_CTRL_TERMINATE;
  439. } else if (ret > 0) {
  440. return AE_OK;
  441. }
  442. }
  443. memset(&win, 0, sizeof(win));
  444. if (acpi_dev_resource_memory(ares, res)
  445. || acpi_dev_resource_io(ares, res)
  446. || acpi_dev_resource_address_space(ares, &win)
  447. || acpi_dev_resource_ext_address_space(ares, &win))
  448. return acpi_dev_new_resource_entry(&win, c);
  449. for (i = 0; acpi_dev_resource_interrupt(ares, i, res); i++) {
  450. acpi_status status;
  451. status = acpi_dev_new_resource_entry(&win, c);
  452. if (ACPI_FAILURE(status))
  453. return status;
  454. }
  455. return AE_OK;
  456. }
  457. /**
  458. * acpi_dev_get_resources - Get current resources of a device.
  459. * @adev: ACPI device node to get the resources for.
  460. * @list: Head of the resultant list of resources (must be empty).
  461. * @preproc: The caller's preprocessing routine.
  462. * @preproc_data: Pointer passed to the caller's preprocessing routine.
  463. *
  464. * Evaluate the _CRS method for the given device node and process its output by
  465. * (1) executing the @preproc() rountine provided by the caller, passing the
  466. * resource pointer and @preproc_data to it as arguments, for each ACPI resource
  467. * returned and (2) converting all of the returned ACPI resources into struct
  468. * resource objects if possible. If the return value of @preproc() in step (1)
  469. * is different from 0, step (2) is not applied to the given ACPI resource and
  470. * if that value is negative, the whole processing is aborted and that value is
  471. * returned as the final error code.
  472. *
  473. * The resultant struct resource objects are put on the list pointed to by
  474. * @list, that must be empty initially, as members of struct resource_entry
  475. * objects. Callers of this routine should use %acpi_dev_free_resource_list() to
  476. * free that list.
  477. *
  478. * The number of resources in the output list is returned on success, an error
  479. * code reflecting the error condition is returned otherwise.
  480. */
  481. int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
  482. int (*preproc)(struct acpi_resource *, void *),
  483. void *preproc_data)
  484. {
  485. struct res_proc_context c;
  486. acpi_status status;
  487. if (!adev || !adev->handle || !list_empty(list))
  488. return -EINVAL;
  489. if (!acpi_has_method(adev->handle, METHOD_NAME__CRS))
  490. return 0;
  491. c.list = list;
  492. c.preproc = preproc;
  493. c.preproc_data = preproc_data;
  494. c.count = 0;
  495. c.error = 0;
  496. status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS,
  497. acpi_dev_process_resource, &c);
  498. if (ACPI_FAILURE(status)) {
  499. acpi_dev_free_resource_list(list);
  500. return c.error ? c.error : -EIO;
  501. }
  502. return c.count;
  503. }
  504. EXPORT_SYMBOL_GPL(acpi_dev_get_resources);
  505. /**
  506. * acpi_dev_filter_resource_type - Filter ACPI resource according to resource
  507. * types
  508. * @ares: Input ACPI resource object.
  509. * @types: Valid resource types of IORESOURCE_XXX
  510. *
  511. * This is a helper function to support acpi_dev_get_resources(), which filters
  512. * ACPI resource objects according to resource types.
  513. */
  514. int acpi_dev_filter_resource_type(struct acpi_resource *ares,
  515. unsigned long types)
  516. {
  517. unsigned long type = 0;
  518. switch (ares->type) {
  519. case ACPI_RESOURCE_TYPE_MEMORY24:
  520. case ACPI_RESOURCE_TYPE_MEMORY32:
  521. case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
  522. type = IORESOURCE_MEM;
  523. break;
  524. case ACPI_RESOURCE_TYPE_IO:
  525. case ACPI_RESOURCE_TYPE_FIXED_IO:
  526. type = IORESOURCE_IO;
  527. break;
  528. case ACPI_RESOURCE_TYPE_IRQ:
  529. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  530. type = IORESOURCE_IRQ;
  531. break;
  532. case ACPI_RESOURCE_TYPE_DMA:
  533. case ACPI_RESOURCE_TYPE_FIXED_DMA:
  534. type = IORESOURCE_DMA;
  535. break;
  536. case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
  537. type = IORESOURCE_REG;
  538. break;
  539. case ACPI_RESOURCE_TYPE_ADDRESS16:
  540. case ACPI_RESOURCE_TYPE_ADDRESS32:
  541. case ACPI_RESOURCE_TYPE_ADDRESS64:
  542. case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
  543. if (ares->data.address.resource_type == ACPI_MEMORY_RANGE)
  544. type = IORESOURCE_MEM;
  545. else if (ares->data.address.resource_type == ACPI_IO_RANGE)
  546. type = IORESOURCE_IO;
  547. else if (ares->data.address.resource_type ==
  548. ACPI_BUS_NUMBER_RANGE)
  549. type = IORESOURCE_BUS;
  550. break;
  551. default:
  552. break;
  553. }
  554. return (type & types) ? 0 : 1;
  555. }
  556. EXPORT_SYMBOL_GPL(acpi_dev_filter_resource_type);