amlresrc.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /******************************************************************************
  2. *
  3. * Module Name: amlresrc.h - AML resource descriptors
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, 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. struct asl_resource_info {
  113. union acpi_parse_object *descriptor_type_op; /* Resource descriptor parse node */
  114. union acpi_parse_object *mapping_op; /* Used for mapfile support */
  115. u32 current_byte_offset; /* Offset in resource template */
  116. };
  117. /* Macros used to generate AML resource length fields */
  118. #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
  119. #define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
  120. /*
  121. * Resource descriptors defined in the ACPI specification.
  122. *
  123. * Packing/alignment must be BYTE because these descriptors
  124. * are used to overlay the raw AML byte stream.
  125. */
  126. #pragma pack(1)
  127. /*
  128. * SMALL descriptors
  129. */
  130. #define AML_RESOURCE_SMALL_HEADER_COMMON \
  131. u8 descriptor_type;
  132. struct aml_resource_small_header {
  133. AML_RESOURCE_SMALL_HEADER_COMMON};
  134. struct aml_resource_irq {
  135. AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
  136. u8 flags;
  137. };
  138. struct aml_resource_irq_noflags {
  139. AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
  140. };
  141. struct aml_resource_dma {
  142. AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask;
  143. u8 flags;
  144. };
  145. struct aml_resource_start_dependent {
  146. AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
  147. };
  148. struct aml_resource_start_dependent_noprio {
  149. AML_RESOURCE_SMALL_HEADER_COMMON};
  150. struct aml_resource_end_dependent {
  151. AML_RESOURCE_SMALL_HEADER_COMMON};
  152. struct aml_resource_io {
  153. AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
  154. u16 minimum;
  155. u16 maximum;
  156. u8 alignment;
  157. u8 address_length;
  158. };
  159. struct aml_resource_fixed_io {
  160. AML_RESOURCE_SMALL_HEADER_COMMON u16 address;
  161. u8 address_length;
  162. };
  163. struct aml_resource_vendor_small {
  164. AML_RESOURCE_SMALL_HEADER_COMMON};
  165. struct aml_resource_end_tag {
  166. AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
  167. };
  168. struct aml_resource_fixed_dma {
  169. AML_RESOURCE_SMALL_HEADER_COMMON u16 request_lines;
  170. u16 channels;
  171. u8 width;
  172. };
  173. /*
  174. * LARGE descriptors
  175. */
  176. #define AML_RESOURCE_LARGE_HEADER_COMMON \
  177. u8 descriptor_type;\
  178. u16 resource_length;
  179. struct aml_resource_large_header {
  180. AML_RESOURCE_LARGE_HEADER_COMMON};
  181. /* General Flags for address space resource descriptors */
  182. #define ACPI_RESOURCE_FLAG_DEC 2
  183. #define ACPI_RESOURCE_FLAG_MIF 4
  184. #define ACPI_RESOURCE_FLAG_MAF 8
  185. struct aml_resource_memory24 {
  186. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  187. u16 minimum;
  188. u16 maximum;
  189. u16 alignment;
  190. u16 address_length;
  191. };
  192. struct aml_resource_vendor_large {
  193. AML_RESOURCE_LARGE_HEADER_COMMON};
  194. struct aml_resource_memory32 {
  195. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  196. u32 minimum;
  197. u32 maximum;
  198. u32 alignment;
  199. u32 address_length;
  200. };
  201. struct aml_resource_fixed_memory32 {
  202. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  203. u32 address;
  204. u32 address_length;
  205. };
  206. #define AML_RESOURCE_ADDRESS_COMMON \
  207. u8 resource_type; \
  208. u8 flags; \
  209. u8 specific_flags;
  210. struct aml_resource_address {
  211. AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
  212. struct aml_resource_extended_address64 {
  213. AML_RESOURCE_LARGE_HEADER_COMMON
  214. AML_RESOURCE_ADDRESS_COMMON u8 revision_ID;
  215. u8 reserved;
  216. u64 granularity;
  217. u64 minimum;
  218. u64 maximum;
  219. u64 translation_offset;
  220. u64 address_length;
  221. u64 type_specific;
  222. };
  223. #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
  224. struct aml_resource_address64 {
  225. AML_RESOURCE_LARGE_HEADER_COMMON
  226. AML_RESOURCE_ADDRESS_COMMON u64 granularity;
  227. u64 minimum;
  228. u64 maximum;
  229. u64 translation_offset;
  230. u64 address_length;
  231. };
  232. struct aml_resource_address32 {
  233. AML_RESOURCE_LARGE_HEADER_COMMON
  234. AML_RESOURCE_ADDRESS_COMMON u32 granularity;
  235. u32 minimum;
  236. u32 maximum;
  237. u32 translation_offset;
  238. u32 address_length;
  239. };
  240. struct aml_resource_address16 {
  241. AML_RESOURCE_LARGE_HEADER_COMMON
  242. AML_RESOURCE_ADDRESS_COMMON u16 granularity;
  243. u16 minimum;
  244. u16 maximum;
  245. u16 translation_offset;
  246. u16 address_length;
  247. };
  248. struct aml_resource_extended_irq {
  249. AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
  250. u8 interrupt_count;
  251. u32 interrupts[1];
  252. /* res_source_index, res_source optional fields follow */
  253. };
  254. struct aml_resource_generic_register {
  255. AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id;
  256. u8 bit_width;
  257. u8 bit_offset;
  258. u8 access_size; /* ACPI 3.0, was previously Reserved */
  259. u64 address;
  260. };
  261. /* Common descriptor for gpio_int and gpio_io (ACPI 5.0) */
  262. struct aml_resource_gpio {
  263. AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id;
  264. u8 connection_type;
  265. u16 flags;
  266. u16 int_flags;
  267. u8 pin_config;
  268. u16 drive_strength;
  269. u16 debounce_timeout;
  270. u16 pin_table_offset;
  271. u8 res_source_index;
  272. u16 res_source_offset;
  273. u16 vendor_offset;
  274. u16 vendor_length;
  275. /*
  276. * Optional fields follow immediately:
  277. * 1) PIN list (Words)
  278. * 2) Resource Source String
  279. * 3) Vendor Data bytes
  280. */
  281. };
  282. #define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */
  283. /* Values for connection_type above */
  284. #define AML_RESOURCE_GPIO_TYPE_INT 0
  285. #define AML_RESOURCE_GPIO_TYPE_IO 1
  286. #define AML_RESOURCE_MAX_GPIOTYPE 1
  287. /* Common preamble for all serial descriptors (ACPI 5.0) */
  288. #define AML_RESOURCE_SERIAL_COMMON \
  289. u8 revision_id; \
  290. u8 res_source_index; \
  291. u8 type; \
  292. u8 flags; \
  293. u16 type_specific_flags; \
  294. u8 type_revision_id; \
  295. u16 type_data_length; \
  296. /* Values for the type field above */
  297. #define AML_RESOURCE_I2C_SERIALBUSTYPE 1
  298. #define AML_RESOURCE_SPI_SERIALBUSTYPE 2
  299. #define AML_RESOURCE_UART_SERIALBUSTYPE 3
  300. #define AML_RESOURCE_MAX_SERIALBUSTYPE 3
  301. #define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
  302. struct aml_resource_common_serialbus {
  303. AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON};
  304. struct aml_resource_i2c_serialbus {
  305. AML_RESOURCE_LARGE_HEADER_COMMON
  306. AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
  307. u16 slave_address;
  308. /*
  309. * Optional fields follow immediately:
  310. * 1) Vendor Data bytes
  311. * 2) Resource Source String
  312. */
  313. };
  314. #define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */
  315. #define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */
  316. #define AML_RESOURCE_I2C_MIN_DATA_LEN 6
  317. struct aml_resource_spi_serialbus {
  318. AML_RESOURCE_LARGE_HEADER_COMMON
  319. AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
  320. u8 data_bit_length;
  321. u8 clock_phase;
  322. u8 clock_polarity;
  323. u16 device_selection;
  324. /*
  325. * Optional fields follow immediately:
  326. * 1) Vendor Data bytes
  327. * 2) Resource Source String
  328. */
  329. };
  330. #define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */
  331. #define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */
  332. #define AML_RESOURCE_SPI_MIN_DATA_LEN 9
  333. struct aml_resource_uart_serialbus {
  334. AML_RESOURCE_LARGE_HEADER_COMMON
  335. AML_RESOURCE_SERIAL_COMMON u32 default_baud_rate;
  336. u16 rx_fifo_size;
  337. u16 tx_fifo_size;
  338. u8 parity;
  339. u8 lines_enabled;
  340. /*
  341. * Optional fields follow immediately:
  342. * 1) Vendor Data bytes
  343. * 2) Resource Source String
  344. */
  345. };
  346. #define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */
  347. #define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */
  348. #define AML_RESOURCE_UART_MIN_DATA_LEN 10
  349. /* restore default alignment */
  350. #pragma pack()
  351. /* Union of all resource descriptors, so we can allocate the worst case */
  352. union aml_resource {
  353. /* Descriptor headers */
  354. u8 descriptor_type;
  355. struct aml_resource_small_header small_header;
  356. struct aml_resource_large_header large_header;
  357. /* Small resource descriptors */
  358. struct aml_resource_irq irq;
  359. struct aml_resource_dma dma;
  360. struct aml_resource_start_dependent start_dpf;
  361. struct aml_resource_end_dependent end_dpf;
  362. struct aml_resource_io io;
  363. struct aml_resource_fixed_io fixed_io;
  364. struct aml_resource_fixed_dma fixed_dma;
  365. struct aml_resource_vendor_small vendor_small;
  366. struct aml_resource_end_tag end_tag;
  367. /* Large resource descriptors */
  368. struct aml_resource_memory24 memory24;
  369. struct aml_resource_generic_register generic_reg;
  370. struct aml_resource_vendor_large vendor_large;
  371. struct aml_resource_memory32 memory32;
  372. struct aml_resource_fixed_memory32 fixed_memory32;
  373. struct aml_resource_address16 address16;
  374. struct aml_resource_address32 address32;
  375. struct aml_resource_address64 address64;
  376. struct aml_resource_extended_address64 ext_address64;
  377. struct aml_resource_extended_irq extended_irq;
  378. struct aml_resource_gpio gpio;
  379. struct aml_resource_i2c_serialbus i2c_serial_bus;
  380. struct aml_resource_spi_serialbus spi_serial_bus;
  381. struct aml_resource_uart_serialbus uart_serial_bus;
  382. struct aml_resource_common_serialbus common_serial_bus;
  383. /* Utility overlays */
  384. struct aml_resource_address address;
  385. u32 dword_item;
  386. u16 word_item;
  387. u8 byte_item;
  388. };
  389. /* Interfaces used by both the disassembler and compiler */
  390. void
  391. mp_save_gpio_info(union acpi_parse_object *op,
  392. union aml_resource *resource,
  393. u32 pin_count, u16 *pin_list, char *device_name);
  394. void
  395. mp_save_serial_info(union acpi_parse_object *op,
  396. union aml_resource *resource, char *device_name);
  397. char *mp_get_hid_from_parse_tree(struct acpi_namespace_node *hid_node);
  398. char *mp_get_hid_via_namestring(char *device_name);
  399. char *mp_get_connection_info(union acpi_parse_object *op,
  400. u32 pin_index,
  401. struct acpi_namespace_node **target_node,
  402. char **target_name);
  403. char *mp_get_parent_device_hid(union acpi_parse_object *op,
  404. struct acpi_namespace_node **target_node,
  405. char **parent_device_name);
  406. char *mp_get_ddn_value(char *device_name);
  407. char *mp_get_hid_value(struct acpi_namespace_node *device_node);
  408. #endif