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 || !(gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) {
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_BAD_PARAMETER;
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 = acpi_raw_enable_gpe(gpe_event_info);
309 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
310 return_ACPI_STATUS(status);
312 ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
314 /*******************************************************************************
316 * FUNCTION: acpi_disable_gpe
318 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
319 * gpe_number - GPE level within the GPE block
323 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
324 * removed, only then is the GPE disabled (for runtime GPEs), or
325 * the GPE mask bit disabled (for wake GPEs)
327 ******************************************************************************/
328 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
330 acpi_status status = AE_BAD_PARAMETER;
331 struct acpi_gpe_event_info *gpe_event_info;
332 acpi_cpu_flags flags;
334 ACPI_FUNCTION_TRACE(acpi_disable_gpe);
336 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
338 /* Ensure that we have a valid GPE number */
340 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
341 if (gpe_event_info) {
342 status = acpi_raw_disable_gpe(gpe_event_info) ;
345 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
346 return_ACPI_STATUS(status);
348 ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
350 /*******************************************************************************
352 * FUNCTION: acpi_gpe_can_wake
354 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
355 * gpe_number - GPE level within the GPE block
359 * DESCRIPTION: Set the ACPI_GPE_CAN_WAKE flag for the given GPE. If the GPE
360 * has a corresponding method and is currently enabled, disable it
361 * (GPEs with corresponding methods are enabled unconditionally
362 * during initialization, but GPEs that can wake up are expected
363 * to be initially disabled).
365 ******************************************************************************/
366 acpi_status acpi_gpe_can_wake(acpi_handle gpe_device, u32 gpe_number)
368 acpi_status status = AE_OK;
369 struct acpi_gpe_event_info *gpe_event_info;
370 acpi_cpu_flags flags;
372 ACPI_FUNCTION_TRACE(acpi_gpe_can_wake);
374 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
376 /* Ensure that we have a valid GPE number */
378 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
379 if (!gpe_event_info) {
380 status = AE_BAD_PARAMETER;
381 goto unlock_and_exit;
384 if (gpe_event_info->flags & ACPI_GPE_CAN_WAKE) {
385 goto unlock_and_exit;
388 gpe_event_info->flags |= ACPI_GPE_CAN_WAKE;
389 if (gpe_event_info->flags & ACPI_GPE_DISPATCH_METHOD) {
390 (void)acpi_raw_disable_gpe(gpe_event_info);
394 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
395 return_ACPI_STATUS(status);
397 ACPI_EXPORT_SYMBOL(acpi_gpe_can_wake)
399 /*******************************************************************************
401 * FUNCTION: acpi_disable_event
403 * PARAMETERS: Event - The fixed eventto be enabled
408 * DESCRIPTION: Disable an ACPI event (fixed)
410 ******************************************************************************/
411 acpi_status acpi_disable_event(u32 event, u32 flags)
413 acpi_status status = AE_OK;
416 ACPI_FUNCTION_TRACE(acpi_disable_event);
418 /* Decode the Fixed Event */
420 if (event > ACPI_EVENT_MAX) {
421 return_ACPI_STATUS(AE_BAD_PARAMETER);
425 * Disable the requested fixed event (by writing a zero to the enable
429 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
430 enable_register_id, ACPI_DISABLE_EVENT);
431 if (ACPI_FAILURE(status)) {
432 return_ACPI_STATUS(status);
436 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
437 enable_register_id, &value);
438 if (ACPI_FAILURE(status)) {
439 return_ACPI_STATUS(status);
444 "Could not disable %s events",
445 acpi_ut_get_event_name(event)));
446 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
449 return_ACPI_STATUS(status);
452 ACPI_EXPORT_SYMBOL(acpi_disable_event)
454 /*******************************************************************************
456 * FUNCTION: acpi_clear_event
458 * PARAMETERS: Event - The fixed event to be cleared
462 * DESCRIPTION: Clear an ACPI event (fixed)
464 ******************************************************************************/
465 acpi_status acpi_clear_event(u32 event)
467 acpi_status status = AE_OK;
469 ACPI_FUNCTION_TRACE(acpi_clear_event);
471 /* Decode the Fixed Event */
473 if (event > ACPI_EVENT_MAX) {
474 return_ACPI_STATUS(AE_BAD_PARAMETER);
478 * Clear the requested fixed event (By writing a one to the status
482 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
483 status_register_id, ACPI_CLEAR_STATUS);
485 return_ACPI_STATUS(status);
488 ACPI_EXPORT_SYMBOL(acpi_clear_event)
490 /*******************************************************************************
492 * FUNCTION: acpi_clear_gpe
494 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
495 * gpe_number - GPE level within the GPE block
499 * DESCRIPTION: Clear an ACPI event (general purpose)
501 ******************************************************************************/
502 acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number)
504 acpi_status status = AE_OK;
505 struct acpi_gpe_event_info *gpe_event_info;
506 acpi_cpu_flags flags;
508 ACPI_FUNCTION_TRACE(acpi_clear_gpe);
510 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
512 /* Ensure that we have a valid GPE number */
514 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
515 if (!gpe_event_info) {
516 status = AE_BAD_PARAMETER;
517 goto unlock_and_exit;
520 status = acpi_hw_clear_gpe(gpe_event_info);
523 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
524 return_ACPI_STATUS(status);
527 ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
528 /*******************************************************************************
530 * FUNCTION: acpi_get_event_status
532 * PARAMETERS: Event - The fixed event
533 * event_status - Where the current status of the event will
538 * DESCRIPTION: Obtains and returns the current status of the event
540 ******************************************************************************/
541 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
543 acpi_status status = AE_OK;
546 ACPI_FUNCTION_TRACE(acpi_get_event_status);
549 return_ACPI_STATUS(AE_BAD_PARAMETER);
552 /* Decode the Fixed Event */
554 if (event > ACPI_EVENT_MAX) {
555 return_ACPI_STATUS(AE_BAD_PARAMETER);
558 /* Get the status of the requested fixed event */
561 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
562 enable_register_id, &value);
563 if (ACPI_FAILURE(status))
564 return_ACPI_STATUS(status);
566 *event_status = value;
569 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
570 status_register_id, &value);
571 if (ACPI_FAILURE(status))
572 return_ACPI_STATUS(status);
575 *event_status |= ACPI_EVENT_FLAG_SET;
577 if (acpi_gbl_fixed_event_handlers[event].handler)
578 *event_status |= ACPI_EVENT_FLAG_HANDLE;
580 return_ACPI_STATUS(status);
583 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
585 /*******************************************************************************
587 * FUNCTION: acpi_get_gpe_status
589 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
590 * gpe_number - GPE level within the GPE block
591 * event_status - Where the current status of the event will
596 * DESCRIPTION: Get status of an event (general purpose)
598 ******************************************************************************/
600 acpi_get_gpe_status(acpi_handle gpe_device,
601 u32 gpe_number, acpi_event_status *event_status)
603 acpi_status status = AE_OK;
604 struct acpi_gpe_event_info *gpe_event_info;
605 acpi_cpu_flags flags;
607 ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
609 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
611 /* Ensure that we have a valid GPE number */
613 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
614 if (!gpe_event_info) {
615 status = AE_BAD_PARAMETER;
616 goto unlock_and_exit;
619 /* Obtain status on the requested GPE number */
621 status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
623 if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)
624 *event_status |= ACPI_EVENT_FLAG_HANDLE;
627 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
628 return_ACPI_STATUS(status);
631 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
632 /*******************************************************************************
634 * FUNCTION: acpi_install_gpe_block
636 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
637 * gpe_block_address - Address and space_iD
638 * register_count - Number of GPE register pairs in the block
639 * interrupt_number - H/W interrupt for the block
643 * DESCRIPTION: Create and Install a block of GPE registers
645 ******************************************************************************/
647 acpi_install_gpe_block(acpi_handle gpe_device,
648 struct acpi_generic_address *gpe_block_address,
649 u32 register_count, u32 interrupt_number)
652 union acpi_operand_object *obj_desc;
653 struct acpi_namespace_node *node;
654 struct acpi_gpe_block_info *gpe_block;
656 ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
658 if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
659 return_ACPI_STATUS(AE_BAD_PARAMETER);
662 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
663 if (ACPI_FAILURE(status)) {
667 node = acpi_ns_validate_handle(gpe_device);
669 status = AE_BAD_PARAMETER;
670 goto unlock_and_exit;
674 * For user-installed GPE Block Devices, the gpe_block_base_number
678 acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
679 interrupt_number, &gpe_block);
680 if (ACPI_FAILURE(status)) {
681 goto unlock_and_exit;
684 /* Install block in the device_object attached to the node */
686 obj_desc = acpi_ns_get_attached_object(node);
690 * No object, create a new one (Device nodes do not always have
691 * an attached object)
693 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
695 status = AE_NO_MEMORY;
696 goto unlock_and_exit;
700 acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
702 /* Remove local reference to the object */
704 acpi_ut_remove_reference(obj_desc);
706 if (ACPI_FAILURE(status)) {
707 goto unlock_and_exit;
711 /* Now install the GPE block in the device_object */
713 obj_desc->device.gpe_block = gpe_block;
715 /* Enable the runtime GPEs in the new block */
717 status = acpi_ev_initialize_gpe_block(node, gpe_block);
720 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
721 return_ACPI_STATUS(status);
724 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
726 /*******************************************************************************
728 * FUNCTION: acpi_remove_gpe_block
730 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
734 * DESCRIPTION: Remove a previously installed block of GPE registers
736 ******************************************************************************/
737 acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
739 union acpi_operand_object *obj_desc;
741 struct acpi_namespace_node *node;
743 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
746 return_ACPI_STATUS(AE_BAD_PARAMETER);
749 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
750 if (ACPI_FAILURE(status)) {
754 node = acpi_ns_validate_handle(gpe_device);
756 status = AE_BAD_PARAMETER;
757 goto unlock_and_exit;
760 /* Get the device_object attached to the node */
762 obj_desc = acpi_ns_get_attached_object(node);
763 if (!obj_desc || !obj_desc->device.gpe_block) {
764 return_ACPI_STATUS(AE_NULL_OBJECT);
767 /* Delete the GPE block (but not the device_object) */
769 status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
770 if (ACPI_SUCCESS(status)) {
771 obj_desc->device.gpe_block = NULL;
775 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
776 return_ACPI_STATUS(status);
779 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
781 /*******************************************************************************
783 * FUNCTION: acpi_get_gpe_device
785 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
786 * gpe_device - Where the parent GPE Device is returned
790 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
791 * gpe device indicates that the gpe number is contained in one of
792 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
794 ******************************************************************************/
796 acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
798 struct acpi_gpe_device_info info;
801 ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
804 return_ACPI_STATUS(AE_BAD_PARAMETER);
807 if (index >= acpi_current_gpe_count) {
808 return_ACPI_STATUS(AE_NOT_EXIST);
811 /* Setup and walk the GPE list */
814 info.status = AE_NOT_EXIST;
815 info.gpe_device = NULL;
816 info.next_block_base_index = 0;
818 status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
819 if (ACPI_FAILURE(status)) {
820 return_ACPI_STATUS(status);
823 *gpe_device = info.gpe_device;
824 return_ACPI_STATUS(info.status);
827 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
829 /*******************************************************************************
831 * FUNCTION: acpi_ev_get_gpe_device
833 * PARAMETERS: GPE_WALK_CALLBACK
837 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
838 * block device. NULL if the GPE is one of the FADT-defined GPEs.
840 ******************************************************************************/
842 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
843 struct acpi_gpe_block_info *gpe_block, void *context)
845 struct acpi_gpe_device_info *info = context;
847 /* Increment Index by the number of GPEs in this block */
849 info->next_block_base_index += gpe_block->gpe_count;
851 if (info->index < info->next_block_base_index) {
853 * The GPE index is within this block, get the node. Leave the node
854 * NULL for the FADT-defined GPEs
856 if ((gpe_block->node)->type == ACPI_TYPE_DEVICE) {
857 info->gpe_device = gpe_block->node;
860 info->status = AE_OK;
861 return (AE_CTRL_END);
867 /******************************************************************************
869 * FUNCTION: acpi_disable_all_gpes
875 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
877 ******************************************************************************/
879 acpi_status acpi_disable_all_gpes(void)
883 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
885 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
886 if (ACPI_FAILURE(status)) {
887 return_ACPI_STATUS(status);
890 status = acpi_hw_disable_all_gpes();
891 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
893 return_ACPI_STATUS(status);
896 /******************************************************************************
898 * FUNCTION: acpi_enable_all_runtime_gpes
904 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
906 ******************************************************************************/
908 acpi_status acpi_enable_all_runtime_gpes(void)
912 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
914 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
915 if (ACPI_FAILURE(status)) {
916 return_ACPI_STATUS(status);
919 status = acpi_hw_enable_all_runtime_gpes();
920 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
922 return_ACPI_STATUS(status);