1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /******************************************************************************
4 * Name: acrestyp.h - Defines, types, and structures for resource descriptors
6 * Copyright (C) 2000 - 2023, Intel Corp.
8 *****************************************************************************/
10 #ifndef __ACRESTYP_H__
11 #define __ACRESTYP_H__
14 * Definitions for Resource Attributes
16 typedef u16 acpi_rs_length
; /* Resource Length field is fixed at 16 bits */
17 typedef u32 acpi_rsdesc_size
; /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */
22 #define ACPI_READ_ONLY_MEMORY (u8) 0x00
23 #define ACPI_READ_WRITE_MEMORY (u8) 0x01
25 #define ACPI_NON_CACHEABLE_MEMORY (u8) 0x00
26 #define ACPI_CACHABLE_MEMORY (u8) 0x01
27 #define ACPI_WRITE_COMBINING_MEMORY (u8) 0x02
28 #define ACPI_PREFETCHABLE_MEMORY (u8) 0x03
30 /*! [Begin] no source code translation */
33 * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh.
34 * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh.
36 /*! [End] no source code translation !*/
38 #define ACPI_NON_ISA_ONLY_RANGES (u8) 0x01
39 #define ACPI_ISA_ONLY_RANGES (u8) 0x02
40 #define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
42 /* Type of translation - 1=Sparse, 0=Dense */
44 #define ACPI_SPARSE_TRANSLATION (u8) 0x01
47 * IO Port Descriptor Decode
49 #define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */
50 #define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */
53 * Interrupt attributes - used in multiple descriptors
58 #define ACPI_LEVEL_SENSITIVE (u8) 0x00
59 #define ACPI_EDGE_SENSITIVE (u8) 0x01
63 #define ACPI_ACTIVE_HIGH (u8) 0x00
64 #define ACPI_ACTIVE_LOW (u8) 0x01
65 #define ACPI_ACTIVE_BOTH (u8) 0x02
69 #define ACPI_EXCLUSIVE (u8) 0x00
70 #define ACPI_SHARED (u8) 0x01
74 #define ACPI_NOT_WAKE_CAPABLE (u8) 0x00
75 #define ACPI_WAKE_CAPABLE (u8) 0x01
80 #define ACPI_COMPATIBILITY (u8) 0x00
81 #define ACPI_TYPE_A (u8) 0x01
82 #define ACPI_TYPE_B (u8) 0x02
83 #define ACPI_TYPE_F (u8) 0x03
85 #define ACPI_NOT_BUS_MASTER (u8) 0x00
86 #define ACPI_BUS_MASTER (u8) 0x01
88 #define ACPI_TRANSFER_8 (u8) 0x00
89 #define ACPI_TRANSFER_8_16 (u8) 0x01
90 #define ACPI_TRANSFER_16 (u8) 0x02
93 * Start Dependent Functions Priority definitions
95 #define ACPI_GOOD_CONFIGURATION (u8) 0x00
96 #define ACPI_ACCEPTABLE_CONFIGURATION (u8) 0x01
97 #define ACPI_SUB_OPTIMAL_CONFIGURATION (u8) 0x02
100 * 16, 32 and 64-bit Address Descriptor resource types
102 #define ACPI_MEMORY_RANGE (u8) 0x00
103 #define ACPI_IO_RANGE (u8) 0x01
104 #define ACPI_BUS_NUMBER_RANGE (u8) 0x02
106 #define ACPI_ADDRESS_NOT_FIXED (u8) 0x00
107 #define ACPI_ADDRESS_FIXED (u8) 0x01
109 #define ACPI_POS_DECODE (u8) 0x00
110 #define ACPI_SUB_DECODE (u8) 0x01
112 /* Producer/Consumer */
114 #define ACPI_PRODUCER (u8) 0x00
115 #define ACPI_CONSUMER (u8) 0x01
118 * If possible, pack the following structures to byte alignment
120 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
124 /* UUID data structures for use in vendor-defined resource descriptors */
127 u8 data
[ACPI_UUID_LENGTH
];
130 struct acpi_vendor_uuid
{
132 u8 data
[ACPI_UUID_LENGTH
];
136 * Structures used to describe device resources
138 struct acpi_resource_irq
{
139 u8 descriptor_length
;
147 ACPI_FLEX_ARRAY(u8
, interrupts
);
151 struct acpi_resource_dma
{
158 ACPI_FLEX_ARRAY(u8
, channels
);
162 struct acpi_resource_start_dependent
{
163 u8 descriptor_length
;
164 u8 compatibility_priority
;
165 u8 performance_robustness
;
169 * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
170 * needed because it has no fields
173 struct acpi_resource_io
{
181 struct acpi_resource_fixed_io
{
186 struct acpi_resource_fixed_dma
{
192 /* Values for Width field above */
194 #define ACPI_DMA_WIDTH8 0
195 #define ACPI_DMA_WIDTH16 1
196 #define ACPI_DMA_WIDTH32 2
197 #define ACPI_DMA_WIDTH64 3
198 #define ACPI_DMA_WIDTH128 4
199 #define ACPI_DMA_WIDTH256 5
201 struct acpi_resource_vendor
{
206 /* Vendor resource with UUID info (introduced in ACPI 3.0) */
208 struct acpi_resource_vendor_typed
{
211 u8 uuid
[ACPI_UUID_LENGTH
];
215 struct acpi_resource_end_tag
{
219 struct acpi_resource_memory24
{
227 struct acpi_resource_memory32
{
235 struct acpi_resource_fixed_memory32
{
241 struct acpi_memory_attribute
{
248 struct acpi_io_attribute
{
255 union acpi_resource_attribute
{
256 struct acpi_memory_attribute mem
;
257 struct acpi_io_attribute io
;
259 /* Used for the *word_space macros */
264 struct acpi_resource_label
{
269 struct acpi_resource_source
{
275 /* Fields common to all address descriptors, 16/32/64 bit */
277 #define ACPI_RESOURCE_ADDRESS_COMMON \
279 u8 producer_consumer; \
281 u8 min_address_fixed; \
282 u8 max_address_fixed; \
283 union acpi_resource_attribute info;
285 struct acpi_address16_attribute
{
289 u16 translation_offset
;
293 struct acpi_address32_attribute
{
297 u32 translation_offset
;
301 struct acpi_address64_attribute
{
305 u64 translation_offset
;
309 struct acpi_resource_address
{
310 ACPI_RESOURCE_ADDRESS_COMMON
};
312 struct acpi_resource_address16
{
313 ACPI_RESOURCE_ADDRESS_COMMON
struct acpi_address16_attribute address
;
314 struct acpi_resource_source resource_source
;
317 struct acpi_resource_address32
{
318 ACPI_RESOURCE_ADDRESS_COMMON
struct acpi_address32_attribute address
;
319 struct acpi_resource_source resource_source
;
322 struct acpi_resource_address64
{
323 ACPI_RESOURCE_ADDRESS_COMMON
struct acpi_address64_attribute address
;
324 struct acpi_resource_source resource_source
;
327 struct acpi_resource_extended_address64
{
328 ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID
;
329 struct acpi_address64_attribute address
;
333 struct acpi_resource_extended_irq
{
334 u8 producer_consumer
;
340 struct acpi_resource_source resource_source
;
343 ACPI_FLEX_ARRAY(u32
, interrupts
);
347 struct acpi_resource_generic_register
{
355 struct acpi_resource_gpio
{
358 u8 producer_consumer
; /* For values, see Producer/Consumer above */
360 u8 shareable
; /* For values, see Interrupt Attributes above */
361 u8 wake_capable
; /* For values, see Interrupt Attributes above */
363 u8 triggering
; /* For values, see Interrupt Attributes above */
364 u8 polarity
; /* For values, see Interrupt Attributes above */
366 u16 debounce_timeout
;
367 u16 pin_table_length
;
369 struct acpi_resource_source resource_source
;
374 /* Values for GPIO connection_type field above */
376 #define ACPI_RESOURCE_GPIO_TYPE_INT 0
377 #define ACPI_RESOURCE_GPIO_TYPE_IO 1
379 /* Values for pin_config field above */
381 #define ACPI_PIN_CONFIG_DEFAULT 0
382 #define ACPI_PIN_CONFIG_PULLUP 1
383 #define ACPI_PIN_CONFIG_PULLDOWN 2
384 #define ACPI_PIN_CONFIG_NOPULL 3
386 /* Values for io_restriction field above */
388 #define ACPI_IO_RESTRICT_NONE 0
389 #define ACPI_IO_RESTRICT_INPUT 1
390 #define ACPI_IO_RESTRICT_OUTPUT 2
391 #define ACPI_IO_RESTRICT_NONE_PRESERVE 3
393 /* Common structure for I2C, SPI, UART, CSI2 serial descriptors */
395 #define ACPI_RESOURCE_SERIAL_COMMON \
398 u8 producer_consumer; /* For values, see Producer/Consumer above */\
400 u8 connection_sharing; \
401 u8 type_revision_id; \
402 u16 type_data_length; \
404 struct acpi_resource_source resource_source; \
407 struct acpi_resource_common_serialbus
{
408 ACPI_RESOURCE_SERIAL_COMMON
};
410 /* Values for the Type field above */
412 #define ACPI_RESOURCE_SERIAL_TYPE_I2C 1
413 #define ACPI_RESOURCE_SERIAL_TYPE_SPI 2
414 #define ACPI_RESOURCE_SERIAL_TYPE_UART 3
415 #define ACPI_RESOURCE_SERIAL_TYPE_CSI2 4
417 /* Values for slave_mode field above */
419 #define ACPI_CONTROLLER_INITIATED 0
420 #define ACPI_DEVICE_INITIATED 1
422 struct acpi_resource_i2c_serialbus
{
423 ACPI_RESOURCE_SERIAL_COMMON u8 access_mode
;
425 u32 connection_speed
;
428 /* Values for access_mode field above */
430 #define ACPI_I2C_7BIT_MODE 0
431 #define ACPI_I2C_10BIT_MODE 1
433 struct acpi_resource_spi_serialbus
{
434 ACPI_RESOURCE_SERIAL_COMMON u8 wire_mode
;
439 u16 device_selection
;
440 u32 connection_speed
;
443 /* Values for wire_mode field above */
445 #define ACPI_SPI_4WIRE_MODE 0
446 #define ACPI_SPI_3WIRE_MODE 1
448 /* Values for device_polarity field above */
450 #define ACPI_SPI_ACTIVE_LOW 0
451 #define ACPI_SPI_ACTIVE_HIGH 1
453 /* Values for clock_phase field above */
455 #define ACPI_SPI_FIRST_PHASE 0
456 #define ACPI_SPI_SECOND_PHASE 1
458 /* Values for clock_polarity field above */
460 #define ACPI_SPI_START_LOW 0
461 #define ACPI_SPI_START_HIGH 1
463 struct acpi_resource_uart_serialbus
{
464 ACPI_RESOURCE_SERIAL_COMMON u8 endian
;
472 u32 default_baud_rate
;
475 /* Values for Endian field above */
477 #define ACPI_UART_LITTLE_ENDIAN 0
478 #define ACPI_UART_BIG_ENDIAN 1
480 /* Values for data_bits field above */
482 #define ACPI_UART_5_DATA_BITS 0
483 #define ACPI_UART_6_DATA_BITS 1
484 #define ACPI_UART_7_DATA_BITS 2
485 #define ACPI_UART_8_DATA_BITS 3
486 #define ACPI_UART_9_DATA_BITS 4
488 /* Values for stop_bits field above */
490 #define ACPI_UART_NO_STOP_BITS 0
491 #define ACPI_UART_1_STOP_BIT 1
492 #define ACPI_UART_1P5_STOP_BITS 2
493 #define ACPI_UART_2_STOP_BITS 3
495 /* Values for flow_control field above */
497 #define ACPI_UART_FLOW_CONTROL_NONE 0
498 #define ACPI_UART_FLOW_CONTROL_HW 1
499 #define ACPI_UART_FLOW_CONTROL_XON_XOFF 2
501 /* Values for Parity field above */
503 #define ACPI_UART_PARITY_NONE 0
504 #define ACPI_UART_PARITY_EVEN 1
505 #define ACPI_UART_PARITY_ODD 2
506 #define ACPI_UART_PARITY_MARK 3
507 #define ACPI_UART_PARITY_SPACE 4
509 /* Values for lines_enabled bitfield above */
511 #define ACPI_UART_CARRIER_DETECT (1<<2)
512 #define ACPI_UART_RING_INDICATOR (1<<3)
513 #define ACPI_UART_DATA_SET_READY (1<<4)
514 #define ACPI_UART_DATA_TERMINAL_READY (1<<5)
515 #define ACPI_UART_CLEAR_TO_SEND (1<<6)
516 #define ACPI_UART_REQUEST_TO_SEND (1<<7)
518 struct acpi_resource_csi2_serialbus
{
519 ACPI_RESOURCE_SERIAL_COMMON u8 local_port_instance
;
523 struct acpi_resource_pin_function
{
526 u8 shareable
; /* For values, see Interrupt Attributes above */
528 u16 pin_table_length
;
530 struct acpi_resource_source resource_source
;
535 struct acpi_resource_pin_config
{
537 u8 producer_consumer
; /* For values, see Producer/Consumer above */
538 u8 shareable
; /* For values, see Interrupt Attributes above */
540 u32 pin_config_value
;
541 u16 pin_table_length
;
543 struct acpi_resource_source resource_source
;
548 struct acpi_resource_clock_input
{
552 u16 frequency_divisor
;
553 u32 frequency_numerator
;
554 struct acpi_resource_source resource_source
;
557 /* Values for pin_config_type field above */
559 #define ACPI_PIN_CONFIG_DEFAULT 0
560 #define ACPI_PIN_CONFIG_BIAS_PULL_UP 1
561 #define ACPI_PIN_CONFIG_BIAS_PULL_DOWN 2
562 #define ACPI_PIN_CONFIG_BIAS_DEFAULT 3
563 #define ACPI_PIN_CONFIG_BIAS_DISABLE 4
564 #define ACPI_PIN_CONFIG_BIAS_HIGH_IMPEDANCE 5
565 #define ACPI_PIN_CONFIG_BIAS_BUS_HOLD 6
566 #define ACPI_PIN_CONFIG_DRIVE_OPEN_DRAIN 7
567 #define ACPI_PIN_CONFIG_DRIVE_OPEN_SOURCE 8
568 #define ACPI_PIN_CONFIG_DRIVE_PUSH_PULL 9
569 #define ACPI_PIN_CONFIG_DRIVE_STRENGTH 10
570 #define ACPI_PIN_CONFIG_SLEW_RATE 11
571 #define ACPI_PIN_CONFIG_INPUT_DEBOUNCE 12
572 #define ACPI_PIN_CONFIG_INPUT_SCHMITT_TRIGGER 13
574 struct acpi_resource_pin_group
{
576 u8 producer_consumer
; /* For values, see Producer/Consumer above */
577 u16 pin_table_length
;
580 struct acpi_resource_label resource_label
;
584 struct acpi_resource_pin_group_function
{
586 u8 producer_consumer
; /* For values, see Producer/Consumer above */
587 u8 shareable
; /* For values, see Interrupt Attributes above */
590 struct acpi_resource_source resource_source
;
591 struct acpi_resource_label resource_source_label
;
595 struct acpi_resource_pin_group_config
{
597 u8 producer_consumer
; /* For values, see Producer/Consumer above */
598 u8 shareable
; /* For values, see Interrupt Attributes above */
599 u8 pin_config_type
; /* For values, see pin_config_type above */
600 u32 pin_config_value
;
602 struct acpi_resource_source resource_source
;
603 struct acpi_resource_label resource_source_label
;
607 /* ACPI_RESOURCE_TYPEs */
609 #define ACPI_RESOURCE_TYPE_IRQ 0
610 #define ACPI_RESOURCE_TYPE_DMA 1
611 #define ACPI_RESOURCE_TYPE_START_DEPENDENT 2
612 #define ACPI_RESOURCE_TYPE_END_DEPENDENT 3
613 #define ACPI_RESOURCE_TYPE_IO 4
614 #define ACPI_RESOURCE_TYPE_FIXED_IO 5
615 #define ACPI_RESOURCE_TYPE_VENDOR 6
616 #define ACPI_RESOURCE_TYPE_END_TAG 7
617 #define ACPI_RESOURCE_TYPE_MEMORY24 8
618 #define ACPI_RESOURCE_TYPE_MEMORY32 9
619 #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10
620 #define ACPI_RESOURCE_TYPE_ADDRESS16 11
621 #define ACPI_RESOURCE_TYPE_ADDRESS32 12
622 #define ACPI_RESOURCE_TYPE_ADDRESS64 13
623 #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */
624 #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15
625 #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16
626 #define ACPI_RESOURCE_TYPE_GPIO 17 /* ACPI 5.0 */
627 #define ACPI_RESOURCE_TYPE_FIXED_DMA 18 /* ACPI 5.0 */
628 #define ACPI_RESOURCE_TYPE_SERIAL_BUS 19 /* ACPI 5.0 */
629 #define ACPI_RESOURCE_TYPE_PIN_FUNCTION 20 /* ACPI 6.2 */
630 #define ACPI_RESOURCE_TYPE_PIN_CONFIG 21 /* ACPI 6.2 */
631 #define ACPI_RESOURCE_TYPE_PIN_GROUP 22 /* ACPI 6.2 */
632 #define ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION 23 /* ACPI 6.2 */
633 #define ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG 24 /* ACPI 6.2 */
634 #define ACPI_RESOURCE_TYPE_CLOCK_INPUT 25 /* ACPI 6.5 */
635 #define ACPI_RESOURCE_TYPE_MAX 25
637 /* Master union for resource descriptors */
639 union acpi_resource_data
{
640 struct acpi_resource_irq irq
;
641 struct acpi_resource_dma dma
;
642 struct acpi_resource_start_dependent start_dpf
;
643 struct acpi_resource_io io
;
644 struct acpi_resource_fixed_io fixed_io
;
645 struct acpi_resource_fixed_dma fixed_dma
;
646 struct acpi_resource_vendor vendor
;
647 struct acpi_resource_vendor_typed vendor_typed
;
648 struct acpi_resource_end_tag end_tag
;
649 struct acpi_resource_memory24 memory24
;
650 struct acpi_resource_memory32 memory32
;
651 struct acpi_resource_fixed_memory32 fixed_memory32
;
652 struct acpi_resource_address16 address16
;
653 struct acpi_resource_address32 address32
;
654 struct acpi_resource_address64 address64
;
655 struct acpi_resource_extended_address64 ext_address64
;
656 struct acpi_resource_extended_irq extended_irq
;
657 struct acpi_resource_generic_register generic_reg
;
658 struct acpi_resource_gpio gpio
;
659 struct acpi_resource_i2c_serialbus i2c_serial_bus
;
660 struct acpi_resource_spi_serialbus spi_serial_bus
;
661 struct acpi_resource_uart_serialbus uart_serial_bus
;
662 struct acpi_resource_csi2_serialbus csi2_serial_bus
;
663 struct acpi_resource_common_serialbus common_serial_bus
;
664 struct acpi_resource_pin_function pin_function
;
665 struct acpi_resource_pin_config pin_config
;
666 struct acpi_resource_pin_group pin_group
;
667 struct acpi_resource_pin_group_function pin_group_function
;
668 struct acpi_resource_pin_group_config pin_group_config
;
669 struct acpi_resource_clock_input clock_input
;
673 struct acpi_resource_address address
; /* Common 16/32/64 address fields */
676 /* Common resource header */
678 struct acpi_resource
{
681 union acpi_resource_data data
;
684 /* restore default alignment */
688 #define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */
689 #define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
690 #define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type))
692 /* Macro for walking resource templates with multiple descriptors */
694 #define ACPI_NEXT_RESOURCE(res) \
695 ACPI_ADD_PTR (struct acpi_resource, (res), (res)->length)
697 struct acpi_pci_routing_table
{
700 u64 address
; /* here for 64-bit alignment */
703 char pad
[4]; /* pad to 64 bits so sizeof() works in all cases */
704 ACPI_FLEX_ARRAY(char, source
);
708 #endif /* __ACRESTYP_H__ */