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 - 2020, 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, and UART 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
407 /* Values for slave_mode field above */
409 #define ACPI_CONTROLLER_INITIATED 0
410 #define ACPI_DEVICE_INITIATED 1
412 struct acpi_resource_i2c_serialbus {
413 ACPI_RESOURCE_SERIAL_COMMON u8 access_mode;
415 u32 connection_speed;
418 /* Values for access_mode field above */
420 #define ACPI_I2C_7BIT_MODE 0
421 #define ACPI_I2C_10BIT_MODE 1
423 struct acpi_resource_spi_serialbus {
424 ACPI_RESOURCE_SERIAL_COMMON u8 wire_mode;
429 u16 device_selection;
430 u32 connection_speed;
433 /* Values for wire_mode field above */
435 #define ACPI_SPI_4WIRE_MODE 0
436 #define ACPI_SPI_3WIRE_MODE 1
438 /* Values for device_polarity field above */
440 #define ACPI_SPI_ACTIVE_LOW 0
441 #define ACPI_SPI_ACTIVE_HIGH 1
443 /* Values for clock_phase field above */
445 #define ACPI_SPI_FIRST_PHASE 0
446 #define ACPI_SPI_SECOND_PHASE 1
448 /* Values for clock_polarity field above */
450 #define ACPI_SPI_START_LOW 0
451 #define ACPI_SPI_START_HIGH 1
453 struct acpi_resource_uart_serialbus {
454 ACPI_RESOURCE_SERIAL_COMMON u8 endian;
462 u32 default_baud_rate;
465 /* Values for Endian field above */
467 #define ACPI_UART_LITTLE_ENDIAN 0
468 #define ACPI_UART_BIG_ENDIAN 1
470 /* Values for data_bits field above */
472 #define ACPI_UART_5_DATA_BITS 0
473 #define ACPI_UART_6_DATA_BITS 1
474 #define ACPI_UART_7_DATA_BITS 2
475 #define ACPI_UART_8_DATA_BITS 3
476 #define ACPI_UART_9_DATA_BITS 4
478 /* Values for stop_bits field above */
480 #define ACPI_UART_NO_STOP_BITS 0
481 #define ACPI_UART_1_STOP_BIT 1
482 #define ACPI_UART_1P5_STOP_BITS 2
483 #define ACPI_UART_2_STOP_BITS 3
485 /* Values for flow_control field above */
487 #define ACPI_UART_FLOW_CONTROL_NONE 0
488 #define ACPI_UART_FLOW_CONTROL_HW 1
489 #define ACPI_UART_FLOW_CONTROL_XON_XOFF 2
491 /* Values for Parity field above */
493 #define ACPI_UART_PARITY_NONE 0
494 #define ACPI_UART_PARITY_EVEN 1
495 #define ACPI_UART_PARITY_ODD 2
496 #define ACPI_UART_PARITY_MARK 3
497 #define ACPI_UART_PARITY_SPACE 4
499 /* Values for lines_enabled bitfield above */
501 #define ACPI_UART_CARRIER_DETECT (1<<2)
502 #define ACPI_UART_RING_INDICATOR (1<<3)
503 #define ACPI_UART_DATA_SET_READY (1<<4)
504 #define ACPI_UART_DATA_TERMINAL_READY (1<<5)
505 #define ACPI_UART_CLEAR_TO_SEND (1<<6)
506 #define ACPI_UART_REQUEST_TO_SEND (1<<7)
508 struct acpi_resource_pin_function {
511 u8 shareable; /* For values, see Interrupt Attributes above */
513 u16 pin_table_length;
515 struct acpi_resource_source resource_source;
520 struct acpi_resource_pin_config {
522 u8 producer_consumer; /* For values, see Producer/Consumer above */
523 u8 shareable; /* For values, see Interrupt Attributes above */
525 u32 pin_config_value;
526 u16 pin_table_length;
528 struct acpi_resource_source resource_source;
533 /* Values for pin_config_type field above */
535 #define ACPI_PIN_CONFIG_DEFAULT 0
536 #define ACPI_PIN_CONFIG_BIAS_PULL_UP 1
537 #define ACPI_PIN_CONFIG_BIAS_PULL_DOWN 2
538 #define ACPI_PIN_CONFIG_BIAS_DEFAULT 3
539 #define ACPI_PIN_CONFIG_BIAS_DISABLE 4
540 #define ACPI_PIN_CONFIG_BIAS_HIGH_IMPEDANCE 5
541 #define ACPI_PIN_CONFIG_BIAS_BUS_HOLD 6
542 #define ACPI_PIN_CONFIG_DRIVE_OPEN_DRAIN 7
543 #define ACPI_PIN_CONFIG_DRIVE_OPEN_SOURCE 8
544 #define ACPI_PIN_CONFIG_DRIVE_PUSH_PULL 9
545 #define ACPI_PIN_CONFIG_DRIVE_STRENGTH 10
546 #define ACPI_PIN_CONFIG_SLEW_RATE 11
547 #define ACPI_PIN_CONFIG_INPUT_DEBOUNCE 12
548 #define ACPI_PIN_CONFIG_INPUT_SCHMITT_TRIGGER 13
550 struct acpi_resource_pin_group {
552 u8 producer_consumer; /* For values, see Producer/Consumer above */
553 u16 pin_table_length;
556 struct acpi_resource_label resource_label;
560 struct acpi_resource_pin_group_function {
562 u8 producer_consumer; /* For values, see Producer/Consumer above */
563 u8 shareable; /* For values, see Interrupt Attributes above */
566 struct acpi_resource_source resource_source;
567 struct acpi_resource_label resource_source_label;
571 struct acpi_resource_pin_group_config {
573 u8 producer_consumer; /* For values, see Producer/Consumer above */
574 u8 shareable; /* For values, see Interrupt Attributes above */
575 u8 pin_config_type; /* For values, see pin_config_type above */
576 u32 pin_config_value;
578 struct acpi_resource_source resource_source;
579 struct acpi_resource_label resource_source_label;
583 /* ACPI_RESOURCE_TYPEs */
585 #define ACPI_RESOURCE_TYPE_IRQ 0
586 #define ACPI_RESOURCE_TYPE_DMA 1
587 #define ACPI_RESOURCE_TYPE_START_DEPENDENT 2
588 #define ACPI_RESOURCE_TYPE_END_DEPENDENT 3
589 #define ACPI_RESOURCE_TYPE_IO 4
590 #define ACPI_RESOURCE_TYPE_FIXED_IO 5
591 #define ACPI_RESOURCE_TYPE_VENDOR 6
592 #define ACPI_RESOURCE_TYPE_END_TAG 7
593 #define ACPI_RESOURCE_TYPE_MEMORY24 8
594 #define ACPI_RESOURCE_TYPE_MEMORY32 9
595 #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10
596 #define ACPI_RESOURCE_TYPE_ADDRESS16 11
597 #define ACPI_RESOURCE_TYPE_ADDRESS32 12
598 #define ACPI_RESOURCE_TYPE_ADDRESS64 13
599 #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */
600 #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15
601 #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16
602 #define ACPI_RESOURCE_TYPE_GPIO 17 /* ACPI 5.0 */
603 #define ACPI_RESOURCE_TYPE_FIXED_DMA 18 /* ACPI 5.0 */
604 #define ACPI_RESOURCE_TYPE_SERIAL_BUS 19 /* ACPI 5.0 */
605 #define ACPI_RESOURCE_TYPE_PIN_FUNCTION 20 /* ACPI 6.2 */
606 #define ACPI_RESOURCE_TYPE_PIN_CONFIG 21 /* ACPI 6.2 */
607 #define ACPI_RESOURCE_TYPE_PIN_GROUP 22 /* ACPI 6.2 */
608 #define ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION 23 /* ACPI 6.2 */
609 #define ACPI_RESOURCE_TYPE_PIN_GROUP_CONFIG 24 /* ACPI 6.2 */
610 #define ACPI_RESOURCE_TYPE_MAX 24
612 /* Master union for resource descriptors */
614 union acpi_resource_data {
615 struct acpi_resource_irq irq;
616 struct acpi_resource_dma dma;
617 struct acpi_resource_start_dependent start_dpf;
618 struct acpi_resource_io io;
619 struct acpi_resource_fixed_io fixed_io;
620 struct acpi_resource_fixed_dma fixed_dma;
621 struct acpi_resource_vendor vendor;
622 struct acpi_resource_vendor_typed vendor_typed;
623 struct acpi_resource_end_tag end_tag;
624 struct acpi_resource_memory24 memory24;
625 struct acpi_resource_memory32 memory32;
626 struct acpi_resource_fixed_memory32 fixed_memory32;
627 struct acpi_resource_address16 address16;
628 struct acpi_resource_address32 address32;
629 struct acpi_resource_address64 address64;
630 struct acpi_resource_extended_address64 ext_address64;
631 struct acpi_resource_extended_irq extended_irq;
632 struct acpi_resource_generic_register generic_reg;
633 struct acpi_resource_gpio gpio;
634 struct acpi_resource_i2c_serialbus i2c_serial_bus;
635 struct acpi_resource_spi_serialbus spi_serial_bus;
636 struct acpi_resource_uart_serialbus uart_serial_bus;
637 struct acpi_resource_common_serialbus common_serial_bus;
638 struct acpi_resource_pin_function pin_function;
639 struct acpi_resource_pin_config pin_config;
640 struct acpi_resource_pin_group pin_group;
641 struct acpi_resource_pin_group_function pin_group_function;
642 struct acpi_resource_pin_group_config pin_group_config;
646 struct acpi_resource_address address; /* Common 16/32/64 address fields */
649 /* Common resource header */
651 struct acpi_resource {
654 union acpi_resource_data data;
657 /* restore default alignment */
661 #define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */
662 #define ACPI_RS_SIZE_MIN (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
663 #define ACPI_RS_SIZE(type) (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type))
665 /* Macro for walking resource templates with multiple descriptors */
667 #define ACPI_NEXT_RESOURCE(res) \
668 ACPI_ADD_PTR (struct acpi_resource, (res), (res)->length)
670 struct acpi_pci_routing_table {
673 u64 address; /* here for 64-bit alignment */
675 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
678 #endif /* __ACRESTYP_H__ */