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