rsirq.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*******************************************************************************
  2. *
  3. * Module Name: rsirq - IRQ resource descriptors
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2008, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include <acpi/acresrc.h>
  44. #define _COMPONENT ACPI_RESOURCES
  45. ACPI_MODULE_NAME("rsirq")
  46. /*******************************************************************************
  47. *
  48. * acpi_rs_get_irq
  49. *
  50. ******************************************************************************/
  51. struct acpi_rsconvert_info acpi_rs_get_irq[8] = {
  52. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ,
  53. ACPI_RS_SIZE(struct acpi_resource_irq),
  54. ACPI_RSC_TABLE_SIZE(acpi_rs_get_irq)},
  55. /* Get the IRQ mask (bytes 1:2) */
  56. {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
  57. AML_OFFSET(irq.irq_mask),
  58. ACPI_RS_OFFSET(data.irq.interrupt_count)},
  59. /* Set default flags (others are zero) */
  60. {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.irq.triggering),
  61. ACPI_EDGE_SENSITIVE,
  62. 1},
  63. /* Get the descriptor length (2 or 3 for IRQ descriptor) */
  64. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.irq.descriptor_length),
  65. AML_OFFSET(irq.descriptor_type),
  66. 0},
  67. /* All done if no flag byte present in descriptor */
  68. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3},
  69. /* Get flags: Triggering[0], Polarity[3], Sharing[4] */
  70. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
  71. AML_OFFSET(irq.flags),
  72. 0},
  73. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
  74. AML_OFFSET(irq.flags),
  75. 3},
  76. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
  77. AML_OFFSET(irq.flags),
  78. 4}
  79. };
  80. /*******************************************************************************
  81. *
  82. * acpi_rs_set_irq
  83. *
  84. ******************************************************************************/
  85. struct acpi_rsconvert_info acpi_rs_set_irq[13] = {
  86. /* Start with a default descriptor of length 3 */
  87. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ,
  88. sizeof(struct aml_resource_irq),
  89. ACPI_RSC_TABLE_SIZE(acpi_rs_set_irq)},
  90. /* Convert interrupt list to 16-bit IRQ bitmask */
  91. {ACPI_RSC_BITMASK16, ACPI_RS_OFFSET(data.irq.interrupts[0]),
  92. AML_OFFSET(irq.irq_mask),
  93. ACPI_RS_OFFSET(data.irq.interrupt_count)},
  94. /* Set the flags byte */
  95. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.triggering),
  96. AML_OFFSET(irq.flags),
  97. 0},
  98. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.polarity),
  99. AML_OFFSET(irq.flags),
  100. 3},
  101. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.irq.sharable),
  102. AML_OFFSET(irq.flags),
  103. 4},
  104. /*
  105. * All done if the output descriptor length is required to be 3
  106. * (i.e., optimization to 2 bytes cannot be attempted)
  107. */
  108. {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
  109. ACPI_RS_OFFSET(data.irq.descriptor_length),
  110. 3},
  111. /* Set length to 2 bytes (no flags byte) */
  112. {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)},
  113. /*
  114. * All done if the output descriptor length is required to be 2.
  115. *
  116. * TBD: Perhaps we should check for error if input flags are not
  117. * compatible with a 2-byte descriptor.
  118. */
  119. {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
  120. ACPI_RS_OFFSET(data.irq.descriptor_length),
  121. 2},
  122. /* Reset length to 3 bytes (descriptor with flags byte) */
  123. {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq)},
  124. /*
  125. * Check if the flags byte is necessary. Not needed if the flags are:
  126. * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE
  127. */
  128. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  129. ACPI_RS_OFFSET(data.irq.triggering),
  130. ACPI_EDGE_SENSITIVE},
  131. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  132. ACPI_RS_OFFSET(data.irq.polarity),
  133. ACPI_ACTIVE_HIGH},
  134. {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
  135. ACPI_RS_OFFSET(data.irq.sharable),
  136. ACPI_EXCLUSIVE},
  137. /* We can optimize to a 2-byte irq_no_flags() descriptor */
  138. {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_irq_noflags)}
  139. };
  140. /*******************************************************************************
  141. *
  142. * acpi_rs_convert_ext_irq
  143. *
  144. ******************************************************************************/
  145. struct acpi_rsconvert_info acpi_rs_convert_ext_irq[9] = {
  146. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ,
  147. ACPI_RS_SIZE(struct acpi_resource_extended_irq),
  148. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_irq)},
  149. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ,
  150. sizeof(struct aml_resource_extended_irq),
  151. 0},
  152. /* Flag bits */
  153. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.producer_consumer),
  154. AML_OFFSET(extended_irq.flags),
  155. 0},
  156. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.triggering),
  157. AML_OFFSET(extended_irq.flags),
  158. 1},
  159. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.polarity),
  160. AML_OFFSET(extended_irq.flags),
  161. 2},
  162. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.extended_irq.sharable),
  163. AML_OFFSET(extended_irq.flags),
  164. 3},
  165. /* IRQ Table length (Byte4) */
  166. {ACPI_RSC_COUNT, ACPI_RS_OFFSET(data.extended_irq.interrupt_count),
  167. AML_OFFSET(extended_irq.interrupt_count),
  168. sizeof(u32)}
  169. ,
  170. /* Copy every IRQ in the table, each is 32 bits */
  171. {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
  172. AML_OFFSET(extended_irq.interrupts[0]),
  173. 0}
  174. ,
  175. /* Optional resource_source (Index and String) */
  176. {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET(data.extended_irq.resource_source),
  177. ACPI_RS_OFFSET(data.extended_irq.interrupts[0]),
  178. sizeof(struct aml_resource_extended_irq)}
  179. };
  180. /*******************************************************************************
  181. *
  182. * acpi_rs_convert_dma
  183. *
  184. ******************************************************************************/
  185. struct acpi_rsconvert_info acpi_rs_convert_dma[6] = {
  186. {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA,
  187. ACPI_RS_SIZE(struct acpi_resource_dma),
  188. ACPI_RSC_TABLE_SIZE(acpi_rs_convert_dma)},
  189. {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA,
  190. sizeof(struct aml_resource_dma),
  191. 0},
  192. /* Flags: transfer preference, bus mastering, channel speed */
  193. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.transfer),
  194. AML_OFFSET(dma.flags),
  195. 0},
  196. {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.dma.bus_master),
  197. AML_OFFSET(dma.flags),
  198. 2},
  199. {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.dma.type),
  200. AML_OFFSET(dma.flags),
  201. 5},
  202. /* DMA channel mask bits */
  203. {ACPI_RSC_BITMASK, ACPI_RS_OFFSET(data.dma.channels[0]),
  204. AML_OFFSET(dma.dma_channel_mask),
  205. ACPI_RS_OFFSET(data.dma.channel_count)}
  206. };