rsparser.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. /*
  2. * pnpacpi -- PnP ACPI driver
  3. *
  4. * Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
  5. * Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com>
  6. * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
  7. * Bjorn Helgaas <bjorn.helgaas@hp.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2, or (at your option) any
  12. * later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/acpi.h>
  25. #include <linux/pci.h>
  26. #include <linux/pnp.h>
  27. #include <linux/slab.h>
  28. #include "../base.h"
  29. #include "pnpacpi.h"
  30. #ifdef CONFIG_IA64
  31. #define valid_IRQ(i) (1)
  32. #else
  33. #define valid_IRQ(i) (((i) != 0) && ((i) != 2))
  34. #endif
  35. /*
  36. * Allocated Resources
  37. */
  38. static int irq_flags(int triggering, int polarity, int shareable)
  39. {
  40. int flags;
  41. if (triggering == ACPI_LEVEL_SENSITIVE) {
  42. if (polarity == ACPI_ACTIVE_LOW)
  43. flags = IORESOURCE_IRQ_LOWLEVEL;
  44. else
  45. flags = IORESOURCE_IRQ_HIGHLEVEL;
  46. } else {
  47. if (polarity == ACPI_ACTIVE_LOW)
  48. flags = IORESOURCE_IRQ_LOWEDGE;
  49. else
  50. flags = IORESOURCE_IRQ_HIGHEDGE;
  51. }
  52. if (shareable == ACPI_SHARED)
  53. flags |= IORESOURCE_IRQ_SHAREABLE;
  54. return flags;
  55. }
  56. static void decode_irq_flags(struct pnp_dev *dev, int flags, int *triggering,
  57. int *polarity, int *shareable)
  58. {
  59. switch (flags & (IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_HIGHLEVEL |
  60. IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE)) {
  61. case IORESOURCE_IRQ_LOWLEVEL:
  62. *triggering = ACPI_LEVEL_SENSITIVE;
  63. *polarity = ACPI_ACTIVE_LOW;
  64. break;
  65. case IORESOURCE_IRQ_HIGHLEVEL:
  66. *triggering = ACPI_LEVEL_SENSITIVE;
  67. *polarity = ACPI_ACTIVE_HIGH;
  68. break;
  69. case IORESOURCE_IRQ_LOWEDGE:
  70. *triggering = ACPI_EDGE_SENSITIVE;
  71. *polarity = ACPI_ACTIVE_LOW;
  72. break;
  73. case IORESOURCE_IRQ_HIGHEDGE:
  74. *triggering = ACPI_EDGE_SENSITIVE;
  75. *polarity = ACPI_ACTIVE_HIGH;
  76. break;
  77. default:
  78. dev_err(&dev->dev, "can't encode invalid IRQ mode %#x\n",
  79. flags);
  80. *triggering = ACPI_EDGE_SENSITIVE;
  81. *polarity = ACPI_ACTIVE_HIGH;
  82. break;
  83. }
  84. if (flags & IORESOURCE_IRQ_SHAREABLE)
  85. *shareable = ACPI_SHARED;
  86. else
  87. *shareable = ACPI_EXCLUSIVE;
  88. }
  89. static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev,
  90. u32 gsi, int triggering,
  91. int polarity, int shareable)
  92. {
  93. int irq, flags;
  94. int p, t;
  95. if (!valid_IRQ(gsi)) {
  96. pnp_add_irq_resource(dev, gsi, IORESOURCE_DISABLED);
  97. return;
  98. }
  99. /*
  100. * in IO-APIC mode, use overrided attribute. Two reasons:
  101. * 1. BIOS bug in DSDT
  102. * 2. BIOS uses IO-APIC mode Interrupt Source Override
  103. */
  104. if (!acpi_get_override_irq(gsi, &t, &p)) {
  105. t = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
  106. p = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
  107. if (triggering != t || polarity != p) {
  108. dev_warn(&dev->dev, "IRQ %d override to %s, %s\n",
  109. gsi, t ? "edge":"level", p ? "low":"high");
  110. triggering = t;
  111. polarity = p;
  112. }
  113. }
  114. flags = irq_flags(triggering, polarity, shareable);
  115. irq = acpi_register_gsi(&dev->dev, gsi, triggering, polarity);
  116. if (irq >= 0)
  117. pcibios_penalize_isa_irq(irq, 1);
  118. else
  119. flags |= IORESOURCE_DISABLED;
  120. pnp_add_irq_resource(dev, irq, flags);
  121. }
  122. static int dma_flags(struct pnp_dev *dev, int type, int bus_master,
  123. int transfer)
  124. {
  125. int flags = 0;
  126. if (bus_master)
  127. flags |= IORESOURCE_DMA_MASTER;
  128. switch (type) {
  129. case ACPI_COMPATIBILITY:
  130. flags |= IORESOURCE_DMA_COMPATIBLE;
  131. break;
  132. case ACPI_TYPE_A:
  133. flags |= IORESOURCE_DMA_TYPEA;
  134. break;
  135. case ACPI_TYPE_B:
  136. flags |= IORESOURCE_DMA_TYPEB;
  137. break;
  138. case ACPI_TYPE_F:
  139. flags |= IORESOURCE_DMA_TYPEF;
  140. break;
  141. default:
  142. /* Set a default value ? */
  143. flags |= IORESOURCE_DMA_COMPATIBLE;
  144. dev_err(&dev->dev, "invalid DMA type %d\n", type);
  145. }
  146. switch (transfer) {
  147. case ACPI_TRANSFER_8:
  148. flags |= IORESOURCE_DMA_8BIT;
  149. break;
  150. case ACPI_TRANSFER_8_16:
  151. flags |= IORESOURCE_DMA_8AND16BIT;
  152. break;
  153. case ACPI_TRANSFER_16:
  154. flags |= IORESOURCE_DMA_16BIT;
  155. break;
  156. default:
  157. /* Set a default value ? */
  158. flags |= IORESOURCE_DMA_8AND16BIT;
  159. dev_err(&dev->dev, "invalid DMA transfer type %d\n", transfer);
  160. }
  161. return flags;
  162. }
  163. static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 start,
  164. u64 len, int io_decode,
  165. int window)
  166. {
  167. int flags = 0;
  168. u64 end = start + len - 1;
  169. if (io_decode == ACPI_DECODE_16)
  170. flags |= IORESOURCE_IO_16BIT_ADDR;
  171. if (len == 0 || end >= 0x10003)
  172. flags |= IORESOURCE_DISABLED;
  173. if (window)
  174. flags |= IORESOURCE_WINDOW;
  175. pnp_add_io_resource(dev, start, end, flags);
  176. }
  177. /*
  178. * Device CSRs that do not appear in PCI config space should be described
  179. * via ACPI. This would normally be done with Address Space Descriptors
  180. * marked as "consumer-only," but old versions of Windows and Linux ignore
  181. * the producer/consumer flag, so HP invented a vendor-defined resource to
  182. * describe the location and size of CSR space.
  183. */
  184. static struct acpi_vendor_uuid hp_ccsr_uuid = {
  185. .subtype = 2,
  186. .data = { 0xf9, 0xad, 0xe9, 0x69, 0x4f, 0x92, 0x5f, 0xab, 0xf6, 0x4a,
  187. 0x24, 0xd2, 0x01, 0x37, 0x0e, 0xad },
  188. };
  189. static int vendor_resource_matches(struct pnp_dev *dev,
  190. struct acpi_resource_vendor_typed *vendor,
  191. struct acpi_vendor_uuid *match,
  192. int expected_len)
  193. {
  194. int uuid_len = sizeof(vendor->uuid);
  195. u8 uuid_subtype = vendor->uuid_subtype;
  196. u8 *uuid = vendor->uuid;
  197. int actual_len;
  198. /* byte_length includes uuid_subtype and uuid */
  199. actual_len = vendor->byte_length - uuid_len - 1;
  200. if (uuid_subtype == match->subtype &&
  201. uuid_len == sizeof(match->data) &&
  202. memcmp(uuid, match->data, uuid_len) == 0) {
  203. if (expected_len && expected_len != actual_len) {
  204. dev_err(&dev->dev, "wrong vendor descriptor size; "
  205. "expected %d, found %d bytes\n",
  206. expected_len, actual_len);
  207. return 0;
  208. }
  209. return 1;
  210. }
  211. return 0;
  212. }
  213. static void pnpacpi_parse_allocated_vendor(struct pnp_dev *dev,
  214. struct acpi_resource_vendor_typed *vendor)
  215. {
  216. if (vendor_resource_matches(dev, vendor, &hp_ccsr_uuid, 16)) {
  217. u64 start, length;
  218. memcpy(&start, vendor->byte_data, sizeof(start));
  219. memcpy(&length, vendor->byte_data + 8, sizeof(length));
  220. pnp_add_mem_resource(dev, start, start + length - 1, 0);
  221. }
  222. }
  223. static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev,
  224. u64 start, u64 len,
  225. int write_protect, int window)
  226. {
  227. int flags = 0;
  228. u64 end = start + len - 1;
  229. if (len == 0)
  230. flags |= IORESOURCE_DISABLED;
  231. if (write_protect == ACPI_READ_WRITE_MEMORY)
  232. flags |= IORESOURCE_MEM_WRITEABLE;
  233. if (window)
  234. flags |= IORESOURCE_WINDOW;
  235. pnp_add_mem_resource(dev, start, end, flags);
  236. }
  237. static void pnpacpi_parse_allocated_busresource(struct pnp_dev *dev,
  238. u64 start, u64 len)
  239. {
  240. u64 end = start + len - 1;
  241. pnp_add_bus_resource(dev, start, end);
  242. }
  243. static void pnpacpi_parse_allocated_address_space(struct pnp_dev *dev,
  244. struct acpi_resource *res)
  245. {
  246. struct acpi_resource_address64 addr, *p = &addr;
  247. acpi_status status;
  248. int window;
  249. u64 len;
  250. status = acpi_resource_to_address64(res, p);
  251. if (!ACPI_SUCCESS(status)) {
  252. dev_warn(&dev->dev, "failed to convert resource type %d\n",
  253. res->type);
  254. return;
  255. }
  256. /* Windows apparently computes length rather than using _LEN */
  257. len = p->maximum - p->minimum + 1;
  258. window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
  259. if (p->resource_type == ACPI_MEMORY_RANGE)
  260. pnpacpi_parse_allocated_memresource(dev, p->minimum, len,
  261. p->info.mem.write_protect, window);
  262. else if (p->resource_type == ACPI_IO_RANGE)
  263. pnpacpi_parse_allocated_ioresource(dev, p->minimum, len,
  264. p->granularity == 0xfff ? ACPI_DECODE_10 :
  265. ACPI_DECODE_16, window);
  266. else if (p->resource_type == ACPI_BUS_NUMBER_RANGE)
  267. pnpacpi_parse_allocated_busresource(dev, p->minimum, len);
  268. }
  269. static void pnpacpi_parse_allocated_ext_address_space(struct pnp_dev *dev,
  270. struct acpi_resource *res)
  271. {
  272. struct acpi_resource_extended_address64 *p = &res->data.ext_address64;
  273. int window;
  274. u64 len;
  275. /* Windows apparently computes length rather than using _LEN */
  276. len = p->maximum - p->minimum + 1;
  277. window = (p->producer_consumer == ACPI_PRODUCER) ? 1 : 0;
  278. if (p->resource_type == ACPI_MEMORY_RANGE)
  279. pnpacpi_parse_allocated_memresource(dev, p->minimum, len,
  280. p->info.mem.write_protect, window);
  281. else if (p->resource_type == ACPI_IO_RANGE)
  282. pnpacpi_parse_allocated_ioresource(dev, p->minimum, len,
  283. p->granularity == 0xfff ? ACPI_DECODE_10 :
  284. ACPI_DECODE_16, window);
  285. else if (p->resource_type == ACPI_BUS_NUMBER_RANGE)
  286. pnpacpi_parse_allocated_busresource(dev, p->minimum, len);
  287. }
  288. static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
  289. void *data)
  290. {
  291. struct pnp_dev *dev = data;
  292. struct acpi_resource_irq *irq;
  293. struct acpi_resource_dma *dma;
  294. struct acpi_resource_io *io;
  295. struct acpi_resource_fixed_io *fixed_io;
  296. struct acpi_resource_vendor_typed *vendor_typed;
  297. struct acpi_resource_memory24 *memory24;
  298. struct acpi_resource_memory32 *memory32;
  299. struct acpi_resource_fixed_memory32 *fixed_memory32;
  300. struct acpi_resource_extended_irq *extended_irq;
  301. int i, flags;
  302. switch (res->type) {
  303. case ACPI_RESOURCE_TYPE_IRQ:
  304. /*
  305. * Per spec, only one interrupt per descriptor is allowed in
  306. * _CRS, but some firmware violates this, so parse them all.
  307. */
  308. irq = &res->data.irq;
  309. if (irq->interrupt_count == 0)
  310. pnp_add_irq_resource(dev, 0, IORESOURCE_DISABLED);
  311. else {
  312. for (i = 0; i < irq->interrupt_count; i++) {
  313. pnpacpi_parse_allocated_irqresource(dev,
  314. irq->interrupts[i],
  315. irq->triggering,
  316. irq->polarity,
  317. irq->sharable);
  318. }
  319. /*
  320. * The IRQ encoder puts a single interrupt in each
  321. * descriptor, so if a _CRS descriptor has more than
  322. * one interrupt, we won't be able to re-encode it.
  323. */
  324. if (pnp_can_write(dev) && irq->interrupt_count > 1) {
  325. dev_warn(&dev->dev, "multiple interrupts in "
  326. "_CRS descriptor; configuration can't "
  327. "be changed\n");
  328. dev->capabilities &= ~PNP_WRITE;
  329. }
  330. }
  331. break;
  332. case ACPI_RESOURCE_TYPE_DMA:
  333. dma = &res->data.dma;
  334. if (dma->channel_count > 0 && dma->channels[0] != (u8) -1)
  335. flags = dma_flags(dev, dma->type, dma->bus_master,
  336. dma->transfer);
  337. else
  338. flags = IORESOURCE_DISABLED;
  339. pnp_add_dma_resource(dev, dma->channels[0], flags);
  340. break;
  341. case ACPI_RESOURCE_TYPE_IO:
  342. io = &res->data.io;
  343. pnpacpi_parse_allocated_ioresource(dev,
  344. io->minimum,
  345. io->address_length,
  346. io->io_decode, 0);
  347. break;
  348. case ACPI_RESOURCE_TYPE_START_DEPENDENT:
  349. case ACPI_RESOURCE_TYPE_END_DEPENDENT:
  350. break;
  351. case ACPI_RESOURCE_TYPE_FIXED_IO:
  352. fixed_io = &res->data.fixed_io;
  353. pnpacpi_parse_allocated_ioresource(dev,
  354. fixed_io->address,
  355. fixed_io->address_length,
  356. ACPI_DECODE_10, 0);
  357. break;
  358. case ACPI_RESOURCE_TYPE_VENDOR:
  359. vendor_typed = &res->data.vendor_typed;
  360. pnpacpi_parse_allocated_vendor(dev, vendor_typed);
  361. break;
  362. case ACPI_RESOURCE_TYPE_END_TAG:
  363. break;
  364. case ACPI_RESOURCE_TYPE_MEMORY24:
  365. memory24 = &res->data.memory24;
  366. pnpacpi_parse_allocated_memresource(dev,
  367. memory24->minimum,
  368. memory24->address_length,
  369. memory24->write_protect, 0);
  370. break;
  371. case ACPI_RESOURCE_TYPE_MEMORY32:
  372. memory32 = &res->data.memory32;
  373. pnpacpi_parse_allocated_memresource(dev,
  374. memory32->minimum,
  375. memory32->address_length,
  376. memory32->write_protect, 0);
  377. break;
  378. case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
  379. fixed_memory32 = &res->data.fixed_memory32;
  380. pnpacpi_parse_allocated_memresource(dev,
  381. fixed_memory32->address,
  382. fixed_memory32->address_length,
  383. fixed_memory32->write_protect, 0);
  384. break;
  385. case ACPI_RESOURCE_TYPE_ADDRESS16:
  386. case ACPI_RESOURCE_TYPE_ADDRESS32:
  387. case ACPI_RESOURCE_TYPE_ADDRESS64:
  388. pnpacpi_parse_allocated_address_space(dev, res);
  389. break;
  390. case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
  391. pnpacpi_parse_allocated_ext_address_space(dev, res);
  392. break;
  393. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  394. extended_irq = &res->data.extended_irq;
  395. if (extended_irq->interrupt_count == 0)
  396. pnp_add_irq_resource(dev, 0, IORESOURCE_DISABLED);
  397. else {
  398. for (i = 0; i < extended_irq->interrupt_count; i++) {
  399. pnpacpi_parse_allocated_irqresource(dev,
  400. extended_irq->interrupts[i],
  401. extended_irq->triggering,
  402. extended_irq->polarity,
  403. extended_irq->sharable);
  404. }
  405. /*
  406. * The IRQ encoder puts a single interrupt in each
  407. * descriptor, so if a _CRS descriptor has more than
  408. * one interrupt, we won't be able to re-encode it.
  409. */
  410. if (pnp_can_write(dev) &&
  411. extended_irq->interrupt_count > 1) {
  412. dev_warn(&dev->dev, "multiple interrupts in "
  413. "_CRS descriptor; configuration can't "
  414. "be changed\n");
  415. dev->capabilities &= ~PNP_WRITE;
  416. }
  417. }
  418. break;
  419. case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
  420. break;
  421. default:
  422. dev_warn(&dev->dev, "unknown resource type %d in _CRS\n",
  423. res->type);
  424. return AE_ERROR;
  425. }
  426. return AE_OK;
  427. }
  428. int pnpacpi_parse_allocated_resource(struct pnp_dev *dev)
  429. {
  430. struct acpi_device *acpi_dev = dev->data;
  431. acpi_handle handle = acpi_dev->handle;
  432. acpi_status status;
  433. pnp_dbg(&dev->dev, "parse allocated resources\n");
  434. pnp_init_resources(dev);
  435. status = acpi_walk_resources(handle, METHOD_NAME__CRS,
  436. pnpacpi_allocated_resource, dev);
  437. if (ACPI_FAILURE(status)) {
  438. if (status != AE_NOT_FOUND)
  439. dev_err(&dev->dev, "can't evaluate _CRS: %d", status);
  440. return -EPERM;
  441. }
  442. return 0;
  443. }
  444. static __init void pnpacpi_parse_dma_option(struct pnp_dev *dev,
  445. unsigned int option_flags,
  446. struct acpi_resource_dma *p)
  447. {
  448. int i;
  449. unsigned char map = 0, flags;
  450. if (p->channel_count == 0)
  451. return;
  452. for (i = 0; i < p->channel_count; i++)
  453. map |= 1 << p->channels[i];
  454. flags = dma_flags(dev, p->type, p->bus_master, p->transfer);
  455. pnp_register_dma_resource(dev, option_flags, map, flags);
  456. }
  457. static __init void pnpacpi_parse_irq_option(struct pnp_dev *dev,
  458. unsigned int option_flags,
  459. struct acpi_resource_irq *p)
  460. {
  461. int i;
  462. pnp_irq_mask_t map;
  463. unsigned char flags;
  464. if (p->interrupt_count == 0)
  465. return;
  466. bitmap_zero(map.bits, PNP_IRQ_NR);
  467. for (i = 0; i < p->interrupt_count; i++)
  468. if (p->interrupts[i])
  469. __set_bit(p->interrupts[i], map.bits);
  470. flags = irq_flags(p->triggering, p->polarity, p->sharable);
  471. pnp_register_irq_resource(dev, option_flags, &map, flags);
  472. }
  473. static __init void pnpacpi_parse_ext_irq_option(struct pnp_dev *dev,
  474. unsigned int option_flags,
  475. struct acpi_resource_extended_irq *p)
  476. {
  477. int i;
  478. pnp_irq_mask_t map;
  479. unsigned char flags;
  480. if (p->interrupt_count == 0)
  481. return;
  482. bitmap_zero(map.bits, PNP_IRQ_NR);
  483. for (i = 0; i < p->interrupt_count; i++) {
  484. if (p->interrupts[i]) {
  485. if (p->interrupts[i] < PNP_IRQ_NR)
  486. __set_bit(p->interrupts[i], map.bits);
  487. else
  488. dev_err(&dev->dev, "ignoring IRQ %d option "
  489. "(too large for %d entry bitmap)\n",
  490. p->interrupts[i], PNP_IRQ_NR);
  491. }
  492. }
  493. flags = irq_flags(p->triggering, p->polarity, p->sharable);
  494. pnp_register_irq_resource(dev, option_flags, &map, flags);
  495. }
  496. static __init void pnpacpi_parse_port_option(struct pnp_dev *dev,
  497. unsigned int option_flags,
  498. struct acpi_resource_io *io)
  499. {
  500. unsigned char flags = 0;
  501. if (io->address_length == 0)
  502. return;
  503. if (io->io_decode == ACPI_DECODE_16)
  504. flags = IORESOURCE_IO_16BIT_ADDR;
  505. pnp_register_port_resource(dev, option_flags, io->minimum, io->maximum,
  506. io->alignment, io->address_length, flags);
  507. }
  508. static __init void pnpacpi_parse_fixed_port_option(struct pnp_dev *dev,
  509. unsigned int option_flags,
  510. struct acpi_resource_fixed_io *io)
  511. {
  512. if (io->address_length == 0)
  513. return;
  514. pnp_register_port_resource(dev, option_flags, io->address, io->address,
  515. 0, io->address_length, IORESOURCE_IO_FIXED);
  516. }
  517. static __init void pnpacpi_parse_mem24_option(struct pnp_dev *dev,
  518. unsigned int option_flags,
  519. struct acpi_resource_memory24 *p)
  520. {
  521. unsigned char flags = 0;
  522. if (p->address_length == 0)
  523. return;
  524. if (p->write_protect == ACPI_READ_WRITE_MEMORY)
  525. flags = IORESOURCE_MEM_WRITEABLE;
  526. pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum,
  527. p->alignment, p->address_length, flags);
  528. }
  529. static __init void pnpacpi_parse_mem32_option(struct pnp_dev *dev,
  530. unsigned int option_flags,
  531. struct acpi_resource_memory32 *p)
  532. {
  533. unsigned char flags = 0;
  534. if (p->address_length == 0)
  535. return;
  536. if (p->write_protect == ACPI_READ_WRITE_MEMORY)
  537. flags = IORESOURCE_MEM_WRITEABLE;
  538. pnp_register_mem_resource(dev, option_flags, p->minimum, p->maximum,
  539. p->alignment, p->address_length, flags);
  540. }
  541. static __init void pnpacpi_parse_fixed_mem32_option(struct pnp_dev *dev,
  542. unsigned int option_flags,
  543. struct acpi_resource_fixed_memory32 *p)
  544. {
  545. unsigned char flags = 0;
  546. if (p->address_length == 0)
  547. return;
  548. if (p->write_protect == ACPI_READ_WRITE_MEMORY)
  549. flags = IORESOURCE_MEM_WRITEABLE;
  550. pnp_register_mem_resource(dev, option_flags, p->address, p->address,
  551. 0, p->address_length, flags);
  552. }
  553. static __init void pnpacpi_parse_address_option(struct pnp_dev *dev,
  554. unsigned int option_flags,
  555. struct acpi_resource *r)
  556. {
  557. struct acpi_resource_address64 addr, *p = &addr;
  558. acpi_status status;
  559. unsigned char flags = 0;
  560. status = acpi_resource_to_address64(r, p);
  561. if (ACPI_FAILURE(status)) {
  562. dev_warn(&dev->dev, "can't convert resource type %d\n",
  563. r->type);
  564. return;
  565. }
  566. if (p->address_length == 0)
  567. return;
  568. if (p->resource_type == ACPI_MEMORY_RANGE) {
  569. if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY)
  570. flags = IORESOURCE_MEM_WRITEABLE;
  571. pnp_register_mem_resource(dev, option_flags, p->minimum,
  572. p->minimum, 0, p->address_length,
  573. flags);
  574. } else if (p->resource_type == ACPI_IO_RANGE)
  575. pnp_register_port_resource(dev, option_flags, p->minimum,
  576. p->minimum, 0, p->address_length,
  577. IORESOURCE_IO_FIXED);
  578. }
  579. static __init void pnpacpi_parse_ext_address_option(struct pnp_dev *dev,
  580. unsigned int option_flags,
  581. struct acpi_resource *r)
  582. {
  583. struct acpi_resource_extended_address64 *p = &r->data.ext_address64;
  584. unsigned char flags = 0;
  585. if (p->address_length == 0)
  586. return;
  587. if (p->resource_type == ACPI_MEMORY_RANGE) {
  588. if (p->info.mem.write_protect == ACPI_READ_WRITE_MEMORY)
  589. flags = IORESOURCE_MEM_WRITEABLE;
  590. pnp_register_mem_resource(dev, option_flags, p->minimum,
  591. p->minimum, 0, p->address_length,
  592. flags);
  593. } else if (p->resource_type == ACPI_IO_RANGE)
  594. pnp_register_port_resource(dev, option_flags, p->minimum,
  595. p->minimum, 0, p->address_length,
  596. IORESOURCE_IO_FIXED);
  597. }
  598. struct acpipnp_parse_option_s {
  599. struct pnp_dev *dev;
  600. unsigned int option_flags;
  601. };
  602. static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res,
  603. void *data)
  604. {
  605. int priority;
  606. struct acpipnp_parse_option_s *parse_data = data;
  607. struct pnp_dev *dev = parse_data->dev;
  608. unsigned int option_flags = parse_data->option_flags;
  609. switch (res->type) {
  610. case ACPI_RESOURCE_TYPE_IRQ:
  611. pnpacpi_parse_irq_option(dev, option_flags, &res->data.irq);
  612. break;
  613. case ACPI_RESOURCE_TYPE_DMA:
  614. pnpacpi_parse_dma_option(dev, option_flags, &res->data.dma);
  615. break;
  616. case ACPI_RESOURCE_TYPE_START_DEPENDENT:
  617. switch (res->data.start_dpf.compatibility_priority) {
  618. case ACPI_GOOD_CONFIGURATION:
  619. priority = PNP_RES_PRIORITY_PREFERRED;
  620. break;
  621. case ACPI_ACCEPTABLE_CONFIGURATION:
  622. priority = PNP_RES_PRIORITY_ACCEPTABLE;
  623. break;
  624. case ACPI_SUB_OPTIMAL_CONFIGURATION:
  625. priority = PNP_RES_PRIORITY_FUNCTIONAL;
  626. break;
  627. default:
  628. priority = PNP_RES_PRIORITY_INVALID;
  629. break;
  630. }
  631. parse_data->option_flags = pnp_new_dependent_set(dev, priority);
  632. break;
  633. case ACPI_RESOURCE_TYPE_END_DEPENDENT:
  634. parse_data->option_flags = 0;
  635. break;
  636. case ACPI_RESOURCE_TYPE_IO:
  637. pnpacpi_parse_port_option(dev, option_flags, &res->data.io);
  638. break;
  639. case ACPI_RESOURCE_TYPE_FIXED_IO:
  640. pnpacpi_parse_fixed_port_option(dev, option_flags,
  641. &res->data.fixed_io);
  642. break;
  643. case ACPI_RESOURCE_TYPE_VENDOR:
  644. case ACPI_RESOURCE_TYPE_END_TAG:
  645. break;
  646. case ACPI_RESOURCE_TYPE_MEMORY24:
  647. pnpacpi_parse_mem24_option(dev, option_flags,
  648. &res->data.memory24);
  649. break;
  650. case ACPI_RESOURCE_TYPE_MEMORY32:
  651. pnpacpi_parse_mem32_option(dev, option_flags,
  652. &res->data.memory32);
  653. break;
  654. case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
  655. pnpacpi_parse_fixed_mem32_option(dev, option_flags,
  656. &res->data.fixed_memory32);
  657. break;
  658. case ACPI_RESOURCE_TYPE_ADDRESS16:
  659. case ACPI_RESOURCE_TYPE_ADDRESS32:
  660. case ACPI_RESOURCE_TYPE_ADDRESS64:
  661. pnpacpi_parse_address_option(dev, option_flags, res);
  662. break;
  663. case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
  664. pnpacpi_parse_ext_address_option(dev, option_flags, res);
  665. break;
  666. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  667. pnpacpi_parse_ext_irq_option(dev, option_flags,
  668. &res->data.extended_irq);
  669. break;
  670. case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
  671. break;
  672. default:
  673. dev_warn(&dev->dev, "unknown resource type %d in _PRS\n",
  674. res->type);
  675. return AE_ERROR;
  676. }
  677. return AE_OK;
  678. }
  679. int __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev)
  680. {
  681. struct acpi_device *acpi_dev = dev->data;
  682. acpi_handle handle = acpi_dev->handle;
  683. acpi_status status;
  684. struct acpipnp_parse_option_s parse_data;
  685. pnp_dbg(&dev->dev, "parse resource options\n");
  686. parse_data.dev = dev;
  687. parse_data.option_flags = 0;
  688. status = acpi_walk_resources(handle, METHOD_NAME__PRS,
  689. pnpacpi_option_resource, &parse_data);
  690. if (ACPI_FAILURE(status)) {
  691. if (status != AE_NOT_FOUND)
  692. dev_err(&dev->dev, "can't evaluate _PRS: %d", status);
  693. return -EPERM;
  694. }
  695. return 0;
  696. }
  697. static int pnpacpi_supported_resource(struct acpi_resource *res)
  698. {
  699. switch (res->type) {
  700. case ACPI_RESOURCE_TYPE_IRQ:
  701. case ACPI_RESOURCE_TYPE_DMA:
  702. case ACPI_RESOURCE_TYPE_IO:
  703. case ACPI_RESOURCE_TYPE_FIXED_IO:
  704. case ACPI_RESOURCE_TYPE_MEMORY24:
  705. case ACPI_RESOURCE_TYPE_MEMORY32:
  706. case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
  707. case ACPI_RESOURCE_TYPE_ADDRESS16:
  708. case ACPI_RESOURCE_TYPE_ADDRESS32:
  709. case ACPI_RESOURCE_TYPE_ADDRESS64:
  710. case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
  711. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  712. return 1;
  713. }
  714. return 0;
  715. }
  716. /*
  717. * Set resource
  718. */
  719. static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
  720. void *data)
  721. {
  722. int *res_cnt = data;
  723. if (pnpacpi_supported_resource(res))
  724. (*res_cnt)++;
  725. return AE_OK;
  726. }
  727. static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data)
  728. {
  729. struct acpi_resource **resource = data;
  730. if (pnpacpi_supported_resource(res)) {
  731. (*resource)->type = res->type;
  732. (*resource)->length = sizeof(struct acpi_resource);
  733. if (res->type == ACPI_RESOURCE_TYPE_IRQ)
  734. (*resource)->data.irq.descriptor_length =
  735. res->data.irq.descriptor_length;
  736. (*resource)++;
  737. }
  738. return AE_OK;
  739. }
  740. int pnpacpi_build_resource_template(struct pnp_dev *dev,
  741. struct acpi_buffer *buffer)
  742. {
  743. struct acpi_device *acpi_dev = dev->data;
  744. acpi_handle handle = acpi_dev->handle;
  745. struct acpi_resource *resource;
  746. int res_cnt = 0;
  747. acpi_status status;
  748. status = acpi_walk_resources(handle, METHOD_NAME__CRS,
  749. pnpacpi_count_resources, &res_cnt);
  750. if (ACPI_FAILURE(status)) {
  751. dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status);
  752. return -EINVAL;
  753. }
  754. if (!res_cnt)
  755. return -EINVAL;
  756. buffer->length = sizeof(struct acpi_resource) * (res_cnt + 1) + 1;
  757. buffer->pointer = kzalloc(buffer->length - 1, GFP_KERNEL);
  758. if (!buffer->pointer)
  759. return -ENOMEM;
  760. resource = (struct acpi_resource *)buffer->pointer;
  761. status = acpi_walk_resources(handle, METHOD_NAME__CRS,
  762. pnpacpi_type_resources, &resource);
  763. if (ACPI_FAILURE(status)) {
  764. kfree(buffer->pointer);
  765. dev_err(&dev->dev, "can't evaluate _CRS: %d\n", status);
  766. return -EINVAL;
  767. }
  768. /* resource will pointer the end resource now */
  769. resource->type = ACPI_RESOURCE_TYPE_END_TAG;
  770. return 0;
  771. }
  772. static void pnpacpi_encode_irq(struct pnp_dev *dev,
  773. struct acpi_resource *resource,
  774. struct resource *p)
  775. {
  776. struct acpi_resource_irq *irq = &resource->data.irq;
  777. int triggering, polarity, shareable;
  778. if (!pnp_resource_enabled(p)) {
  779. irq->interrupt_count = 0;
  780. pnp_dbg(&dev->dev, " encode irq (%s)\n",
  781. p ? "disabled" : "missing");
  782. return;
  783. }
  784. decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable);
  785. irq->triggering = triggering;
  786. irq->polarity = polarity;
  787. irq->sharable = shareable;
  788. irq->interrupt_count = 1;
  789. irq->interrupts[0] = p->start;
  790. pnp_dbg(&dev->dev, " encode irq %d %s %s %s (%d-byte descriptor)\n",
  791. (int) p->start,
  792. triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge",
  793. polarity == ACPI_ACTIVE_LOW ? "low" : "high",
  794. irq->sharable == ACPI_SHARED ? "shared" : "exclusive",
  795. irq->descriptor_length);
  796. }
  797. static void pnpacpi_encode_ext_irq(struct pnp_dev *dev,
  798. struct acpi_resource *resource,
  799. struct resource *p)
  800. {
  801. struct acpi_resource_extended_irq *extended_irq = &resource->data.extended_irq;
  802. int triggering, polarity, shareable;
  803. if (!pnp_resource_enabled(p)) {
  804. extended_irq->interrupt_count = 0;
  805. pnp_dbg(&dev->dev, " encode extended irq (%s)\n",
  806. p ? "disabled" : "missing");
  807. return;
  808. }
  809. decode_irq_flags(dev, p->flags, &triggering, &polarity, &shareable);
  810. extended_irq->producer_consumer = ACPI_CONSUMER;
  811. extended_irq->triggering = triggering;
  812. extended_irq->polarity = polarity;
  813. extended_irq->sharable = shareable;
  814. extended_irq->interrupt_count = 1;
  815. extended_irq->interrupts[0] = p->start;
  816. pnp_dbg(&dev->dev, " encode irq %d %s %s %s\n", (int) p->start,
  817. triggering == ACPI_LEVEL_SENSITIVE ? "level" : "edge",
  818. polarity == ACPI_ACTIVE_LOW ? "low" : "high",
  819. extended_irq->sharable == ACPI_SHARED ? "shared" : "exclusive");
  820. }
  821. static void pnpacpi_encode_dma(struct pnp_dev *dev,
  822. struct acpi_resource *resource,
  823. struct resource *p)
  824. {
  825. struct acpi_resource_dma *dma = &resource->data.dma;
  826. if (!pnp_resource_enabled(p)) {
  827. dma->channel_count = 0;
  828. pnp_dbg(&dev->dev, " encode dma (%s)\n",
  829. p ? "disabled" : "missing");
  830. return;
  831. }
  832. /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
  833. switch (p->flags & IORESOURCE_DMA_SPEED_MASK) {
  834. case IORESOURCE_DMA_TYPEA:
  835. dma->type = ACPI_TYPE_A;
  836. break;
  837. case IORESOURCE_DMA_TYPEB:
  838. dma->type = ACPI_TYPE_B;
  839. break;
  840. case IORESOURCE_DMA_TYPEF:
  841. dma->type = ACPI_TYPE_F;
  842. break;
  843. default:
  844. dma->type = ACPI_COMPATIBILITY;
  845. }
  846. switch (p->flags & IORESOURCE_DMA_TYPE_MASK) {
  847. case IORESOURCE_DMA_8BIT:
  848. dma->transfer = ACPI_TRANSFER_8;
  849. break;
  850. case IORESOURCE_DMA_8AND16BIT:
  851. dma->transfer = ACPI_TRANSFER_8_16;
  852. break;
  853. default:
  854. dma->transfer = ACPI_TRANSFER_16;
  855. }
  856. dma->bus_master = !!(p->flags & IORESOURCE_DMA_MASTER);
  857. dma->channel_count = 1;
  858. dma->channels[0] = p->start;
  859. pnp_dbg(&dev->dev, " encode dma %d "
  860. "type %#x transfer %#x master %d\n",
  861. (int) p->start, dma->type, dma->transfer, dma->bus_master);
  862. }
  863. static void pnpacpi_encode_io(struct pnp_dev *dev,
  864. struct acpi_resource *resource,
  865. struct resource *p)
  866. {
  867. struct acpi_resource_io *io = &resource->data.io;
  868. if (pnp_resource_enabled(p)) {
  869. /* Note: pnp_assign_port copies pnp_port->flags into p->flags */
  870. io->io_decode = (p->flags & IORESOURCE_IO_16BIT_ADDR) ?
  871. ACPI_DECODE_16 : ACPI_DECODE_10;
  872. io->minimum = p->start;
  873. io->maximum = p->end;
  874. io->alignment = 0; /* Correct? */
  875. io->address_length = p->end - p->start + 1;
  876. } else {
  877. io->minimum = 0;
  878. io->address_length = 0;
  879. }
  880. pnp_dbg(&dev->dev, " encode io %#x-%#x decode %#x\n", io->minimum,
  881. io->minimum + io->address_length - 1, io->io_decode);
  882. }
  883. static void pnpacpi_encode_fixed_io(struct pnp_dev *dev,
  884. struct acpi_resource *resource,
  885. struct resource *p)
  886. {
  887. struct acpi_resource_fixed_io *fixed_io = &resource->data.fixed_io;
  888. if (pnp_resource_enabled(p)) {
  889. fixed_io->address = p->start;
  890. fixed_io->address_length = p->end - p->start + 1;
  891. } else {
  892. fixed_io->address = 0;
  893. fixed_io->address_length = 0;
  894. }
  895. pnp_dbg(&dev->dev, " encode fixed_io %#x-%#x\n", fixed_io->address,
  896. fixed_io->address + fixed_io->address_length - 1);
  897. }
  898. static void pnpacpi_encode_mem24(struct pnp_dev *dev,
  899. struct acpi_resource *resource,
  900. struct resource *p)
  901. {
  902. struct acpi_resource_memory24 *memory24 = &resource->data.memory24;
  903. if (pnp_resource_enabled(p)) {
  904. /* Note: pnp_assign_mem copies pnp_mem->flags into p->flags */
  905. memory24->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ?
  906. ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
  907. memory24->minimum = p->start;
  908. memory24->maximum = p->end;
  909. memory24->alignment = 0;
  910. memory24->address_length = p->end - p->start + 1;
  911. } else {
  912. memory24->minimum = 0;
  913. memory24->address_length = 0;
  914. }
  915. pnp_dbg(&dev->dev, " encode mem24 %#x-%#x write_protect %#x\n",
  916. memory24->minimum,
  917. memory24->minimum + memory24->address_length - 1,
  918. memory24->write_protect);
  919. }
  920. static void pnpacpi_encode_mem32(struct pnp_dev *dev,
  921. struct acpi_resource *resource,
  922. struct resource *p)
  923. {
  924. struct acpi_resource_memory32 *memory32 = &resource->data.memory32;
  925. if (pnp_resource_enabled(p)) {
  926. memory32->write_protect = p->flags & IORESOURCE_MEM_WRITEABLE ?
  927. ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
  928. memory32->minimum = p->start;
  929. memory32->maximum = p->end;
  930. memory32->alignment = 0;
  931. memory32->address_length = p->end - p->start + 1;
  932. } else {
  933. memory32->minimum = 0;
  934. memory32->alignment = 0;
  935. }
  936. pnp_dbg(&dev->dev, " encode mem32 %#x-%#x write_protect %#x\n",
  937. memory32->minimum,
  938. memory32->minimum + memory32->address_length - 1,
  939. memory32->write_protect);
  940. }
  941. static void pnpacpi_encode_fixed_mem32(struct pnp_dev *dev,
  942. struct acpi_resource *resource,
  943. struct resource *p)
  944. {
  945. struct acpi_resource_fixed_memory32 *fixed_memory32 = &resource->data.fixed_memory32;
  946. if (pnp_resource_enabled(p)) {
  947. fixed_memory32->write_protect =
  948. p->flags & IORESOURCE_MEM_WRITEABLE ?
  949. ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
  950. fixed_memory32->address = p->start;
  951. fixed_memory32->address_length = p->end - p->start + 1;
  952. } else {
  953. fixed_memory32->address = 0;
  954. fixed_memory32->address_length = 0;
  955. }
  956. pnp_dbg(&dev->dev, " encode fixed_mem32 %#x-%#x write_protect %#x\n",
  957. fixed_memory32->address,
  958. fixed_memory32->address + fixed_memory32->address_length - 1,
  959. fixed_memory32->write_protect);
  960. }
  961. int pnpacpi_encode_resources(struct pnp_dev *dev, struct acpi_buffer *buffer)
  962. {
  963. int i = 0;
  964. /* pnpacpi_build_resource_template allocates extra mem */
  965. int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1;
  966. struct acpi_resource *resource = buffer->pointer;
  967. int port = 0, irq = 0, dma = 0, mem = 0;
  968. pnp_dbg(&dev->dev, "encode %d resources\n", res_cnt);
  969. while (i < res_cnt) {
  970. switch (resource->type) {
  971. case ACPI_RESOURCE_TYPE_IRQ:
  972. pnpacpi_encode_irq(dev, resource,
  973. pnp_get_resource(dev, IORESOURCE_IRQ, irq));
  974. irq++;
  975. break;
  976. case ACPI_RESOURCE_TYPE_DMA:
  977. pnpacpi_encode_dma(dev, resource,
  978. pnp_get_resource(dev, IORESOURCE_DMA, dma));
  979. dma++;
  980. break;
  981. case ACPI_RESOURCE_TYPE_IO:
  982. pnpacpi_encode_io(dev, resource,
  983. pnp_get_resource(dev, IORESOURCE_IO, port));
  984. port++;
  985. break;
  986. case ACPI_RESOURCE_TYPE_FIXED_IO:
  987. pnpacpi_encode_fixed_io(dev, resource,
  988. pnp_get_resource(dev, IORESOURCE_IO, port));
  989. port++;
  990. break;
  991. case ACPI_RESOURCE_TYPE_MEMORY24:
  992. pnpacpi_encode_mem24(dev, resource,
  993. pnp_get_resource(dev, IORESOURCE_MEM, mem));
  994. mem++;
  995. break;
  996. case ACPI_RESOURCE_TYPE_MEMORY32:
  997. pnpacpi_encode_mem32(dev, resource,
  998. pnp_get_resource(dev, IORESOURCE_MEM, mem));
  999. mem++;
  1000. break;
  1001. case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
  1002. pnpacpi_encode_fixed_mem32(dev, resource,
  1003. pnp_get_resource(dev, IORESOURCE_MEM, mem));
  1004. mem++;
  1005. break;
  1006. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  1007. pnpacpi_encode_ext_irq(dev, resource,
  1008. pnp_get_resource(dev, IORESOURCE_IRQ, irq));
  1009. irq++;
  1010. break;
  1011. case ACPI_RESOURCE_TYPE_START_DEPENDENT:
  1012. case ACPI_RESOURCE_TYPE_END_DEPENDENT:
  1013. case ACPI_RESOURCE_TYPE_VENDOR:
  1014. case ACPI_RESOURCE_TYPE_END_TAG:
  1015. case ACPI_RESOURCE_TYPE_ADDRESS16:
  1016. case ACPI_RESOURCE_TYPE_ADDRESS32:
  1017. case ACPI_RESOURCE_TYPE_ADDRESS64:
  1018. case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
  1019. case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
  1020. default: /* other type */
  1021. dev_warn(&dev->dev, "can't encode unknown resource "
  1022. "type %d\n", resource->type);
  1023. return -EINVAL;
  1024. }
  1025. resource++;
  1026. i++;
  1027. }
  1028. return 0;
  1029. }