1/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2/******************************************************************************
3 *
4 * Name: acrestyp.h - Defines, types, and structures for resource descriptors
5 *
6 * Copyright (C) 2000 - 2019, Intel Corp.
7 *
8 *****************************************************************************/
9
10#ifndef __ACRESTYP_H__
11#define __ACRESTYP_H__
12
13/*
14 * Definitions for Resource Attributes
15 */
16typedef u16 acpi_rs_length; /* Resource Length field is fixed at 16 bits */
17typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */
18
19/*
20 * Memory Attributes
21 */
22#define ACPI_READ_ONLY_MEMORY (u8) 0x00
23#define ACPI_READ_WRITE_MEMORY (u8) 0x01
24
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
29
30/*! [Begin] no source code translation */
31/*
32 * IO Attributes
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.
35 */
36/*! [End] no source code translation !*/
37
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)
41
42/* Type of translation - 1=Sparse, 0=Dense */
43
44#define ACPI_SPARSE_TRANSLATION (u8) 0x01
45
46/*
47 * IO Port Descriptor Decode
48 */
49#define ACPI_DECODE_10 (u8) 0x00 /* 10-bit IO address decode */
50#define ACPI_DECODE_16 (u8) 0x01 /* 16-bit IO address decode */
51
52/*
53 * Interrupt attributes - used in multiple descriptors
54 */
55
56/* Triggering */
57
58#define ACPI_LEVEL_SENSITIVE (u8) 0x00
59#define ACPI_EDGE_SENSITIVE (u8) 0x01
60
61/* Polarity */
62
63#define ACPI_ACTIVE_HIGH (u8) 0x00
64#define ACPI_ACTIVE_LOW (u8) 0x01
65#define ACPI_ACTIVE_BOTH (u8) 0x02
66
67/* Sharing */
68
69#define ACPI_EXCLUSIVE (u8) 0x00
70#define ACPI_SHARED (u8) 0x01
71
72/* Wake */
73
74#define ACPI_NOT_WAKE_CAPABLE (u8) 0x00
75#define ACPI_WAKE_CAPABLE (u8) 0x01
76
77/*
78 * DMA Attributes
79 */
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
84
85#define ACPI_NOT_BUS_MASTER (u8) 0x00
86#define ACPI_BUS_MASTER (u8) 0x01
87
88#define ACPI_TRANSFER_8 (u8) 0x00
89#define ACPI_TRANSFER_8_16 (u8) 0x01
90#define ACPI_TRANSFER_16 (u8) 0x02
91
92/*
93 * Start Dependent Functions Priority definitions
94 */
95#define ACPI_GOOD_CONFIGURATION (u8) 0x00
96#define ACPI_ACCEPTABLE_CONFIGURATION (u8) 0x01
97#define ACPI_SUB_OPTIMAL_CONFIGURATION (u8) 0x02
98
99/*
100 * 16, 32 and 64-bit Address Descriptor resource types
101 */
102#define ACPI_MEMORY_RANGE (u8) 0x00
103#define ACPI_IO_RANGE (u8) 0x01
104#define ACPI_BUS_NUMBER_RANGE (u8) 0x02
105
106#define ACPI_ADDRESS_NOT_FIXED (u8) 0x00
107#define ACPI_ADDRESS_FIXED (u8) 0x01
108
109#define ACPI_POS_DECODE (u8) 0x00
110#define ACPI_SUB_DECODE (u8) 0x01
111
112/* Producer/Consumer */
113
114#define ACPI_PRODUCER (u8) 0x00
115#define ACPI_CONSUMER (u8) 0x01
116
117/*
118 * If possible, pack the following structures to byte alignment
119 */
120#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
121#pragma pack(1)
122#endif
123
124/* UUID data structures for use in vendor-defined resource descriptors */
125
126struct acpi_uuid {
127 u8 data[ACPI_UUID_LENGTH];
128};
129
130struct acpi_vendor_uuid {
131 u8 subtype;
132 u8 data[ACPI_UUID_LENGTH];
133};
134
135/*
136 * Structures used to describe device resources
137 */
138struct acpi_resource_irq {
139 u8 descriptor_length;
140 u8 triggering;
141 u8 polarity;
142 u8 shareable;
143 u8 wake_capable;
144 u8 interrupt_count;
145 u8 interrupts[1];
146};
147
148struct acpi_resource_dma {
149 u8 type;
150 u8 bus_master;
151 u8 transfer;
152 u8 channel_count;
153 u8 channels[1];
154};
155
156struct acpi_resource_start_dependent {
157 u8 descriptor_length;
158 u8 compatibility_priority;
159 u8 performance_robustness;
160};
161
162/*
163 * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
164 * needed because it has no fields
165 */
166
167struct acpi_resource_io {
168 u8 io_decode;
169 u8 alignment;
170 u8 address_length;
171 u16 minimum;
172 u16 maximum;
173};
174
175struct acpi_resource_fixed_io {
176 u16 address;
177 u8 address_length;
178};
179
180struct acpi_resource_fixed_dma {
181 u16 request_lines;
182 u16 channels;
183 u8 width;
184};
185
186/* Values for Width field above */
187
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
194
195struct acpi_resource_vendor {
196 u16 byte_length;
197 u8 byte_data[1];
198};
199
200/* Vendor resource with UUID info (introduced in ACPI 3.0) */
201
202struct acpi_resource_vendor_typed {
203 u16 byte_length;
204 u8 uuid_subtype;
205 u8 uuid[ACPI_UUID_LENGTH];
206 u8 byte_data[1];
207};
208
209struct acpi_resource_end_tag {
210 u8 checksum;
211};
212
213struct acpi_resource_memory24 {
214 u8 write_protect;
215 u16 minimum;
216 u16 maximum;
217 u16 alignment;
218 u16 address_length;
219};
220
221struct acpi_resource_memory32 {
222 u8 write_protect;
223 u32 minimum;
224 u32 maximum;
225 u32 alignment;
226 u32 address_length;
227};
228
229struct acpi_resource_fixed_memory32 {
230 u8 write_protect;
231 u32 address;
232 u32 address_length;
233};
234
235struct acpi_memory_attribute {
236 u8 write_protect;
237 u8 caching;
238 u8 range_type;
239 u8 translation;
240};
241
242struct acpi_io_attribute {
243 u8 range_type;
244 u8 translation;
245 u8 translation_type;
246 u8 reserved1;
247};
248
249union acpi_resource_attribute {
250 struct acpi_memory_attribute mem;
251 struct acpi_io_attribute io;
252
253 /* Used for the *word_space macros */
254
255 u8 type_specific;
256};
257
258struct acpi_resource_label {
259 u16 string_length;
260 char *string_ptr;
261};
262
263struct acpi_resource_source {
264 u8 index;
265 u16 string_length;
266 char *string_ptr;
267};
268
269/* Fields common to all address descriptors, 16/32/64 bit */
270
271#define ACPI_RESOURCE_ADDRESS_COMMON \
272 u8 resource_type; \
273 u8 producer_consumer; \
274 u8 decode; \
275 u8 min_address_fixed; \
276 u8 max_address_fixed; \
277 union acpi_resource_attribute info;
278
279struct acpi_address16_attribute {
280 u16 granularity;
281 u16 minimum;
282 u16 maximum;
283 u16 translation_offset;
284 u16 address_length;
285};
286
287struct acpi_address32_attribute {
288 u32 granularity;
289 u32 minimum;
290 u32 maximum;
291 u32 translation_offset;
292 u32 address_length;
293};
294
295struct acpi_address64_attribute {
296 u64 granularity;
297 u64 minimum;
298 u64 maximum;
299 u64 translation_offset;
300 u64 address_length;
301};
302
303struct acpi_resource_address {
304ACPI_RESOURCE_ADDRESS_COMMON};
305
306struct acpi_resource_address16 {
307 ACPI_RESOURCE_ADDRESS_COMMON struct acpi_address16_attribute address;
308 struct acpi_resource_source resource_source;
309};
310
311struct acpi_resource_address32 {
312 ACPI_RESOURCE_ADDRESS_COMMON struct acpi_address32_attribute address;
313 struct acpi_resource_source resource_source;
314};
315
316struct acpi_resource_address64 {
317 ACPI_RESOURCE_ADDRESS_COMMON struct acpi_address64_attribute address;
318 struct acpi_resource_source resource_source;
319};
320
321struct acpi_resource_extended_address64 {
322 ACPI_RESOURCE_ADDRESS_COMMON u8 revision_ID;
323 struct acpi_address64_attribute address;
324 u64 type_specific;
325};
326
327struct acpi_resource_extended_irq {
328 u8 producer_consumer;
329 u8 triggering;
330 u8 polarity;
331 u8 shareable;
332 u8 wake_capable;
333 u8 interrupt_count;
334 struct acpi_resource_source resource_source;
335 u32 interrupts[1];
336};
337
338struct acpi_resource_generic_register {
339 u8 space_id;
340 u8 bit_width;
341 u8 bit_offset;
342 u8 access_size;
343 u64 address;
344};
345
346struct acpi_resource_gpio {
347 u8 revision_id;
348 u8 connection_type;
349 u8 producer_consumer; /* For values, see Producer/Consumer above */
350 u8 pin_config;
351 u8 shareable; /* For values, see Interrupt Attributes above */
352 u8 wake_capable; /* For values, see Interrupt Attributes above */
353 u8 io_restriction;
354 u8 triggering; /* For values, see Interrupt Attributes above */
355 u8 polarity; /* For values, see Interrupt Attributes above */
356 u16 drive_strength;
357 u16 debounce_timeout;
358 u16 pin_table_length;
359 u16 vendor_length;
360 struct acpi_resource_source resource_source;
361 u16 *pin_table;
362 u8 *vendor_data;
363};
364
365/* Values for GPIO connection_type field above */
366
367#define ACPI_RESOURCE_GPIO_TYPE_INT 0
368#define ACPI_RESOURCE_GPIO_TYPE_IO 1
369
370/* Values for pin_config field above */
371
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
376
377/* Values for io_restriction field above */
378
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
383
384/* Common structure for I2C, SPI, and UART serial descriptors */
385
386#define ACPI_RESOURCE_SERIAL_COMMON \
387 u8 revision_id; \
388 u8 type; \
389 u8 producer_consumer; /* For values, see Producer/Consumer above */\
390 u8 slave_mode; \
391 u8 connection_sharing; \
392 u8 type_revision_id; \
393 u16 type_data_length; \
394 u16 vendor_length; \
395 struct acpi_resource_source resource_source; \
396 u8 *vendor_data;
397
398struct acpi_resource_common_serialbus {
399ACPI_RESOURCE_SERIAL_COMMON};
400
401/* Values for the Type field above */
402
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
407/* Values for slave_mode field above */
408
409#define ACPI_CONTROLLER_INITIATED 0
410#define ACPI_DEVICE_INITIATED 1
411
412struct acpi_resource_i2c_serialbus {
413 ACPI_RESOURCE_SERIAL_COMMON u8 access_mode;
414 u16 slave_address;
415 u32 connection_speed;
416};
417
418/* Values for access_mode field above */
419
420#define ACPI_I2C_7BIT_MODE 0
421#define ACPI_I2C_10BIT_MODE 1
422
423struct acpi_resource_spi_serialbus {
424 ACPI_RESOURCE_SERIAL_COMMON u8 wire_mode;
425 u8 device_polarity;
426 u8 data_bit_length;
427 u8 clock_phase;
428 u8 clock_polarity;
429 u16 device_selection;
430 u32 connection_speed;
431};
432
433/* Values for wire_mode field above */
434
435#define ACPI_SPI_4WIRE_MODE 0
436#define ACPI_SPI_3WIRE_MODE 1
437
438/* Values for device_polarity field above */
439
440#define ACPI_SPI_ACTIVE_LOW 0
441#define ACPI_SPI_ACTIVE_HIGH 1
442
443/* Values for clock_phase field above */
444
445#define ACPI_SPI_FIRST_PHASE 0
446#define ACPI_SPI_SECOND_PHASE 1
447
448/* Values for clock_polarity field above */
449
450#define ACPI_SPI_START_LOW 0
451#define ACPI_SPI_START_HIGH 1
452
453struct acpi_resource_uart_serialbus {
454 ACPI_RESOURCE_SERIAL_COMMON u8 endian;
455 u8 data_bits;
456 u8 stop_bits;
457 u8 flow_control;
458 u8 parity;
459 u8 lines_enabled;
460 u16 rx_fifo_size;
461 u16 tx_fifo_size;
462 u32 default_baud_rate;
463};
464
465/* Values for Endian field above */
466
467#define ACPI_UART_LITTLE_ENDIAN 0
468#define ACPI_UART_BIG_ENDIAN 1
469
470/* Values for data_bits field above */
471
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
477
478/* Values for stop_bits field above */
479
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
484
485/* Values for flow_control field above */
486
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
490
491/* Values for Parity field above */
492
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
498
499/* Values for lines_enabled bitfield above */
500
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)
507
508struct acpi_resource_pin_function {
509 u8 revision_id;
510 u8 pin_config;
511 u8 shareable; /* For values, see Interrupt Attributes above */
512 u16 function_number;
513 u16 pin_table_length;
514 u16 vendor_length;
515 struct acpi_resource_source resource_source;
516 u16 *pin_table;
517 u8 *vendor_data;
518};
519
520struct acpi_resource_pin_config {
521 u8 revision_id;
522 u8 producer_consumer; /* For values, see Producer/Consumer above */
523 u8 shareable; /* For values, see Interrupt Attributes above */
524 u8 pin_config_type;
525 u32 pin_config_value;
526 u16 pin_table_length;
527 u16 vendor_length;
528 struct acpi_resource_source resource_source;
529 u16 *pin_table;
530 u8 *vendor_data;
531};
532
533/* Values for pin_config_type field above */
534
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
549
550struct acpi_resource_pin_group {
551 u8 revision_id;
552 u8 producer_consumer; /* For values, see Producer/Consumer above */
553 u16 pin_table_length;
554 u16 vendor_length;
555 u16 *pin_table;
556 struct acpi_resource_label resource_label;
557 u8 *vendor_data;
558};
559
560struct acpi_resource_pin_group_function {
561 u8 revision_id;
562 u8 producer_consumer; /* For values, see Producer/Consumer above */
563 u8 shareable; /* For values, see Interrupt Attributes above */
564 u16 function_number;
565 u16 vendor_length;
566 struct acpi_resource_source resource_source;
567 struct acpi_resource_label resource_source_label;
568 u8 *vendor_data;
569};
570
571struct acpi_resource_pin_group_config {
572 u8 revision_id;
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;
577 u16 vendor_length;
578 struct acpi_resource_source resource_source;
579 struct acpi_resource_label resource_source_label;
580 u8 *vendor_data;
581};
582
583/* ACPI_RESOURCE_TYPEs */
584
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
611
612/* Master union for resource descriptors */
613
614union 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;
643
644 /* Common fields */
645
646 struct acpi_resource_address address; /* Common 16/32/64 address fields */
647};
648
649/* Common resource header */
650
651struct acpi_resource {
652 u32 type;
653 u32 length;
654 union acpi_resource_data data;
655};
656
657/* restore default alignment */
658
659#pragma pack()
660
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))
664
665/* Macro for walking resource templates with multiple descriptors */
666
667#define ACPI_NEXT_RESOURCE(res) \
668 ACPI_ADD_PTR (struct acpi_resource, (res), (res)->length)
669
670struct acpi_pci_routing_table {
671 u32 length;
672 u32 pin;
673 u64 address; /* here for 64-bit alignment */
674 u32 source_index;
675 char source[4]; /* pad to 64 bits so sizeof() works in all cases */
676};
677
678#endif /* __ACRESTYP_H__ */
679