Linux 4.19.133
[linux/fpc-iii.git] / drivers / acpi / acpica / rsio.c
blob687aaed9655ae3a50dabc031799dc61f533d0049
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: rsio - IO and DMA resource descriptors
6 ******************************************************************************/
8 #include <acpi/acpi.h>
9 #include "accommon.h"
10 #include "acresrc.h"
12 #define _COMPONENT ACPI_RESOURCES
13 ACPI_MODULE_NAME("rsio")
15 /*******************************************************************************
17 * acpi_rs_convert_io
19 ******************************************************************************/
20 struct acpi_rsconvert_info acpi_rs_convert_io[5] = {
21 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO,
22 ACPI_RS_SIZE(struct acpi_resource_io),
23 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io)},
25 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO,
26 sizeof(struct aml_resource_io),
27 0},
29 /* Decode flag */
31 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.io.io_decode),
32 AML_OFFSET(io.flags),
33 0},
35 * These fields are contiguous in both the source and destination:
36 * Address Alignment
37 * Length
38 * Minimum Base Address
39 * Maximum Base Address
41 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.io.alignment),
42 AML_OFFSET(io.alignment),
43 2},
45 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.io.minimum),
46 AML_OFFSET(io.minimum),
50 /*******************************************************************************
52 * acpi_rs_convert_fixed_io
54 ******************************************************************************/
56 struct acpi_rsconvert_info acpi_rs_convert_fixed_io[4] = {
57 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO,
58 ACPI_RS_SIZE(struct acpi_resource_fixed_io),
59 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_fixed_io)},
61 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO,
62 sizeof(struct aml_resource_fixed_io),
63 0},
65 * These fields are contiguous in both the source and destination:
66 * Base Address
67 * Length
69 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.fixed_io.address_length),
70 AML_OFFSET(fixed_io.address_length),
71 1},
73 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.fixed_io.address),
74 AML_OFFSET(fixed_io.address),
78 /*******************************************************************************
80 * acpi_rs_convert_generic_reg
82 ******************************************************************************/
84 struct acpi_rsconvert_info acpi_rs_convert_generic_reg[4] = {
85 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER,
86 ACPI_RS_SIZE(struct acpi_resource_generic_register),
87 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_generic_reg)},
89 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER,
90 sizeof(struct aml_resource_generic_register),
91 0},
93 * These fields are contiguous in both the source and destination:
94 * Address Space ID
95 * Register Bit Width
96 * Register Bit Offset
97 * Access Size
99 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.generic_reg.space_id),
100 AML_OFFSET(generic_reg.address_space_id),
103 /* Get the Register Address */
105 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.generic_reg.address),
106 AML_OFFSET(generic_reg.address),
110 /*******************************************************************************
112 * acpi_rs_convert_end_dpf
114 ******************************************************************************/
116 struct acpi_rsconvert_info acpi_rs_convert_end_dpf[2] = {
117 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT,
118 ACPI_RS_SIZE_MIN,
119 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_dpf)},
121 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT,
122 sizeof(struct aml_resource_end_dependent),
126 /*******************************************************************************
128 * acpi_rs_convert_end_tag
130 ******************************************************************************/
132 struct acpi_rsconvert_info acpi_rs_convert_end_tag[2] = {
133 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG,
134 ACPI_RS_SIZE_MIN,
135 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_end_tag)},
138 * Note: The checksum field is set to zero, meaning that the resource
139 * data is treated as if the checksum operation succeeded.
140 * (ACPI Spec 1.0b Section 6.4.2.8)
142 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG,
143 sizeof(struct aml_resource_end_tag),
147 /*******************************************************************************
149 * acpi_rs_get_start_dpf
151 ******************************************************************************/
153 struct acpi_rsconvert_info acpi_rs_get_start_dpf[6] = {
154 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT,
155 ACPI_RS_SIZE(struct acpi_resource_start_dependent),
156 ACPI_RSC_TABLE_SIZE(acpi_rs_get_start_dpf)},
158 /* Defaults for Compatibility and Performance priorities */
160 {ACPI_RSC_SET8, ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
161 ACPI_ACCEPTABLE_CONFIGURATION,
164 /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */
166 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
167 AML_OFFSET(start_dpf.descriptor_type),
170 /* All done if there is no flag byte present in the descriptor */
172 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1},
174 /* Flag byte is present, get the flags */
176 {ACPI_RSC_2BITFLAG,
177 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
178 AML_OFFSET(start_dpf.flags),
181 {ACPI_RSC_2BITFLAG,
182 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
183 AML_OFFSET(start_dpf.flags),
187 /*******************************************************************************
189 * acpi_rs_set_start_dpf
191 ******************************************************************************/
193 struct acpi_rsconvert_info acpi_rs_set_start_dpf[10] = {
194 /* Start with a default descriptor of length 1 */
196 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT,
197 sizeof(struct aml_resource_start_dependent),
198 ACPI_RSC_TABLE_SIZE(acpi_rs_set_start_dpf)},
200 /* Set the default flag values */
202 {ACPI_RSC_2BITFLAG,
203 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
204 AML_OFFSET(start_dpf.flags),
207 {ACPI_RSC_2BITFLAG,
208 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
209 AML_OFFSET(start_dpf.flags),
212 * All done if the output descriptor length is required to be 1
213 * (i.e., optimization to 0 bytes cannot be attempted)
215 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
216 ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
219 /* Set length to 0 bytes (no flags byte) */
221 {ACPI_RSC_LENGTH, 0, 0,
222 sizeof(struct aml_resource_start_dependent_noprio)},
225 * All done if the output descriptor length is required to be 0.
227 * TBD: Perhaps we should check for error if input flags are not
228 * compatible with a 0-byte descriptor.
230 {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE,
231 ACPI_RS_OFFSET(data.start_dpf.descriptor_length),
234 /* Reset length to 1 byte (descriptor with flags byte) */
236 {ACPI_RSC_LENGTH, 0, 0, sizeof(struct aml_resource_start_dependent)},
239 * All done if flags byte is necessary -- if either priority value
240 * is not ACPI_ACCEPTABLE_CONFIGURATION
242 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
243 ACPI_RS_OFFSET(data.start_dpf.compatibility_priority),
244 ACPI_ACCEPTABLE_CONFIGURATION},
246 {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE,
247 ACPI_RS_OFFSET(data.start_dpf.performance_robustness),
248 ACPI_ACCEPTABLE_CONFIGURATION},
250 /* Flag byte is not necessary */
252 {ACPI_RSC_LENGTH, 0, 0,
253 sizeof(struct aml_resource_start_dependent_noprio)}