aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/utresrc.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/acpi/acpica/utresrc.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/acpi/acpica/utresrc.c')
-rw-r--r--drivers/acpi/acpica/utresrc.c292
1 files changed, 42 insertions, 250 deletions
diff --git a/drivers/acpi/acpica/utresrc.c b/drivers/acpi/acpica/utresrc.c
index e38bef4980b..6ffd3a8bdaa 100644
--- a/drivers/acpi/acpica/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -5,7 +5,7 @@
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
7/* 7/*
8 * Copyright (C) 2000 - 2012, Intel Corp. 8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved. 9 * All rights reserved.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "acresrc.h" 46#include "amlresrc.h"
47 47
48#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utresrc") 49ACPI_MODULE_NAME("utresrc")
@@ -154,138 +154,6 @@ const char *acpi_gbl_typ_decode[] = {
154 "TypeF" 154 "TypeF"
155}; 155};
156 156
157const char *acpi_gbl_ppc_decode[] = {
158 "PullDefault",
159 "PullUp",
160 "PullDown",
161 "PullNone"
162};
163
164const char *acpi_gbl_ior_decode[] = {
165 "IoRestrictionNone",
166 "IoRestrictionInputOnly",
167 "IoRestrictionOutputOnly",
168 "IoRestrictionNoneAndPreserve"
169};
170
171const char *acpi_gbl_dts_decode[] = {
172 "Width8bit",
173 "Width16bit",
174 "Width32bit",
175 "Width64bit",
176 "Width128bit",
177 "Width256bit",
178};
179
180/* GPIO connection type */
181
182const char *acpi_gbl_ct_decode[] = {
183 "Interrupt",
184 "I/O"
185};
186
187/* Serial bus type */
188
189const char *acpi_gbl_sbt_decode[] = {
190 "/* UNKNOWN serial bus type */",
191 "I2C",
192 "SPI",
193 "UART"
194};
195
196/* I2C serial bus access mode */
197
198const char *acpi_gbl_am_decode[] = {
199 "AddressingMode7Bit",
200 "AddressingMode10Bit"
201};
202
203/* I2C serial bus slave mode */
204
205const char *acpi_gbl_sm_decode[] = {
206 "ControllerInitiated",
207 "DeviceInitiated"
208};
209
210/* SPI serial bus wire mode */
211
212const char *acpi_gbl_wm_decode[] = {
213 "FourWireMode",
214 "ThreeWireMode"
215};
216
217/* SPI serial clock phase */
218
219const char *acpi_gbl_cph_decode[] = {
220 "ClockPhaseFirst",
221 "ClockPhaseSecond"
222};
223
224/* SPI serial bus clock polarity */
225
226const char *acpi_gbl_cpo_decode[] = {
227 "ClockPolarityLow",
228 "ClockPolarityHigh"
229};
230
231/* SPI serial bus device polarity */
232
233const char *acpi_gbl_dp_decode[] = {
234 "PolarityLow",
235 "PolarityHigh"
236};
237
238/* UART serial bus endian */
239
240const char *acpi_gbl_ed_decode[] = {
241 "LittleEndian",
242 "BigEndian"
243};
244
245/* UART serial bus bits per byte */
246
247const char *acpi_gbl_bpb_decode[] = {
248 "DataBitsFive",
249 "DataBitsSix",
250 "DataBitsSeven",
251 "DataBitsEight",
252 "DataBitsNine",
253 "/* UNKNOWN Bits per byte */",
254 "/* UNKNOWN Bits per byte */",
255 "/* UNKNOWN Bits per byte */"
256};
257
258/* UART serial bus stop bits */
259
260const char *acpi_gbl_sb_decode[] = {
261 "StopBitsNone",
262 "StopBitsOne",
263 "StopBitsOnePlusHalf",
264 "StopBitsTwo"
265};
266
267/* UART serial bus flow control */
268
269const char *acpi_gbl_fc_decode[] = {
270 "FlowControlNone",
271 "FlowControlHardware",
272 "FlowControlXON",
273 "/* UNKNOWN flow control keyword */"
274};
275
276/* UART serial bus parity type */
277
278const char *acpi_gbl_pt_decode[] = {
279 "ParityTypeNone",
280 "ParityTypeEven",
281 "ParityTypeOdd",
282 "ParityTypeMark",
283 "ParityTypeSpace",
284 "/* UNKNOWN parity keyword */",
285 "/* UNKNOWN parity keyword */",
286 "/* UNKNOWN parity keyword */"
287};
288
289#endif 157#endif
290 158
291/* 159/*
@@ -305,7 +173,7 @@ const u8 acpi_gbl_resource_aml_sizes[] = {
305 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent), 173 ACPI_AML_SIZE_SMALL(struct aml_resource_end_dependent),
306 ACPI_AML_SIZE_SMALL(struct aml_resource_io), 174 ACPI_AML_SIZE_SMALL(struct aml_resource_io),
307 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io), 175 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_io),
308 ACPI_AML_SIZE_SMALL(struct aml_resource_fixed_dma), 176 0,
309 0, 177 0,
310 0, 178 0,
311 0, 179 0,
@@ -325,17 +193,7 @@ const u8 acpi_gbl_resource_aml_sizes[] = {
325 ACPI_AML_SIZE_LARGE(struct aml_resource_address16), 193 ACPI_AML_SIZE_LARGE(struct aml_resource_address16),
326 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq), 194 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_irq),
327 ACPI_AML_SIZE_LARGE(struct aml_resource_address64), 195 ACPI_AML_SIZE_LARGE(struct aml_resource_address64),
328 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64), 196 ACPI_AML_SIZE_LARGE(struct aml_resource_extended_address64)
329 ACPI_AML_SIZE_LARGE(struct aml_resource_gpio),
330 0,
331 ACPI_AML_SIZE_LARGE(struct aml_resource_common_serialbus),
332};
333
334const u8 acpi_gbl_resource_aml_serial_bus_sizes[] = {
335 0,
336 ACPI_AML_SIZE_LARGE(struct aml_resource_i2c_serialbus),
337 ACPI_AML_SIZE_LARGE(struct aml_resource_spi_serialbus),
338 ACPI_AML_SIZE_LARGE(struct aml_resource_uart_serialbus),
339}; 197};
340 198
341/* 199/*
@@ -351,58 +209,44 @@ static const u8 acpi_gbl_resource_types[] = {
351 0, 209 0,
352 0, 210 0,
353 0, 211 0,
354 ACPI_SMALL_VARIABLE_LENGTH, /* 04 IRQ */ 212 ACPI_SMALL_VARIABLE_LENGTH,
355 ACPI_FIXED_LENGTH, /* 05 DMA */ 213 ACPI_FIXED_LENGTH,
356 ACPI_SMALL_VARIABLE_LENGTH, /* 06 start_dependent_functions */ 214 ACPI_SMALL_VARIABLE_LENGTH,
357 ACPI_FIXED_LENGTH, /* 07 end_dependent_functions */ 215 ACPI_FIXED_LENGTH,
358 ACPI_FIXED_LENGTH, /* 08 IO */ 216 ACPI_FIXED_LENGTH,
359 ACPI_FIXED_LENGTH, /* 09 fixed_IO */ 217 ACPI_FIXED_LENGTH,
360 ACPI_FIXED_LENGTH, /* 0A fixed_DMA */ 218 0,
361 0, 219 0,
362 0, 220 0,
363 0, 221 0,
364 ACPI_VARIABLE_LENGTH, /* 0E vendor_short */ 222 ACPI_VARIABLE_LENGTH,
365 ACPI_FIXED_LENGTH, /* 0F end_tag */ 223 ACPI_FIXED_LENGTH,
366 224
367 /* Large descriptors */ 225 /* Large descriptors */
368 226
369 0, 227 0,
370 ACPI_FIXED_LENGTH, /* 01 Memory24 */ 228 ACPI_FIXED_LENGTH,
371 ACPI_FIXED_LENGTH, /* 02 generic_register */ 229 ACPI_FIXED_LENGTH,
372 0, 230 0,
373 ACPI_VARIABLE_LENGTH, /* 04 vendor_long */ 231 ACPI_VARIABLE_LENGTH,
374 ACPI_FIXED_LENGTH, /* 05 Memory32 */ 232 ACPI_FIXED_LENGTH,
375 ACPI_FIXED_LENGTH, /* 06 memory32_fixed */ 233 ACPI_FIXED_LENGTH,
376 ACPI_VARIABLE_LENGTH, /* 07 Dword* address */ 234 ACPI_VARIABLE_LENGTH,
377 ACPI_VARIABLE_LENGTH, /* 08 Word* address */ 235 ACPI_VARIABLE_LENGTH,
378 ACPI_VARIABLE_LENGTH, /* 09 extended_IRQ */ 236 ACPI_VARIABLE_LENGTH,
379 ACPI_VARIABLE_LENGTH, /* 0A Qword* address */ 237 ACPI_VARIABLE_LENGTH,
380 ACPI_FIXED_LENGTH, /* 0B Extended* address */ 238 ACPI_FIXED_LENGTH
381 ACPI_VARIABLE_LENGTH, /* 0C Gpio* */
382 0,
383 ACPI_VARIABLE_LENGTH /* 0E *serial_bus */
384}; 239};
385 240
386/*
387 * For the iASL compiler/disassembler, we don't want any error messages
388 * because the disassembler uses the resource validation code to determine
389 * if Buffer objects are actually Resource Templates.
390 */
391#ifdef ACPI_ASL_COMPILER
392#define ACPI_RESOURCE_ERROR(plist)
393#else
394#define ACPI_RESOURCE_ERROR(plist) ACPI_ERROR(plist)
395#endif
396
397/******************************************************************************* 241/*******************************************************************************
398 * 242 *
399 * FUNCTION: acpi_ut_walk_aml_resources 243 * FUNCTION: acpi_ut_walk_aml_resources
400 * 244 *
401 * PARAMETERS: aml - Pointer to the raw AML resource template 245 * PARAMETERS: Aml - Pointer to the raw AML resource template
402 * aml_length - Length of the entire template 246 * aml_length - Length of the entire template
403 * user_function - Called once for each descriptor found. If 247 * user_function - Called once for each descriptor found. If
404 * NULL, a pointer to the end_tag is returned 248 * NULL, a pointer to the end_tag is returned
405 * context - Passed to user_function 249 * Context - Passed to user_function
406 * 250 *
407 * RETURN: Status 251 * RETURN: Status
408 * 252 *
@@ -421,7 +265,6 @@ acpi_ut_walk_aml_resources(u8 * aml,
421 u8 resource_index; 265 u8 resource_index;
422 u32 length; 266 u32 length;
423 u32 offset = 0; 267 u32 offset = 0;
424 u8 end_tag[2] = { 0x79, 0x00 };
425 268
426 ACPI_FUNCTION_TRACE(ut_walk_aml_resources); 269 ACPI_FUNCTION_TRACE(ut_walk_aml_resources);
427 270
@@ -443,10 +286,6 @@ acpi_ut_walk_aml_resources(u8 * aml,
443 286
444 status = acpi_ut_validate_resource(aml, &resource_index); 287 status = acpi_ut_validate_resource(aml, &resource_index);
445 if (ACPI_FAILURE(status)) { 288 if (ACPI_FAILURE(status)) {
446 /*
447 * Exit on failure. Cannot continue because the descriptor length
448 * may be bogus also.
449 */
450 return_ACPI_STATUS(status); 289 return_ACPI_STATUS(status);
451 } 290 }
452 291
@@ -461,7 +300,7 @@ acpi_ut_walk_aml_resources(u8 * aml,
461 user_function(aml, length, offset, resource_index, 300 user_function(aml, length, offset, resource_index,
462 context); 301 context);
463 if (ACPI_FAILURE(status)) { 302 if (ACPI_FAILURE(status)) {
464 return_ACPI_STATUS(status); 303 return (status);
465 } 304 }
466 } 305 }
467 306
@@ -494,26 +333,14 @@ acpi_ut_walk_aml_resources(u8 * aml,
494 333
495 /* Did not find an end_tag descriptor */ 334 /* Did not find an end_tag descriptor */
496 335
497 if (user_function) { 336 return (AE_AML_NO_RESOURCE_END_TAG);
498
499 /* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */
500
501 (void)acpi_ut_validate_resource(end_tag, &resource_index);
502 status =
503 user_function(end_tag, 2, offset, resource_index, context);
504 if (ACPI_FAILURE(status)) {
505 return_ACPI_STATUS(status);
506 }
507 }
508
509 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
510} 337}
511 338
512/******************************************************************************* 339/*******************************************************************************
513 * 340 *
514 * FUNCTION: acpi_ut_validate_resource 341 * FUNCTION: acpi_ut_validate_resource
515 * 342 *
516 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 343 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
517 * return_index - Where the resource index is returned. NULL 344 * return_index - Where the resource index is returned. NULL
518 * if the index is not required. 345 * if the index is not required.
519 * 346 *
@@ -527,7 +354,6 @@ acpi_ut_walk_aml_resources(u8 * aml,
527 354
528acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index) 355acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
529{ 356{
530 union aml_resource *aml_resource;
531 u8 resource_type; 357 u8 resource_type;
532 u8 resource_index; 358 u8 resource_index;
533 acpi_rs_length resource_length; 359 acpi_rs_length resource_length;
@@ -549,7 +375,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
549 /* Verify the large resource type (name) against the max */ 375 /* Verify the large resource type (name) against the max */
550 376
551 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) { 377 if (resource_type > ACPI_RESOURCE_NAME_LARGE_MAX) {
552 goto invalid_resource; 378 return (AE_AML_INVALID_RESOURCE_TYPE);
553 } 379 }
554 380
555 /* 381 /*
@@ -566,17 +392,15 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
566 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); 392 ((resource_type & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3);
567 } 393 }
568 394
569 /* 395 /* Check validity of the resource type, zero indicates name is invalid */
570 * Check validity of the resource type, via acpi_gbl_resource_types. Zero 396
571 * indicates an invalid resource.
572 */
573 if (!acpi_gbl_resource_types[resource_index]) { 397 if (!acpi_gbl_resource_types[resource_index]) {
574 goto invalid_resource; 398 return (AE_AML_INVALID_RESOURCE_TYPE);
575 } 399 }
576 400
577 /* 401 /*
578 * Validate the resource_length field. This ensures that the length 402 * 2) Validate the resource_length field. This ensures that the length
579 * is at least reasonable, and guarantees that it is non-zero. 403 * is at least reasonable, and guarantees that it is non-zero.
580 */ 404 */
581 resource_length = acpi_ut_get_resource_length(aml); 405 resource_length = acpi_ut_get_resource_length(aml);
582 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index]; 406 minimum_resource_length = acpi_gbl_resource_aml_sizes[resource_index];
@@ -589,7 +413,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
589 /* Fixed length resource, length must match exactly */ 413 /* Fixed length resource, length must match exactly */
590 414
591 if (resource_length != minimum_resource_length) { 415 if (resource_length != minimum_resource_length) {
592 goto bad_resource_length; 416 return (AE_AML_BAD_RESOURCE_LENGTH);
593 } 417 }
594 break; 418 break;
595 419
@@ -598,7 +422,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
598 /* Variable length resource, length must be at least the minimum */ 422 /* Variable length resource, length must be at least the minimum */
599 423
600 if (resource_length < minimum_resource_length) { 424 if (resource_length < minimum_resource_length) {
601 goto bad_resource_length; 425 return (AE_AML_BAD_RESOURCE_LENGTH);
602 } 426 }
603 break; 427 break;
604 428
@@ -608,7 +432,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
608 432
609 if ((resource_length > minimum_resource_length) || 433 if ((resource_length > minimum_resource_length) ||
610 (resource_length < (minimum_resource_length - 1))) { 434 (resource_length < (minimum_resource_length - 1))) {
611 goto bad_resource_length; 435 return (AE_AML_BAD_RESOURCE_LENGTH);
612 } 436 }
613 break; 437 break;
614 438
@@ -616,23 +440,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
616 440
617 /* Shouldn't happen (because of validation earlier), but be sure */ 441 /* Shouldn't happen (because of validation earlier), but be sure */
618 442
619 goto invalid_resource; 443 return (AE_AML_INVALID_RESOURCE_TYPE);
620 }
621
622 aml_resource = ACPI_CAST_PTR(union aml_resource, aml);
623 if (resource_type == ACPI_RESOURCE_NAME_SERIAL_BUS) {
624
625 /* Validate the bus_type field */
626
627 if ((aml_resource->common_serial_bus.type == 0) ||
628 (aml_resource->common_serial_bus.type >
629 AML_RESOURCE_MAX_SERIALBUSTYPE)) {
630 ACPI_RESOURCE_ERROR((AE_INFO,
631 "Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
632 aml_resource->common_serial_bus.
633 type));
634 return (AE_AML_INVALID_RESOURCE_TYPE);
635 }
636 } 444 }
637 445
638 /* Optionally return the resource table index */ 446 /* Optionally return the resource table index */
@@ -642,29 +450,13 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
642 } 450 }
643 451
644 return (AE_OK); 452 return (AE_OK);
645
646 invalid_resource:
647
648 ACPI_RESOURCE_ERROR((AE_INFO,
649 "Invalid/unsupported resource descriptor: Type 0x%2.2X",
650 resource_type));
651 return (AE_AML_INVALID_RESOURCE_TYPE);
652
653 bad_resource_length:
654
655 ACPI_RESOURCE_ERROR((AE_INFO,
656 "Invalid resource descriptor length: Type "
657 "0x%2.2X, Length 0x%4.4X, MinLength 0x%4.4X",
658 resource_type, resource_length,
659 minimum_resource_length));
660 return (AE_AML_BAD_RESOURCE_LENGTH);
661} 453}
662 454
663/******************************************************************************* 455/*******************************************************************************
664 * 456 *
665 * FUNCTION: acpi_ut_get_resource_type 457 * FUNCTION: acpi_ut_get_resource_type
666 * 458 *
667 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 459 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
668 * 460 *
669 * RETURN: The Resource Type with no extraneous bits (except the 461 * RETURN: The Resource Type with no extraneous bits (except the
670 * Large/Small descriptor bit -- this is left alone) 462 * Large/Small descriptor bit -- this is left alone)
@@ -698,7 +490,7 @@ u8 acpi_ut_get_resource_type(void *aml)
698 * 490 *
699 * FUNCTION: acpi_ut_get_resource_length 491 * FUNCTION: acpi_ut_get_resource_length
700 * 492 *
701 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 493 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
702 * 494 *
703 * RETURN: Byte Length 495 * RETURN: Byte Length
704 * 496 *
@@ -738,7 +530,7 @@ u16 acpi_ut_get_resource_length(void *aml)
738 * 530 *
739 * FUNCTION: acpi_ut_get_resource_header_length 531 * FUNCTION: acpi_ut_get_resource_header_length
740 * 532 *
741 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 533 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
742 * 534 *
743 * RETURN: Length of the AML header (depends on large/small descriptor) 535 * RETURN: Length of the AML header (depends on large/small descriptor)
744 * 536 *
@@ -763,7 +555,7 @@ u8 acpi_ut_get_resource_header_length(void *aml)
763 * 555 *
764 * FUNCTION: acpi_ut_get_descriptor_length 556 * FUNCTION: acpi_ut_get_descriptor_length
765 * 557 *
766 * PARAMETERS: aml - Pointer to the raw AML resource descriptor 558 * PARAMETERS: Aml - Pointer to the raw AML resource descriptor
767 * 559 *
768 * RETURN: Byte length 560 * RETURN: Byte length
769 * 561 *