]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/acpi/acpica/amlresrc.h
Merge branch 'yem-kconfig-rc-fixes' of git://gitorious.org/linux-kconfig/linux-kconfi...
[mirror_ubuntu-bionic-kernel.git] / drivers / acpi / acpica / amlresrc.h
CommitLineData
1da177e4
LT
1/******************************************************************************
2 *
3 * Module Name: amlresrc.h - AML resource descriptors
4 *
5 *****************************************************************************/
6
7/*
77848130 8 * Copyright (C) 2000 - 2012, Intel Corp.
1da177e4
LT
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
61686124
BM
44/* acpisrc:struct_defs -- for acpisrc conversion */
45
1da177e4
LT
46#ifndef __AMLRESRC_H
47#define __AMLRESRC_H
48
61686124
BM
49/*
50 * Resource descriptor tags, as defined in the ACPI specification.
51 * Used to symbolically reference fields within a descriptor.
52 */
8313524a
BM
53#define ACPI_RESTAG_ADDRESS "_ADR"
54#define ACPI_RESTAG_ALIGNMENT "_ALN"
55#define ACPI_RESTAG_ADDRESSSPACE "_ASI"
56#define ACPI_RESTAG_ACCESSSIZE "_ASZ"
57#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
58#define ACPI_RESTAG_BASEADDRESS "_BAS"
59#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
e0fe0a8d 60#define ACPI_RESTAG_DEBOUNCETIME "_DBT"
8313524a 61#define ACPI_RESTAG_DECODE "_DEC"
e0fe0a8d 62#define ACPI_RESTAG_DEVICEPOLARITY "_DPL"
8313524a
BM
63#define ACPI_RESTAG_DMA "_DMA"
64#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
e0fe0a8d
LM
65#define ACPI_RESTAG_DRIVESTRENGTH "_DRS"
66#define ACPI_RESTAG_ENDIANNESS "_END"
67#define ACPI_RESTAG_FLOWCONTROL "_FLC"
8313524a
BM
68#define ACPI_RESTAG_GRANULARITY "_GRA"
69#define ACPI_RESTAG_INTERRUPT "_INT"
958dd242
BM
70#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */
71#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */
8313524a 72#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
e0fe0a8d 73#define ACPI_RESTAG_IORESTRICTION "_IOR"
8313524a 74#define ACPI_RESTAG_LENGTH "_LEN"
e0fe0a8d 75#define ACPI_RESTAG_LINE "_LIN"
8313524a 76#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
958dd242 77#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
8313524a
BM
78#define ACPI_RESTAG_MAXADDR "_MAX"
79#define ACPI_RESTAG_MINADDR "_MIN"
80#define ACPI_RESTAG_MAXTYPE "_MAF"
81#define ACPI_RESTAG_MINTYPE "_MIF"
e0fe0a8d
LM
82#define ACPI_RESTAG_MODE "_MOD"
83#define ACPI_RESTAG_PARITY "_PAR"
84#define ACPI_RESTAG_PHASE "_PHA"
85#define ACPI_RESTAG_PIN "_PIN"
86#define ACPI_RESTAG_PINCONFIG "_PPI"
87#define ACPI_RESTAG_POLARITY "_POL"
8313524a
BM
88#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
89#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
90#define ACPI_RESTAG_RANGETYPE "_RNG"
958dd242 91#define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */
e0fe0a8d
LM
92#define ACPI_RESTAG_LENGTH_RX "_RXL"
93#define ACPI_RESTAG_LENGTH_TX "_TXL"
94#define ACPI_RESTAG_SLAVEMODE "_SLV"
95#define ACPI_RESTAG_SPEED "_SPE"
96#define ACPI_RESTAG_STOPBITS "_STB"
8313524a
BM
97#define ACPI_RESTAG_TRANSLATION "_TRA"
98#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
99#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
ba494bee 100#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */
e0fe0a8d 101#define ACPI_RESTAG_VENDORDATA "_VEN"
1da177e4
LT
102
103/* Default sizes for "small" resource descriptors */
104
105#define ASL_RDESC_IRQ_SIZE 0x02
106#define ASL_RDESC_DMA_SIZE 0x02
107#define ASL_RDESC_ST_DEPEND_SIZE 0x00
108#define ASL_RDESC_END_DEPEND_SIZE 0x00
109#define ASL_RDESC_IO_SIZE 0x07
110#define ASL_RDESC_FIXED_IO_SIZE 0x03
e0fe0a8d 111#define ASL_RDESC_FIXED_DMA_SIZE 0x05
1da177e4
LT
112#define ASL_RDESC_END_TAG_SIZE 0x01
113
4be44fcd
LB
114struct asl_resource_node {
115 u32 buffer_length;
116 void *buffer;
117 struct asl_resource_node *next;
1da177e4
LT
118};
119
96db255c
BM
120/* Macros used to generate AML resource length fields */
121
122#define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
123#define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
124
1da177e4
LT
125/*
126 * Resource descriptors defined in the ACPI specification.
127 *
128 * Packing/alignment must be BYTE because these descriptors
50eca3eb 129 * are used to overlay the raw AML byte stream.
1da177e4
LT
130 */
131#pragma pack(1)
132
50eca3eb
BM
133/*
134 * SMALL descriptors
135 */
136#define AML_RESOURCE_SMALL_HEADER_COMMON \
61686124 137 u8 descriptor_type;
50eca3eb
BM
138
139struct aml_resource_small_header {
140AML_RESOURCE_SMALL_HEADER_COMMON};
141
142struct aml_resource_irq {
143 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
4be44fcd 144 u8 flags;
1da177e4
LT
145};
146
50eca3eb
BM
147struct aml_resource_irq_noflags {
148 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
1da177e4
LT
149};
150
50eca3eb
BM
151struct aml_resource_dma {
152 AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask;
4be44fcd 153 u8 flags;
1da177e4
LT
154};
155
50eca3eb
BM
156struct aml_resource_start_dependent {
157 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
1da177e4
LT
158};
159
50eca3eb
BM
160struct aml_resource_start_dependent_noprio {
161AML_RESOURCE_SMALL_HEADER_COMMON};
1da177e4 162
50eca3eb
BM
163struct aml_resource_end_dependent {
164AML_RESOURCE_SMALL_HEADER_COMMON};
1da177e4 165
50eca3eb 166struct aml_resource_io {
0897831b 167 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
50eca3eb
BM
168 u16 minimum;
169 u16 maximum;
4be44fcd 170 u8 alignment;
50eca3eb 171 u8 address_length;
1da177e4
LT
172};
173
50eca3eb
BM
174struct aml_resource_fixed_io {
175 AML_RESOURCE_SMALL_HEADER_COMMON u16 address;
176 u8 address_length;
1da177e4
LT
177};
178
50eca3eb
BM
179struct aml_resource_vendor_small {
180AML_RESOURCE_SMALL_HEADER_COMMON};
1da177e4 181
50eca3eb
BM
182struct aml_resource_end_tag {
183 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
1da177e4
LT
184};
185
e0fe0a8d
LM
186struct aml_resource_fixed_dma {
187 AML_RESOURCE_SMALL_HEADER_COMMON u16 request_lines;
188 u16 channels;
189 u8 width;
190};
191
50eca3eb
BM
192/*
193 * LARGE descriptors
194 */
195#define AML_RESOURCE_LARGE_HEADER_COMMON \
61686124
BM
196 u8 descriptor_type;\
197 u16 resource_length;
bda663d3 198
50eca3eb
BM
199struct aml_resource_large_header {
200AML_RESOURCE_LARGE_HEADER_COMMON};
bda663d3 201
50eca3eb 202struct aml_resource_memory24 {
0897831b 203 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
50eca3eb
BM
204 u16 minimum;
205 u16 maximum;
4be44fcd 206 u16 alignment;
50eca3eb 207 u16 address_length;
1da177e4
LT
208};
209
50eca3eb
BM
210struct aml_resource_vendor_large {
211AML_RESOURCE_LARGE_HEADER_COMMON};
1da177e4 212
50eca3eb 213struct aml_resource_memory32 {
0897831b 214 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
50eca3eb
BM
215 u32 minimum;
216 u32 maximum;
4be44fcd 217 u32 alignment;
50eca3eb 218 u32 address_length;
1da177e4
LT
219};
220
50eca3eb 221struct aml_resource_fixed_memory32 {
0897831b 222 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
50eca3eb
BM
223 u32 address;
224 u32 address_length;
1da177e4
LT
225};
226
50eca3eb 227#define AML_RESOURCE_ADDRESS_COMMON \
61686124
BM
228 u8 resource_type; \
229 u8 flags; \
230 u8 specific_flags;
50eca3eb
BM
231
232struct aml_resource_address {
233AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
234
235struct aml_resource_extended_address64 {
236 AML_RESOURCE_LARGE_HEADER_COMMON
ba494bee 237 AML_RESOURCE_ADDRESS_COMMON u8 revision_ID;
4be44fcd
LB
238 u8 reserved;
239 u64 granularity;
50eca3eb
BM
240 u64 minimum;
241 u64 maximum;
4be44fcd
LB
242 u64 translation_offset;
243 u64 address_length;
0897831b 244 u64 type_specific;
1da177e4
LT
245};
246
50eca3eb 247#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
4be44fcd 248
50eca3eb
BM
249struct aml_resource_address64 {
250 AML_RESOURCE_LARGE_HEADER_COMMON
251 AML_RESOURCE_ADDRESS_COMMON u64 granularity;
252 u64 minimum;
253 u64 maximum;
4be44fcd
LB
254 u64 translation_offset;
255 u64 address_length;
1da177e4
LT
256};
257
50eca3eb
BM
258struct aml_resource_address32 {
259 AML_RESOURCE_LARGE_HEADER_COMMON
260 AML_RESOURCE_ADDRESS_COMMON u32 granularity;
261 u32 minimum;
262 u32 maximum;
4be44fcd
LB
263 u32 translation_offset;
264 u32 address_length;
1da177e4
LT
265};
266
50eca3eb
BM
267struct aml_resource_address16 {
268 AML_RESOURCE_LARGE_HEADER_COMMON
269 AML_RESOURCE_ADDRESS_COMMON u16 granularity;
270 u16 minimum;
271 u16 maximum;
4be44fcd
LB
272 u16 translation_offset;
273 u16 address_length;
1da177e4
LT
274};
275
50eca3eb
BM
276struct aml_resource_extended_irq {
277 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
0897831b
BM
278 u8 interrupt_count;
279 u32 interrupts[1];
1da177e4
LT
280 /* res_source_index, res_source optional fields follow */
281};
282
50eca3eb
BM
283struct aml_resource_generic_register {
284 AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id;
4be44fcd
LB
285 u8 bit_width;
286 u8 bit_offset;
50eca3eb 287 u8 access_size; /* ACPI 3.0, was previously Reserved */
4be44fcd 288 u64 address;
1da177e4
LT
289};
290
e0fe0a8d
LM
291/* Common descriptor for gpio_int and gpio_io (ACPI 5.0) */
292
293struct aml_resource_gpio {
294 AML_RESOURCE_LARGE_HEADER_COMMON u8 revision_id;
295 u8 connection_type;
296 u16 flags;
297 u16 int_flags;
298 u8 pin_config;
299 u16 drive_strength;
300 u16 debounce_timeout;
301 u16 pin_table_offset;
302 u8 res_source_index;
303 u16 res_source_offset;
304 u16 vendor_offset;
305 u16 vendor_length;
306 /*
307 * Optional fields follow immediately:
308 * 1) PIN list (Words)
309 * 2) Resource Source String
310 * 3) Vendor Data bytes
311 */
312};
313
314#define AML_RESOURCE_GPIO_REVISION 1 /* ACPI 5.0 */
315
316/* Values for connection_type above */
317
318#define AML_RESOURCE_GPIO_TYPE_INT 0
319#define AML_RESOURCE_GPIO_TYPE_IO 1
320#define AML_RESOURCE_MAX_GPIOTYPE 1
321
322/* Common preamble for all serial descriptors (ACPI 5.0) */
323
324#define AML_RESOURCE_SERIAL_COMMON \
325 u8 revision_id; \
326 u8 res_source_index; \
327 u8 type; \
328 u8 flags; \
329 u16 type_specific_flags; \
330 u8 type_revision_id; \
331 u16 type_data_length; \
332
333/* Values for the type field above */
334
335#define AML_RESOURCE_I2C_SERIALBUSTYPE 1
336#define AML_RESOURCE_SPI_SERIALBUSTYPE 2
337#define AML_RESOURCE_UART_SERIALBUSTYPE 3
338#define AML_RESOURCE_MAX_SERIALBUSTYPE 3
339#define AML_RESOURCE_VENDOR_SERIALBUSTYPE 192 /* Vendor defined is 0xC0-0xFF (NOT SUPPORTED) */
340
341struct aml_resource_common_serialbus {
342AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_SERIAL_COMMON};
343
344struct aml_resource_i2c_serialbus {
345 AML_RESOURCE_LARGE_HEADER_COMMON
346 AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
347 u16 slave_address;
348 /*
349 * Optional fields follow immediately:
350 * 1) Vendor Data bytes
351 * 2) Resource Source String
352 */
353};
354
355#define AML_RESOURCE_I2C_REVISION 1 /* ACPI 5.0 */
356#define AML_RESOURCE_I2C_TYPE_REVISION 1 /* ACPI 5.0 */
357#define AML_RESOURCE_I2C_MIN_DATA_LEN 6
358
359struct aml_resource_spi_serialbus {
360 AML_RESOURCE_LARGE_HEADER_COMMON
361 AML_RESOURCE_SERIAL_COMMON u32 connection_speed;
362 u8 data_bit_length;
363 u8 clock_phase;
364 u8 clock_polarity;
365 u16 device_selection;
366 /*
367 * Optional fields follow immediately:
368 * 1) Vendor Data bytes
369 * 2) Resource Source String
370 */
371};
372
373#define AML_RESOURCE_SPI_REVISION 1 /* ACPI 5.0 */
374#define AML_RESOURCE_SPI_TYPE_REVISION 1 /* ACPI 5.0 */
375#define AML_RESOURCE_SPI_MIN_DATA_LEN 9
376
377struct aml_resource_uart_serialbus {
378 AML_RESOURCE_LARGE_HEADER_COMMON
379 AML_RESOURCE_SERIAL_COMMON u32 default_baud_rate;
380 u16 rx_fifo_size;
381 u16 tx_fifo_size;
382 u8 parity;
383 u8 lines_enabled;
384 /*
385 * Optional fields follow immediately:
386 * 1) Vendor Data bytes
387 * 2) Resource Source String
388 */
389};
390
391#define AML_RESOURCE_UART_REVISION 1 /* ACPI 5.0 */
392#define AML_RESOURCE_UART_TYPE_REVISION 1 /* ACPI 5.0 */
393#define AML_RESOURCE_UART_MIN_DATA_LEN 10
394
1da177e4
LT
395/* restore default alignment */
396
397#pragma pack()
398
399/* Union of all resource descriptors, so we can allocate the worst case */
400
50eca3eb
BM
401union aml_resource {
402 /* Descriptor headers */
403
8313524a 404 u8 descriptor_type;
50eca3eb
BM
405 struct aml_resource_small_header small_header;
406 struct aml_resource_large_header large_header;
407
408 /* Small resource descriptors */
409
410 struct aml_resource_irq irq;
411 struct aml_resource_dma dma;
412 struct aml_resource_start_dependent start_dpf;
413 struct aml_resource_end_dependent end_dpf;
414 struct aml_resource_io io;
415 struct aml_resource_fixed_io fixed_io;
e0fe0a8d 416 struct aml_resource_fixed_dma fixed_dma;
50eca3eb
BM
417 struct aml_resource_vendor_small vendor_small;
418 struct aml_resource_end_tag end_tag;
419
420 /* Large resource descriptors */
421
422 struct aml_resource_memory24 memory24;
423 struct aml_resource_generic_register generic_reg;
424 struct aml_resource_vendor_large vendor_large;
425 struct aml_resource_memory32 memory32;
426 struct aml_resource_fixed_memory32 fixed_memory32;
427 struct aml_resource_address16 address16;
428 struct aml_resource_address32 address32;
429 struct aml_resource_address64 address64;
430 struct aml_resource_extended_address64 ext_address64;
431 struct aml_resource_extended_irq extended_irq;
e0fe0a8d
LM
432 struct aml_resource_gpio gpio;
433 struct aml_resource_i2c_serialbus i2c_serial_bus;
434 struct aml_resource_spi_serialbus spi_serial_bus;
435 struct aml_resource_uart_serialbus uart_serial_bus;
436 struct aml_resource_common_serialbus common_serial_bus;
50eca3eb
BM
437
438 /* Utility overlays */
439
440 struct aml_resource_address address;
958dd242
BM
441 u32 dword_item;
442 u16 word_item;
443 u8 byte_item;
1da177e4
LT
444};
445
1da177e4 446#endif