resource.c 19 KB

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