1 /******************************************************************************
2  *
3  * Name: acrestyp.h - Defines, types, and structures for resource descriptors
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2011, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #ifndef __ACRESTYP_H__
45 #define __ACRESTYP_H__
46 
47 /*
48  * Definitions for Resource Attributes
49  */
50 typedef u16 acpi_rs_length;	/* Resource Length field is fixed at 16 bits */
51 typedef u32 acpi_rsdesc_size;	/* Max Resource Descriptor size is (Length+3) = (64_k-1)+3 */
52 
53 /*
54  * Memory Attributes
55  */
56 #define ACPI_READ_ONLY_MEMORY           (u8) 0x00
57 #define ACPI_READ_WRITE_MEMORY          (u8) 0x01
58 
59 #define ACPI_NON_CACHEABLE_MEMORY       (u8) 0x00
60 #define ACPI_CACHABLE_MEMORY            (u8) 0x01
61 #define ACPI_WRITE_COMBINING_MEMORY     (u8) 0x02
62 #define ACPI_PREFETCHABLE_MEMORY        (u8) 0x03
63 
64 /*! [Begin] no source code translation */
65 /*
66  * IO Attributes
67  * The ISA IO ranges are:     n000-n0FFh,  n400-n4FFh, n800-n8FFh, nC00-nCFFh.
68  * The non-ISA IO ranges are: n100-n3FFh,  n500-n7FFh, n900-nBFFh, nCD0-nFFFh.
69  */
70 /*! [End] no source code translation !*/
71 
72 #define ACPI_NON_ISA_ONLY_RANGES        (u8) 0x01
73 #define ACPI_ISA_ONLY_RANGES            (u8) 0x02
74 #define ACPI_ENTIRE_RANGE               (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES)
75 
76 /* Type of translation - 1=Sparse, 0=Dense */
77 
78 #define ACPI_SPARSE_TRANSLATION         (u8) 0x01
79 
80 /*
81  * IO Port Descriptor Decode
82  */
83 #define ACPI_DECODE_10                  (u8) 0x00	/* 10-bit IO address decode */
84 #define ACPI_DECODE_16                  (u8) 0x01	/* 16-bit IO address decode */
85 
86 /*
87  * Interrupt attributes - used in multiple descriptors
88  */
89 
90 /* Triggering */
91 
92 #define ACPI_LEVEL_SENSITIVE            (u8) 0x00
93 #define ACPI_EDGE_SENSITIVE             (u8) 0x01
94 
95 /* Polarity */
96 
97 #define ACPI_ACTIVE_HIGH                (u8) 0x00
98 #define ACPI_ACTIVE_LOW                 (u8) 0x01
99 #define ACPI_ACTIVE_BOTH                (u8) 0x02
100 
101 /* Sharing */
102 
103 #define ACPI_EXCLUSIVE                  (u8) 0x00
104 #define ACPI_SHARED                     (u8) 0x01
105 #define ACPI_EXCLUSIVE_AND_WAKE         (u8) 0x02
106 #define ACPI_SHARED_AND_WAKE            (u8) 0x03
107 
108 /*
109  * DMA Attributes
110  */
111 #define ACPI_COMPATIBILITY              (u8) 0x00
112 #define ACPI_TYPE_A                     (u8) 0x01
113 #define ACPI_TYPE_B                     (u8) 0x02
114 #define ACPI_TYPE_F                     (u8) 0x03
115 
116 #define ACPI_NOT_BUS_MASTER             (u8) 0x00
117 #define ACPI_BUS_MASTER                 (u8) 0x01
118 
119 #define ACPI_TRANSFER_8                 (u8) 0x00
120 #define ACPI_TRANSFER_8_16              (u8) 0x01
121 #define ACPI_TRANSFER_16                (u8) 0x02
122 
123 /*
124  * Start Dependent Functions Priority definitions
125  */
126 #define ACPI_GOOD_CONFIGURATION         (u8) 0x00
127 #define ACPI_ACCEPTABLE_CONFIGURATION   (u8) 0x01
128 #define ACPI_SUB_OPTIMAL_CONFIGURATION  (u8) 0x02
129 
130 /*
131  * 16, 32 and 64-bit Address Descriptor resource types
132  */
133 #define ACPI_MEMORY_RANGE               (u8) 0x00
134 #define ACPI_IO_RANGE                   (u8) 0x01
135 #define ACPI_BUS_NUMBER_RANGE           (u8) 0x02
136 
137 #define ACPI_ADDRESS_NOT_FIXED          (u8) 0x00
138 #define ACPI_ADDRESS_FIXED              (u8) 0x01
139 
140 #define ACPI_POS_DECODE                 (u8) 0x00
141 #define ACPI_SUB_DECODE                 (u8) 0x01
142 
143 /* Producer/Consumer */
144 
145 #define ACPI_PRODUCER                   (u8) 0x00
146 #define ACPI_CONSUMER                   (u8) 0x01
147 
148 /*
149  * If possible, pack the following structures to byte alignment
150  */
151 #ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
152 #pragma pack(1)
153 #endif
154 
155 /* UUID data structures for use in vendor-defined resource descriptors */
156 
157 struct acpi_uuid {
158 	u8 data[ACPI_UUID_LENGTH];
159 };
160 
161 struct acpi_vendor_uuid {
162 	u8 subtype;
163 	u8 data[ACPI_UUID_LENGTH];
164 };
165 
166 /*
167  * Structures used to describe device resources
168  */
169 struct acpi_resource_irq {
170 	u8 descriptor_length;
171 	u8 triggering;
172 	u8 polarity;
173 	u8 sharable;
174 	u8 interrupt_count;
175 	u8 interrupts[1];
176 };
177 
178 struct acpi_resource_dma {
179 	u8 type;
180 	u8 bus_master;
181 	u8 transfer;
182 	u8 channel_count;
183 	u8 channels[1];
184 };
185 
186 struct acpi_resource_start_dependent {
187 	u8 descriptor_length;
188 	u8 compatibility_priority;
189 	u8 performance_robustness;
190 };
191 
192 /*
193  * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
194  * needed because it has no fields
195  */
196 
197 struct acpi_resource_io {
198 	u8 io_decode;
199 	u8 alignment;
200 	u8 address_length;
201 	u16 minimum;
202 	u16 maximum;
203 };
204 
205 struct acpi_resource_fixed_io {
206 	u16 address;
207 	u8 address_length;
208 };
209 
210 struct acpi_resource_fixed_dma {
211 	u16 request_lines;
212 	u16 channels;
213 	u8 width;
214 };
215 
216 /* Values for Width field above */
217 
218 #define ACPI_DMA_WIDTH8                         0
219 #define ACPI_DMA_WIDTH16                        1
220 #define ACPI_DMA_WIDTH32                        2
221 #define ACPI_DMA_WIDTH64                        3
222 #define ACPI_DMA_WIDTH128                       4
223 #define ACPI_DMA_WIDTH256                       5
224 
225 struct acpi_resource_vendor {
226 	u16 byte_length;
227 	u8 byte_data[1];
228 };
229 
230 /* Vendor resource with UUID info (introduced in ACPI 3.0) */
231 
232 struct acpi_resource_vendor_typed {
233 	u16 byte_length;
234 	u8 uuid_subtype;
235 	u8 uuid[ACPI_UUID_LENGTH];
236 	u8 byte_data[1];
237 };
238 
239 struct acpi_resource_end_tag {
240 	u8 checksum;
241 };
242 
243 struct acpi_resource_memory24 {
244 	u8 write_protect;
245 	u16 minimum;
246 	u16 maximum;
247 	u16 alignment;
248 	u16 address_length;
249 };
250 
251 struct acpi_resource_memory32 {
252 	u8 write_protect;
253 	u32 minimum;
254 	u32 maximum;
255 	u32 alignment;
256 	u32 address_length;
257 };
258 
259 struct acpi_resource_fixed_memory32 {
260 	u8 write_protect;
261 	u32 address;
262 	u32 address_length;
263 };
264 
265 struct acpi_memory_attribute {
266 	u8 write_protect;
267 	u8 caching;
268 	u8 range_type;
269 	u8 translation;
270 };
271 
272 struct acpi_io_attribute {
273 	u8 range_type;
274 	u8 translation;
275 	u8 translation_type;
276 	u8 reserved1;
277 };
278 
279 union acpi_resource_attribute {
280 	struct acpi_memory_attribute mem;
281 	struct acpi_io_attribute io;
282 
283 	/* Used for the *word_space macros */
284 
285 	u8 type_specific;
286 };
287 
288 struct acpi_resource_source {
289 	u8 index;
290 	u16 string_length;
291 	char *string_ptr;
292 };
293 
294 /* Fields common to all address descriptors, 16/32/64 bit */
295 
296 #define ACPI_RESOURCE_ADDRESS_COMMON \
297 	u8                                      resource_type; \
298 	u8                                      producer_consumer; \
299 	u8                                      decode; \
300 	u8                                      min_address_fixed; \
301 	u8                                      max_address_fixed; \
302 	union acpi_resource_attribute           info;
303 
304 struct acpi_resource_address {
305 ACPI_RESOURCE_ADDRESS_COMMON};
306 
307 struct acpi_resource_address16 {
308 	ACPI_RESOURCE_ADDRESS_COMMON u16 granularity;
309 	u16 minimum;
310 	u16 maximum;
311 	u16 translation_offset;
312 	u16 address_length;
313 	struct acpi_resource_source resource_source;
314 };
315 
316 struct acpi_resource_address32 {
317 	ACPI_RESOURCE_ADDRESS_COMMON u32 granularity;
318 	u32 minimum;
319 	u32 maximum;
320 	u32 translation_offset;
321 	u32 address_length;
322 	struct acpi_resource_source resource_source;
323 };
324 
325 struct acpi_resource_address64 {
326 	ACPI_RESOURCE_ADDRESS_COMMON u64 granularity;
327 	u64 minimum;
328 	u64 maximum;
329 	u64 translation_offset;
330 	u64 address_length;
331 	struct acpi_resource_source resource_source;
332 };
333 
334 struct acpi_resource_extended_address64 {
335 	ACPI_RESOURCE_ADDRESS_COMMON u8 revision_iD;
336 	u64 granularity;
337 	u64 minimum;
338 	u64 maximum;
339 	u64 translation_offset;
340 	u64 address_length;
341 	u64 type_specific;
342 };
343 
344 struct acpi_resource_extended_irq {
345 	u8 producer_consumer;
346 	u8 triggering;
347 	u8 polarity;
348 	u8 sharable;
349 	u8 interrupt_count;
350 	struct acpi_resource_source resource_source;
351 	u32 interrupts[1];
352 };
353 
354 struct acpi_resource_generic_register {
355 	u8 space_id;
356 	u8 bit_width;
357 	u8 bit_offset;
358 	u8 access_size;
359 	u64 address;
360 };
361 
362 struct acpi_resource_gpio {
363 	u8 revision_id;
364 	u8 connection_type;
365 	u8 producer_consumer;	/* For values, see Producer/Consumer above */
366 	u8 pin_config;
367 	u8 sharable;		/* For values, see Interrupt Attributes above */
368 	u8 io_restriction;
369 	u8 triggering;		/* For values, see Interrupt Attributes above */
370 	u8 polarity;		/* For values, see Interrupt Attributes above */
371 	u16 drive_strength;
372 	u16 debounce_timeout;
373 	u16 pin_table_length;
374 	u16 vendor_length;
375 	struct acpi_resource_source resource_source;
376 	u16 *pin_table;
377 	u8 *vendor_data;
378 };
379 
380 /* Values for GPIO connection_type field above */
381 
382 #define ACPI_RESOURCE_GPIO_TYPE_INT             0
383 #define ACPI_RESOURCE_GPIO_TYPE_IO              1
384 
385 /* Values for pin_config field above */
386 
387 #define ACPI_PIN_CONFIG_DEFAULT                 0
388 #define ACPI_PIN_CONFIG_PULLUP                  1
389 #define ACPI_PIN_CONFIG_PULLDOWN                2
390 #define ACPI_PIN_CONFIG_NOPULL                  3
391 
392 /* Values for io_restriction field above */
393 
394 #define ACPI_IO_RESTRICT_NONE                   0
395 #define ACPI_IO_RESTRICT_INPUT                  1
396 #define ACPI_IO_RESTRICT_OUTPUT                 2
397 #define ACPI_IO_RESTRICT_NONE_PRESERVE          3
398 
399 /* Common structure for I2C, SPI, and UART serial descriptors */
400 
401 #define ACPI_RESOURCE_SERIAL_COMMON \
402 	u8                                      revision_id; \
403 	u8                                      type; \
404 	u8                                      producer_consumer;   /* For values, see Producer/Consumer above */\
405 	u8                                      slave_mode; \
406 	u8                                      type_revision_id; \
407 	u16                                     type_data_length; \
408 	u16                                     vendor_length; \
409 	struct acpi_resource_source             resource_source; \
410 	u8                                      *vendor_data;
411 
412 struct acpi_resource_common_serialbus {
413 ACPI_RESOURCE_SERIAL_COMMON};
414 
415 /* Values for the Type field above */
416 
417 #define ACPI_RESOURCE_SERIAL_TYPE_I2C           1
418 #define ACPI_RESOURCE_SERIAL_TYPE_SPI           2
419 #define ACPI_RESOURCE_SERIAL_TYPE_UART          3
420 
421 /* Values for slave_mode field above */
422 
423 #define ACPI_CONTROLLER_INITIATED               0
424 #define ACPI_DEVICE_INITIATED                   1
425 
426 struct acpi_resource_i2c_serialbus {
427 	ACPI_RESOURCE_SERIAL_COMMON u8 access_mode;
428 	u16 slave_address;
429 	u32 connection_speed;
430 };
431 
432 /* Values for access_mode field above */
433 
434 #define ACPI_I2C_7BIT_MODE                      0
435 #define ACPI_I2C_10BIT_MODE                     1
436 
437 struct acpi_resource_spi_serialbus {
438 	ACPI_RESOURCE_SERIAL_COMMON u8 wire_mode;
439 	u8 device_polarity;
440 	u8 data_bit_length;
441 	u8 clock_phase;
442 	u8 clock_polarity;
443 	u16 device_selection;
444 	u32 connection_speed;
445 };
446 
447 /* Values for wire_mode field above */
448 
449 #define ACPI_SPI_4WIRE_MODE                     0
450 #define ACPI_SPI_3WIRE_MODE                     1
451 
452 /* Values for device_polarity field above */
453 
454 #define ACPI_SPI_ACTIVE_LOW                     0
455 #define ACPI_SPI_ACTIVE_HIGH                    1
456 
457 /* Values for clock_phase field above */
458 
459 #define ACPI_SPI_FIRST_PHASE                    0
460 #define ACPI_SPI_SECOND_PHASE                   1
461 
462 /* Values for clock_polarity field above */
463 
464 #define ACPI_SPI_START_LOW                      0
465 #define ACPI_SPI_START_HIGH                     1
466 
467 struct acpi_resource_uart_serialbus {
468 	ACPI_RESOURCE_SERIAL_COMMON u8 endian;
469 	u8 data_bits;
470 	u8 stop_bits;
471 	u8 flow_control;
472 	u8 parity;
473 	u8 lines_enabled;
474 	u16 rx_fifo_size;
475 	u16 tx_fifo_size;
476 	u32 default_baud_rate;
477 };
478 
479 /* Values for Endian field above */
480 
481 #define ACPI_UART_LITTLE_ENDIAN                 0
482 #define ACPI_UART_BIG_ENDIAN                    1
483 
484 /* Values for data_bits field above */
485 
486 #define ACPI_UART_5_DATA_BITS                   0
487 #define ACPI_UART_6_DATA_BITS                   1
488 #define ACPI_UART_7_DATA_BITS                   2
489 #define ACPI_UART_8_DATA_BITS                   3
490 #define ACPI_UART_9_DATA_BITS                   4
491 
492 /* Values for stop_bits field above */
493 
494 #define ACPI_UART_NO_STOP_BITS                  0
495 #define ACPI_UART_1_STOP_BIT                    1
496 #define ACPI_UART_1P5_STOP_BITS                 2
497 #define ACPI_UART_2_STOP_BITS                   3
498 
499 /* Values for flow_control field above */
500 
501 #define ACPI_UART_FLOW_CONTROL_NONE             0
502 #define ACPI_UART_FLOW_CONTROL_HW               1
503 #define ACPI_UART_FLOW_CONTROL_XON_XOFF         2
504 
505 /* Values for Parity field above */
506 
507 #define ACPI_UART_PARITY_NONE                   0
508 #define ACPI_UART_PARITY_EVEN                   1
509 #define ACPI_UART_PARITY_ODD                    2
510 #define ACPI_UART_PARITY_MARK                   3
511 #define ACPI_UART_PARITY_SPACE                  4
512 
513 /* Values for lines_enabled bitfield above */
514 
515 #define ACPI_UART_CARRIER_DETECT                (1<<2)
516 #define ACPI_UART_RING_INDICATOR                (1<<3)
517 #define ACPI_UART_DATA_SET_READY                (1<<4)
518 #define ACPI_UART_DATA_TERMINAL_READY           (1<<5)
519 #define ACPI_UART_CLEAR_TO_SEND                 (1<<6)
520 #define ACPI_UART_REQUEST_TO_SEND               (1<<7)
521 
522 /* ACPI_RESOURCE_TYPEs */
523 
524 #define ACPI_RESOURCE_TYPE_IRQ                  0
525 #define ACPI_RESOURCE_TYPE_DMA                  1
526 #define ACPI_RESOURCE_TYPE_START_DEPENDENT      2
527 #define ACPI_RESOURCE_TYPE_END_DEPENDENT        3
528 #define ACPI_RESOURCE_TYPE_IO                   4
529 #define ACPI_RESOURCE_TYPE_FIXED_IO             5
530 #define ACPI_RESOURCE_TYPE_VENDOR               6
531 #define ACPI_RESOURCE_TYPE_END_TAG              7
532 #define ACPI_RESOURCE_TYPE_MEMORY24             8
533 #define ACPI_RESOURCE_TYPE_MEMORY32             9
534 #define ACPI_RESOURCE_TYPE_FIXED_MEMORY32       10
535 #define ACPI_RESOURCE_TYPE_ADDRESS16            11
536 #define ACPI_RESOURCE_TYPE_ADDRESS32            12
537 #define ACPI_RESOURCE_TYPE_ADDRESS64            13
538 #define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64   14	/* ACPI 3.0 */
539 #define ACPI_RESOURCE_TYPE_EXTENDED_IRQ         15
540 #define ACPI_RESOURCE_TYPE_GENERIC_REGISTER     16
541 #define ACPI_RESOURCE_TYPE_GPIO                 17	/* ACPI 5.0 */
542 #define ACPI_RESOURCE_TYPE_FIXED_DMA            18	/* ACPI 5.0 */
543 #define ACPI_RESOURCE_TYPE_SERIAL_BUS           19	/* ACPI 5.0 */
544 #define ACPI_RESOURCE_TYPE_MAX                  19
545 
546 /* Master union for resource descriptors */
547 
548 union acpi_resource_data {
549 	struct acpi_resource_irq irq;
550 	struct acpi_resource_dma dma;
551 	struct acpi_resource_start_dependent start_dpf;
552 	struct acpi_resource_io io;
553 	struct acpi_resource_fixed_io fixed_io;
554 	struct acpi_resource_fixed_dma fixed_dma;
555 	struct acpi_resource_vendor vendor;
556 	struct acpi_resource_vendor_typed vendor_typed;
557 	struct acpi_resource_end_tag end_tag;
558 	struct acpi_resource_memory24 memory24;
559 	struct acpi_resource_memory32 memory32;
560 	struct acpi_resource_fixed_memory32 fixed_memory32;
561 	struct acpi_resource_address16 address16;
562 	struct acpi_resource_address32 address32;
563 	struct acpi_resource_address64 address64;
564 	struct acpi_resource_extended_address64 ext_address64;
565 	struct acpi_resource_extended_irq extended_irq;
566 	struct acpi_resource_generic_register generic_reg;
567 	struct acpi_resource_gpio gpio;
568 	struct acpi_resource_i2c_serialbus i2c_serial_bus;
569 	struct acpi_resource_spi_serialbus spi_serial_bus;
570 	struct acpi_resource_uart_serialbus uart_serial_bus;
571 	struct acpi_resource_common_serialbus common_serial_bus;
572 
573 	/* Common fields */
574 
575 	struct acpi_resource_address address;	/* Common 16/32/64 address fields */
576 };
577 
578 /* Common resource header */
579 
580 struct acpi_resource {
581 	u32 type;
582 	u32 length;
583 	union acpi_resource_data data;
584 };
585 
586 /* restore default alignment */
587 
588 #pragma pack()
589 
590 #define ACPI_RS_SIZE_NO_DATA                8	/* Id + Length fields */
591 #define ACPI_RS_SIZE_MIN                    (u32) ACPI_ROUND_UP_TO_NATIVE_WORD (12)
592 #define ACPI_RS_SIZE(type)                  (u32) (ACPI_RS_SIZE_NO_DATA + sizeof (type))
593 
594 #define ACPI_NEXT_RESOURCE(res)             (struct acpi_resource *)((u8 *) res + res->length)
595 
596 struct acpi_pci_routing_table {
597 	u32 length;
598 	u32 pin;
599 	u64 address;		/* here for 64-bit alignment */
600 	u32 source_index;
601 	char source[4];		/* pad to 64 bits so sizeof() works in all cases */
602 };
603 
604 #endif				/* __ACRESTYP_H__ */
605