amlresrc.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /******************************************************************************
  2. *
  3. * Module Name: amlresrc.h - AML resource descriptors
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2012, 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. /* acpisrc:struct_defs -- for acpisrc conversion */
  43. #ifndef __AMLRESRC_H
  44. #define __AMLRESRC_H
  45. /*
  46. * Resource descriptor tags, as defined in the ACPI specification.
  47. * Used to symbolically reference fields within a descriptor.
  48. */
  49. #define ACPI_RESTAG_ADDRESS "_ADR"
  50. #define ACPI_RESTAG_ALIGNMENT "_ALN"
  51. #define ACPI_RESTAG_ADDRESSSPACE "_ASI"
  52. #define ACPI_RESTAG_ACCESSSIZE "_ASZ"
  53. #define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
  54. #define ACPI_RESTAG_BASEADDRESS "_BAS"
  55. #define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
  56. #define ACPI_RESTAG_DEBOUNCETIME "_DBT"
  57. #define ACPI_RESTAG_DECODE "_DEC"
  58. #define ACPI_RESTAG_DEVICEPOLARITY "_DPL"
  59. #define ACPI_RESTAG_DMA "_DMA"
  60. #define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
  61. #define ACPI_RESTAG_DRIVESTRENGTH "_DRS"
  62. #define ACPI_RESTAG_ENDIANNESS "_END"
  63. #define ACPI_RESTAG_FLOWCONTROL "_FLC"
  64. #define ACPI_RESTAG_GRANULARITY "_GRA"
  65. #define ACPI_RESTAG_INTERRUPT "_INT"
  66. #define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */
  67. #define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */
  68. #define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
  69. #define ACPI_RESTAG_IORESTRICTION "_IOR"
  70. #define ACPI_RESTAG_LENGTH "_LEN"
  71. #define ACPI_RESTAG_LINE "_LIN"
  72. #define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
  73. #define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
  74. #define ACPI_RESTAG_MAXADDR "_MAX"
  75. #define ACPI_RESTAG_MINADDR "_MIN"
  76. #define ACPI_RESTAG_MAXTYPE "_MAF"
  77. #define ACPI_RESTAG_MINTYPE "_MIF"
  78. #define ACPI_RESTAG_MODE "_MOD"
  79. #define ACPI_RESTAG_PARITY "_PAR"
  80. #define ACPI_RESTAG_PHASE "_PHA"
  81. #define ACPI_RESTAG_PIN "_PIN"
  82. #define ACPI_RESTAG_PINCONFIG "_PPI"
  83. #define ACPI_RESTAG_POLARITY "_POL"
  84. #define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
  85. #define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
  86. #define ACPI_RESTAG_RANGETYPE "_RNG"
  87. #define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */
  88. #define ACPI_RESTAG_LENGTH_RX "_RXL"
  89. #define ACPI_RESTAG_LENGTH_TX "_TXL"
  90. #define ACPI_RESTAG_SLAVEMODE "_SLV"
  91. #define ACPI_RESTAG_SPEED "_SPE"
  92. #define ACPI_RESTAG_STOPBITS "_STB"
  93. #define ACPI_RESTAG_TRANSLATION "_TRA"
  94. #define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
  95. #define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
  96. #define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8_and16(1), 16(2) */
  97. #define ACPI_RESTAG_VENDORDATA "_VEN"
  98. /* Default sizes for "small" resource descriptors */
  99. #define ASL_RDESC_IRQ_SIZE 0x02
  100. #define ASL_RDESC_DMA_SIZE 0x02
  101. #define ASL_RDESC_ST_DEPEND_SIZE 0x00
  102. #define ASL_RDESC_END_DEPEND_SIZE 0x00
  103. #define ASL_RDESC_IO_SIZE 0x07
  104. #define ASL_RDESC_FIXED_IO_SIZE 0x03
  105. #define ASL_RDESC_FIXED_DMA_SIZE 0x05
  106. #define ASL_RDESC_END_TAG_SIZE 0x01
  107. struct asl_resource_node {
  108. u32 buffer_length;
  109. void *buffer;
  110. struct asl_resource_node *next;
  111. };
  112. /* Macros used to generate AML resource length fields */
  113. #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
  114. #define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
  115. /*
  116. * Resource descriptors defined in the ACPI specification.
  117. *
  118. * Packing/alignment must be BYTE because these descriptors
  119. * are used to overlay the raw AML byte stream.
  120. */
  121. #pragma pack(1)
  122. /*
  123. * SMALL descriptors
  124. */
  125. #define AML_RESOURCE_SMALL_HEADER_COMMON \
  126. u8 descriptor_type;
  127. struct aml_resource_small_header {
  128. AML_RESOURCE_SMALL_HEADER_COMMON};
  129. struct aml_resource_irq {
  130. AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
  131. u8 flags;
  132. };
  133. struct aml_resource_irq_noflags {
  134. AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
  135. };
  136. struct aml_resource_dma {
  137. AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask;
  138. u8 flags;
  139. };
  140. struct aml_resource_start_dependent {
  141. AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
  142. };
  143. struct aml_resource_start_dependent_noprio {
  144. AML_RESOURCE_SMALL_HEADER_COMMON};
  145. struct aml_resource_end_dependent {
  146. AML_RESOURCE_SMALL_HEADER_COMMON};
  147. struct aml_resource_io {
  148. AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
  149. u16 minimum;
  150. u16 maximum;
  151. u8 alignment;
  152. u8 address_length;
  153. };
  154. struct aml_resource_fixed_io {
  155. AML_RESOURCE_SMALL_HEADER_COMMON u16 address;
  156. u8 address_length;
  157. };
  158. struct aml_resource_vendor_small {
  159. AML_RESOURCE_SMALL_HEADER_COMMON};
  160. struct aml_resource_end_tag {
  161. AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
  162. };
  163. struct aml_resource_fixed_dma {
  164. AML_RESOURCE_SMALL_HEADER_COMMON u16 request_lines;
  165. u16 channels;
  166. u8 width;
  167. };
  168. /*
  169. * LARGE descriptors
  170. */
  171. #define AML_RESOURCE_LARGE_HEADER_COMMON \
  172. u8 descriptor_type;\
  173. u16 resource_length;
  174. struct aml_resource_large_header {
  175. AML_RESOURCE_LARGE_HEADER_COMMON};
  176. struct aml_resource_memory24 {
  177. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  178. u16 minimum;
  179. u16 maximum;
  180. u16 alignment;
  181. u16 address_length;
  182. };
  183. struct aml_resource_vendor_large {
  184. AML_RESOURCE_LARGE_HEADER_COMMON};
  185. struct aml_resource_memory32 {
  186. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  187. u32 minimum;
  188. u32 maximum;
  189. u32 alignment;
  190. u32 address_length;
  191. };
  192. struct aml_resource_fixed_memory32 {
  193. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  194. u32 address;
  195. u32 address_length;
  196. };
  197. #define AML_RESOURCE_ADDRESS_COMMON \
  198. u8 resource_type; \
  199. u8 flags; \
  200. u8 specific_flags;
  201. struct aml_resource_address {
  202. AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
  203. struct aml_resource_extended_address64 {
  204. AML_RESOURCE_LARGE_HEADER_COMMON
  205. AML_RESOURCE_ADDRESS_COMMON u8 revision_iD;
  206. u8 reserved;
  207. u64 granularity;
  208. u64 minimum;
  209. u64 maximum;
  210. u64 translation_offset;
  211. u64 address_length;
  212. u64 type_specific;
  213. };
  214. #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
  215. struct aml_resource_address64 {
  216. AML_RESOURCE_LARGE_HEADER_COMMON
  217. AML_RESOURCE_ADDRESS_COMMON u64 granularity;
  218. u64 minimum;
  219. u64 maximum;
  220. u64 translation_offset;
  221. u64 address_length;
  222. };
  223. struct aml_resource_address32 {
  224. AML_RESOURCE_LARGE_HEADER_COMMON
  225. AML_RESOURCE_ADDRESS_COMMON u32 granularity;
  226. u32 minimum;
  227. u32 maximum;
  228. u32 translation_offset;
  229. u32 address_length;
  230. };
  231. struct aml_resource_address16 {
  232. AML_RESOURCE_LARGE_HEADER_COMMON
  233. AML_RESOURCE_ADDRESS_COMMON u16 granularity;
  234. u16 minimum;
  235. u16 maximum;
  236. u16 translation_offset;
  237. u16 address_length;
  238. };
  239. struct aml_resource_extended_irq {
  240. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  241. u8 interrupt_count;
  242. u32 interrupts[1];
  243. /* res_source_index, res_source optional fields follow */
  244. };
  245. struct aml_resource_generic_register {
  246. AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id;
  247. u8 bit_width;
  248. u8 bit_offset;
  249. u8 access_size; /* ACPI 3.0, was previously Reserved */
  250. u64 address;
  251. };
  252. /* Common descriptor for gpio_int and gpio_io (ACPI 5.0) */
  253. struct aml_resource_gpio {
  254. AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id;
  255. u8 connection_type;
  256. u16 flags;
  257. u16 int_flags;
  258. u8 pin_config;
  259. u16 drive_strength;
  260. u16 debounce_timeout;
  261. u16 pin_table_offset;
  262. u8 res_source_index;
  263. u16 res_source_offset;
  264. u16 vendor_offset;
  265. u16 vendor_length;
  266. /*
  267. * Optional fields follow immediately:
  268. * 1) PIN list (Words)
  269. * 2) Resource Source String
  270. * 3) Vendor Data bytes
  271. */
  272. };
  273. #define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */
  274. /* Values for connection_type above */
  275. #define AML_RESOURCE_GPIO_TYPE_INT 0
  276. #define AML_RESOURCE_GPIO_TYPE_IO 1
  277. #define AML_RESOURCE_MAX_GPIOTYPE 1
  278. /* Common preamble for all serial descriptors (ACPI 5.0) */
  279. #define AML_RESOURCE_SERIAL_COMMON \
  280. u8 revision_id; \
  281. u8 res_source_index; \
  282. u8 type; \
  283. u8 flags; \
  284. u16 type_specific_flags; \
  285. u8 type_revision_id; \
  286. u16 type_data_length; \
  287. /* Values for the type field above */
  288. #define AML_RESOURCE_I2C_SERIALBUSTYPE 1
  289. #define AML_RESOURCE_SPI_SERIALBUSTYPE 2
  290. #define AML_RESOURCE_UART_SERIALBUSTYPE 3
  291. #define AML_RESOURCE_MAX_SERIALBUSTYPE 3
  292. #define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
  293. struct aml_resource_common_serialbus {
  294. AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON};
  295. struct aml_resource_i2c_serialbus {
  296. AML_RESOURCE_LARGE_HEADER_COMMON
  297. AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
  298. u16 slave_address;
  299. /*
  300. * Optional fields follow immediately:
  301. * 1) Vendor Data bytes
  302. * 2) Resource Source String
  303. */
  304. };
  305. #define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */
  306. #define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */
  307. #define AML_RESOURCE_I2C_MIN_DATA_LEN 6
  308. struct aml_resource_spi_serialbus {
  309. AML_RESOURCE_LARGE_HEADER_COMMON
  310. AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
  311. u8 data_bit_length;
  312. u8 clock_phase;
  313. u8 clock_polarity;
  314. u16 device_selection;
  315. /*
  316. * Optional fields follow immediately:
  317. * 1) Vendor Data bytes
  318. * 2) Resource Source String
  319. */
  320. };
  321. #define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */
  322. #define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */
  323. #define AML_RESOURCE_SPI_MIN_DATA_LEN 9
  324. struct aml_resource_uart_serialbus {
  325. AML_RESOURCE_LARGE_HEADER_COMMON
  326. AML_RESOURCE_SERIAL_COMMON u32 default_baud_rate;
  327. u16 rx_fifo_size;
  328. u16 tx_fifo_size;
  329. u8 parity;
  330. u8 lines_enabled;
  331. /*
  332. * Optional fields follow immediately:
  333. * 1) Vendor Data bytes
  334. * 2) Resource Source String
  335. */
  336. };
  337. #define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */
  338. #define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */
  339. #define AML_RESOURCE_UART_MIN_DATA_LEN 10
  340. /* restore default alignment */
  341. #pragma pack()
  342. /* Union of all resource descriptors, so we can allocate the worst case */
  343. union aml_resource {
  344. /* Descriptor headers */
  345. u8 descriptor_type;
  346. struct aml_resource_small_header small_header;
  347. struct aml_resource_large_header large_header;
  348. /* Small resource descriptors */
  349. struct aml_resource_irq irq;
  350. struct aml_resource_dma dma;
  351. struct aml_resource_start_dependent start_dpf;
  352. struct aml_resource_end_dependent end_dpf;
  353. struct aml_resource_io io;
  354. struct aml_resource_fixed_io fixed_io;
  355. struct aml_resource_fixed_dma fixed_dma;
  356. struct aml_resource_vendor_small vendor_small;
  357. struct aml_resource_end_tag end_tag;
  358. /* Large resource descriptors */
  359. struct aml_resource_memory24 memory24;
  360. struct aml_resource_generic_register generic_reg;
  361. struct aml_resource_vendor_large vendor_large;
  362. struct aml_resource_memory32 memory32;
  363. struct aml_resource_fixed_memory32 fixed_memory32;
  364. struct aml_resource_address16 address16;
  365. struct aml_resource_address32 address32;
  366. struct aml_resource_address64 address64;
  367. struct aml_resource_extended_address64 ext_address64;
  368. struct aml_resource_extended_irq extended_irq;
  369. struct aml_resource_gpio gpio;
  370. struct aml_resource_i2c_serialbus i2c_serial_bus;
  371. struct aml_resource_spi_serialbus spi_serial_bus;
  372. struct aml_resource_uart_serialbus uart_serial_bus;
  373. struct aml_resource_common_serialbus common_serial_bus;
  374. /* Utility overlays */
  375. struct aml_resource_address address;
  376. u32 dword_item;
  377. u16 word_item;
  378. u8 byte_item;
  379. };
  380. #endif