1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /******************************************************************************
4 * Module Name: amlresrc.h - AML resource descriptors
6 * Copyright (C) 2000 - 2023, Intel Corp.
8 *****************************************************************************/
10 /* acpisrc:struct_defs -- for acpisrc conversion */
16 * Resource descriptor tags, as defined in the ACPI specification.
17 * Used to symbolically reference fields within a descriptor.
19 #define ACPI_RESTAG_ADDRESS "_ADR"
20 #define ACPI_RESTAG_ALIGNMENT "_ALN"
21 #define ACPI_RESTAG_ADDRESSSPACE "_ASI"
22 #define ACPI_RESTAG_ACCESSSIZE "_ASZ"
23 #define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
24 #define ACPI_RESTAG_BASEADDRESS "_BAS"
25 #define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
26 #define ACPI_RESTAG_DEBOUNCETIME "_DBT"
27 #define ACPI_RESTAG_DECODE "_DEC"
28 #define ACPI_RESTAG_DEVICEPOLARITY "_DPL"
29 #define ACPI_RESTAG_DMA "_DMA"
30 #define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
31 #define ACPI_RESTAG_DRIVESTRENGTH "_DRS"
32 #define ACPI_RESTAG_ENDIANNESS "_END"
33 #define ACPI_RESTAG_FLOWCONTROL "_FLC"
34 #define ACPI_RESTAG_FUNCTION "_FUN"
35 #define ACPI_RESTAG_GRANULARITY "_GRA"
36 #define ACPI_RESTAG_INTERRUPT "_INT"
37 #define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */
38 #define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */
39 #define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
40 #define ACPI_RESTAG_IORESTRICTION "_IOR"
41 #define ACPI_RESTAG_LENGTH "_LEN"
42 #define ACPI_RESTAG_LINE "_LIN"
43 #define ACPI_RESTAG_LOCALPORT "_PRT"
44 #define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
45 #define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
46 #define ACPI_RESTAG_MAXADDR "_MAX"
47 #define ACPI_RESTAG_MINADDR "_MIN"
48 #define ACPI_RESTAG_MAXTYPE "_MAF"
49 #define ACPI_RESTAG_MINTYPE "_MIF"
50 #define ACPI_RESTAG_MODE "_MOD"
51 #define ACPI_RESTAG_PARITY "_PAR"
52 #define ACPI_RESTAG_PHASE "_PHA"
53 #define ACPI_RESTAG_PHYTYPE "_PHY"
54 #define ACPI_RESTAG_PIN "_PIN"
55 #define ACPI_RESTAG_PINCONFIG "_PPI"
56 #define ACPI_RESTAG_PINCONFIG_TYPE "_TYP"
57 #define ACPI_RESTAG_PINCONFIG_VALUE "_VAL"
58 #define ACPI_RESTAG_POLARITY "_POL"
59 #define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
60 #define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
61 #define ACPI_RESTAG_RANGETYPE "_RNG"
62 #define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */
63 #define ACPI_RESTAG_LENGTH_RX "_RXL"
64 #define ACPI_RESTAG_LENGTH_TX "_TXL"
65 #define ACPI_RESTAG_SLAVEMODE "_SLV"
66 #define ACPI_RESTAG_SPEED "_SPE"
67 #define ACPI_RESTAG_STOPBITS "_STB"
68 #define ACPI_RESTAG_TRANSLATION "_TRA"
69 #define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
70 #define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
71 #define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */
72 #define ACPI_RESTAG_VENDORDATA "_VEN"
73 #define ACPI_RESTAG_FQN "_FQN"
74 #define ACPI_RESTAG_FQD "_FQD"
76 /* Default sizes for "small" resource descriptors */
78 #define ASL_RDESC_IRQ_SIZE 0x02
79 #define ASL_RDESC_DMA_SIZE 0x02
80 #define ASL_RDESC_ST_DEPEND_SIZE 0x00
81 #define ASL_RDESC_END_DEPEND_SIZE 0x00
82 #define ASL_RDESC_IO_SIZE 0x07
83 #define ASL_RDESC_FIXED_IO_SIZE 0x03
84 #define ASL_RDESC_FIXED_DMA_SIZE 0x05
85 #define ASL_RDESC_END_TAG_SIZE 0x01
87 struct asl_resource_node
{
90 struct asl_resource_node
*next
;
93 struct asl_resource_info
{
94 union acpi_parse_object
*descriptor_type_op
; /* Resource descriptor parse node */
95 union acpi_parse_object
*mapping_op
; /* Used for mapfile support */
96 u32 current_byte_offset
; /* Offset in resource template */
99 /* Macros used to generate AML resource length fields */
101 #define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
102 #define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
105 * Resource descriptors defined in the ACPI specification.
107 * Packing/alignment must be BYTE because these descriptors
108 * are used to overlay the raw AML byte stream.
115 #define AML_RESOURCE_SMALL_HEADER_COMMON \
118 struct aml_resource_small_header
{
119 AML_RESOURCE_SMALL_HEADER_COMMON
};
121 struct aml_resource_irq
{
122 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask
;
126 struct aml_resource_irq_noflags
{
127 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask
;
130 struct aml_resource_dma
{
131 AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask
;
135 struct aml_resource_start_dependent
{
136 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags
;
139 struct aml_resource_start_dependent_noprio
{
140 AML_RESOURCE_SMALL_HEADER_COMMON
};
142 struct aml_resource_end_dependent
{
143 AML_RESOURCE_SMALL_HEADER_COMMON
};
145 struct aml_resource_io
{
146 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags
;
153 struct aml_resource_fixed_io
{
154 AML_RESOURCE_SMALL_HEADER_COMMON u16 address
;
158 struct aml_resource_vendor_small
{
159 AML_RESOURCE_SMALL_HEADER_COMMON
};
161 struct aml_resource_end_tag
{
162 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum
;
165 struct aml_resource_fixed_dma
{
166 AML_RESOURCE_SMALL_HEADER_COMMON u16 request_lines
;
174 #define AML_RESOURCE_LARGE_HEADER_COMMON \
178 struct aml_resource_large_header
{
179 AML_RESOURCE_LARGE_HEADER_COMMON
};
181 /* General Flags for address space resource descriptors */
183 #define ACPI_RESOURCE_FLAG_DEC 2
184 #define ACPI_RESOURCE_FLAG_MIF 4
185 #define ACPI_RESOURCE_FLAG_MAF 8
187 struct aml_resource_memory24
{
188 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags
;
195 struct aml_resource_vendor_large
{
196 AML_RESOURCE_LARGE_HEADER_COMMON
};
198 struct aml_resource_memory32
{
199 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags
;
206 struct aml_resource_fixed_memory32
{
207 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags
;
212 #define AML_RESOURCE_ADDRESS_COMMON \
217 struct aml_resource_address
{
218 AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON
};
220 struct aml_resource_extended_address64
{
221 AML_RESOURCE_LARGE_HEADER_COMMON
222 AML_RESOURCE_ADDRESS_COMMON u8 revision_ID
;
227 u64 translation_offset
;
232 #define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
234 struct aml_resource_address64
{
235 AML_RESOURCE_LARGE_HEADER_COMMON
236 AML_RESOURCE_ADDRESS_COMMON u64 granularity
;
239 u64 translation_offset
;
243 struct aml_resource_address32
{
244 AML_RESOURCE_LARGE_HEADER_COMMON
245 AML_RESOURCE_ADDRESS_COMMON u32 granularity
;
248 u32 translation_offset
;
252 struct aml_resource_address16
{
253 AML_RESOURCE_LARGE_HEADER_COMMON
254 AML_RESOURCE_ADDRESS_COMMON u16 granularity
;
257 u16 translation_offset
;
261 struct aml_resource_extended_irq
{
262 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags
;
266 ACPI_FLEX_ARRAY(u32
, interrupts
);
268 /* res_source_index, res_source optional fields follow */
271 struct aml_resource_generic_register
{
272 AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id
;
275 u8 access_size
; /* ACPI 3.0, was previously Reserved */
279 /* Common descriptor for gpio_int and gpio_io (ACPI 5.0) */
281 struct aml_resource_gpio
{
282 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id
;
288 u16 debounce_timeout
;
289 u16 pin_table_offset
;
291 u16 res_source_offset
;
295 * Optional fields follow immediately:
296 * 1) PIN list (Words)
297 * 2) Resource Source String
298 * 3) Vendor Data bytes
302 #define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */
304 /* Values for connection_type above */
306 #define AML_RESOURCE_GPIO_TYPE_INT 0
307 #define AML_RESOURCE_GPIO_TYPE_IO 1
308 #define AML_RESOURCE_MAX_GPIOTYPE 1
310 /* Common preamble for all serial descriptors (ACPI 5.0) */
312 #define AML_RESOURCE_SERIAL_COMMON \
314 u8 res_source_index; \
317 u16 type_specific_flags; \
318 u8 type_revision_id; \
319 u16 type_data_length; \
321 /* Values for the type field above */
323 #define AML_RESOURCE_I2C_SERIALBUSTYPE 1
324 #define AML_RESOURCE_SPI_SERIALBUSTYPE 2
325 #define AML_RESOURCE_UART_SERIALBUSTYPE 3
326 #define AML_RESOURCE_CSI2_SERIALBUSTYPE 4
327 #define AML_RESOURCE_MAX_SERIALBUSTYPE 4
328 #define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
330 struct aml_resource_common_serialbus
{
331 AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON
};
333 struct aml_resource_csi2_serialbus
{
334 AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON
336 * Optional fields follow immediately:
337 * 1) Vendor Data bytes
338 * 2) Resource Source String
342 #define AML_RESOURCE_CSI2_REVISION 1 /* ACPI 6.4 */
343 #define AML_RESOURCE_CSI2_TYPE_REVISION 1 /* ACPI 6.4 */
344 #define AML_RESOURCE_CSI2_MIN_DATA_LEN 0 /* ACPI 6.4 */
346 struct aml_resource_i2c_serialbus
{
347 AML_RESOURCE_LARGE_HEADER_COMMON
348 AML_RESOURCE_SERIAL_COMMON u32 connection_speed
;
351 * Optional fields follow immediately:
352 * 1) Vendor Data bytes
353 * 2) Resource Source String
357 #define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */
358 #define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */
359 #define AML_RESOURCE_I2C_MIN_DATA_LEN 6
361 struct aml_resource_spi_serialbus
{
362 AML_RESOURCE_LARGE_HEADER_COMMON
363 AML_RESOURCE_SERIAL_COMMON u32 connection_speed
;
367 u16 device_selection
;
369 * Optional fields follow immediately:
370 * 1) Vendor Data bytes
371 * 2) Resource Source String
375 #define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */
376 #define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */
377 #define AML_RESOURCE_SPI_MIN_DATA_LEN 9
379 struct aml_resource_uart_serialbus
{
380 AML_RESOURCE_LARGE_HEADER_COMMON
381 AML_RESOURCE_SERIAL_COMMON u32 default_baud_rate
;
387 * Optional fields follow immediately:
388 * 1) Vendor Data bytes
389 * 2) Resource Source String
393 #define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */
394 #define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */
395 #define AML_RESOURCE_UART_MIN_DATA_LEN 10
397 struct aml_resource_pin_function
{
398 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id
;
402 u16 pin_table_offset
;
404 u16 res_source_offset
;
408 * Optional fields follow immediately:
409 * 1) PIN list (Words)
410 * 2) Resource Source String
411 * 3) Vendor Data bytes
415 #define AML_RESOURCE_PIN_FUNCTION_REVISION 1 /* ACPI 6.2 */
417 struct aml_resource_pin_config
{
418 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id
;
421 u32 pin_config_value
;
422 u16 pin_table_offset
;
424 u16 res_source_offset
;
428 * Optional fields follow immediately:
429 * 1) PIN list (Words)
430 * 2) Resource Source String
431 * 3) Vendor Data bytes
435 #define AML_RESOURCE_CLOCK_INPUT_REVISION 1 /* ACPI 6.5 */
437 struct aml_resource_clock_input
{
438 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id
;
440 u16 frequency_divisor
;
441 u32 frequency_numerator
;
443 * Optional fields follow immediately:
444 * 1) Resource Source index
445 * 2) Resource Source String
449 #define AML_RESOURCE_PIN_CONFIG_REVISION 1 /* ACPI 6.2 */
451 struct aml_resource_pin_group
{
452 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id
;
454 u16 pin_table_offset
;
459 * Optional fields follow immediately:
460 * 1) PIN list (Words)
461 * 2) Resource Label String
462 * 3) Vendor Data bytes
466 #define AML_RESOURCE_PIN_GROUP_REVISION 1 /* ACPI 6.2 */
468 struct aml_resource_pin_group_function
{
469 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id
;
473 u16 res_source_offset
;
474 u16 res_source_label_offset
;
478 * Optional fields follow immediately:
479 * 1) Resource Source String
480 * 2) Resource Source Label String
481 * 3) Vendor Data bytes
485 #define AML_RESOURCE_PIN_GROUP_FUNCTION_REVISION 1 /* ACPI 6.2 */
487 struct aml_resource_pin_group_config
{
488 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id
;
491 u32 pin_config_value
;
493 u16 res_source_offset
;
494 u16 res_source_label_offset
;
498 * Optional fields follow immediately:
499 * 1) Resource Source String
500 * 2) Resource Source Label String
501 * 3) Vendor Data bytes
505 #define AML_RESOURCE_PIN_GROUP_CONFIG_REVISION 1 /* ACPI 6.2 */
507 /* restore default alignment */
511 /* Union of all resource descriptors, so we can allocate the worst case */
514 /* Descriptor headers */
517 struct aml_resource_small_header small_header
;
518 struct aml_resource_large_header large_header
;
520 /* Small resource descriptors */
522 struct aml_resource_irq irq
;
523 struct aml_resource_dma dma
;
524 struct aml_resource_start_dependent start_dpf
;
525 struct aml_resource_end_dependent end_dpf
;
526 struct aml_resource_io io
;
527 struct aml_resource_fixed_io fixed_io
;
528 struct aml_resource_fixed_dma fixed_dma
;
529 struct aml_resource_vendor_small vendor_small
;
530 struct aml_resource_end_tag end_tag
;
532 /* Large resource descriptors */
534 struct aml_resource_memory24 memory24
;
535 struct aml_resource_generic_register generic_reg
;
536 struct aml_resource_vendor_large vendor_large
;
537 struct aml_resource_memory32 memory32
;
538 struct aml_resource_fixed_memory32 fixed_memory32
;
539 struct aml_resource_address16 address16
;
540 struct aml_resource_address32 address32
;
541 struct aml_resource_address64 address64
;
542 struct aml_resource_extended_address64 ext_address64
;
543 struct aml_resource_extended_irq extended_irq
;
544 struct aml_resource_gpio gpio
;
545 struct aml_resource_i2c_serialbus i2c_serial_bus
;
546 struct aml_resource_spi_serialbus spi_serial_bus
;
547 struct aml_resource_uart_serialbus uart_serial_bus
;
548 struct aml_resource_csi2_serialbus csi2_serial_bus
;
549 struct aml_resource_common_serialbus common_serial_bus
;
550 struct aml_resource_pin_function pin_function
;
551 struct aml_resource_pin_config pin_config
;
552 struct aml_resource_pin_group pin_group
;
553 struct aml_resource_pin_group_function pin_group_function
;
554 struct aml_resource_pin_group_config pin_group_config
;
555 struct aml_resource_clock_input clock_input
;
557 /* Utility overlays */
559 struct aml_resource_address address
;
565 /* Interfaces used by both the disassembler and compiler */
568 mp_save_gpio_info(union acpi_parse_object
*op
,
569 union aml_resource
*resource
,
570 u32 pin_count
, u16
*pin_list
, char *device_name
);
573 mp_save_serial_info(union acpi_parse_object
*op
,
574 union aml_resource
*resource
, char *device_name
);
576 char *mp_get_hid_from_parse_tree(struct acpi_namespace_node
*hid_node
);
578 char *mp_get_hid_via_namestring(char *device_name
);
580 char *mp_get_connection_info(union acpi_parse_object
*op
,
582 struct acpi_namespace_node
**target_node
,
585 char *mp_get_parent_device_hid(union acpi_parse_object
*op
,
586 struct acpi_namespace_node
**target_node
,
587 char **parent_device_name
);
589 char *mp_get_ddn_value(char *device_name
);
591 char *mp_get_hid_value(struct acpi_namespace_node
*device_node
);