aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/hardware/hwregs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/hardware/hwregs.c')
-rw-r--r--drivers/acpi/hardware/hwregs.c89
1 files changed, 35 insertions, 54 deletions
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index 1d371fa663f2..73f9c5fb1ba7 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -75,8 +75,7 @@ acpi_status acpi_hw_clear_acpi_status(void)
75 75
76 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); 76 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
77 77
78 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, 78 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
79 ACPI_REGISTER_PM1_STATUS,
80 ACPI_BITMASK_ALL_FIXED_STATUS); 79 ACPI_BITMASK_ALL_FIXED_STATUS);
81 if (ACPI_FAILURE(status)) { 80 if (ACPI_FAILURE(status)) {
82 goto unlock_and_exit; 81 goto unlock_and_exit;
@@ -259,7 +258,7 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
259 * 258 *
260 ******************************************************************************/ 259 ******************************************************************************/
261 260
262acpi_status acpi_get_register(u32 register_id, u32 * return_value) 261acpi_status acpi_get_register_unlocked(u32 register_id, u32 * return_value)
263{ 262{
264 u32 register_value = 0; 263 u32 register_value = 0;
265 struct acpi_bit_register_info *bit_reg_info; 264 struct acpi_bit_register_info *bit_reg_info;
@@ -276,8 +275,7 @@ acpi_status acpi_get_register(u32 register_id, u32 * return_value)
276 275
277 /* Read from the register */ 276 /* Read from the register */
278 277
279 status = acpi_hw_register_read(ACPI_MTX_LOCK, 278 status = acpi_hw_register_read(bit_reg_info->parent_register,
280 bit_reg_info->parent_register,
281 &register_value); 279 &register_value);
282 280
283 if (ACPI_SUCCESS(status)) { 281 if (ACPI_SUCCESS(status)) {
@@ -298,6 +296,16 @@ acpi_status acpi_get_register(u32 register_id, u32 * return_value)
298 return_ACPI_STATUS(status); 296 return_ACPI_STATUS(status);
299} 297}
300 298
299acpi_status acpi_get_register(u32 register_id, u32 * return_value)
300{
301 acpi_status status;
302 acpi_cpu_flags flags;
303 flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
304 status = acpi_get_register_unlocked(register_id, return_value);
305 acpi_os_release_lock(acpi_gbl_hardware_lock, flags);
306 return status;
307}
308
301ACPI_EXPORT_SYMBOL(acpi_get_register) 309ACPI_EXPORT_SYMBOL(acpi_get_register)
302 310
303/******************************************************************************* 311/*******************************************************************************
@@ -335,8 +343,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
335 343
336 /* Always do a register read first so we can insert the new bits */ 344 /* Always do a register read first so we can insert the new bits */
337 345
338 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, 346 status = acpi_hw_register_read(bit_reg_info->parent_register,
339 bit_reg_info->parent_register,
340 &register_value); 347 &register_value);
341 if (ACPI_FAILURE(status)) { 348 if (ACPI_FAILURE(status)) {
342 goto unlock_and_exit; 349 goto unlock_and_exit;
@@ -363,8 +370,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
363 bit_reg_info-> 370 bit_reg_info->
364 access_bit_mask); 371 access_bit_mask);
365 if (value) { 372 if (value) {
366 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, 373 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
367 ACPI_REGISTER_PM1_STATUS,
368 (u16) value); 374 (u16) value);
369 register_value = 0; 375 register_value = 0;
370 } 376 }
@@ -377,8 +383,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
377 bit_reg_info->access_bit_mask, 383 bit_reg_info->access_bit_mask,
378 value); 384 value);
379 385
380 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, 386 status = acpi_hw_register_write(ACPI_REGISTER_PM1_ENABLE,
381 ACPI_REGISTER_PM1_ENABLE,
382 (u16) register_value); 387 (u16) register_value);
383 break; 388 break;
384 389
@@ -397,15 +402,13 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
397 bit_reg_info->access_bit_mask, 402 bit_reg_info->access_bit_mask,
398 value); 403 value);
399 404
400 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, 405 status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
401 ACPI_REGISTER_PM1_CONTROL,
402 (u16) register_value); 406 (u16) register_value);
403 break; 407 break;
404 408
405 case ACPI_REGISTER_PM2_CONTROL: 409 case ACPI_REGISTER_PM2_CONTROL:
406 410
407 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, 411 status = acpi_hw_register_read(ACPI_REGISTER_PM2_CONTROL,
408 ACPI_REGISTER_PM2_CONTROL,
409 &register_value); 412 &register_value);
410 if (ACPI_FAILURE(status)) { 413 if (ACPI_FAILURE(status)) {
411 goto unlock_and_exit; 414 goto unlock_and_exit;
@@ -430,8 +433,7 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
430 xpm2_control_block. 433 xpm2_control_block.
431 address))); 434 address)));
432 435
433 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, 436 status = acpi_hw_register_write(ACPI_REGISTER_PM2_CONTROL,
434 ACPI_REGISTER_PM2_CONTROL,
435 (u8) (register_value)); 437 (u8) (register_value));
436 break; 438 break;
437 439
@@ -461,8 +463,7 @@ ACPI_EXPORT_SYMBOL(acpi_set_register)
461 * 463 *
462 * FUNCTION: acpi_hw_register_read 464 * FUNCTION: acpi_hw_register_read
463 * 465 *
464 * PARAMETERS: use_lock - Lock hardware? True/False 466 * PARAMETERS: register_id - ACPI Register ID
465 * register_id - ACPI Register ID
466 * return_value - Where the register value is returned 467 * return_value - Where the register value is returned
467 * 468 *
468 * RETURN: Status and the value read. 469 * RETURN: Status and the value read.
@@ -471,19 +472,14 @@ ACPI_EXPORT_SYMBOL(acpi_set_register)
471 * 472 *
472 ******************************************************************************/ 473 ******************************************************************************/
473acpi_status 474acpi_status
474acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value) 475acpi_hw_register_read(u32 register_id, u32 * return_value)
475{ 476{
476 u32 value1 = 0; 477 u32 value1 = 0;
477 u32 value2 = 0; 478 u32 value2 = 0;
478 acpi_status status; 479 acpi_status status;
479 acpi_cpu_flags lock_flags = 0;
480 480
481 ACPI_FUNCTION_TRACE(hw_register_read); 481 ACPI_FUNCTION_TRACE(hw_register_read);
482 482
483 if (ACPI_MTX_LOCK == use_lock) {
484 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
485 }
486
487 switch (register_id) { 483 switch (register_id) {
488 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 484 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
489 485
@@ -491,7 +487,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
491 acpi_hw_low_level_read(16, &value1, 487 acpi_hw_low_level_read(16, &value1,
492 &acpi_gbl_FADT.xpm1a_event_block); 488 &acpi_gbl_FADT.xpm1a_event_block);
493 if (ACPI_FAILURE(status)) { 489 if (ACPI_FAILURE(status)) {
494 goto unlock_and_exit; 490 goto exit;
495 } 491 }
496 492
497 /* PM1B is optional */ 493 /* PM1B is optional */
@@ -507,7 +503,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
507 status = 503 status =
508 acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable); 504 acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable);
509 if (ACPI_FAILURE(status)) { 505 if (ACPI_FAILURE(status)) {
510 goto unlock_and_exit; 506 goto exit;
511 } 507 }
512 508
513 /* PM1B is optional */ 509 /* PM1B is optional */
@@ -523,7 +519,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
523 acpi_hw_low_level_read(16, &value1, 519 acpi_hw_low_level_read(16, &value1,
524 &acpi_gbl_FADT.xpm1a_control_block); 520 &acpi_gbl_FADT.xpm1a_control_block);
525 if (ACPI_FAILURE(status)) { 521 if (ACPI_FAILURE(status)) {
526 goto unlock_and_exit; 522 goto exit;
527 } 523 }
528 524
529 status = 525 status =
@@ -558,10 +554,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
558 break; 554 break;
559 } 555 }
560 556
561 unlock_and_exit: 557 exit:
562 if (ACPI_MTX_LOCK == use_lock) {
563 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
564 }
565 558
566 if (ACPI_SUCCESS(status)) { 559 if (ACPI_SUCCESS(status)) {
567 *return_value = value1; 560 *return_value = value1;
@@ -574,8 +567,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
574 * 567 *
575 * FUNCTION: acpi_hw_register_write 568 * FUNCTION: acpi_hw_register_write
576 * 569 *
577 * PARAMETERS: use_lock - Lock hardware? True/False 570 * PARAMETERS: register_id - ACPI Register ID
578 * register_id - ACPI Register ID
579 * Value - The value to write 571 * Value - The value to write
580 * 572 *
581 * RETURN: Status 573 * RETURN: Status
@@ -597,28 +589,22 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
597 * 589 *
598 ******************************************************************************/ 590 ******************************************************************************/
599 591
600acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value) 592acpi_status acpi_hw_register_write(u32 register_id, u32 value)
601{ 593{
602 acpi_status status; 594 acpi_status status;
603 acpi_cpu_flags lock_flags = 0;
604 u32 read_value; 595 u32 read_value;
605 596
606 ACPI_FUNCTION_TRACE(hw_register_write); 597 ACPI_FUNCTION_TRACE(hw_register_write);
607 598
608 if (ACPI_MTX_LOCK == use_lock) {
609 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
610 }
611
612 switch (register_id) { 599 switch (register_id) {
613 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 600 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
614 601
615 /* Perform a read first to preserve certain bits (per ACPI spec) */ 602 /* Perform a read first to preserve certain bits (per ACPI spec) */
616 603
617 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, 604 status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS,
618 ACPI_REGISTER_PM1_STATUS,
619 &read_value); 605 &read_value);
620 if (ACPI_FAILURE(status)) { 606 if (ACPI_FAILURE(status)) {
621 goto unlock_and_exit; 607 goto exit;
622 } 608 }
623 609
624 /* Insert the bits to be preserved */ 610 /* Insert the bits to be preserved */
@@ -632,7 +618,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
632 acpi_hw_low_level_write(16, value, 618 acpi_hw_low_level_write(16, value,
633 &acpi_gbl_FADT.xpm1a_event_block); 619 &acpi_gbl_FADT.xpm1a_event_block);
634 if (ACPI_FAILURE(status)) { 620 if (ACPI_FAILURE(status)) {
635 goto unlock_and_exit; 621 goto exit;
636 } 622 }
637 623
638 /* PM1B is optional */ 624 /* PM1B is optional */
@@ -647,7 +633,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
647 status = 633 status =
648 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable); 634 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable);
649 if (ACPI_FAILURE(status)) { 635 if (ACPI_FAILURE(status)) {
650 goto unlock_and_exit; 636 goto exit;
651 } 637 }
652 638
653 /* PM1B is optional */ 639 /* PM1B is optional */
@@ -661,11 +647,10 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
661 /* 647 /*
662 * Perform a read first to preserve certain bits (per ACPI spec) 648 * Perform a read first to preserve certain bits (per ACPI spec)
663 */ 649 */
664 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, 650 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
665 ACPI_REGISTER_PM1_CONTROL,
666 &read_value); 651 &read_value);
667 if (ACPI_FAILURE(status)) { 652 if (ACPI_FAILURE(status)) {
668 goto unlock_and_exit; 653 goto exit;
669 } 654 }
670 655
671 /* Insert the bits to be preserved */ 656 /* Insert the bits to be preserved */
@@ -679,7 +664,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
679 acpi_hw_low_level_write(16, value, 664 acpi_hw_low_level_write(16, value,
680 &acpi_gbl_FADT.xpm1a_control_block); 665 &acpi_gbl_FADT.xpm1a_control_block);
681 if (ACPI_FAILURE(status)) { 666 if (ACPI_FAILURE(status)) {
682 goto unlock_and_exit; 667 goto exit;
683 } 668 }
684 669
685 status = 670 status =
@@ -728,11 +713,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
728 break; 713 break;
729 } 714 }
730 715
731 unlock_and_exit: 716 exit:
732 if (ACPI_MTX_LOCK == use_lock) {
733 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
734 }
735
736 return_ACPI_STATUS(status); 717 return_ACPI_STATUS(status);
737} 718}
738 719