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.c98
1 files changed, 45 insertions, 53 deletions
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index fa58c1edce1e..1d371fa663f2 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -7,7 +7,7 @@
7 ******************************************************************************/ 7 ******************************************************************************/
8 8
9/* 9/*
10 * Copyright (C) 2000 - 2006, R. Byron Moore 10 * Copyright (C) 2000 - 2007, R. Byron Moore
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
@@ -54,17 +54,15 @@ ACPI_MODULE_NAME("hwregs")
54 * 54 *
55 * FUNCTION: acpi_hw_clear_acpi_status 55 * FUNCTION: acpi_hw_clear_acpi_status
56 * 56 *
57 * PARAMETERS: Flags - Lock the hardware or not 57 * PARAMETERS: None
58 * 58 *
59 * RETURN: none 59 * RETURN: None
60 * 60 *
61 * DESCRIPTION: Clears all fixed and general purpose status bits 61 * DESCRIPTION: Clears all fixed and general purpose status bits
62 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 62 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
63 * 63 *
64 * NOTE: TBD: Flags parameter is obsolete, to be removed
65 *
66 ******************************************************************************/ 64 ******************************************************************************/
67acpi_status acpi_hw_clear_acpi_status(u32 flags) 65acpi_status acpi_hw_clear_acpi_status(void)
68{ 66{
69 acpi_status status; 67 acpi_status status;
70 acpi_cpu_flags lock_flags = 0; 68 acpi_cpu_flags lock_flags = 0;
@@ -73,7 +71,7 @@ acpi_status acpi_hw_clear_acpi_status(u32 flags)
73 71
74 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n", 72 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n",
75 ACPI_BITMASK_ALL_FIXED_STATUS, 73 ACPI_BITMASK_ALL_FIXED_STATUS,
76 (u16) acpi_gbl_FADT->xpm1a_evt_blk.address)); 74 (u16) acpi_gbl_FADT.xpm1a_event_block.address));
77 75
78 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); 76 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
79 77
@@ -86,10 +84,10 @@ acpi_status acpi_hw_clear_acpi_status(u32 flags)
86 84
87 /* Clear the fixed events */ 85 /* Clear the fixed events */
88 86
89 if (acpi_gbl_FADT->xpm1b_evt_blk.address) { 87 if (acpi_gbl_FADT.xpm1b_event_block.address) {
90 status = 88 status =
91 acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS, 89 acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS,
92 &acpi_gbl_FADT->xpm1b_evt_blk); 90 &acpi_gbl_FADT.xpm1b_event_block);
93 if (ACPI_FAILURE(status)) { 91 if (ACPI_FAILURE(status)) {
94 goto unlock_and_exit; 92 goto unlock_and_exit;
95 } 93 }
@@ -253,18 +251,15 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
253 * 251 *
254 * PARAMETERS: register_id - ID of ACPI bit_register to access 252 * PARAMETERS: register_id - ID of ACPI bit_register to access
255 * return_value - Value that was read from the register 253 * return_value - Value that was read from the register
256 * Flags - Lock the hardware or not
257 * 254 *
258 * RETURN: Status and the value read from specified Register. Value 255 * RETURN: Status and the value read from specified Register. Value
259 * returned is normalized to bit0 (is shifted all the way right) 256 * returned is normalized to bit0 (is shifted all the way right)
260 * 257 *
261 * DESCRIPTION: ACPI bit_register read function. 258 * DESCRIPTION: ACPI bit_register read function.
262 * 259 *
263 * NOTE: TBD: Flags parameter is obsolete, to be removed
264 *
265 ******************************************************************************/ 260 ******************************************************************************/
266 261
267acpi_status acpi_get_register(u32 register_id, u32 * return_value, u32 flags) 262acpi_status acpi_get_register(u32 register_id, u32 * return_value)
268{ 263{
269 u32 register_value = 0; 264 u32 register_value = 0;
270 struct acpi_bit_register_info *bit_reg_info; 265 struct acpi_bit_register_info *bit_reg_info;
@@ -312,16 +307,13 @@ ACPI_EXPORT_SYMBOL(acpi_get_register)
312 * PARAMETERS: register_id - ID of ACPI bit_register to access 307 * PARAMETERS: register_id - ID of ACPI bit_register to access
313 * Value - (only used on write) value to write to the 308 * Value - (only used on write) value to write to the
314 * Register, NOT pre-normalized to the bit pos 309 * Register, NOT pre-normalized to the bit pos
315 * Flags - Lock the hardware or not
316 * 310 *
317 * RETURN: Status 311 * RETURN: Status
318 * 312 *
319 * DESCRIPTION: ACPI Bit Register write function. 313 * DESCRIPTION: ACPI Bit Register write function.
320 * 314 *
321 * NOTE: TBD: Flags parameter is obsolete, to be removed
322 *
323 ******************************************************************************/ 315 ******************************************************************************/
324acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags) 316acpi_status acpi_set_register(u32 register_id, u32 value)
325{ 317{
326 u32 register_value = 0; 318 u32 register_value = 0;
327 struct acpi_bit_register_info *bit_reg_info; 319 struct acpi_bit_register_info *bit_reg_info;
@@ -422,8 +414,9 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
422 ACPI_DEBUG_PRINT((ACPI_DB_IO, 414 ACPI_DEBUG_PRINT((ACPI_DB_IO,
423 "PM2 control: Read %X from %8.8X%8.8X\n", 415 "PM2 control: Read %X from %8.8X%8.8X\n",
424 register_value, 416 register_value,
425 ACPI_FORMAT_UINT64(acpi_gbl_FADT-> 417 ACPI_FORMAT_UINT64(acpi_gbl_FADT.
426 xpm2_cnt_blk.address))); 418 xpm2_control_block.
419 address)));
427 420
428 ACPI_REGISTER_INSERT_VALUE(register_value, 421 ACPI_REGISTER_INSERT_VALUE(register_value,
429 bit_reg_info->bit_position, 422 bit_reg_info->bit_position,
@@ -433,8 +426,9 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
433 ACPI_DEBUG_PRINT((ACPI_DB_IO, 426 ACPI_DEBUG_PRINT((ACPI_DB_IO,
434 "About to write %4.4X to %8.8X%8.8X\n", 427 "About to write %4.4X to %8.8X%8.8X\n",
435 register_value, 428 register_value,
436 ACPI_FORMAT_UINT64(acpi_gbl_FADT-> 429 ACPI_FORMAT_UINT64(acpi_gbl_FADT.
437 xpm2_cnt_blk.address))); 430 xpm2_control_block.
431 address)));
438 432
439 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK, 433 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
440 ACPI_REGISTER_PM2_CONTROL, 434 ACPI_REGISTER_PM2_CONTROL,
@@ -495,7 +489,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
495 489
496 status = 490 status =
497 acpi_hw_low_level_read(16, &value1, 491 acpi_hw_low_level_read(16, &value1,
498 &acpi_gbl_FADT->xpm1a_evt_blk); 492 &acpi_gbl_FADT.xpm1a_event_block);
499 if (ACPI_FAILURE(status)) { 493 if (ACPI_FAILURE(status)) {
500 goto unlock_and_exit; 494 goto unlock_and_exit;
501 } 495 }
@@ -504,7 +498,7 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
504 498
505 status = 499 status =
506 acpi_hw_low_level_read(16, &value2, 500 acpi_hw_low_level_read(16, &value2,
507 &acpi_gbl_FADT->xpm1b_evt_blk); 501 &acpi_gbl_FADT.xpm1b_event_block);
508 value1 |= value2; 502 value1 |= value2;
509 break; 503 break;
510 504
@@ -527,14 +521,14 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
527 521
528 status = 522 status =
529 acpi_hw_low_level_read(16, &value1, 523 acpi_hw_low_level_read(16, &value1,
530 &acpi_gbl_FADT->xpm1a_cnt_blk); 524 &acpi_gbl_FADT.xpm1a_control_block);
531 if (ACPI_FAILURE(status)) { 525 if (ACPI_FAILURE(status)) {
532 goto unlock_and_exit; 526 goto unlock_and_exit;
533 } 527 }
534 528
535 status = 529 status =
536 acpi_hw_low_level_read(16, &value2, 530 acpi_hw_low_level_read(16, &value2,
537 &acpi_gbl_FADT->xpm1b_cnt_blk); 531 &acpi_gbl_FADT.xpm1b_control_block);
538 value1 |= value2; 532 value1 |= value2;
539 break; 533 break;
540 534
@@ -542,19 +536,20 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
542 536
543 status = 537 status =
544 acpi_hw_low_level_read(8, &value1, 538 acpi_hw_low_level_read(8, &value1,
545 &acpi_gbl_FADT->xpm2_cnt_blk); 539 &acpi_gbl_FADT.xpm2_control_block);
546 break; 540 break;
547 541
548 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 542 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
549 543
550 status = 544 status =
551 acpi_hw_low_level_read(32, &value1, 545 acpi_hw_low_level_read(32, &value1,
552 &acpi_gbl_FADT->xpm_tmr_blk); 546 &acpi_gbl_FADT.xpm_timer_block);
553 break; 547 break;
554 548
555 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 549 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
556 550
557 status = acpi_os_read_port(acpi_gbl_FADT->smi_cmd, &value1, 8); 551 status =
552 acpi_os_read_port(acpi_gbl_FADT.smi_command, &value1, 8);
558 break; 553 break;
559 554
560 default: 555 default:
@@ -635,7 +630,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
635 630
636 status = 631 status =
637 acpi_hw_low_level_write(16, value, 632 acpi_hw_low_level_write(16, value,
638 &acpi_gbl_FADT->xpm1a_evt_blk); 633 &acpi_gbl_FADT.xpm1a_event_block);
639 if (ACPI_FAILURE(status)) { 634 if (ACPI_FAILURE(status)) {
640 goto unlock_and_exit; 635 goto unlock_and_exit;
641 } 636 }
@@ -644,7 +639,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
644 639
645 status = 640 status =
646 acpi_hw_low_level_write(16, value, 641 acpi_hw_low_level_write(16, value,
647 &acpi_gbl_FADT->xpm1b_evt_blk); 642 &acpi_gbl_FADT.xpm1b_event_block);
648 break; 643 break;
649 644
650 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ 645 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
@@ -682,49 +677,50 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
682 677
683 status = 678 status =
684 acpi_hw_low_level_write(16, value, 679 acpi_hw_low_level_write(16, value,
685 &acpi_gbl_FADT->xpm1a_cnt_blk); 680 &acpi_gbl_FADT.xpm1a_control_block);
686 if (ACPI_FAILURE(status)) { 681 if (ACPI_FAILURE(status)) {
687 goto unlock_and_exit; 682 goto unlock_and_exit;
688 } 683 }
689 684
690 status = 685 status =
691 acpi_hw_low_level_write(16, value, 686 acpi_hw_low_level_write(16, value,
692 &acpi_gbl_FADT->xpm1b_cnt_blk); 687 &acpi_gbl_FADT.xpm1b_control_block);
693 break; 688 break;
694 689
695 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ 690 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
696 691
697 status = 692 status =
698 acpi_hw_low_level_write(16, value, 693 acpi_hw_low_level_write(16, value,
699 &acpi_gbl_FADT->xpm1a_cnt_blk); 694 &acpi_gbl_FADT.xpm1a_control_block);
700 break; 695 break;
701 696
702 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ 697 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
703 698
704 status = 699 status =
705 acpi_hw_low_level_write(16, value, 700 acpi_hw_low_level_write(16, value,
706 &acpi_gbl_FADT->xpm1b_cnt_blk); 701 &acpi_gbl_FADT.xpm1b_control_block);
707 break; 702 break;
708 703
709 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 704 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
710 705
711 status = 706 status =
712 acpi_hw_low_level_write(8, value, 707 acpi_hw_low_level_write(8, value,
713 &acpi_gbl_FADT->xpm2_cnt_blk); 708 &acpi_gbl_FADT.xpm2_control_block);
714 break; 709 break;
715 710
716 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 711 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
717 712
718 status = 713 status =
719 acpi_hw_low_level_write(32, value, 714 acpi_hw_low_level_write(32, value,
720 &acpi_gbl_FADT->xpm_tmr_blk); 715 &acpi_gbl_FADT.xpm_timer_block);
721 break; 716 break;
722 717
723 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 718 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
724 719
725 /* SMI_CMD is currently always in IO space */ 720 /* SMI_CMD is currently always in IO space */
726 721
727 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd, value, 8); 722 status =
723 acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8);
728 break; 724 break;
729 725
730 default: 726 default:
@@ -783,7 +779,7 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
783 * Two address spaces supported: Memory or IO. 779 * Two address spaces supported: Memory or IO.
784 * PCI_Config is not supported here because the GAS struct is insufficient 780 * PCI_Config is not supported here because the GAS struct is insufficient
785 */ 781 */
786 switch (reg->address_space_id) { 782 switch (reg->space_id) {
787 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 783 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
788 784
789 status = acpi_os_read_memory((acpi_physical_address) address, 785 status = acpi_os_read_memory((acpi_physical_address) address,
@@ -792,22 +788,20 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
792 788
793 case ACPI_ADR_SPACE_SYSTEM_IO: 789 case ACPI_ADR_SPACE_SYSTEM_IO:
794 790
795 status = acpi_os_read_port((acpi_io_address) address, 791 status =
796 value, width); 792 acpi_os_read_port((acpi_io_address) address, value, width);
797 break; 793 break;
798 794
799 default: 795 default:
800 ACPI_ERROR((AE_INFO, 796 ACPI_ERROR((AE_INFO,
801 "Unsupported address space: %X", 797 "Unsupported address space: %X", reg->space_id));
802 reg->address_space_id));
803 return (AE_BAD_PARAMETER); 798 return (AE_BAD_PARAMETER);
804 } 799 }
805 800
806 ACPI_DEBUG_PRINT((ACPI_DB_IO, 801 ACPI_DEBUG_PRINT((ACPI_DB_IO,
807 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", 802 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
808 *value, width, 803 *value, width, ACPI_FORMAT_UINT64(address),
809 ACPI_FORMAT_UINT64(address), 804 acpi_ut_get_region_name(reg->space_id)));
810 acpi_ut_get_region_name(reg->address_space_id)));
811 805
812 return (status); 806 return (status);
813} 807}
@@ -854,7 +848,7 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
854 * Two address spaces supported: Memory or IO. 848 * Two address spaces supported: Memory or IO.
855 * PCI_Config is not supported here because the GAS struct is insufficient 849 * PCI_Config is not supported here because the GAS struct is insufficient
856 */ 850 */
857 switch (reg->address_space_id) { 851 switch (reg->space_id) {
858 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 852 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
859 853
860 status = acpi_os_write_memory((acpi_physical_address) address, 854 status = acpi_os_write_memory((acpi_physical_address) address,
@@ -863,22 +857,20 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
863 857
864 case ACPI_ADR_SPACE_SYSTEM_IO: 858 case ACPI_ADR_SPACE_SYSTEM_IO:
865 859
866 status = acpi_os_write_port((acpi_io_address) address, 860 status = acpi_os_write_port((acpi_io_address) address, value,
867 value, width); 861 width);
868 break; 862 break;
869 863
870 default: 864 default:
871 ACPI_ERROR((AE_INFO, 865 ACPI_ERROR((AE_INFO,
872 "Unsupported address space: %X", 866 "Unsupported address space: %X", reg->space_id));
873 reg->address_space_id));
874 return (AE_BAD_PARAMETER); 867 return (AE_BAD_PARAMETER);
875 } 868 }
876 869
877 ACPI_DEBUG_PRINT((ACPI_DB_IO, 870 ACPI_DEBUG_PRINT((ACPI_DB_IO,
878 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", 871 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
879 value, width, 872 value, width, ACPI_FORMAT_UINT64(address),
880 ACPI_FORMAT_UINT64(address), 873 acpi_ut_get_region_name(reg->space_id)));
881 acpi_ut_get_region_name(reg->address_space_id)));
882 874
883 return (status); 875 return (status);
884} 876}