diff options
Diffstat (limited to 'drivers/acpi/hardware/hwregs.c')
-rw-r--r-- | drivers/acpi/hardware/hwregs.c | 117 |
1 files changed, 53 insertions, 64 deletions
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c index 69dc8b45d76c..d6d2ec6969f4 100644 --- a/drivers/acpi/hardware/hwregs.c +++ b/drivers/acpi/hardware/hwregs.c | |||
@@ -84,9 +84,8 @@ acpi_status acpi_hw_clear_acpi_status(void) | |||
84 | /* Clear the fixed events */ | 84 | /* Clear the fixed events */ |
85 | 85 | ||
86 | if (acpi_gbl_FADT.xpm1b_event_block.address) { | 86 | if (acpi_gbl_FADT.xpm1b_event_block.address) { |
87 | status = | 87 | status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS, |
88 | acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS, | 88 | &acpi_gbl_FADT.xpm1b_event_block); |
89 | &acpi_gbl_FADT.xpm1b_event_block); | ||
90 | if (ACPI_FAILURE(status)) { | 89 | if (ACPI_FAILURE(status)) { |
91 | goto unlock_and_exit; | 90 | goto unlock_and_exit; |
92 | } | 91 | } |
@@ -244,6 +243,8 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) | |||
244 | return (&acpi_gbl_bit_register_info[register_id]); | 243 | return (&acpi_gbl_bit_register_info[register_id]); |
245 | } | 244 | } |
246 | 245 | ||
246 | ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked) | ||
247 | |||
247 | /******************************************************************************* | 248 | /******************************************************************************* |
248 | * | 249 | * |
249 | * FUNCTION: acpi_get_register | 250 | * FUNCTION: acpi_get_register |
@@ -483,63 +484,49 @@ acpi_hw_register_read(u32 register_id, u32 * return_value) | |||
483 | switch (register_id) { | 484 | switch (register_id) { |
484 | case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ | 485 | case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ |
485 | 486 | ||
486 | status = | 487 | status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_event_block); |
487 | acpi_hw_low_level_read(16, &value1, | ||
488 | &acpi_gbl_FADT.xpm1a_event_block); | ||
489 | if (ACPI_FAILURE(status)) { | 488 | if (ACPI_FAILURE(status)) { |
490 | goto exit; | 489 | goto exit; |
491 | } | 490 | } |
492 | 491 | ||
493 | /* PM1B is optional */ | 492 | /* PM1B is optional */ |
494 | 493 | ||
495 | status = | 494 | status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_event_block); |
496 | acpi_hw_low_level_read(16, &value2, | ||
497 | &acpi_gbl_FADT.xpm1b_event_block); | ||
498 | value1 |= value2; | 495 | value1 |= value2; |
499 | break; | 496 | break; |
500 | 497 | ||
501 | case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ | 498 | case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ |
502 | 499 | ||
503 | status = | 500 | status = acpi_read(&value1, &acpi_gbl_xpm1a_enable); |
504 | acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable); | ||
505 | if (ACPI_FAILURE(status)) { | 501 | if (ACPI_FAILURE(status)) { |
506 | goto exit; | 502 | goto exit; |
507 | } | 503 | } |
508 | 504 | ||
509 | /* PM1B is optional */ | 505 | /* PM1B is optional */ |
510 | 506 | ||
511 | status = | 507 | status = acpi_read(&value2, &acpi_gbl_xpm1b_enable); |
512 | acpi_hw_low_level_read(16, &value2, &acpi_gbl_xpm1b_enable); | ||
513 | value1 |= value2; | 508 | value1 |= value2; |
514 | break; | 509 | break; |
515 | 510 | ||
516 | case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ | 511 | case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ |
517 | 512 | ||
518 | status = | 513 | status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_control_block); |
519 | acpi_hw_low_level_read(16, &value1, | ||
520 | &acpi_gbl_FADT.xpm1a_control_block); | ||
521 | if (ACPI_FAILURE(status)) { | 514 | if (ACPI_FAILURE(status)) { |
522 | goto exit; | 515 | goto exit; |
523 | } | 516 | } |
524 | 517 | ||
525 | status = | 518 | status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_control_block); |
526 | acpi_hw_low_level_read(16, &value2, | ||
527 | &acpi_gbl_FADT.xpm1b_control_block); | ||
528 | value1 |= value2; | 519 | value1 |= value2; |
529 | break; | 520 | break; |
530 | 521 | ||
531 | case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ | 522 | case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ |
532 | 523 | ||
533 | status = | 524 | status = acpi_read(&value1, &acpi_gbl_FADT.xpm2_control_block); |
534 | acpi_hw_low_level_read(8, &value1, | ||
535 | &acpi_gbl_FADT.xpm2_control_block); | ||
536 | break; | 525 | break; |
537 | 526 | ||
538 | case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ | 527 | case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ |
539 | 528 | ||
540 | status = | 529 | status = acpi_read(&value1, &acpi_gbl_FADT.xpm_timer_block); |
541 | acpi_hw_low_level_read(32, &value1, | ||
542 | &acpi_gbl_FADT.xpm_timer_block); | ||
543 | break; | 530 | break; |
544 | 531 | ||
545 | case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ | 532 | case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ |
@@ -614,32 +601,26 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) | |||
614 | 601 | ||
615 | /* Now we can write the data */ | 602 | /* Now we can write the data */ |
616 | 603 | ||
617 | status = | 604 | status = acpi_write(value, &acpi_gbl_FADT.xpm1a_event_block); |
618 | acpi_hw_low_level_write(16, value, | ||
619 | &acpi_gbl_FADT.xpm1a_event_block); | ||
620 | if (ACPI_FAILURE(status)) { | 605 | if (ACPI_FAILURE(status)) { |
621 | goto exit; | 606 | goto exit; |
622 | } | 607 | } |
623 | 608 | ||
624 | /* PM1B is optional */ | 609 | /* PM1B is optional */ |
625 | 610 | ||
626 | status = | 611 | status = acpi_write(value, &acpi_gbl_FADT.xpm1b_event_block); |
627 | acpi_hw_low_level_write(16, value, | ||
628 | &acpi_gbl_FADT.xpm1b_event_block); | ||
629 | break; | 612 | break; |
630 | 613 | ||
631 | case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ | 614 | case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ |
632 | 615 | ||
633 | status = | 616 | status = acpi_write(value, &acpi_gbl_xpm1a_enable); |
634 | acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable); | ||
635 | if (ACPI_FAILURE(status)) { | 617 | if (ACPI_FAILURE(status)) { |
636 | goto exit; | 618 | goto exit; |
637 | } | 619 | } |
638 | 620 | ||
639 | /* PM1B is optional */ | 621 | /* PM1B is optional */ |
640 | 622 | ||
641 | status = | 623 | status = acpi_write(value, &acpi_gbl_xpm1b_enable); |
642 | acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1b_enable); | ||
643 | break; | 624 | break; |
644 | 625 | ||
645 | case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ | 626 | case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ |
@@ -660,44 +641,32 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) | |||
660 | 641 | ||
661 | /* Now we can write the data */ | 642 | /* Now we can write the data */ |
662 | 643 | ||
663 | status = | 644 | status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block); |
664 | acpi_hw_low_level_write(16, value, | ||
665 | &acpi_gbl_FADT.xpm1a_control_block); | ||
666 | if (ACPI_FAILURE(status)) { | 645 | if (ACPI_FAILURE(status)) { |
667 | goto exit; | 646 | goto exit; |
668 | } | 647 | } |
669 | 648 | ||
670 | status = | 649 | status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block); |
671 | acpi_hw_low_level_write(16, value, | ||
672 | &acpi_gbl_FADT.xpm1b_control_block); | ||
673 | break; | 650 | break; |
674 | 651 | ||
675 | case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ | 652 | case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ |
676 | 653 | ||
677 | status = | 654 | status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block); |
678 | acpi_hw_low_level_write(16, value, | ||
679 | &acpi_gbl_FADT.xpm1a_control_block); | ||
680 | break; | 655 | break; |
681 | 656 | ||
682 | case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ | 657 | case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ |
683 | 658 | ||
684 | status = | 659 | status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block); |
685 | acpi_hw_low_level_write(16, value, | ||
686 | &acpi_gbl_FADT.xpm1b_control_block); | ||
687 | break; | 660 | break; |
688 | 661 | ||
689 | case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ | 662 | case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ |
690 | 663 | ||
691 | status = | 664 | status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block); |
692 | acpi_hw_low_level_write(8, value, | ||
693 | &acpi_gbl_FADT.xpm2_control_block); | ||
694 | break; | 665 | break; |
695 | 666 | ||
696 | case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ | 667 | case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ |
697 | 668 | ||
698 | status = | 669 | status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block); |
699 | acpi_hw_low_level_write(32, value, | ||
700 | &acpi_gbl_FADT.xpm_timer_block); | ||
701 | break; | 670 | break; |
702 | 671 | ||
703 | case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ | 672 | case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ |
@@ -719,10 +688,9 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) | |||
719 | 688 | ||
720 | /****************************************************************************** | 689 | /****************************************************************************** |
721 | * | 690 | * |
722 | * FUNCTION: acpi_hw_low_level_read | 691 | * FUNCTION: acpi_read |
723 | * | 692 | * |
724 | * PARAMETERS: Width - 8, 16, or 32 | 693 | * PARAMETERS: Value - Where the value is returned |
725 | * Value - Where the value is returned | ||
726 | * Reg - GAS register structure | 694 | * Reg - GAS register structure |
727 | * | 695 | * |
728 | * RETURN: Status | 696 | * RETURN: Status |
@@ -731,13 +699,13 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value) | |||
731 | * | 699 | * |
732 | ******************************************************************************/ | 700 | ******************************************************************************/ |
733 | 701 | ||
734 | acpi_status | 702 | acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg) |
735 | acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg) | ||
736 | { | 703 | { |
704 | u32 width; | ||
737 | u64 address; | 705 | u64 address; |
738 | acpi_status status; | 706 | acpi_status status; |
739 | 707 | ||
740 | ACPI_FUNCTION_NAME(hw_low_level_read); | 708 | ACPI_FUNCTION_NAME(acpi_read); |
741 | 709 | ||
742 | /* | 710 | /* |
743 | * Must have a valid pointer to a GAS structure, and | 711 | * Must have a valid pointer to a GAS structure, and |
@@ -754,6 +722,16 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg) | |||
754 | if (!address) { | 722 | if (!address) { |
755 | return (AE_OK); | 723 | return (AE_OK); |
756 | } | 724 | } |
725 | |||
726 | /* Supported widths are 8/16/32 */ | ||
727 | |||
728 | width = reg->bit_width; | ||
729 | if ((width != 8) && (width != 16) && (width != 32)) { | ||
730 | return (AE_SUPPORT); | ||
731 | } | ||
732 | |||
733 | /* Initialize entire 32-bit return value to zero */ | ||
734 | |||
757 | *value = 0; | 735 | *value = 0; |
758 | 736 | ||
759 | /* | 737 | /* |
@@ -787,12 +765,13 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg) | |||
787 | return (status); | 765 | return (status); |
788 | } | 766 | } |
789 | 767 | ||
768 | ACPI_EXPORT_SYMBOL(acpi_read) | ||
769 | |||
790 | /****************************************************************************** | 770 | /****************************************************************************** |
791 | * | 771 | * |
792 | * FUNCTION: acpi_hw_low_level_write | 772 | * FUNCTION: acpi_write |
793 | * | 773 | * |
794 | * PARAMETERS: Width - 8, 16, or 32 | 774 | * PARAMETERS: Value - To be written |
795 | * Value - To be written | ||
796 | * Reg - GAS register structure | 775 | * Reg - GAS register structure |
797 | * | 776 | * |
798 | * RETURN: Status | 777 | * RETURN: Status |
@@ -802,12 +781,13 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg) | |||
802 | ******************************************************************************/ | 781 | ******************************************************************************/ |
803 | 782 | ||
804 | acpi_status | 783 | acpi_status |
805 | acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg) | 784 | acpi_write(u32 value, struct acpi_generic_address *reg) |
806 | { | 785 | { |
786 | u32 width; | ||
807 | u64 address; | 787 | u64 address; |
808 | acpi_status status; | 788 | acpi_status status; |
809 | 789 | ||
810 | ACPI_FUNCTION_NAME(hw_low_level_write); | 790 | ACPI_FUNCTION_NAME(acpi_write); |
811 | 791 | ||
812 | /* | 792 | /* |
813 | * Must have a valid pointer to a GAS structure, and | 793 | * Must have a valid pointer to a GAS structure, and |
@@ -825,6 +805,13 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg) | |||
825 | return (AE_OK); | 805 | return (AE_OK); |
826 | } | 806 | } |
827 | 807 | ||
808 | /* Supported widths are 8/16/32 */ | ||
809 | |||
810 | width = reg->bit_width; | ||
811 | if ((width != 8) && (width != 16) && (width != 32)) { | ||
812 | return (AE_SUPPORT); | ||
813 | } | ||
814 | |||
828 | /* | 815 | /* |
829 | * Two address spaces supported: Memory or IO. | 816 | * Two address spaces supported: Memory or IO. |
830 | * PCI_Config is not supported here because the GAS struct is insufficient | 817 | * PCI_Config is not supported here because the GAS struct is insufficient |
@@ -855,3 +842,5 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg) | |||
855 | 842 | ||
856 | return (status); | 843 | return (status); |
857 | } | 844 | } |
845 | |||
846 | ACPI_EXPORT_SYMBOL(acpi_write) | ||