]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/acpi/acpica/rsinfo.c
ebccc6a4267b7847c147be0f7191077f22b96012
[karo-tx-linux.git] / drivers / acpi / acpica / rsinfo.c
1 /*******************************************************************************
2  *
3  * Module Name: rsinfo - Dispatch and Info tables
4  *
5  ******************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2017, 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 #include <acpi/acpi.h>
45 #include "accommon.h"
46 #include "acresrc.h"
47
48 #define _COMPONENT          ACPI_RESOURCES
49 ACPI_MODULE_NAME("rsinfo")
50
51 /*
52  * Resource dispatch and information tables. Any new resource types (either
53  * Large or Small) must be reflected in each of these tables, so they are here
54  * in one place.
55  *
56  * The tables for Large descriptors are indexed by bits 6:0 of the AML
57  * descriptor type byte. The tables for Small descriptors are indexed by
58  * bits 6:3 of the descriptor byte. The tables for internal resource
59  * descriptors are indexed by the acpi_resource_type field.
60  */
61 /* Dispatch table for resource-to-AML (Set Resource) conversion functions */
62 struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[] = {
63         acpi_rs_set_irq,        /* 0x00, ACPI_RESOURCE_TYPE_IRQ */
64         acpi_rs_convert_dma,    /* 0x01, ACPI_RESOURCE_TYPE_DMA */
65         acpi_rs_set_start_dpf,  /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */
66         acpi_rs_convert_end_dpf,        /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */
67         acpi_rs_convert_io,     /* 0x04, ACPI_RESOURCE_TYPE_IO */
68         acpi_rs_convert_fixed_io,       /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */
69         acpi_rs_set_vendor,     /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */
70         acpi_rs_convert_end_tag,        /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */
71         acpi_rs_convert_memory24,       /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */
72         acpi_rs_convert_memory32,       /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */
73         acpi_rs_convert_fixed_memory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
74         acpi_rs_convert_address16,      /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */
75         acpi_rs_convert_address32,      /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */
76         acpi_rs_convert_address64,      /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */
77         acpi_rs_convert_ext_address64,  /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
78         acpi_rs_convert_ext_irq,        /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
79         acpi_rs_convert_generic_reg,    /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
80         acpi_rs_convert_gpio,   /* 0x11, ACPI_RESOURCE_TYPE_GPIO */
81         acpi_rs_convert_fixed_dma,      /* 0x12, ACPI_RESOURCE_TYPE_FIXED_DMA */
82         NULL,                   /* 0x13, ACPI_RESOURCE_TYPE_SERIAL_BUS - Use subtype table below */
83         acpi_rs_convert_pin_function,   /* 0x14, ACPI_RESOURCE_TYPE_PIN_FUNCTION */
84         acpi_rs_convert_pin_config,     /* 0x15, ACPI_RESOURCE_TYPE_PIN_CONFIG */
85         acpi_rs_convert_pin_group,      /* 0x16, ACPI_RESOURCE_TYPE_PIN_GROUP */
86         acpi_rs_convert_pin_group_function,     /* 0x17, ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION */
87 };
88
89 /* Dispatch tables for AML-to-resource (Get Resource) conversion functions */
90
91 struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[] = {
92         /* Small descriptors */
93
94         NULL,                   /* 0x00, Reserved */
95         NULL,                   /* 0x01, Reserved */
96         NULL,                   /* 0x02, Reserved */
97         NULL,                   /* 0x03, Reserved */
98         acpi_rs_get_irq,        /* 0x04, ACPI_RESOURCE_NAME_IRQ */
99         acpi_rs_convert_dma,    /* 0x05, ACPI_RESOURCE_NAME_DMA */
100         acpi_rs_get_start_dpf,  /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
101         acpi_rs_convert_end_dpf,        /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
102         acpi_rs_convert_io,     /* 0x08, ACPI_RESOURCE_NAME_IO */
103         acpi_rs_convert_fixed_io,       /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */
104         acpi_rs_convert_fixed_dma,      /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */
105         NULL,                   /* 0x0B, Reserved */
106         NULL,                   /* 0x0C, Reserved */
107         NULL,                   /* 0x0D, Reserved */
108         acpi_rs_get_vendor_small,       /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */
109         acpi_rs_convert_end_tag,        /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */
110
111         /* Large descriptors */
112
113         NULL,                   /* 0x00, Reserved */
114         acpi_rs_convert_memory24,       /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */
115         acpi_rs_convert_generic_reg,    /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
116         NULL,                   /* 0x03, Reserved */
117         acpi_rs_get_vendor_large,       /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */
118         acpi_rs_convert_memory32,       /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */
119         acpi_rs_convert_fixed_memory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */
120         acpi_rs_convert_address32,      /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */
121         acpi_rs_convert_address16,      /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */
122         acpi_rs_convert_ext_irq,        /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */
123         acpi_rs_convert_address64,      /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */
124         acpi_rs_convert_ext_address64,  /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */
125         acpi_rs_convert_gpio,   /* 0x0C, ACPI_RESOURCE_NAME_GPIO */
126         acpi_rs_convert_pin_function,   /* 0x0D, ACPI_RESOURCE_NAME_PIN_FUNCTION */
127         NULL,                   /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS - Use subtype table below */
128         acpi_rs_convert_pin_config,     /* 0x0F, ACPI_RESOURCE_NAME_PIN_CONFIG */
129         acpi_rs_convert_pin_group,      /* 0x10, ACPI_RESOURCE_NAME_PIN_GROUP */
130         acpi_rs_convert_pin_group_function,     /* 0x11, ACPI_RESOURCE_NAME_PIN_GROUP_FUNCTION */
131 };
132
133 /* Subtype table for serial_bus -- I2C, SPI, and UART */
134
135 struct acpi_rsconvert_info *acpi_gbl_convert_resource_serial_bus_dispatch[] = {
136         NULL,
137         acpi_rs_convert_i2c_serial_bus,
138         acpi_rs_convert_spi_serial_bus,
139         acpi_rs_convert_uart_serial_bus,
140 };
141
142 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
143
144 /* Dispatch table for resource dump functions */
145
146 struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[] = {
147         acpi_rs_dump_irq,       /* ACPI_RESOURCE_TYPE_IRQ */
148         acpi_rs_dump_dma,       /* ACPI_RESOURCE_TYPE_DMA */
149         acpi_rs_dump_start_dpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */
150         acpi_rs_dump_end_dpf,   /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
151         acpi_rs_dump_io,        /* ACPI_RESOURCE_TYPE_IO */
152         acpi_rs_dump_fixed_io,  /* ACPI_RESOURCE_TYPE_FIXED_IO */
153         acpi_rs_dump_vendor,    /* ACPI_RESOURCE_TYPE_VENDOR */
154         acpi_rs_dump_end_tag,   /* ACPI_RESOURCE_TYPE_END_TAG */
155         acpi_rs_dump_memory24,  /* ACPI_RESOURCE_TYPE_MEMORY24 */
156         acpi_rs_dump_memory32,  /* ACPI_RESOURCE_TYPE_MEMORY32 */
157         acpi_rs_dump_fixed_memory32,    /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
158         acpi_rs_dump_address16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */
159         acpi_rs_dump_address32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */
160         acpi_rs_dump_address64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */
161         acpi_rs_dump_ext_address64,     /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
162         acpi_rs_dump_ext_irq,   /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
163         acpi_rs_dump_generic_reg,       /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
164         acpi_rs_dump_gpio,      /* ACPI_RESOURCE_TYPE_GPIO */
165         acpi_rs_dump_fixed_dma, /* ACPI_RESOURCE_TYPE_FIXED_DMA */
166         NULL,                   /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
167         acpi_rs_dump_pin_function,      /* ACPI_RESOURCE_TYPE_PIN_FUNCTION */
168         acpi_rs_dump_pin_config,        /* ACPI_RESOURCE_TYPE_PIN_CONFIG */
169         acpi_rs_dump_pin_group, /* ACPI_RESOURCE_TYPE_PIN_GROUP */
170         acpi_rs_dump_pin_group_function,        /* ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION */
171 };
172
173 struct acpi_rsdump_info *acpi_gbl_dump_serial_bus_dispatch[] = {
174         NULL,
175         acpi_rs_dump_i2c_serial_bus,    /* AML_RESOURCE_I2C_BUS_TYPE */
176         acpi_rs_dump_spi_serial_bus,    /* AML_RESOURCE_SPI_BUS_TYPE */
177         acpi_rs_dump_uart_serial_bus,   /* AML_RESOURCE_UART_BUS_TYPE */
178 };
179 #endif
180
181 /*
182  * Base sizes for external AML resource descriptors, indexed by internal type.
183  * Includes size of the descriptor header (1 byte for small descriptors,
184  * 3 bytes for large descriptors)
185  */
186 const u8 acpi_gbl_aml_resource_sizes[] = {
187         sizeof(struct aml_resource_irq),        /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */
188         sizeof(struct aml_resource_dma),        /* ACPI_RESOURCE_TYPE_DMA */
189         sizeof(struct aml_resource_start_dependent),    /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */
190         sizeof(struct aml_resource_end_dependent),      /* ACPI_RESOURCE_TYPE_END_DEPENDENT */
191         sizeof(struct aml_resource_io), /* ACPI_RESOURCE_TYPE_IO */
192         sizeof(struct aml_resource_fixed_io),   /* ACPI_RESOURCE_TYPE_FIXED_IO */
193         sizeof(struct aml_resource_vendor_small),       /* ACPI_RESOURCE_TYPE_VENDOR */
194         sizeof(struct aml_resource_end_tag),    /* ACPI_RESOURCE_TYPE_END_TAG */
195         sizeof(struct aml_resource_memory24),   /* ACPI_RESOURCE_TYPE_MEMORY24 */
196         sizeof(struct aml_resource_memory32),   /* ACPI_RESOURCE_TYPE_MEMORY32 */
197         sizeof(struct aml_resource_fixed_memory32),     /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */
198         sizeof(struct aml_resource_address16),  /* ACPI_RESOURCE_TYPE_ADDRESS16 */
199         sizeof(struct aml_resource_address32),  /* ACPI_RESOURCE_TYPE_ADDRESS32 */
200         sizeof(struct aml_resource_address64),  /* ACPI_RESOURCE_TYPE_ADDRESS64 */
201         sizeof(struct aml_resource_extended_address64), /*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */
202         sizeof(struct aml_resource_extended_irq),       /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */
203         sizeof(struct aml_resource_generic_register),   /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */
204         sizeof(struct aml_resource_gpio),       /* ACPI_RESOURCE_TYPE_GPIO */
205         sizeof(struct aml_resource_fixed_dma),  /* ACPI_RESOURCE_TYPE_FIXED_DMA */
206         sizeof(struct aml_resource_common_serialbus),   /* ACPI_RESOURCE_TYPE_SERIAL_BUS */
207         sizeof(struct aml_resource_pin_function),       /* ACPI_RESOURCE_TYPE_PIN_FUNCTION */
208         sizeof(struct aml_resource_pin_config), /* ACPI_RESOURCE_TYPE_PIN_CONFIG */
209         sizeof(struct aml_resource_pin_group),  /* ACPI_RESOURCE_TYPE_PIN_GROUP */
210         sizeof(struct aml_resource_pin_group_function), /* ACPI_RESOURCE_TYPE_PIN_GROUP_FUNCTION */
211 };
212
213 const u8 acpi_gbl_resource_struct_sizes[] = {
214         /* Small descriptors */
215
216         0,
217         0,
218         0,
219         0,
220         ACPI_RS_SIZE(struct acpi_resource_irq),
221         ACPI_RS_SIZE(struct acpi_resource_dma),
222         ACPI_RS_SIZE(struct acpi_resource_start_dependent),
223         ACPI_RS_SIZE_MIN,
224         ACPI_RS_SIZE(struct acpi_resource_io),
225         ACPI_RS_SIZE(struct acpi_resource_fixed_io),
226         ACPI_RS_SIZE(struct acpi_resource_fixed_dma),
227         0,
228         0,
229         0,
230         ACPI_RS_SIZE(struct acpi_resource_vendor),
231         ACPI_RS_SIZE_MIN,
232
233         /* Large descriptors */
234
235         0,
236         ACPI_RS_SIZE(struct acpi_resource_memory24),
237         ACPI_RS_SIZE(struct acpi_resource_generic_register),
238         0,
239         ACPI_RS_SIZE(struct acpi_resource_vendor),
240         ACPI_RS_SIZE(struct acpi_resource_memory32),
241         ACPI_RS_SIZE(struct acpi_resource_fixed_memory32),
242         ACPI_RS_SIZE(struct acpi_resource_address32),
243         ACPI_RS_SIZE(struct acpi_resource_address16),
244         ACPI_RS_SIZE(struct acpi_resource_extended_irq),
245         ACPI_RS_SIZE(struct acpi_resource_address64),
246         ACPI_RS_SIZE(struct acpi_resource_extended_address64),
247         ACPI_RS_SIZE(struct acpi_resource_gpio),
248         ACPI_RS_SIZE(struct acpi_resource_pin_function),
249         ACPI_RS_SIZE(struct acpi_resource_common_serialbus),
250         ACPI_RS_SIZE(struct acpi_resource_pin_config),
251         ACPI_RS_SIZE(struct acpi_resource_pin_group),
252         ACPI_RS_SIZE(struct acpi_resource_pin_group_function),
253 };
254
255 const u8 acpi_gbl_aml_resource_serial_bus_sizes[] = {
256         0,
257         sizeof(struct aml_resource_i2c_serialbus),
258         sizeof(struct aml_resource_spi_serialbus),
259         sizeof(struct aml_resource_uart_serialbus),
260 };
261
262 const u8 acpi_gbl_resource_struct_serial_bus_sizes[] = {
263         0,
264         ACPI_RS_SIZE(struct acpi_resource_i2c_serialbus),
265         ACPI_RS_SIZE(struct acpi_resource_spi_serialbus),
266         ACPI_RS_SIZE(struct acpi_resource_uart_serialbus),
267 };