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 - 2021, 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;
148 struct acpi_resource_dma {
156 struct acpi_resource_start_dependent {
157 u8 descriptor_length;
158 u8 compatibility_priority;
159 u8 performance_robustness;
163 * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
164 * needed because it has no fields
167 struct acpi_resource_io {
175 struct acpi_resource_fixed_io {
180 struct acpi_resource_fixed_dma {
186 /* Values for Width field above */
188 #define ACPI_DMA_WIDTH8 0
189 #define ACPI_DMA_WIDTH16 1
190 #define ACPI_DMA_WIDTH32 2
191 #define ACPI_DMA_WIDTH64 3
192 #define ACPI_DMA_WIDTH128 4
193 #define ACPI_DMA_WIDTH256 5
195 struct acpi_resource_vendor {
200 /* Vendor resource with UUID info (introduced in ACPI 3.0) */
202 struct acpi_resource_vendor_typed {
205 u8 uuid[ACPI_UUID_LENGTH];
209 struct acpi_resource_end_tag {
213 struct acpi_resource_memory24 {
221 struct acpi_resource_memory32 {
229 struct acpi_resource_fixed_memory32 {
235 struct acpi_memory_attribute {
242 struct acpi_io_attribute {
249 union acpi_resource_attribute {
250 struct acpi_memory_attribute mem;
251 struct acpi_io_attribute io;
253 /* Used for the *word_space macros */
258 struct acpi_resource_label {
263 struct acpi_resource_source {
269 /* Fields common to all address descriptors, 16/32/64 bit */
271 #define ACPI_RESOURCE_ADDRESS_COMMON \
273 u8 producer_consumer; \
275 u8 min_address_fixed; \
276 u8 max_address_fixed; \
277 union acpi_resource_attribute info;
279 struct acpi_address16_attribute {
283 u16 translation_offset;
287 struct acpi_address32_attribute {
291 u32 translation_offset;
295 struct acpi_address64_attribute {
299 u64 translation_offset;
303 struct acpi_resource_address {
304 ACPI_RESOURCE_ADDRESS_COMMON};
306 struct acpi_resource_address16 {
307 ACPI_RESOURCE_ADDRESS_COMMON struct acpi_address16_attribute address;
308 struct acpi_resource_source resource_source;
311 struct acpi_resource_address32 {
312 ACPI_RESOURCE_ADDRESS_COMMON struct acpi_address32_attribute address;
313 struct acpi_resource_source resource_source;
316 struct acpi_resource_address64 {
317 ACPI_RESOURCE_ADDRESS_COMMON struct acpi_address64_attribute address;
318 struct acpi_resource_source resource_source;
321 struct acpi_resource_extended_address64 {
322 ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID;
323 struct acpi_address64_attribute address;
327 struct acpi_resource_extended_irq {
328 u8 producer_consumer;
334 struct acpi_resource_source resource_source;
338 struct acpi_resource_generic_register {
346 struct acpi_resource_gpio {
349 u8 producer_consumer; /* For values, see Producer/Consumer above */
351 u8 shareable; /* For values, see Interrupt Attributes above */
352 u8 wake_capable; /* For values, see Interrupt Attributes above */
354 u8 triggering; /* For values, see Interrupt Attributes above */
355 u8 polarity; /* For values, see Interrupt Attributes above */
357 u16 debounce_timeout;
358 u16 pin_table_length;
360 struct acpi_resource_source resource_source;
365 /* Values for GPIO connection_type field above */
367 #define ACPI_RESOURCE_GPIO_TYPE_INT 0
368 #define ACPI_RESOURCE_GPIO_TYPE_IO 1
370 /* Values for pin_config field above */
372 #define ACPI_PIN_CONFIG_DEFAULT 0
373 #define ACPI_PIN_CONFIG_PULLUP 1
374 #define ACPI_PIN_CONFIG_PULLDOWN 2
375 #define ACPI_PIN_CONFIG_NOPULL 3
377 /* Values for io_restriction field above */
379 #define ACPI_IO_RESTRICT_NONE 0
380 #define ACPI_IO_RESTRICT_INPUT 1
381 #define ACPI_IO_RESTRICT_OUTPUT 2
382 #define ACPI_IO_RESTRICT_NONE_PRESERVE 3
384 /* Common structure for I2C, SPI, UART, CSI2 serial descriptors */
386 #define ACPI_RESOURCE_SERIAL_COMMON \
389 u8 producer_consumer; /* For values, see Producer/Consumer above */\
391 u8 connection_sharing; \
392 u8 type_revision_id; \
393 u16 type_data_length; \
395 struct acpi_resource_source resource_source; \
398 struct acpi_resource_common_serialbus {
399 ACPI_RESOURCE_SERIAL_COMMON};
401 /* Values for the Type field above */
403 #define ACPI_RESOURCE_SERIAL_TYPE_I2C 1
404 #define ACPI_RESOURCE_SERIAL_TYPE_SPI 2
405 #define ACPI_RESOURCE_SERIAL_TYPE_UART 3
406 #define ACPI_RESOURCE_SERIAL_TYPE_CSI2 4
408 /* Values for slave_mode field above */
410 #define ACPI_CONTROLLER_INITIATED 0
411 #define ACPI_DEVICE_INITIATED 1
413 struct acpi_resource_i2c_serialbus {
414 ACPI_RESOURCE_SERIAL_COMMON u8 access_mode;
416 u32 connection_speed;
419 /* Values for access_mode field above */
421 #define ACPI_I2C_7BIT_MODE 0
422 #define ACPI_I2C_10BIT_MODE 1
424 struct acpi_resource_spi_serialbus {
425 ACPI_RESOURCE_SERIAL_COMMON u8 wire_mode;
430 u16 device_selection;
431 u32 connection_speed;
434 /* Values for wire_mode field above */
436 #define ACPI_SPI_4WIRE_MODE 0
437 #define ACPI_SPI_3WIRE_MODE 1
439 /* Values for device_polarity field above */
441 #define ACPI_SPI_ACTIVE_LOW 0
442 #define ACPI_SPI_ACTIVE_HIGH 1
444 /* Values for clock_phase field above */
446 #define ACPI_SPI_FIRST_PHASE 0
447 #define ACPI_SPI_SECOND_PHASE 1
449 /* Values for clock_polarity field above */
451 #define ACPI_SPI_START_LOW 0
452 #define ACPI_SPI_START_HIGH 1
454 struct acpi_resource_uart_serialbus {
455 ACPI_RESOURCE_SERIAL_COMMON u8 endian;
463 u32 default_baud_rate;
466 /* Values for Endian field above */
468 #define ACPI_UART_LITTLE_ENDIAN 0
469 #define ACPI_UART_BIG_ENDIAN 1
471 /* Values for data_bits field above */
473 #define ACPI_UART_5_DATA_BITS 0
474 #define ACPI_UART_6_DATA_BITS 1
475 #define ACPI_UART_7_DATA_BITS 2
476 #define ACPI_UART_8_DATA_BITS 3
477 #define ACPI_UART_9_DATA_BITS 4
479 /* Values for stop_bits field above */
481 #define ACPI_UART_NO_STOP_BITS 0
482 #define ACPI_UART_1_STOP_BIT 1
483 #define ACPI_UART_1P5_STOP_BITS 2
484 #define ACPI_UART_2_STOP_BITS 3
486 /* Values for flow_control field above */
488 #define ACPI_UART_FLOW_CONTROL_NONE 0
489 #define ACPI_UART_FLOW_CONTROL_HW 1
490 #define ACPI_UART_FLOW_CONTROL_XON_XOFF 2
492 /* Values for Parity field above */
494 #define ACPI_UART_PARITY_NONE 0
495 #define ACPI_UART_PARITY_EVEN 1
496 #define ACPI_UART_PARITY_ODD 2
497 #define ACPI_UART_PARITY_MARK 3
498 #define ACPI_UART_PARITY_SPACE 4
500 /* Values for lines_enabled bitfield above */
502 #define ACPI_UART_CARRIER_DETECT (1<<2)
503 #define ACPI_UART_RING_INDICATOR (1<<3)
504 #define ACPI_UART_DATA_SET_READY (1<<4)
505 #define ACPI_UART_DATA_TERMINAL_READY (1<<5)
506 #define ACPI_UART_CLEAR_TO_SEND (1<<6)
507 #define ACPI_UART_REQUEST_TO_SEND (1<<7)
509 struct acpi_resource_csi2_serialbus {
510 ACPI_RESOURCE_SERIAL_COMMON u8 local_port_instance;
514 struct acpi_resource_pin_function {
517 u8 shareable; /* For values, see Interrupt Attributes above */
519 u16 pin_table_length;
521 struct acpi_resource_source resource_source;
526 struct acpi_resource_pin_config {
528 u8 producer_consumer; /* For values, see Producer/Consumer above */
529 u8 shareable; /* For values, see Interrupt Attributes above */
531 u32 pin_config_value;
532 u16 pin_table_length;
534 struct acpi_resource_source resource_source;
539 /* Values for pin_config_type field above */
541 #define ACPI_PIN_CONFIG_DEFAULT 0
542 #define ACPI_PIN_CONFIG_BIAS_PULL_UP 1
543 #define ACPI_PIN_CONFIG_BIAS_PULL_DOWN 2
544 #define ACPI_PIN_CONFIG_BIAS_DEFAULT 3
545 #define ACPI_PIN_CONFIG_BIAS_DISABLE 4
546 #define ACPI_PIN_CONFIG_BIAS_HIGH_IMPEDANCE 5
547 #define ACPI_PIN_CONFIG_BIAS_BUS_HOLD 6
548 #define ACPI_PIN_CONFIG_DRIVE_OPEN_DRAIN 7
549 #define ACPI_PIN_CONFIG_DRIVE_OPEN_SOURCE 8
550 #define ACPI_PIN_CONFIG_DRIVE_PUSH_PULL 9
551 #define ACPI_PIN_CONFIG_DRIVE_STRENGTH 10
552 #define ACPI_PIN_CONFIG_SLEW_RATE 11
553 #define ACPI_PIN_CONFIG_INPUT_DEBOUNCE 12
554 #define ACPI_PIN_CONFIG_INPUT_SCHMITT_TRIGGER 13
556 struct acpi_resource_pin_group {
558 u8 producer_consumer; /* For values, see Producer/Consumer above */
559 u16 pin_table_length;
562 struct acpi_resource_label resource_label;
566 struct acpi_resource_pin_group_function {
568 u8 producer_consumer; /* For values, see Producer/Consumer above */
569 u8 shareable; /* For values, see Interrupt Attributes above */
572 struct acpi_resource_source resource_source;
573 struct acpi_resource_label resource_source_label;
577 struct acpi_resource_pin_group_config {
579 u8 producer_consumer; /* For values, see Producer/Consumer above */
580 u8 shareable; /* For values, see Interrupt Attributes above */
581 u8 pin_config_type; /* For values, see pin_config_type above */
582 u32 pin_config_value;
584 struct acpi_resource_source resource_source;
585 struct acpi_resource_label resource_source_label;
589 /* ACPI_RESOURCE_TYPEs */
591 #define ACPI_RESOURCE_TYPE_IRQ 0
592 #define ACPI_RESOURCE_TYPE_DMA 1
593 #define ACPI_RESOURCE_TYPE_START_DEPENDENT 2
594 #define ACPI_RESOURCE_TYPE_END_DEPENDENT 3
595 #define ACPI_RESOURCE_TYPE_IO 4
596 #define ACPI_RESOURCE_TYPE_FIXED_IO 5
597 #define ACPI_RESOURCE_TYPE_VENDOR 6
598 #define ACPI_RESOURCE_TYPE_END_TAG 7
599 #define ACPI_RESOURCE_TYPE_MEMORY24 8
600 #define ACPI_RESOURCE_TYPE_MEMORY32 9
601 #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10
602 #define ACPI_RESOURCE_TYPE_ADDRESS16 11
603 #define ACPI_RESOURCE_TYPE_ADDRESS32 12
604 #define ACPI_RESOURCE_TYPE_ADDRESS64 13
605 #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */
606 #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15
607 #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16
608 #define ACPI_RESOURCE_TYPE_GPIO 17 /* ACPI 5.0 */
609 #define ACPI_RESOURCE_TYPE_FIXED_DMA 18 /* ACPI 5.0 */
610 #define ACPI_RESOURCE_TYPE_SERIAL_BUS 19 /* ACPI 5.0 */
611 #define ACPI_RESOURCE_TYPE_PIN_FUNCTION 20 /* ACPI 6.2 */
612 #define ACPI_RESOURCE_TYPE_PIN_CONFIG 21 /* ACPI 6.2 */
613 #define ACPI_RESOURCE_TYPE_PIN_GROUP 22 /* ACPI 6.2 */
614 #define ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION 23 /* ACPI 6.2 */
615 #define ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG 24 /* ACPI 6.2 */
616 #define ACPI_RESOURCE_TYPE_MAX 24
618 /* Master union for resource descriptors */
620 union acpi_resource_data {
621 struct acpi_resource_irq irq;
622 struct acpi_resource_dma dma;
623 struct acpi_resource_start_dependent start_dpf;
624 struct acpi_resource_io io;
625 struct acpi_resource_fixed_io fixed_io;
626 struct acpi_resource_fixed_dma fixed_dma;
627 struct acpi_resource_vendor vendor;
628 struct acpi_resource_vendor_typed vendor_typed;
629 struct acpi_resource_end_tag end_tag;
630 struct acpi_resource_memory24 memory24;
631 struct acpi_resource_memory32 memory32;
632 struct acpi_resource_fixed_memory32 fixed_memory32;
633 struct acpi_resource_address16 address16;
634 struct acpi_resource_address32 address32;
635 struct acpi_resource_address64 address64;
636 struct acpi_resource_extended_address64 ext_address64;
637 struct acpi_resource_extended_irq extended_irq;
638 struct acpi_resource_generic_register generic_reg;
639 struct acpi_resource_gpio gpio;
640 struct acpi_resource_i2c_serialbus i2c_serial_bus;
641 struct acpi_resource_spi_serialbus spi_serial_bus;
642 struct acpi_resource_uart_serialbus uart_serial_bus;
643 struct acpi_resource_csi2_serialbus csi2_serial_bus;
644 struct acpi_resource_common_serialbus common_serial_bus;
645 struct acpi_resource_pin_function pin_function;
646 struct acpi_resource_pin_config pin_config;
647 struct acpi_resource_pin_group pin_group;
648 struct acpi_resource_pin_group_function pin_group_function;
649 struct acpi_resource_pin_group_config pin_group_config;
653 struct acpi_resource_address address; /* Common 16/32/64 address fields */
656 /* Common resource header */
658 struct acpi_resource {
661 union acpi_resource_data data;
664 /* restore default alignment */
668 #define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */
669 #define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
670 #define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type))
672 /* Macro for walking resource templates with multiple descriptors */
674 #define ACPI_NEXT_RESOURCE(res) \
675 ACPI_ADD_PTR (struct acpi_resource, (res), (res)->length)
677 struct acpi_pci_routing_table {
680 u64 address; /* here for 64-bit alignment */
682 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
685 #endif /* __ACRESTYP_H__ */