amlresrc.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. /******************************************************************************
  2. *
  3. * Module Name: amlresrc.h - AML resource descriptors
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2013, 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), 8And16(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. /* General Flags for address space resource descriptors */
  177. #define ACPI_RESOURCE_FLAG_DEC 2
  178. #define ACPI_RESOURCE_FLAG_MIF 4
  179. #define ACPI_RESOURCE_FLAG_MAF 8
  180. struct aml_resource_memory24 {
  181. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  182. u16 minimum;
  183. u16 maximum;
  184. u16 alignment;
  185. u16 address_length;
  186. };
  187. struct aml_resource_vendor_large {
  188. AML_RESOURCE_LARGE_HEADER_COMMON};
  189. struct aml_resource_memory32 {
  190. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  191. u32 minimum;
  192. u32 maximum;
  193. u32 alignment;
  194. u32 address_length;
  195. };
  196. struct aml_resource_fixed_memory32 {
  197. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  198. u32 address;
  199. u32 address_length;
  200. };
  201. #define AML_RESOURCE_ADDRESS_COMMON \
  202. u8 resource_type; \
  203. u8 flags; \
  204. u8 specific_flags;
  205. struct aml_resource_address {
  206. AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
  207. struct aml_resource_extended_address64 {
  208. AML_RESOURCE_LARGE_HEADER_COMMON
  209. AML_RESOURCE_ADDRESS_COMMON u8 revision_ID;
  210. u8 reserved;
  211. u64 granularity;
  212. u64 minimum;
  213. u64 maximum;
  214. u64 translation_offset;
  215. u64 address_length;
  216. u64 type_specific;
  217. };
  218. #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
  219. struct aml_resource_address64 {
  220. AML_RESOURCE_LARGE_HEADER_COMMON
  221. AML_RESOURCE_ADDRESS_COMMON u64 granularity;
  222. u64 minimum;
  223. u64 maximum;
  224. u64 translation_offset;
  225. u64 address_length;
  226. };
  227. struct aml_resource_address32 {
  228. AML_RESOURCE_LARGE_HEADER_COMMON
  229. AML_RESOURCE_ADDRESS_COMMON u32 granularity;
  230. u32 minimum;
  231. u32 maximum;
  232. u32 translation_offset;
  233. u32 address_length;
  234. };
  235. struct aml_resource_address16 {
  236. AML_RESOURCE_LARGE_HEADER_COMMON
  237. AML_RESOURCE_ADDRESS_COMMON u16 granularity;
  238. u16 minimum;
  239. u16 maximum;
  240. u16 translation_offset;
  241. u16 address_length;
  242. };
  243. struct aml_resource_extended_irq {
  244. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  245. u8 interrupt_count;
  246. u32 interrupts[1];
  247. /* res_source_index, res_source optional fields follow */
  248. };
  249. struct aml_resource_generic_register {
  250. AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id;
  251. u8 bit_width;
  252. u8 bit_offset;
  253. u8 access_size; /* ACPI 3.0, was previously Reserved */
  254. u64 address;
  255. };
  256. /* Common descriptor for gpio_int and gpio_io (ACPI 5.0) */
  257. struct aml_resource_gpio {
  258. AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id;
  259. u8 connection_type;
  260. u16 flags;
  261. u16 int_flags;
  262. u8 pin_config;
  263. u16 drive_strength;
  264. u16 debounce_timeout;
  265. u16 pin_table_offset;
  266. u8 res_source_index;
  267. u16 res_source_offset;
  268. u16 vendor_offset;
  269. u16 vendor_length;
  270. /*
  271. * Optional fields follow immediately:
  272. * 1) PIN list (Words)
  273. * 2) Resource Source String
  274. * 3) Vendor Data bytes
  275. */
  276. };
  277. #define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */
  278. /* Values for connection_type above */
  279. #define AML_RESOURCE_GPIO_TYPE_INT 0
  280. #define AML_RESOURCE_GPIO_TYPE_IO 1
  281. #define AML_RESOURCE_MAX_GPIOTYPE 1
  282. /* Common preamble for all serial descriptors (ACPI 5.0) */
  283. #define AML_RESOURCE_SERIAL_COMMON \
  284. u8 revision_id; \
  285. u8 res_source_index; \
  286. u8 type; \
  287. u8 flags; \
  288. u16 type_specific_flags; \
  289. u8 type_revision_id; \
  290. u16 type_data_length; \
  291. /* Values for the type field above */
  292. #define AML_RESOURCE_I2C_SERIALBUSTYPE 1
  293. #define AML_RESOURCE_SPI_SERIALBUSTYPE 2
  294. #define AML_RESOURCE_UART_SERIALBUSTYPE 3
  295. #define AML_RESOURCE_MAX_SERIALBUSTYPE 3
  296. #define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
  297. struct aml_resource_common_serialbus {
  298. AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON};
  299. struct aml_resource_i2c_serialbus {
  300. AML_RESOURCE_LARGE_HEADER_COMMON
  301. AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
  302. u16 slave_address;
  303. /*
  304. * Optional fields follow immediately:
  305. * 1) Vendor Data bytes
  306. * 2) Resource Source String
  307. */
  308. };
  309. #define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */
  310. #define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */
  311. #define AML_RESOURCE_I2C_MIN_DATA_LEN 6
  312. struct aml_resource_spi_serialbus {
  313. AML_RESOURCE_LARGE_HEADER_COMMON
  314. AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
  315. u8 data_bit_length;
  316. u8 clock_phase;
  317. u8 clock_polarity;
  318. u16 device_selection;
  319. /*
  320. * Optional fields follow immediately:
  321. * 1) Vendor Data bytes
  322. * 2) Resource Source String
  323. */
  324. };
  325. #define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */
  326. #define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */
  327. #define AML_RESOURCE_SPI_MIN_DATA_LEN 9
  328. struct aml_resource_uart_serialbus {
  329. AML_RESOURCE_LARGE_HEADER_COMMON
  330. AML_RESOURCE_SERIAL_COMMON u32 default_baud_rate;
  331. u16 rx_fifo_size;
  332. u16 tx_fifo_size;
  333. u8 parity;
  334. u8 lines_enabled;
  335. /*
  336. * Optional fields follow immediately:
  337. * 1) Vendor Data bytes
  338. * 2) Resource Source String
  339. */
  340. };
  341. #define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */
  342. #define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */
  343. #define AML_RESOURCE_UART_MIN_DATA_LEN 10
  344. /* restore default alignment */
  345. #pragma pack()
  346. /* Union of all resource descriptors, so we can allocate the worst case */
  347. union aml_resource {
  348. /* Descriptor headers */
  349. u8 descriptor_type;
  350. struct aml_resource_small_header small_header;
  351. struct aml_resource_large_header large_header;
  352. /* Small resource descriptors */
  353. struct aml_resource_irq irq;
  354. struct aml_resource_dma dma;
  355. struct aml_resource_start_dependent start_dpf;
  356. struct aml_resource_end_dependent end_dpf;
  357. struct aml_resource_io io;
  358. struct aml_resource_fixed_io fixed_io;
  359. struct aml_resource_fixed_dma fixed_dma;
  360. struct aml_resource_vendor_small vendor_small;
  361. struct aml_resource_end_tag end_tag;
  362. /* Large resource descriptors */
  363. struct aml_resource_memory24 memory24;
  364. struct aml_resource_generic_register generic_reg;
  365. struct aml_resource_vendor_large vendor_large;
  366. struct aml_resource_memory32 memory32;
  367. struct aml_resource_fixed_memory32 fixed_memory32;
  368. struct aml_resource_address16 address16;
  369. struct aml_resource_address32 address32;
  370. struct aml_resource_address64 address64;
  371. struct aml_resource_extended_address64 ext_address64;
  372. struct aml_resource_extended_irq extended_irq;
  373. struct aml_resource_gpio gpio;
  374. struct aml_resource_i2c_serialbus i2c_serial_bus;
  375. struct aml_resource_spi_serialbus spi_serial_bus;
  376. struct aml_resource_uart_serialbus uart_serial_bus;
  377. struct aml_resource_common_serialbus common_serial_bus;
  378. /* Utility overlays */
  379. struct aml_resource_address address;
  380. u32 dword_item;
  381. u16 word_item;
  382. u8 byte_item;
  383. };
  384. #endif