PRCM: 34XX: Fix wrong shift value used in dpll4_m4x2_ck enable bit
[linux-ginger.git] / drivers / acpi / resources / rsaddr.c
blob7f96332822bf2cff8bab0a3a88d1ed1c19c7329a
1 /*******************************************************************************
3 * Module Name: rsaddr - Address resource descriptors (16/32/64)
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include <acpi/acresrc.h>
47 #define _COMPONENT ACPI_RESOURCES
48 ACPI_MODULE_NAME("rsaddr")
50 /*******************************************************************************
52 * acpi_rs_convert_address16 - All WORD (16-bit) address resources
54 ******************************************************************************/
55 struct acpi_rsconvert_info acpi_rs_convert_address16[5] = {
56 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16,
57 ACPI_RS_SIZE(struct acpi_resource_address16),
58 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address16)},
60 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16,
61 sizeof(struct aml_resource_address16),
62 0},
64 /* Resource Type, General Flags, and Type-Specific Flags */
66 {ACPI_RSC_ADDRESS, 0, 0, 0},
69 * These fields are contiguous in both the source and destination:
70 * Address Granularity
71 * Address Range Minimum
72 * Address Range Maximum
73 * Address Translation Offset
74 * Address Length
76 {ACPI_RSC_MOVE16, ACPI_RS_OFFSET(data.address16.granularity),
77 AML_OFFSET(address16.granularity),
78 5},
80 /* Optional resource_source (Index and String) */
82 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address16.resource_source),
84 sizeof(struct aml_resource_address16)}
87 /*******************************************************************************
89 * acpi_rs_convert_address32 - All DWORD (32-bit) address resources
91 ******************************************************************************/
93 struct acpi_rsconvert_info acpi_rs_convert_address32[5] = {
94 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32,
95 ACPI_RS_SIZE(struct acpi_resource_address32),
96 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address32)},
98 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32,
99 sizeof(struct aml_resource_address32),
102 /* Resource Type, General Flags, and Type-Specific Flags */
104 {ACPI_RSC_ADDRESS, 0, 0, 0},
107 * These fields are contiguous in both the source and destination:
108 * Address Granularity
109 * Address Range Minimum
110 * Address Range Maximum
111 * Address Translation Offset
112 * Address Length
114 {ACPI_RSC_MOVE32, ACPI_RS_OFFSET(data.address32.granularity),
115 AML_OFFSET(address32.granularity),
118 /* Optional resource_source (Index and String) */
120 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address32.resource_source),
122 sizeof(struct aml_resource_address32)}
125 /*******************************************************************************
127 * acpi_rs_convert_address64 - All QWORD (64-bit) address resources
129 ******************************************************************************/
131 struct acpi_rsconvert_info acpi_rs_convert_address64[5] = {
132 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64,
133 ACPI_RS_SIZE(struct acpi_resource_address64),
134 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_address64)},
136 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64,
137 sizeof(struct aml_resource_address64),
140 /* Resource Type, General Flags, and Type-Specific Flags */
142 {ACPI_RSC_ADDRESS, 0, 0, 0},
145 * These fields are contiguous in both the source and destination:
146 * Address Granularity
147 * Address Range Minimum
148 * Address Range Maximum
149 * Address Translation Offset
150 * Address Length
152 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.address64.granularity),
153 AML_OFFSET(address64.granularity),
156 /* Optional resource_source (Index and String) */
158 {ACPI_RSC_SOURCE, ACPI_RS_OFFSET(data.address64.resource_source),
160 sizeof(struct aml_resource_address64)}
163 /*******************************************************************************
165 * acpi_rs_convert_ext_address64 - All Extended (64-bit) address resources
167 ******************************************************************************/
169 struct acpi_rsconvert_info acpi_rs_convert_ext_address64[5] = {
170 {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64,
171 ACPI_RS_SIZE(struct acpi_resource_extended_address64),
172 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_ext_address64)},
174 {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64,
175 sizeof(struct aml_resource_extended_address64),
178 /* Resource Type, General Flags, and Type-Specific Flags */
180 {ACPI_RSC_ADDRESS, 0, 0, 0},
182 /* Revision ID */
184 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.ext_address64.revision_iD),
185 AML_OFFSET(ext_address64.revision_iD),
188 * These fields are contiguous in both the source and destination:
189 * Address Granularity
190 * Address Range Minimum
191 * Address Range Maximum
192 * Address Translation Offset
193 * Address Length
194 * Type-Specific Attribute
196 {ACPI_RSC_MOVE64, ACPI_RS_OFFSET(data.ext_address64.granularity),
197 AML_OFFSET(ext_address64.granularity),
201 /*******************************************************************************
203 * acpi_rs_convert_general_flags - Flags common to all address descriptors
205 ******************************************************************************/
207 static struct acpi_rsconvert_info acpi_rs_convert_general_flags[6] = {
208 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.flags),
209 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_general_flags)},
211 /* Resource Type (Memory, Io, bus_number, etc.) */
213 {ACPI_RSC_MOVE8, ACPI_RS_OFFSET(data.address.resource_type),
214 AML_OFFSET(address.resource_type),
217 /* General Flags - Consume, Decode, min_fixed, max_fixed */
219 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.producer_consumer),
220 AML_OFFSET(address.flags),
223 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.decode),
224 AML_OFFSET(address.flags),
227 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.min_address_fixed),
228 AML_OFFSET(address.flags),
231 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.max_address_fixed),
232 AML_OFFSET(address.flags),
236 /*******************************************************************************
238 * acpi_rs_convert_mem_flags - Flags common to Memory address descriptors
240 ******************************************************************************/
242 static struct acpi_rsconvert_info acpi_rs_convert_mem_flags[5] = {
243 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
244 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_mem_flags)},
246 /* Memory-specific flags */
248 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.write_protect),
249 AML_OFFSET(address.specific_flags),
252 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.caching),
253 AML_OFFSET(address.specific_flags),
256 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.range_type),
257 AML_OFFSET(address.specific_flags),
260 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.mem.translation),
261 AML_OFFSET(address.specific_flags),
265 /*******************************************************************************
267 * acpi_rs_convert_io_flags - Flags common to I/O address descriptors
269 ******************************************************************************/
271 static struct acpi_rsconvert_info acpi_rs_convert_io_flags[4] = {
272 {ACPI_RSC_FLAGINIT, 0, AML_OFFSET(address.specific_flags),
273 ACPI_RSC_TABLE_SIZE(acpi_rs_convert_io_flags)},
275 /* I/O-specific flags */
277 {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET(data.address.info.io.range_type),
278 AML_OFFSET(address.specific_flags),
281 {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET(data.address.info.io.translation),
282 AML_OFFSET(address.specific_flags),
285 {ACPI_RSC_1BITFLAG,
286 ACPI_RS_OFFSET(data.address.info.io.translation_type),
287 AML_OFFSET(address.specific_flags),
291 /*******************************************************************************
293 * FUNCTION: acpi_rs_get_address_common
295 * PARAMETERS: Resource - Pointer to the internal resource struct
296 * Aml - Pointer to the AML resource descriptor
298 * RETURN: TRUE if the resource_type field is OK, FALSE otherwise
300 * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor
301 * to an internal resource descriptor
303 ******************************************************************************/
306 acpi_rs_get_address_common(struct acpi_resource *resource,
307 union aml_resource *aml)
309 ACPI_FUNCTION_ENTRY();
311 /* Validate the Resource Type */
313 if ((aml->address.resource_type > 2)
314 && (aml->address.resource_type < 0xC0)) {
315 return (FALSE);
318 /* Get the Resource Type and General Flags */
320 (void)acpi_rs_convert_aml_to_resource(resource, aml,
321 acpi_rs_convert_general_flags);
323 /* Get the Type-Specific Flags (Memory and I/O descriptors only) */
325 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
326 (void)acpi_rs_convert_aml_to_resource(resource, aml,
327 acpi_rs_convert_mem_flags);
328 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
329 (void)acpi_rs_convert_aml_to_resource(resource, aml,
330 acpi_rs_convert_io_flags);
331 } else {
332 /* Generic resource type, just grab the type_specific byte */
334 resource->data.address.info.type_specific =
335 aml->address.specific_flags;
338 return (TRUE);
341 /*******************************************************************************
343 * FUNCTION: acpi_rs_set_address_common
345 * PARAMETERS: Aml - Pointer to the AML resource descriptor
346 * Resource - Pointer to the internal resource struct
348 * RETURN: None
350 * DESCRIPTION: Convert common flag fields from a resource descriptor to an
351 * AML descriptor
353 ******************************************************************************/
355 void
356 acpi_rs_set_address_common(union aml_resource *aml,
357 struct acpi_resource *resource)
359 ACPI_FUNCTION_ENTRY();
361 /* Set the Resource Type and General Flags */
363 (void)acpi_rs_convert_resource_to_aml(resource, aml,
364 acpi_rs_convert_general_flags);
366 /* Set the Type-Specific Flags (Memory and I/O descriptors only) */
368 if (resource->data.address.resource_type == ACPI_MEMORY_RANGE) {
369 (void)acpi_rs_convert_resource_to_aml(resource, aml,
370 acpi_rs_convert_mem_flags);
371 } else if (resource->data.address.resource_type == ACPI_IO_RANGE) {
372 (void)acpi_rs_convert_resource_to_aml(resource, aml,
373 acpi_rs_convert_io_flags);
374 } else {
375 /* Generic resource type, just copy the type_specific byte */
377 aml->address.specific_flags =
378 resource->data.address.info.type_specific;