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_gpe_wakeup
215 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
216 * gpe_number - GPE level within the GPE block
217 * Action - Enable or Disable
221 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit.
223 ******************************************************************************/
224 acpi_status acpi_gpe_wakeup(acpi_handle gpe_device, u32 gpe_number, u8 action)
226 acpi_status status = AE_OK;
227 struct acpi_gpe_event_info *gpe_event_info;
228 struct acpi_gpe_register_info *gpe_register_info;
229 acpi_cpu_flags flags;
232 ACPI_FUNCTION_TRACE(acpi_gpe_wakeup);
234 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
236 /* Ensure that we have a valid GPE number */
238 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
239 if (!gpe_event_info) {
240 status = AE_BAD_PARAMETER;
241 goto unlock_and_exit;
244 gpe_register_info = gpe_event_info->register_info;
245 if (!gpe_register_info) {
246 status = AE_NOT_EXIST;
247 goto unlock_and_exit;
251 acpi_hw_get_gpe_register_bit(gpe_event_info, gpe_register_info);
253 /* Perform the action */
256 case ACPI_GPE_ENABLE:
257 ACPI_SET_BIT(gpe_register_info->enable_for_wake,
261 case ACPI_GPE_DISABLE:
262 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
267 ACPI_ERROR((AE_INFO, "%u, Invalid action", action));
268 status = AE_BAD_PARAMETER;
273 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
274 return_ACPI_STATUS(status);
277 ACPI_EXPORT_SYMBOL(acpi_gpe_wakeup)
279 /*******************************************************************************
281 * FUNCTION: acpi_enable_gpe
283 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
284 * gpe_number - GPE level within the GPE block
288 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
291 ******************************************************************************/
292 acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
294 acpi_status status = AE_OK;
295 struct acpi_gpe_event_info *gpe_event_info;
296 acpi_cpu_flags flags;
298 ACPI_FUNCTION_TRACE(acpi_enable_gpe);
300 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
302 /* Ensure that we have a valid GPE number */
304 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
305 if (!gpe_event_info) {
306 status = AE_BAD_PARAMETER;
307 goto unlock_and_exit;
310 if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) {
311 status = AE_LIMIT; /* Too many references */
312 goto unlock_and_exit;
315 gpe_event_info->runtime_count++;
316 if (gpe_event_info->runtime_count == 1) {
317 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
318 if (ACPI_SUCCESS(status)) {
319 status = acpi_ev_enable_gpe(gpe_event_info);
321 if (ACPI_FAILURE(status)) {
322 gpe_event_info->runtime_count--;
327 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
328 return_ACPI_STATUS(status);
330 ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
332 /*******************************************************************************
334 * FUNCTION: acpi_disable_gpe
336 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
337 * gpe_number - GPE level within the GPE block
341 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
342 * removed, only then is the GPE disabled (for runtime GPEs), or
343 * the GPE mask bit disabled (for wake GPEs)
345 ******************************************************************************/
346 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
348 acpi_status status = AE_OK;
349 struct acpi_gpe_event_info *gpe_event_info;
350 acpi_cpu_flags flags;
352 ACPI_FUNCTION_TRACE(acpi_disable_gpe);
354 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
356 /* Ensure that we have a valid GPE number */
358 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
359 if (!gpe_event_info) {
360 status = AE_BAD_PARAMETER;
361 goto unlock_and_exit;
364 /* Hardware-disable a runtime GPE on removal of the last reference */
366 if (!gpe_event_info->runtime_count) {
367 status = AE_LIMIT; /* There are no references to remove */
368 goto unlock_and_exit;
371 gpe_event_info->runtime_count--;
372 if (!gpe_event_info->runtime_count) {
373 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
374 if (ACPI_SUCCESS(status)) {
376 acpi_hw_low_set_gpe(gpe_event_info,
379 if (ACPI_FAILURE(status)) {
380 gpe_event_info->runtime_count++;
385 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
386 return_ACPI_STATUS(status);
388 ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
390 /*******************************************************************************
392 * FUNCTION: acpi_gpe_can_wake
394 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
395 * gpe_number - GPE level within the GPE block
399 * DESCRIPTION: Set the ACPI_GPE_CAN_WAKE flag for the given GPE. If the GPE
400 * has a corresponding method and is currently enabled, disable it
401 * (GPEs with corresponding methods are enabled unconditionally
402 * during initialization, but GPEs that can wake up are expected
403 * to be initially disabled).
405 ******************************************************************************/
406 acpi_status acpi_gpe_can_wake(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;
413 ACPI_FUNCTION_TRACE(acpi_gpe_can_wake);
415 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
417 /* Ensure that we have a valid GPE number */
419 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
420 if (!gpe_event_info) {
421 status = AE_BAD_PARAMETER;
422 goto unlock_and_exit;
425 if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) {
426 goto unlock_and_exit;
429 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
430 disable = (gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD)
431 && gpe_event_info->runtime_count;
434 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
437 status = acpi_disable_gpe(gpe_device, gpe_number);
439 return_ACPI_STATUS(status);
441 ACPI_EXPORT_SYMBOL(acpi_gpe_can_wake)
443 /*******************************************************************************
445 * FUNCTION: acpi_disable_event
447 * PARAMETERS: Event - The fixed eventto be enabled
452 * DESCRIPTION: Disable an ACPI event (fixed)
454 ******************************************************************************/
455 acpi_status acpi_disable_event(u32 event, u32 flags)
457 acpi_status status = AE_OK;
460 ACPI_FUNCTION_TRACE(acpi_disable_event);
462 /* Decode the Fixed Event */
464 if (event > ACPI_EVENT_MAX) {
465 return_ACPI_STATUS(AE_BAD_PARAMETER);
469 * Disable the requested fixed event (by writing a zero to the enable
473 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
474 enable_register_id, ACPI_DISABLE_EVENT);
475 if (ACPI_FAILURE(status)) {
476 return_ACPI_STATUS(status);
480 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
481 enable_register_id, &value);
482 if (ACPI_FAILURE(status)) {
483 return_ACPI_STATUS(status);
488 "Could not disable %s events",
489 acpi_ut_get_event_name(event)));
490 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
493 return_ACPI_STATUS(status);
496 ACPI_EXPORT_SYMBOL(acpi_disable_event)
498 /*******************************************************************************
500 * FUNCTION: acpi_clear_event
502 * PARAMETERS: Event - The fixed event to be cleared
506 * DESCRIPTION: Clear an ACPI event (fixed)
508 ******************************************************************************/
509 acpi_status acpi_clear_event(u32 event)
511 acpi_status status = AE_OK;
513 ACPI_FUNCTION_TRACE(acpi_clear_event);
515 /* Decode the Fixed Event */
517 if (event > ACPI_EVENT_MAX) {
518 return_ACPI_STATUS(AE_BAD_PARAMETER);
522 * Clear the requested fixed event (By writing a one to the status
526 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
527 status_register_id, ACPI_CLEAR_STATUS);
529 return_ACPI_STATUS(status);
532 ACPI_EXPORT_SYMBOL(acpi_clear_event)
534 /*******************************************************************************
536 * FUNCTION: acpi_clear_gpe
538 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
539 * gpe_number - GPE level within the GPE block
543 * DESCRIPTION: Clear an ACPI event (general purpose)
545 ******************************************************************************/
546 acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number)
548 acpi_status status = AE_OK;
549 struct acpi_gpe_event_info *gpe_event_info;
550 acpi_cpu_flags flags;
552 ACPI_FUNCTION_TRACE(acpi_clear_gpe);
554 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
556 /* Ensure that we have a valid GPE number */
558 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
559 if (!gpe_event_info) {
560 status = AE_BAD_PARAMETER;
561 goto unlock_and_exit;
564 status = acpi_hw_clear_gpe(gpe_event_info);
567 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
568 return_ACPI_STATUS(status);
571 ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
572 /*******************************************************************************
574 * FUNCTION: acpi_get_event_status
576 * PARAMETERS: Event - The fixed event
577 * event_status - Where the current status of the event will
582 * DESCRIPTION: Obtains and returns the current status of the event
584 ******************************************************************************/
585 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
587 acpi_status status = AE_OK;
590 ACPI_FUNCTION_TRACE(acpi_get_event_status);
593 return_ACPI_STATUS(AE_BAD_PARAMETER);
596 /* Decode the Fixed Event */
598 if (event > ACPI_EVENT_MAX) {
599 return_ACPI_STATUS(AE_BAD_PARAMETER);
602 /* Get the status of the requested fixed event */
605 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
606 enable_register_id, &value);
607 if (ACPI_FAILURE(status))
608 return_ACPI_STATUS(status);
610 *event_status = value;
613 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
614 status_register_id, &value);
615 if (ACPI_FAILURE(status))
616 return_ACPI_STATUS(status);
619 *event_status |= ACPI_EVENT_FLAG_SET;
621 if (acpi_gbl_fixed_event_handlers[event].handler)
622 *event_status |= ACPI_EVENT_FLAG_HANDLE;
624 return_ACPI_STATUS(status);
627 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
629 /*******************************************************************************
631 * FUNCTION: acpi_get_gpe_status
633 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
634 * gpe_number - GPE level within the GPE block
635 * event_status - Where the current status of the event will
640 * DESCRIPTION: Get status of an event (general purpose)
642 ******************************************************************************/
644 acpi_get_gpe_status(acpi_handle gpe_device,
645 u32 gpe_number, acpi_event_status *event_status)
647 acpi_status status = AE_OK;
648 struct acpi_gpe_event_info *gpe_event_info;
649 acpi_cpu_flags flags;
651 ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
653 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
655 /* Ensure that we have a valid GPE number */
657 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
658 if (!gpe_event_info) {
659 status = AE_BAD_PARAMETER;
660 goto unlock_and_exit;
663 /* Obtain status on the requested GPE number */
665 status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
667 if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)
668 *event_status |= ACPI_EVENT_FLAG_HANDLE;
671 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
672 return_ACPI_STATUS(status);
675 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
676 /*******************************************************************************
678 * FUNCTION: acpi_install_gpe_block
680 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
681 * gpe_block_address - Address and space_iD
682 * register_count - Number of GPE register pairs in the block
683 * interrupt_number - H/W interrupt for the block
687 * DESCRIPTION: Create and Install a block of GPE registers
689 ******************************************************************************/
691 acpi_install_gpe_block(acpi_handle gpe_device,
692 struct acpi_generic_address *gpe_block_address,
693 u32 register_count, u32 interrupt_number)
696 union acpi_operand_object *obj_desc;
697 struct acpi_namespace_node *node;
698 struct acpi_gpe_block_info *gpe_block;
700 ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
702 if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
703 return_ACPI_STATUS(AE_BAD_PARAMETER);
706 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
707 if (ACPI_FAILURE(status)) {
711 node = acpi_ns_validate_handle(gpe_device);
713 status = AE_BAD_PARAMETER;
714 goto unlock_and_exit;
718 * For user-installed GPE Block Devices, the gpe_block_base_number
722 acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
723 interrupt_number, &gpe_block);
724 if (ACPI_FAILURE(status)) {
725 goto unlock_and_exit;
728 /* Install block in the device_object attached to the node */
730 obj_desc = acpi_ns_get_attached_object(node);
734 * No object, create a new one (Device nodes do not always have
735 * an attached object)
737 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
739 status = AE_NO_MEMORY;
740 goto unlock_and_exit;
744 acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
746 /* Remove local reference to the object */
748 acpi_ut_remove_reference(obj_desc);
750 if (ACPI_FAILURE(status)) {
751 goto unlock_and_exit;
755 /* Now install the GPE block in the device_object */
757 obj_desc->device.gpe_block = gpe_block;
759 /* Enable the runtime GPEs in the new block */
761 status = acpi_ev_initialize_gpe_block(node, gpe_block);
764 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
765 return_ACPI_STATUS(status);
768 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
770 /*******************************************************************************
772 * FUNCTION: acpi_remove_gpe_block
774 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
778 * DESCRIPTION: Remove a previously installed block of GPE registers
780 ******************************************************************************/
781 acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
783 union acpi_operand_object *obj_desc;
785 struct acpi_namespace_node *node;
787 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
790 return_ACPI_STATUS(AE_BAD_PARAMETER);
793 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
794 if (ACPI_FAILURE(status)) {
798 node = acpi_ns_validate_handle(gpe_device);
800 status = AE_BAD_PARAMETER;
801 goto unlock_and_exit;
804 /* Get the device_object attached to the node */
806 obj_desc = acpi_ns_get_attached_object(node);
807 if (!obj_desc || !obj_desc->device.gpe_block) {
808 return_ACPI_STATUS(AE_NULL_OBJECT);
811 /* Delete the GPE block (but not the device_object) */
813 status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
814 if (ACPI_SUCCESS(status)) {
815 obj_desc->device.gpe_block = NULL;
819 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
820 return_ACPI_STATUS(status);
823 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
825 /*******************************************************************************
827 * FUNCTION: acpi_get_gpe_device
829 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
830 * gpe_device - Where the parent GPE Device is returned
834 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
835 * gpe device indicates that the gpe number is contained in one of
836 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
838 ******************************************************************************/
840 acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
842 struct acpi_gpe_device_info info;
845 ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
848 return_ACPI_STATUS(AE_BAD_PARAMETER);
851 if (index >= acpi_current_gpe_count) {
852 return_ACPI_STATUS(AE_NOT_EXIST);
855 /* Setup and walk the GPE list */
858 info.status = AE_NOT_EXIST;
859 info.gpe_device = NULL;
860 info.next_block_base_index = 0;
862 status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
863 if (ACPI_FAILURE(status)) {
864 return_ACPI_STATUS(status);
867 *gpe_device = info.gpe_device;
868 return_ACPI_STATUS(info.status);
871 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
873 /*******************************************************************************
875 * FUNCTION: acpi_ev_get_gpe_device
877 * PARAMETERS: GPE_WALK_CALLBACK
881 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
882 * block device. NULL if the GPE is one of the FADT-defined GPEs.
884 ******************************************************************************/
886 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
887 struct acpi_gpe_block_info *gpe_block, void *context)
889 struct acpi_gpe_device_info *info = context;
891 /* Increment Index by the number of GPEs in this block */
893 info->next_block_base_index += gpe_block->gpe_count;
895 if (info->index < info->next_block_base_index) {
897 * The GPE index is within this block, get the node. Leave the node
898 * NULL for the FADT-defined GPEs
900 if ((gpe_block->node)->type == ACPI_TYPE_DEVICE) {
901 info->gpe_device = gpe_block->node;
904 info->status = AE_OK;
905 return (AE_CTRL_END);
911 /******************************************************************************
913 * FUNCTION: acpi_disable_all_gpes
919 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
921 ******************************************************************************/
923 acpi_status acpi_disable_all_gpes(void)
927 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
929 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
930 if (ACPI_FAILURE(status)) {
931 return_ACPI_STATUS(status);
934 status = acpi_hw_disable_all_gpes();
935 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
937 return_ACPI_STATUS(status);
940 /******************************************************************************
942 * FUNCTION: acpi_enable_all_runtime_gpes
948 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
950 ******************************************************************************/
952 acpi_status acpi_enable_all_runtime_gpes(void)
956 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
958 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
959 if (ACPI_FAILURE(status)) {
960 return_ACPI_STATUS(status);
963 status = acpi_hw_enable_all_runtime_gpes();
964 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
966 return_ACPI_STATUS(status);