aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/events
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/events')
-rw-r--r--drivers/acpi/events/evevent.c42
-rw-r--r--drivers/acpi/events/evgpeblk.c159
-rw-r--r--drivers/acpi/events/evxfevnt.c7
3 files changed, 150 insertions, 58 deletions
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/events/evevent.c
index 842d1e3fb37b..9522c643b88b 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/events/evevent.c
@@ -100,6 +100,48 @@ acpi_status acpi_ev_initialize_events(void)
100 100
101/******************************************************************************* 101/*******************************************************************************
102 * 102 *
103 * FUNCTION: acpi_ev_install_fadt_gpes
104 *
105 * PARAMETERS: None
106 *
107 * RETURN: Status
108 *
109 * DESCRIPTION: Completes initialization of the FADT-defined GPE blocks
110 * (0 and 1). This causes the _PRW methods to be run, so the HW
111 * must be fully initialized at this point, including global lock
112 * support.
113 *
114 ******************************************************************************/
115
116acpi_status acpi_ev_install_fadt_gpes(void)
117{
118 acpi_status status;
119
120 ACPI_FUNCTION_TRACE("ev_install_fadt_gpes");
121
122 /* Namespace must be locked */
123
124 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
125 if (ACPI_FAILURE(status)) {
126 return (status);
127 }
128
129 /* FADT GPE Block 0 */
130
131 (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device,
132 acpi_gbl_gpe_fadt_blocks[0]);
133
134 /* FADT GPE Block 1 */
135
136 (void)acpi_ev_initialize_gpe_block(acpi_gbl_fadt_gpe_device,
137 acpi_gbl_gpe_fadt_blocks[1]);
138
139 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
140 return_ACPI_STATUS(AE_OK);
141}
142
143/*******************************************************************************
144 *
103 * FUNCTION: acpi_ev_install_xrupt_handlers 145 * FUNCTION: acpi_ev_install_xrupt_handlers
104 * 146 *
105 * PARAMETERS: None 147 * PARAMETERS: None
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index 7ca10c5f2914..8efca2eac27e 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -78,7 +78,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block);
78 * 78 *
79 * RETURN: TRUE if the gpe_event is valid 79 * RETURN: TRUE if the gpe_event is valid
80 * 80 *
81 * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. 81 * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL.
82 * Should be called only when the GPE lists are semaphore locked 82 * Should be called only when the GPE lists are semaphore locked
83 * and not subject to change. 83 * and not subject to change.
84 * 84 *
@@ -264,7 +264,7 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
264 * 2) Edge/Level determination is based on the 2nd character 264 * 2) Edge/Level determination is based on the 2nd character
265 * of the method name 265 * of the method name
266 * 266 *
267 * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE 267 * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE
268 * if a _PRW object is found that points to this GPE. 268 * if a _PRW object is found that points to this GPE.
269 */ 269 */
270 switch (name[1]) { 270 switch (name[1]) {
@@ -313,14 +313,14 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
313 313
314 /* 314 /*
315 * Now we can add this information to the gpe_event_info block 315 * Now we can add this information to the gpe_event_info block
316 * for use during dispatch of this GPE. Default type is RUNTIME, although 316 * for use during dispatch of this GPE. Default type is RUNTIME, although
317 * this may change when the _PRW methods are executed later. 317 * this may change when the _PRW methods are executed later.
318 */ 318 */
319 gpe_event_info = 319 gpe_event_info =
320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 320 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
321 321
322 gpe_event_info->flags = (u8) (type | ACPI_GPE_DISPATCH_METHOD | 322 gpe_event_info->flags = (u8)
323 ACPI_GPE_TYPE_RUNTIME); 323 (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME);
324 324
325 gpe_event_info->dispatch.method_node = 325 gpe_event_info->dispatch.method_node =
326 (struct acpi_namespace_node *)obj_handle; 326 (struct acpi_namespace_node *)obj_handle;
@@ -341,11 +341,11 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
341 * 341 *
342 * PARAMETERS: Callback from walk_namespace 342 * PARAMETERS: Callback from walk_namespace
343 * 343 *
344 * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is 344 * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is
345 * not aborted on a single _PRW failure. 345 * not aborted on a single _PRW failure.
346 * 346 *
347 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a 347 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a
348 * Device. Run the _PRW method. If present, extract the GPE 348 * Device. Run the _PRW method. If present, extract the GPE
349 * number and mark the GPE as a WAKE GPE. 349 * number and mark the GPE as a WAKE GPE.
350 * 350 *
351 ******************************************************************************/ 351 ******************************************************************************/
@@ -443,6 +443,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
443 443
444 gpe_event_info->flags &= 444 gpe_event_info->flags &=
445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); 445 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
446
446 status = 447 status =
447 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); 448 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
448 if (ACPI_FAILURE(status)) { 449 if (ACPI_FAILURE(status)) {
@@ -466,7 +467,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
466 * 467 *
467 * RETURN: A GPE interrupt block 468 * RETURN: A GPE interrupt block
468 * 469 *
469 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 470 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
470 * block per unique interrupt level used for GPEs. 471 * block per unique interrupt level used for GPEs.
471 * Should be called only when the GPE lists are semaphore locked 472 * Should be called only when the GPE lists are semaphore locked
472 * and not subject to change. 473 * and not subject to change.
@@ -566,8 +567,9 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
566 567
567 /* Disable this interrupt */ 568 /* Disable this interrupt */
568 569
569 status = acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, 570 status =
570 acpi_ev_gpe_xrupt_handler); 571 acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number,
572 acpi_ev_gpe_xrupt_handler);
571 if (ACPI_FAILURE(status)) { 573 if (ACPI_FAILURE(status)) {
572 return_ACPI_STATUS(status); 574 return_ACPI_STATUS(status);
573 } 575 }
@@ -750,7 +752,7 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
750 752
751 /* 753 /*
752 * Allocate the GPE event_info block. There are eight distinct GPEs 754 * Allocate the GPE event_info block. There are eight distinct GPEs
753 * per register. Initialization to zeros is sufficient. 755 * per register. Initialization to zeros is sufficient.
754 */ 756 */
755 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block-> 757 gpe_event_info = ACPI_MEM_CALLOCATE(((acpi_size) gpe_block->
756 register_count * 758 register_count *
@@ -769,9 +771,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
769 gpe_block->event_info = gpe_event_info; 771 gpe_block->event_info = gpe_event_info;
770 772
771 /* 773 /*
772 * Initialize the GPE Register and Event structures. A goal of these 774 * Initialize the GPE Register and Event structures. A goal of these
773 * tables is to hide the fact that there are two separate GPE register sets 775 * tables is to hide the fact that there are two separate GPE register sets
774 * in a given gpe hardware block, the status registers occupy the first half, 776 * in a given GPE hardware block, the status registers occupy the first half,
775 * and the enable registers occupy the second half. 777 * and the enable registers occupy the second half.
776 */ 778 */
777 this_register = gpe_register_info; 779 this_register = gpe_register_info;
@@ -812,11 +814,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
812 this_event++; 814 this_event++;
813 } 815 }
814 816
815 /* 817 /* Disable all GPEs within this register */
816 * Clear the status/enable registers. Note that status registers 818
817 * are cleared by writing a '1', while enable registers are cleared
818 * by writing a '0'.
819 */
820 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, 819 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
821 &this_register-> 820 &this_register->
822 enable_address); 821 enable_address);
@@ -824,6 +823,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
824 goto error_exit; 823 goto error_exit;
825 } 824 }
826 825
826 /* Clear any pending GPE events within this register */
827
827 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, 828 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
828 &this_register-> 829 &this_register->
829 status_address); 830 status_address);
@@ -860,7 +861,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
860 * 861 *
861 * RETURN: Status 862 * RETURN: Status
862 * 863 *
863 * DESCRIPTION: Create and Install a block of GPE registers 864 * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within
865 * the block are disabled at exit.
866 * Note: Assumes namespace is locked.
864 * 867 *
865 ******************************************************************************/ 868 ******************************************************************************/
866 869
@@ -872,14 +875,8 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
872 u32 interrupt_number, 875 u32 interrupt_number,
873 struct acpi_gpe_block_info **return_gpe_block) 876 struct acpi_gpe_block_info **return_gpe_block)
874{ 877{
875 struct acpi_gpe_block_info *gpe_block;
876 struct acpi_gpe_event_info *gpe_event_info;
877 acpi_native_uint i;
878 acpi_native_uint j;
879 u32 wake_gpe_count;
880 u32 gpe_enabled_count;
881 acpi_status status; 878 acpi_status status;
882 struct acpi_gpe_walk_info gpe_info; 879 struct acpi_gpe_block_info *gpe_block;
883 880
884 ACPI_FUNCTION_TRACE("ev_create_gpe_block"); 881 ACPI_FUNCTION_TRACE("ev_create_gpe_block");
885 882
@@ -896,22 +893,24 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
896 893
897 /* Initialize the new GPE block */ 894 /* Initialize the new GPE block */
898 895
896 gpe_block->node = gpe_device;
899 gpe_block->register_count = register_count; 897 gpe_block->register_count = register_count;
900 gpe_block->block_base_number = gpe_block_base_number; 898 gpe_block->block_base_number = gpe_block_base_number;
901 gpe_block->node = gpe_device;
902 899
903 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address, 900 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
904 sizeof(struct acpi_generic_address)); 901 sizeof(struct acpi_generic_address));
905 902
906 /* Create the register_info and event_info sub-structures */ 903 /*
907 904 * Create the register_info and event_info sub-structures
905 * Note: disables and clears all GPEs in the block
906 */
908 status = acpi_ev_create_gpe_info_blocks(gpe_block); 907 status = acpi_ev_create_gpe_info_blocks(gpe_block);
909 if (ACPI_FAILURE(status)) { 908 if (ACPI_FAILURE(status)) {
910 ACPI_MEM_FREE(gpe_block); 909 ACPI_MEM_FREE(gpe_block);
911 return_ACPI_STATUS(status); 910 return_ACPI_STATUS(status);
912 } 911 }
913 912
914 /* Install the new block in the global list(s) */ 913 /* Install the new block in the global lists */
915 914
916 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); 915 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
917 if (ACPI_FAILURE(status)) { 916 if (ACPI_FAILURE(status)) {
@@ -926,16 +925,70 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
926 acpi_ev_save_method_info, gpe_block, 925 acpi_ev_save_method_info, gpe_block,
927 NULL); 926 NULL);
928 927
928 /* Return the new block */
929
930 if (return_gpe_block) {
931 (*return_gpe_block) = gpe_block;
932 }
933
934 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
935 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
936 (u32) gpe_block->block_base_number,
937 (u32) (gpe_block->block_base_number +
938 ((gpe_block->register_count *
939 ACPI_GPE_REGISTER_WIDTH) - 1)),
940 gpe_device->name.ascii, gpe_block->register_count,
941 interrupt_number));
942
943 return_ACPI_STATUS(AE_OK);
944}
945
946/*******************************************************************************
947 *
948 * FUNCTION: acpi_ev_initialize_gpe_block
949 *
950 * PARAMETERS: gpe_device - Handle to the parent GPE block
951 * gpe_block - Gpe Block info
952 *
953 * RETURN: Status
954 *
955 * DESCRIPTION: Initialize and enable a GPE block. First find and run any
956 * _PRT methods associated with the block, then enable the
957 * appropriate GPEs.
958 * Note: Assumes namespace is locked.
959 *
960 ******************************************************************************/
961
962acpi_status
963acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
964 struct acpi_gpe_block_info *gpe_block)
965{
966 acpi_status status;
967 struct acpi_gpe_event_info *gpe_event_info;
968 struct acpi_gpe_walk_info gpe_info;
969 u32 wake_gpe_count;
970 u32 gpe_enabled_count;
971 acpi_native_uint i;
972 acpi_native_uint j;
973
974 ACPI_FUNCTION_TRACE("ev_initialize_gpe_block");
975
976 /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */
977
978 if (!gpe_block) {
979 return_ACPI_STATUS(AE_OK);
980 }
981
929 /* 982 /*
930 * Runtime option: Should Wake GPEs be enabled at runtime? The default 983 * Runtime option: Should wake GPEs be enabled at runtime? The default
931 * is No, they should only be enabled just as the machine goes to sleep. 984 * is no, they should only be enabled just as the machine goes to sleep.
932 */ 985 */
933 if (acpi_gbl_leave_wake_gpes_disabled) { 986 if (acpi_gbl_leave_wake_gpes_disabled) {
934 /* 987 /*
935 * Differentiate RUNTIME vs WAKE GPEs, via the _PRW control methods. 988 * Differentiate runtime vs wake GPEs, via the _PRW control methods.
936 * (Each GPE that has one or more _PRWs that reference it is by 989 * Each GPE that has one or more _PRWs that reference it is by
937 * definition a WAKE GPE and will not be enabled while the machine 990 * definition a wake GPE and will not be enabled while the machine
938 * is running.) 991 * is running.
939 */ 992 */
940 gpe_info.gpe_block = gpe_block; 993 gpe_info.gpe_block = gpe_block;
941 gpe_info.gpe_device = gpe_device; 994 gpe_info.gpe_device = gpe_device;
@@ -948,9 +1001,12 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
948 } 1001 }
949 1002
950 /* 1003 /*
951 * Enable all GPEs in this block that are 1) "runtime" or "run/wake" GPEs, 1004 * Enable all GPEs in this block that have these attributes:
952 * and 2) have a corresponding _Lxx or _Exx method. All other GPEs must 1005 * 1) are "runtime" or "run/wake" GPEs, and
953 * be enabled via the acpi_enable_gpe() external interface. 1006 * 2) have a corresponding _Lxx or _Exx method
1007 *
1008 * Any other GPEs within this block must be enabled via the acpi_enable_gpe()
1009 * external interface.
954 */ 1010 */
955 wake_gpe_count = 0; 1011 wake_gpe_count = 0;
956 gpe_enabled_count = 0; 1012 gpe_enabled_count = 0;
@@ -976,32 +1032,19 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
976 } 1032 }
977 } 1033 }
978 1034
979 /* Dump info about this GPE block */
980
981 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
982 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
983 (u32) gpe_block->block_base_number,
984 (u32) (gpe_block->block_base_number +
985 ((gpe_block->register_count *
986 ACPI_GPE_REGISTER_WIDTH) - 1)),
987 gpe_device->name.ascii, gpe_block->register_count,
988 interrupt_number));
989
990 /* Enable all valid GPEs found above */
991
992 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
993
994 ACPI_DEBUG_PRINT((ACPI_DB_INIT, 1035 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
995 "Found %u Wake, Enabled %u Runtime GPEs in this block\n", 1036 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
996 wake_gpe_count, gpe_enabled_count)); 1037 wake_gpe_count, gpe_enabled_count));
997 1038
998 /* Return the new block */ 1039 /* Enable all valid runtime GPEs found above */
999 1040
1000 if (return_gpe_block) { 1041 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block);
1001 (*return_gpe_block) = gpe_block; 1042 if (ACPI_FAILURE(status)) {
1043 ACPI_REPORT_ERROR(("Could not enable GPEs in gpe_block %p\n",
1044 gpe_block));
1002 } 1045 }
1003 1046
1004 return_ACPI_STATUS(AE_OK); 1047 return_ACPI_STATUS(status);
1005} 1048}
1006 1049
1007/******************************************************************************* 1050/*******************************************************************************
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/events/evxfevnt.c
index 887ff9f28a0d..c1b898928256 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/events/evxfevnt.c
@@ -626,6 +626,13 @@ acpi_install_gpe_block(acpi_handle gpe_device,
626 goto unlock_and_exit; 626 goto unlock_and_exit;
627 } 627 }
628 628
629 /* Run the _PRW methods and enable the GPEs */
630
631 status = acpi_ev_initialize_gpe_block(node, gpe_block);
632 if (ACPI_FAILURE(status)) {
633 goto unlock_and_exit;
634 }
635
629 /* Get the device_object attached to the node */ 636 /* Get the device_object attached to the node */
630 637
631 obj_desc = acpi_ns_get_attached_object(node); 638 obj_desc = acpi_ns_get_attached_object(node);