1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2010, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <acpi/acpi.h>
50 #define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME("evxfevnt")
53 /* Local prototypes */
55 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
56 struct acpi_gpe_block_info *gpe_block, void *context);
58 /*******************************************************************************
60 * FUNCTION: acpi_enable
66 * DESCRIPTION: Transfers the system into ACPI mode.
68 ******************************************************************************/
70 acpi_status acpi_enable(void)
74 ACPI_FUNCTION_TRACE(acpi_enable);
76 /* ACPI tables must be present */
78 if (!acpi_tb_tables_loaded()) {
79 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
82 /* Check current mode */
84 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
85 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
86 "System is already in ACPI mode\n"));
87 return_ACPI_STATUS(AE_OK);
90 /* Transition to ACPI mode */
92 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
93 if (ACPI_FAILURE(status)) {
95 "Could not transition to ACPI mode"));
96 return_ACPI_STATUS(status);
99 /* Sanity check that transition succeeded */
101 if (acpi_hw_get_mode() != ACPI_SYS_MODE_ACPI) {
103 "Hardware did not enter ACPI mode"));
104 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
107 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
108 "Transition to ACPI mode successful\n"));
110 return_ACPI_STATUS(AE_OK);
113 ACPI_EXPORT_SYMBOL(acpi_enable)
115 /*******************************************************************************
117 * FUNCTION: acpi_disable
123 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
125 ******************************************************************************/
126 acpi_status acpi_disable(void)
128 acpi_status status = AE_OK;
130 ACPI_FUNCTION_TRACE(acpi_disable);
132 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
133 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
134 "System is already in legacy (non-ACPI) mode\n"));
136 /* Transition to LEGACY mode */
138 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
140 if (ACPI_FAILURE(status)) {
142 "Could not exit ACPI mode to legacy mode"));
143 return_ACPI_STATUS(status);
146 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
149 return_ACPI_STATUS(status);
152 ACPI_EXPORT_SYMBOL(acpi_disable)
154 /*******************************************************************************
156 * FUNCTION: acpi_enable_event
158 * PARAMETERS: Event - The fixed eventto be enabled
163 * DESCRIPTION: Enable an ACPI event (fixed)
165 ******************************************************************************/
166 acpi_status acpi_enable_event(u32 event, u32 flags)
168 acpi_status status = AE_OK;
171 ACPI_FUNCTION_TRACE(acpi_enable_event);
173 /* Decode the Fixed Event */
175 if (event > ACPI_EVENT_MAX) {
176 return_ACPI_STATUS(AE_BAD_PARAMETER);
180 * Enable the requested fixed event (by writing a one to the enable
184 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
185 enable_register_id, ACPI_ENABLE_EVENT);
186 if (ACPI_FAILURE(status)) {
187 return_ACPI_STATUS(status);
190 /* Make sure that the hardware responded */
193 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
194 enable_register_id, &value);
195 if (ACPI_FAILURE(status)) {
196 return_ACPI_STATUS(status);
201 "Could not enable %s event",
202 acpi_ut_get_event_name(event)));
203 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
206 return_ACPI_STATUS(status);
209 ACPI_EXPORT_SYMBOL(acpi_enable_event)
211 /*******************************************************************************
213 * FUNCTION: acpi_set_gpe
215 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
216 * gpe_number - GPE level within the GPE block
217 * action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
221 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
222 * the reference count mechanism used in the acpi_enable_gpe and
223 * acpi_disable_gpe interfaces -- and should be used with care.
225 * Note: Typically used to disable a runtime GPE for short period of time,
226 * then re-enable it, without disturbing the existing reference counts. This
227 * is useful, for example, in the Embedded Controller (EC) driver.
229 ******************************************************************************/
230 acpi_status acpi_set_gpe(acpi_handle gpe_device, u32 gpe_number, u8 action)
232 struct acpi_gpe_event_info *gpe_event_info;
234 acpi_cpu_flags flags;
236 ACPI_FUNCTION_TRACE(acpi_set_gpe);
238 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
240 /* Ensure that we have a valid GPE number */
242 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
243 if (!gpe_event_info) {
244 status = AE_BAD_PARAMETER;
245 goto unlock_and_exit;
248 /* Perform the action */
251 case ACPI_GPE_ENABLE:
252 status = acpi_ev_enable_gpe(gpe_event_info);
255 case ACPI_GPE_DISABLE:
256 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
260 status = AE_BAD_PARAMETER;
265 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
266 return_ACPI_STATUS(status);
269 ACPI_EXPORT_SYMBOL(acpi_set_gpe)
271 /*******************************************************************************
273 * FUNCTION: acpi_gpe_wakeup
275 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
276 * gpe_number - GPE level within the GPE block
277 * Action - Enable or Disable
281 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit.
283 ******************************************************************************/
284 acpi_status acpi_gpe_wakeup(acpi_handle gpe_device, u32 gpe_number, u8 action)
286 acpi_status status = AE_OK;
287 struct acpi_gpe_event_info *gpe_event_info;
288 struct acpi_gpe_register_info *gpe_register_info;
289 acpi_cpu_flags flags;
292 ACPI_FUNCTION_TRACE(acpi_gpe_wakeup);
294 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
296 /* Ensure that we have a valid GPE number */
298 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
299 if (!gpe_event_info) {
300 status = AE_BAD_PARAMETER;
301 goto unlock_and_exit;
304 gpe_register_info = gpe_event_info->register_info;
305 if (!gpe_register_info) {
306 status = AE_NOT_EXIST;
307 goto unlock_and_exit;
311 acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
313 /* Perform the action */
316 case ACPI_GPE_ENABLE:
317 ACPI_SET_BIT(gpe_register_info->enable_for_wake,
321 case ACPI_GPE_DISABLE:
322 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
327 ACPI_ERROR((AE_INFO, "%u, Invalid action", action));
328 status = AE_BAD_PARAMETER;
333 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
334 return_ACPI_STATUS(status);
337 ACPI_EXPORT_SYMBOL(acpi_gpe_wakeup)
339 /*******************************************************************************
341 * FUNCTION: acpi_enable_gpe
343 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
344 * gpe_number - GPE level within the GPE block
348 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
351 ******************************************************************************/
352 acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
354 acpi_status status = AE_OK;
355 struct acpi_gpe_event_info *gpe_event_info;
356 acpi_cpu_flags flags;
358 ACPI_FUNCTION_TRACE(acpi_enable_gpe);
360 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
362 /* Ensure that we have a valid GPE number */
364 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
365 if (!gpe_event_info) {
366 status = AE_BAD_PARAMETER;
367 goto unlock_and_exit;
370 if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) {
371 status = AE_LIMIT; /* Too many references */
372 goto unlock_and_exit;
375 gpe_event_info->runtime_count++;
376 if (gpe_event_info->runtime_count == 1) {
377 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
378 if (ACPI_SUCCESS(status)) {
379 status = acpi_ev_enable_gpe(gpe_event_info);
381 if (ACPI_FAILURE(status)) {
382 gpe_event_info->runtime_count--;
387 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
388 return_ACPI_STATUS(status);
390 ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
392 /*******************************************************************************
394 * FUNCTION: acpi_disable_gpe
396 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
397 * gpe_number - GPE level within the GPE block
401 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
402 * removed, only then is the GPE disabled (for runtime GPEs), or
403 * the GPE mask bit disabled (for wake GPEs)
405 ******************************************************************************/
406 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
408 acpi_status status = AE_OK;
409 struct acpi_gpe_event_info *gpe_event_info;
410 acpi_cpu_flags flags;
412 ACPI_FUNCTION_TRACE(acpi_disable_gpe);
414 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
416 /* Ensure that we have a valid GPE number */
418 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
419 if (!gpe_event_info) {
420 status = AE_BAD_PARAMETER;
421 goto unlock_and_exit;
424 /* Hardware-disable a runtime GPE on removal of the last reference */
426 if (!gpe_event_info->runtime_count) {
427 status = AE_LIMIT; /* There are no references to remove */
428 goto unlock_and_exit;
431 gpe_event_info->runtime_count--;
432 if (!gpe_event_info->runtime_count) {
433 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
434 if (ACPI_SUCCESS(status)) {
436 acpi_hw_low_set_gpe(gpe_event_info,
439 if (ACPI_FAILURE(status)) {
440 gpe_event_info->runtime_count++;
445 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
446 return_ACPI_STATUS(status);
448 ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
450 /*******************************************************************************
452 * FUNCTION: acpi_disable_event
454 * PARAMETERS: Event - The fixed eventto be enabled
459 * DESCRIPTION: Disable an ACPI event (fixed)
461 ******************************************************************************/
462 acpi_status acpi_disable_event(u32 event, u32 flags)
464 acpi_status status = AE_OK;
467 ACPI_FUNCTION_TRACE(acpi_disable_event);
469 /* Decode the Fixed Event */
471 if (event > ACPI_EVENT_MAX) {
472 return_ACPI_STATUS(AE_BAD_PARAMETER);
476 * Disable the requested fixed event (by writing a zero to the enable
480 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
481 enable_register_id, ACPI_DISABLE_EVENT);
482 if (ACPI_FAILURE(status)) {
483 return_ACPI_STATUS(status);
487 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
488 enable_register_id, &value);
489 if (ACPI_FAILURE(status)) {
490 return_ACPI_STATUS(status);
495 "Could not disable %s events",
496 acpi_ut_get_event_name(event)));
497 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
500 return_ACPI_STATUS(status);
503 ACPI_EXPORT_SYMBOL(acpi_disable_event)
505 /*******************************************************************************
507 * FUNCTION: acpi_clear_event
509 * PARAMETERS: Event - The fixed event to be cleared
513 * DESCRIPTION: Clear an ACPI event (fixed)
515 ******************************************************************************/
516 acpi_status acpi_clear_event(u32 event)
518 acpi_status status = AE_OK;
520 ACPI_FUNCTION_TRACE(acpi_clear_event);
522 /* Decode the Fixed Event */
524 if (event > ACPI_EVENT_MAX) {
525 return_ACPI_STATUS(AE_BAD_PARAMETER);
529 * Clear the requested fixed event (By writing a one to the status
533 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
534 status_register_id, ACPI_CLEAR_STATUS);
536 return_ACPI_STATUS(status);
539 ACPI_EXPORT_SYMBOL(acpi_clear_event)
541 /*******************************************************************************
543 * FUNCTION: acpi_clear_gpe
545 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
546 * gpe_number - GPE level within the GPE block
550 * DESCRIPTION: Clear an ACPI event (general purpose)
552 ******************************************************************************/
553 acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number)
555 acpi_status status = AE_OK;
556 struct acpi_gpe_event_info *gpe_event_info;
557 acpi_cpu_flags flags;
559 ACPI_FUNCTION_TRACE(acpi_clear_gpe);
561 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
563 /* Ensure that we have a valid GPE number */
565 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
566 if (!gpe_event_info) {
567 status = AE_BAD_PARAMETER;
568 goto unlock_and_exit;
571 status = acpi_hw_clear_gpe(gpe_event_info);
574 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
575 return_ACPI_STATUS(status);
578 ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
579 /*******************************************************************************
581 * FUNCTION: acpi_get_event_status
583 * PARAMETERS: Event - The fixed event
584 * event_status - Where the current status of the event will
589 * DESCRIPTION: Obtains and returns the current status of the event
591 ******************************************************************************/
592 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
594 acpi_status status = AE_OK;
597 ACPI_FUNCTION_TRACE(acpi_get_event_status);
600 return_ACPI_STATUS(AE_BAD_PARAMETER);
603 /* Decode the Fixed Event */
605 if (event > ACPI_EVENT_MAX) {
606 return_ACPI_STATUS(AE_BAD_PARAMETER);
609 /* Get the status of the requested fixed event */
612 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
613 enable_register_id, &value);
614 if (ACPI_FAILURE(status))
615 return_ACPI_STATUS(status);
617 *event_status = value;
620 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
621 status_register_id, &value);
622 if (ACPI_FAILURE(status))
623 return_ACPI_STATUS(status);
626 *event_status |= ACPI_EVENT_FLAG_SET;
628 if (acpi_gbl_fixed_event_handlers[event].handler)
629 *event_status |= ACPI_EVENT_FLAG_HANDLE;
631 return_ACPI_STATUS(status);
634 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
636 /*******************************************************************************
638 * FUNCTION: acpi_get_gpe_status
640 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
641 * gpe_number - GPE level within the GPE block
642 * event_status - Where the current status of the event will
647 * DESCRIPTION: Get status of an event (general purpose)
649 ******************************************************************************/
651 acpi_get_gpe_status(acpi_handle gpe_device,
652 u32 gpe_number, acpi_event_status *event_status)
654 acpi_status status = AE_OK;
655 struct acpi_gpe_event_info *gpe_event_info;
656 acpi_cpu_flags flags;
658 ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
660 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
662 /* Ensure that we have a valid GPE number */
664 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
665 if (!gpe_event_info) {
666 status = AE_BAD_PARAMETER;
667 goto unlock_and_exit;
670 /* Obtain status on the requested GPE number */
672 status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
674 if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)
675 *event_status |= ACPI_EVENT_FLAG_HANDLE;
678 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
679 return_ACPI_STATUS(status);
682 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
683 /*******************************************************************************
685 * FUNCTION: acpi_install_gpe_block
687 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
688 * gpe_block_address - Address and space_iD
689 * register_count - Number of GPE register pairs in the block
690 * interrupt_number - H/W interrupt for the block
694 * DESCRIPTION: Create and Install a block of GPE registers
696 ******************************************************************************/
698 acpi_install_gpe_block(acpi_handle gpe_device,
699 struct acpi_generic_address *gpe_block_address,
700 u32 register_count, u32 interrupt_number)
703 union acpi_operand_object *obj_desc;
704 struct acpi_namespace_node *node;
705 struct acpi_gpe_block_info *gpe_block;
707 ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
709 if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
710 return_ACPI_STATUS(AE_BAD_PARAMETER);
713 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
714 if (ACPI_FAILURE(status)) {
718 node = acpi_ns_validate_handle(gpe_device);
720 status = AE_BAD_PARAMETER;
721 goto unlock_and_exit;
725 * For user-installed GPE Block Devices, the gpe_block_base_number
729 acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
730 interrupt_number, &gpe_block);
731 if (ACPI_FAILURE(status)) {
732 goto unlock_and_exit;
735 /* Install block in the device_object attached to the node */
737 obj_desc = acpi_ns_get_attached_object(node);
741 * No object, create a new one (Device nodes do not always have
742 * an attached object)
744 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
746 status = AE_NO_MEMORY;
747 goto unlock_and_exit;
751 acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
753 /* Remove local reference to the object */
755 acpi_ut_remove_reference(obj_desc);
757 if (ACPI_FAILURE(status)) {
758 goto unlock_and_exit;
762 /* Now install the GPE block in the device_object */
764 obj_desc->device.gpe_block = gpe_block;
766 /* Run the _PRW methods and enable the runtime GPEs in the new block */
768 status = acpi_ev_initialize_gpe_block(node, gpe_block);
771 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
772 return_ACPI_STATUS(status);
775 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
777 /*******************************************************************************
779 * FUNCTION: acpi_remove_gpe_block
781 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
785 * DESCRIPTION: Remove a previously installed block of GPE registers
787 ******************************************************************************/
788 acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
790 union acpi_operand_object *obj_desc;
792 struct acpi_namespace_node *node;
794 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
797 return_ACPI_STATUS(AE_BAD_PARAMETER);
800 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
801 if (ACPI_FAILURE(status)) {
805 node = acpi_ns_validate_handle(gpe_device);
807 status = AE_BAD_PARAMETER;
808 goto unlock_and_exit;
811 /* Get the device_object attached to the node */
813 obj_desc = acpi_ns_get_attached_object(node);
814 if (!obj_desc || !obj_desc->device.gpe_block) {
815 return_ACPI_STATUS(AE_NULL_OBJECT);
818 /* Delete the GPE block (but not the device_object) */
820 status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
821 if (ACPI_SUCCESS(status)) {
822 obj_desc->device.gpe_block = NULL;
826 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
827 return_ACPI_STATUS(status);
830 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
832 /*******************************************************************************
834 * FUNCTION: acpi_get_gpe_device
836 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
837 * gpe_device - Where the parent GPE Device is returned
841 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
842 * gpe device indicates that the gpe number is contained in one of
843 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
845 ******************************************************************************/
847 acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
849 struct acpi_gpe_device_info info;
852 ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
855 return_ACPI_STATUS(AE_BAD_PARAMETER);
858 if (index >= acpi_current_gpe_count) {
859 return_ACPI_STATUS(AE_NOT_EXIST);
862 /* Setup and walk the GPE list */
865 info.status = AE_NOT_EXIST;
866 info.gpe_device = NULL;
867 info.next_block_base_index = 0;
869 status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
870 if (ACPI_FAILURE(status)) {
871 return_ACPI_STATUS(status);
874 *gpe_device = info.gpe_device;
875 return_ACPI_STATUS(info.status);
878 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
880 /*******************************************************************************
882 * FUNCTION: acpi_ev_get_gpe_device
884 * PARAMETERS: GPE_WALK_CALLBACK
888 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
889 * block device. NULL if the GPE is one of the FADT-defined GPEs.
891 ******************************************************************************/
893 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
894 struct acpi_gpe_block_info *gpe_block, void *context)
896 struct acpi_gpe_device_info *info = context;
898 /* Increment Index by the number of GPEs in this block */
900 info->next_block_base_index += gpe_block->gpe_count;
902 if (info->index < info->next_block_base_index) {
904 * The GPE index is within this block, get the node. Leave the node
905 * NULL for the FADT-defined GPEs
907 if ((gpe_block->node)->type == ACPI_TYPE_DEVICE) {
908 info->gpe_device = gpe_block->node;
911 info->status = AE_OK;
912 return (AE_CTRL_END);
918 /******************************************************************************
920 * FUNCTION: acpi_disable_all_gpes
926 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
928 ******************************************************************************/
930 acpi_status acpi_disable_all_gpes(void)
934 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
936 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
937 if (ACPI_FAILURE(status)) {
938 return_ACPI_STATUS(status);
941 status = acpi_hw_disable_all_gpes();
942 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
944 return_ACPI_STATUS(status);
947 /******************************************************************************
949 * FUNCTION: acpi_enable_all_runtime_gpes
955 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
957 ******************************************************************************/
959 acpi_status acpi_enable_all_runtime_gpes(void)
963 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
965 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
966 if (ACPI_FAILURE(status)) {
967 return_ACPI_STATUS(status);
970 status = acpi_hw_enable_all_runtime_gpes();
971 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
973 return_ACPI_STATUS(status);