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)
72 acpi_status status
= AE_OK
;
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"));
88 /* Transition to ACPI mode */
90 status
= acpi_hw_set_mode(ACPI_SYS_MODE_ACPI
);
91 if (ACPI_FAILURE(status
)) {
93 "Could not transition to ACPI mode"));
94 return_ACPI_STATUS(status
);
97 ACPI_DEBUG_PRINT((ACPI_DB_INIT
,
98 "Transition to ACPI mode successful\n"));
101 return_ACPI_STATUS(status
);
104 ACPI_EXPORT_SYMBOL(acpi_enable
)
106 /*******************************************************************************
108 * FUNCTION: acpi_disable
114 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
116 ******************************************************************************/
117 acpi_status
acpi_disable(void)
119 acpi_status status
= AE_OK
;
121 ACPI_FUNCTION_TRACE(acpi_disable
);
123 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY
) {
124 ACPI_DEBUG_PRINT((ACPI_DB_INIT
,
125 "System is already in legacy (non-ACPI) mode\n"));
127 /* Transition to LEGACY mode */
129 status
= acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY
);
131 if (ACPI_FAILURE(status
)) {
133 "Could not exit ACPI mode to legacy mode"));
134 return_ACPI_STATUS(status
);
137 ACPI_DEBUG_PRINT((ACPI_DB_INIT
, "ACPI mode disabled\n"));
140 return_ACPI_STATUS(status
);
143 ACPI_EXPORT_SYMBOL(acpi_disable
)
145 /*******************************************************************************
147 * FUNCTION: acpi_enable_event
149 * PARAMETERS: Event - The fixed eventto be enabled
154 * DESCRIPTION: Enable an ACPI event (fixed)
156 ******************************************************************************/
157 acpi_status
acpi_enable_event(u32 event
, u32 flags
)
159 acpi_status status
= AE_OK
;
162 ACPI_FUNCTION_TRACE(acpi_enable_event
);
164 /* Decode the Fixed Event */
166 if (event
> ACPI_EVENT_MAX
) {
167 return_ACPI_STATUS(AE_BAD_PARAMETER
);
171 * Enable the requested fixed event (by writing a one to the enable
175 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
176 enable_register_id
, ACPI_ENABLE_EVENT
);
177 if (ACPI_FAILURE(status
)) {
178 return_ACPI_STATUS(status
);
181 /* Make sure that the hardware responded */
184 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
185 enable_register_id
, &value
);
186 if (ACPI_FAILURE(status
)) {
187 return_ACPI_STATUS(status
);
192 "Could not enable %s event",
193 acpi_ut_get_event_name(event
)));
194 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
197 return_ACPI_STATUS(status
);
200 ACPI_EXPORT_SYMBOL(acpi_enable_event
)
202 /*******************************************************************************
204 * FUNCTION: acpi_set_gpe
206 * PARAMETERS: gpe_device - Parent GPE Device
207 * gpe_number - GPE level within the GPE block
208 * action - Enable or disable
209 * Called from ISR or not
213 * DESCRIPTION: Enable or disable an ACPI event (general purpose)
215 ******************************************************************************/
216 acpi_status
acpi_set_gpe(acpi_handle gpe_device
, u32 gpe_number
, u8 action
)
218 acpi_status status
= AE_OK
;
219 acpi_cpu_flags flags
;
220 struct acpi_gpe_event_info
*gpe_event_info
;
222 ACPI_FUNCTION_TRACE(acpi_set_gpe
);
224 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
226 /* Ensure that we have a valid GPE number */
228 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
229 if (!gpe_event_info
) {
230 status
= AE_BAD_PARAMETER
;
231 goto unlock_and_exit
;
234 /* Perform the action */
237 case ACPI_GPE_ENABLE
:
238 status
= acpi_ev_enable_gpe(gpe_event_info
);
241 case ACPI_GPE_DISABLE
:
242 status
= acpi_ev_disable_gpe(gpe_event_info
);
246 ACPI_ERROR((AE_INFO
, "Invalid action\n"));
247 status
= AE_BAD_PARAMETER
;
252 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
253 return_ACPI_STATUS(status
);
256 ACPI_EXPORT_SYMBOL(acpi_set_gpe
)
258 /*******************************************************************************
260 * FUNCTION: acpi_enable_gpe
262 * PARAMETERS: gpe_device - Parent GPE Device
263 * gpe_number - GPE level within the GPE block
264 * type - Purpose the GPE will be used for
268 * DESCRIPTION: Take a reference to a GPE and enable it if necessary
270 ******************************************************************************/
271 acpi_status
acpi_enable_gpe(acpi_handle gpe_device
, u32 gpe_number
, u8 type
)
273 acpi_status status
= AE_OK
;
274 acpi_cpu_flags flags
;
275 struct acpi_gpe_event_info
*gpe_event_info
;
277 ACPI_FUNCTION_TRACE(acpi_enable_gpe
);
279 if (type
& ~ACPI_GPE_TYPE_WAKE_RUN
)
280 return_ACPI_STATUS(AE_BAD_PARAMETER
);
282 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
284 /* Ensure that we have a valid GPE number */
286 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
287 if (!gpe_event_info
) {
288 status
= AE_BAD_PARAMETER
;
289 goto unlock_and_exit
;
292 if (type
& ACPI_GPE_TYPE_RUNTIME
) {
293 if (++gpe_event_info
->runtime_count
== 1) {
294 status
= acpi_ev_enable_gpe(gpe_event_info
);
295 if (ACPI_FAILURE(status
))
296 gpe_event_info
->runtime_count
--;
300 if (type
& ACPI_GPE_TYPE_WAKE
) {
301 if (!(gpe_event_info
->flags
& ACPI_GPE_CAN_WAKE
)) {
302 status
= AE_BAD_PARAMETER
;
303 goto unlock_and_exit
;
307 * Wake-up GPEs are only enabled right prior to putting the
308 * system into a sleep state.
310 if (++gpe_event_info
->wakeup_count
== 1)
311 acpi_ev_update_gpe_enable_masks(gpe_event_info
);
315 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
316 return_ACPI_STATUS(status
);
318 ACPI_EXPORT_SYMBOL(acpi_enable_gpe
)
320 /*******************************************************************************
322 * FUNCTION: acpi_disable_gpe
324 * PARAMETERS: gpe_device - Parent GPE Device
325 * gpe_number - GPE level within the GPE block
326 * type - Purpose the GPE won't be used for any more
330 * DESCRIPTION: Release a reference to a GPE and disable it if necessary
332 ******************************************************************************/
333 acpi_status
acpi_disable_gpe(acpi_handle gpe_device
, u32 gpe_number
, u8 type
)
335 acpi_status status
= AE_OK
;
336 acpi_cpu_flags flags
;
337 struct acpi_gpe_event_info
*gpe_event_info
;
339 ACPI_FUNCTION_TRACE(acpi_disable_gpe
);
341 if (type
& ~ACPI_GPE_TYPE_WAKE_RUN
)
342 return_ACPI_STATUS(AE_BAD_PARAMETER
);
344 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
345 /* Ensure that we have a valid GPE number */
347 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
348 if (!gpe_event_info
) {
349 status
= AE_BAD_PARAMETER
;
350 goto unlock_and_exit
;
353 if ((type
& ACPI_GPE_TYPE_RUNTIME
) && gpe_event_info
->runtime_count
) {
354 if (--gpe_event_info
->runtime_count
== 0)
355 status
= acpi_ev_disable_gpe(gpe_event_info
);
358 if ((type
& ACPI_GPE_TYPE_WAKE
) && gpe_event_info
->wakeup_count
) {
360 * Wake-up GPEs are not enabled after leaving system sleep
361 * states, so we don't need to disable them here.
363 if (--gpe_event_info
->wakeup_count
== 0)
364 acpi_ev_update_gpe_enable_masks(gpe_event_info
);
368 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
369 return_ACPI_STATUS(status
);
371 ACPI_EXPORT_SYMBOL(acpi_disable_gpe
)
373 /*******************************************************************************
375 * FUNCTION: acpi_disable_event
377 * PARAMETERS: Event - The fixed eventto be enabled
382 * DESCRIPTION: Disable an ACPI event (fixed)
384 ******************************************************************************/
385 acpi_status
acpi_disable_event(u32 event
, u32 flags
)
387 acpi_status status
= AE_OK
;
390 ACPI_FUNCTION_TRACE(acpi_disable_event
);
392 /* Decode the Fixed Event */
394 if (event
> ACPI_EVENT_MAX
) {
395 return_ACPI_STATUS(AE_BAD_PARAMETER
);
399 * Disable the requested fixed event (by writing a zero to the enable
403 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
404 enable_register_id
, ACPI_DISABLE_EVENT
);
405 if (ACPI_FAILURE(status
)) {
406 return_ACPI_STATUS(status
);
410 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
411 enable_register_id
, &value
);
412 if (ACPI_FAILURE(status
)) {
413 return_ACPI_STATUS(status
);
418 "Could not disable %s events",
419 acpi_ut_get_event_name(event
)));
420 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
423 return_ACPI_STATUS(status
);
426 ACPI_EXPORT_SYMBOL(acpi_disable_event
)
428 /*******************************************************************************
430 * FUNCTION: acpi_clear_event
432 * PARAMETERS: Event - The fixed event to be cleared
436 * DESCRIPTION: Clear an ACPI event (fixed)
438 ******************************************************************************/
439 acpi_status
acpi_clear_event(u32 event
)
441 acpi_status status
= AE_OK
;
443 ACPI_FUNCTION_TRACE(acpi_clear_event
);
445 /* Decode the Fixed Event */
447 if (event
> ACPI_EVENT_MAX
) {
448 return_ACPI_STATUS(AE_BAD_PARAMETER
);
452 * Clear the requested fixed event (By writing a one to the status
456 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
457 status_register_id
, ACPI_CLEAR_STATUS
);
459 return_ACPI_STATUS(status
);
462 ACPI_EXPORT_SYMBOL(acpi_clear_event
)
464 /*******************************************************************************
466 * FUNCTION: acpi_clear_gpe
468 * PARAMETERS: gpe_device - Parent GPE Device
469 * gpe_number - GPE level within the GPE block
470 * Flags - Called from an ISR or not
474 * DESCRIPTION: Clear an ACPI event (general purpose)
476 ******************************************************************************/
477 acpi_status
acpi_clear_gpe(acpi_handle gpe_device
, u32 gpe_number
, u32 flags
)
479 acpi_status status
= AE_OK
;
480 struct acpi_gpe_event_info
*gpe_event_info
;
482 ACPI_FUNCTION_TRACE(acpi_clear_gpe
);
484 /* Use semaphore lock if not executing at interrupt level */
486 if (flags
& ACPI_NOT_ISR
) {
487 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
488 if (ACPI_FAILURE(status
)) {
489 return_ACPI_STATUS(status
);
493 /* Ensure that we have a valid GPE number */
495 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
496 if (!gpe_event_info
) {
497 status
= AE_BAD_PARAMETER
;
498 goto unlock_and_exit
;
501 status
= acpi_hw_clear_gpe(gpe_event_info
);
504 if (flags
& ACPI_NOT_ISR
) {
505 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
507 return_ACPI_STATUS(status
);
510 ACPI_EXPORT_SYMBOL(acpi_clear_gpe
)
511 /*******************************************************************************
513 * FUNCTION: acpi_get_event_status
515 * PARAMETERS: Event - The fixed event
516 * event_status - Where the current status of the event will
521 * DESCRIPTION: Obtains and returns the current status of the event
523 ******************************************************************************/
524 acpi_status
acpi_get_event_status(u32 event
, acpi_event_status
* event_status
)
526 acpi_status status
= AE_OK
;
529 ACPI_FUNCTION_TRACE(acpi_get_event_status
);
532 return_ACPI_STATUS(AE_BAD_PARAMETER
);
535 /* Decode the Fixed Event */
537 if (event
> ACPI_EVENT_MAX
) {
538 return_ACPI_STATUS(AE_BAD_PARAMETER
);
541 /* Get the status of the requested fixed event */
544 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
545 enable_register_id
, &value
);
546 if (ACPI_FAILURE(status
))
547 return_ACPI_STATUS(status
);
549 *event_status
= value
;
552 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
553 status_register_id
, &value
);
554 if (ACPI_FAILURE(status
))
555 return_ACPI_STATUS(status
);
558 *event_status
|= ACPI_EVENT_FLAG_SET
;
560 if (acpi_gbl_fixed_event_handlers
[event
].handler
)
561 *event_status
|= ACPI_EVENT_FLAG_HANDLE
;
563 return_ACPI_STATUS(status
);
566 ACPI_EXPORT_SYMBOL(acpi_get_event_status
)
568 /*******************************************************************************
570 * FUNCTION: acpi_get_gpe_status
572 * PARAMETERS: gpe_device - Parent GPE Device
573 * gpe_number - GPE level within the GPE block
574 * Flags - Called from an ISR or not
575 * event_status - Where the current status of the event will
580 * DESCRIPTION: Get status of an event (general purpose)
582 ******************************************************************************/
584 acpi_get_gpe_status(acpi_handle gpe_device
,
585 u32 gpe_number
, u32 flags
, acpi_event_status
* event_status
)
587 acpi_status status
= AE_OK
;
588 struct acpi_gpe_event_info
*gpe_event_info
;
590 ACPI_FUNCTION_TRACE(acpi_get_gpe_status
);
592 /* Use semaphore lock if not executing at interrupt level */
594 if (flags
& ACPI_NOT_ISR
) {
595 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
596 if (ACPI_FAILURE(status
)) {
597 return_ACPI_STATUS(status
);
601 /* Ensure that we have a valid GPE number */
603 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
604 if (!gpe_event_info
) {
605 status
= AE_BAD_PARAMETER
;
606 goto unlock_and_exit
;
609 /* Obtain status on the requested GPE number */
611 status
= acpi_hw_get_gpe_status(gpe_event_info
, event_status
);
613 if (gpe_event_info
->flags
& ACPI_GPE_DISPATCH_MASK
)
614 *event_status
|= ACPI_EVENT_FLAG_HANDLE
;
617 if (flags
& ACPI_NOT_ISR
) {
618 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
620 return_ACPI_STATUS(status
);
623 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status
)
624 /*******************************************************************************
626 * FUNCTION: acpi_install_gpe_block
628 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
629 * gpe_block_address - Address and space_iD
630 * register_count - Number of GPE register pairs in the block
631 * interrupt_number - H/W interrupt for the block
635 * DESCRIPTION: Create and Install a block of GPE registers
637 ******************************************************************************/
639 acpi_install_gpe_block(acpi_handle gpe_device
,
640 struct acpi_generic_address
*gpe_block_address
,
641 u32 register_count
, u32 interrupt_number
)
644 union acpi_operand_object
*obj_desc
;
645 struct acpi_namespace_node
*node
;
646 struct acpi_gpe_block_info
*gpe_block
;
648 ACPI_FUNCTION_TRACE(acpi_install_gpe_block
);
650 if ((!gpe_device
) || (!gpe_block_address
) || (!register_count
)) {
651 return_ACPI_STATUS(AE_BAD_PARAMETER
);
654 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
655 if (ACPI_FAILURE(status
)) {
659 node
= acpi_ns_validate_handle(gpe_device
);
661 status
= AE_BAD_PARAMETER
;
662 goto unlock_and_exit
;
666 * For user-installed GPE Block Devices, the gpe_block_base_number
670 acpi_ev_create_gpe_block(node
, gpe_block_address
, register_count
, 0,
671 interrupt_number
, &gpe_block
);
672 if (ACPI_FAILURE(status
)) {
673 goto unlock_and_exit
;
676 /* Run the _PRW methods and enable the GPEs */
678 status
= acpi_ev_initialize_gpe_block(node
, gpe_block
);
679 if (ACPI_FAILURE(status
)) {
680 goto unlock_and_exit
;
683 /* Get the device_object attached to the node */
685 obj_desc
= acpi_ns_get_attached_object(node
);
688 /* No object, create a new one */
690 obj_desc
= acpi_ut_create_internal_object(ACPI_TYPE_DEVICE
);
692 status
= AE_NO_MEMORY
;
693 goto unlock_and_exit
;
697 acpi_ns_attach_object(node
, obj_desc
, ACPI_TYPE_DEVICE
);
699 /* Remove local reference to the object */
701 acpi_ut_remove_reference(obj_desc
);
703 if (ACPI_FAILURE(status
)) {
704 goto unlock_and_exit
;
708 /* Install the GPE block in the device_object */
710 obj_desc
->device
.gpe_block
= gpe_block
;
713 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
714 return_ACPI_STATUS(status
);
717 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block
)
719 /*******************************************************************************
721 * FUNCTION: acpi_remove_gpe_block
723 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
727 * DESCRIPTION: Remove a previously installed block of GPE registers
729 ******************************************************************************/
730 acpi_status
acpi_remove_gpe_block(acpi_handle gpe_device
)
732 union acpi_operand_object
*obj_desc
;
734 struct acpi_namespace_node
*node
;
736 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block
);
739 return_ACPI_STATUS(AE_BAD_PARAMETER
);
742 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
743 if (ACPI_FAILURE(status
)) {
747 node
= acpi_ns_validate_handle(gpe_device
);
749 status
= AE_BAD_PARAMETER
;
750 goto unlock_and_exit
;
753 /* Get the device_object attached to the node */
755 obj_desc
= acpi_ns_get_attached_object(node
);
756 if (!obj_desc
|| !obj_desc
->device
.gpe_block
) {
757 return_ACPI_STATUS(AE_NULL_OBJECT
);
760 /* Delete the GPE block (but not the device_object) */
762 status
= acpi_ev_delete_gpe_block(obj_desc
->device
.gpe_block
);
763 if (ACPI_SUCCESS(status
)) {
764 obj_desc
->device
.gpe_block
= NULL
;
768 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
769 return_ACPI_STATUS(status
);
772 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block
)
774 /*******************************************************************************
776 * FUNCTION: acpi_get_gpe_device
778 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
779 * gpe_device - Where the parent GPE Device is returned
783 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
784 * gpe device indicates that the gpe number is contained in one of
785 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
787 ******************************************************************************/
789 acpi_get_gpe_device(u32 index
, acpi_handle
*gpe_device
)
791 struct acpi_gpe_device_info info
;
794 ACPI_FUNCTION_TRACE(acpi_get_gpe_device
);
797 return_ACPI_STATUS(AE_BAD_PARAMETER
);
800 if (index
>= acpi_current_gpe_count
) {
801 return_ACPI_STATUS(AE_NOT_EXIST
);
804 /* Setup and walk the GPE list */
807 info
.status
= AE_NOT_EXIST
;
808 info
.gpe_device
= NULL
;
809 info
.next_block_base_index
= 0;
811 status
= acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device
, &info
);
812 if (ACPI_FAILURE(status
)) {
813 return_ACPI_STATUS(status
);
816 *gpe_device
= info
.gpe_device
;
817 return_ACPI_STATUS(info
.status
);
820 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device
)
822 /*******************************************************************************
824 * FUNCTION: acpi_ev_get_gpe_device
826 * PARAMETERS: GPE_WALK_CALLBACK
830 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
831 * block device. NULL if the GPE is one of the FADT-defined GPEs.
833 ******************************************************************************/
835 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info
*gpe_xrupt_info
,
836 struct acpi_gpe_block_info
*gpe_block
, void *context
)
838 struct acpi_gpe_device_info
*info
= context
;
840 /* Increment Index by the number of GPEs in this block */
842 info
->next_block_base_index
+=
843 (gpe_block
->register_count
* ACPI_GPE_REGISTER_WIDTH
);
845 if (info
->index
< info
->next_block_base_index
) {
847 * The GPE index is within this block, get the node. Leave the node
848 * NULL for the FADT-defined GPEs
850 if ((gpe_block
->node
)->type
== ACPI_TYPE_DEVICE
) {
851 info
->gpe_device
= gpe_block
->node
;
854 info
->status
= AE_OK
;
855 return (AE_CTRL_END
);
861 /******************************************************************************
863 * FUNCTION: acpi_disable_all_gpes
869 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
871 ******************************************************************************/
873 acpi_status
acpi_disable_all_gpes(void)
877 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes
);
879 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
880 if (ACPI_FAILURE(status
)) {
881 return_ACPI_STATUS(status
);
884 status
= acpi_hw_disable_all_gpes();
885 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
887 return_ACPI_STATUS(status
);
890 /******************************************************************************
892 * FUNCTION: acpi_enable_all_runtime_gpes
898 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
900 ******************************************************************************/
902 acpi_status
acpi_enable_all_runtime_gpes(void)
906 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes
);
908 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
909 if (ACPI_FAILURE(status
)) {
910 return_ACPI_STATUS(status
);
913 status
= acpi_hw_enable_all_runtime_gpes();
914 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
916 return_ACPI_STATUS(status
);