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)
75 ACPI_FUNCTION_TRACE(acpi_enable
);
77 /* ACPI tables must be present */
79 if (!acpi_tb_tables_loaded()) {
80 return_ACPI_STATUS(AE_NO_ACPI_TABLES
);
83 /* Check current mode */
85 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI
) {
86 ACPI_DEBUG_PRINT((ACPI_DB_INIT
,
87 "System is already in ACPI mode\n"));
88 return_ACPI_STATUS(AE_OK
);
91 /* Transition to ACPI mode */
93 status
= acpi_hw_set_mode(ACPI_SYS_MODE_ACPI
);
94 if (ACPI_FAILURE(status
)) {
96 "Could not transition to ACPI mode"));
97 return_ACPI_STATUS(status
);
100 /* Sanity check that transition succeeded */
102 for (retry
= 0; retry
< 30000; ++retry
) {
103 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI
) {
105 ACPI_WARNING((AE_INFO
,
106 "Platform took > %d00 usec to enter ACPI mode", retry
));
107 return_ACPI_STATUS(AE_OK
);
109 acpi_os_stall(100); /* 100 usec */
112 ACPI_ERROR((AE_INFO
, "Hardware did not enter ACPI mode"));
113 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
116 ACPI_EXPORT_SYMBOL(acpi_enable
)
118 /*******************************************************************************
120 * FUNCTION: acpi_disable
126 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
128 ******************************************************************************/
129 acpi_status
acpi_disable(void)
131 acpi_status status
= AE_OK
;
133 ACPI_FUNCTION_TRACE(acpi_disable
);
135 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY
) {
136 ACPI_DEBUG_PRINT((ACPI_DB_INIT
,
137 "System is already in legacy (non-ACPI) mode\n"));
139 /* Transition to LEGACY mode */
141 status
= acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY
);
143 if (ACPI_FAILURE(status
)) {
145 "Could not exit ACPI mode to legacy mode"));
146 return_ACPI_STATUS(status
);
149 ACPI_DEBUG_PRINT((ACPI_DB_INIT
, "ACPI mode disabled\n"));
152 return_ACPI_STATUS(status
);
155 ACPI_EXPORT_SYMBOL(acpi_disable
)
157 /*******************************************************************************
159 * FUNCTION: acpi_enable_event
161 * PARAMETERS: Event - The fixed eventto be enabled
166 * DESCRIPTION: Enable an ACPI event (fixed)
168 ******************************************************************************/
169 acpi_status
acpi_enable_event(u32 event
, u32 flags
)
171 acpi_status status
= AE_OK
;
174 ACPI_FUNCTION_TRACE(acpi_enable_event
);
176 /* Decode the Fixed Event */
178 if (event
> ACPI_EVENT_MAX
) {
179 return_ACPI_STATUS(AE_BAD_PARAMETER
);
183 * Enable the requested fixed event (by writing a one to the enable
187 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
188 enable_register_id
, ACPI_ENABLE_EVENT
);
189 if (ACPI_FAILURE(status
)) {
190 return_ACPI_STATUS(status
);
193 /* Make sure that the hardware responded */
196 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
197 enable_register_id
, &value
);
198 if (ACPI_FAILURE(status
)) {
199 return_ACPI_STATUS(status
);
204 "Could not enable %s event",
205 acpi_ut_get_event_name(event
)));
206 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
209 return_ACPI_STATUS(status
);
212 ACPI_EXPORT_SYMBOL(acpi_enable_event
)
214 /*******************************************************************************
216 * FUNCTION: acpi_gpe_wakeup
218 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
219 * gpe_number - GPE level within the GPE block
220 * Action - Enable or Disable
224 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit.
226 ******************************************************************************/
227 acpi_status
acpi_gpe_wakeup(acpi_handle gpe_device
, u32 gpe_number
, u8 action
)
229 acpi_status status
= AE_OK
;
230 struct acpi_gpe_event_info
*gpe_event_info
;
231 struct acpi_gpe_register_info
*gpe_register_info
;
232 acpi_cpu_flags flags
;
235 ACPI_FUNCTION_TRACE(acpi_gpe_wakeup
);
237 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
239 /* Ensure that we have a valid GPE number */
241 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
242 if (!gpe_event_info
|| !(gpe_event_info
->flags
& ACPI_GPE_CAN_WAKE
)) {
243 status
= AE_BAD_PARAMETER
;
244 goto unlock_and_exit
;
247 gpe_register_info
= gpe_event_info
->register_info
;
248 if (!gpe_register_info
) {
249 status
= AE_NOT_EXIST
;
250 goto unlock_and_exit
;
254 acpi_hw_get_gpe_register_bit(gpe_event_info
, gpe_register_info
);
256 /* Perform the action */
259 case ACPI_GPE_ENABLE
:
260 ACPI_SET_BIT(gpe_register_info
->enable_for_wake
,
264 case ACPI_GPE_DISABLE
:
265 ACPI_CLEAR_BIT(gpe_register_info
->enable_for_wake
,
270 ACPI_ERROR((AE_INFO
, "%u, Invalid action", action
));
271 status
= AE_BAD_PARAMETER
;
276 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
277 return_ACPI_STATUS(status
);
280 ACPI_EXPORT_SYMBOL(acpi_gpe_wakeup
)
282 /*******************************************************************************
284 * FUNCTION: acpi_enable_gpe
286 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
287 * gpe_number - GPE level within the GPE block
291 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
294 ******************************************************************************/
295 acpi_status
acpi_enable_gpe(acpi_handle gpe_device
, u32 gpe_number
)
297 acpi_status status
= AE_BAD_PARAMETER
;
298 struct acpi_gpe_event_info
*gpe_event_info
;
299 acpi_cpu_flags flags
;
301 ACPI_FUNCTION_TRACE(acpi_enable_gpe
);
303 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
305 /* Ensure that we have a valid GPE number */
307 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
308 if (gpe_event_info
) {
309 status
= acpi_raw_enable_gpe(gpe_event_info
);
312 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
313 return_ACPI_STATUS(status
);
315 ACPI_EXPORT_SYMBOL(acpi_enable_gpe
)
317 /*******************************************************************************
319 * FUNCTION: acpi_disable_gpe
321 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
322 * gpe_number - GPE level within the GPE block
326 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
327 * removed, only then is the GPE disabled (for runtime GPEs), or
328 * the GPE mask bit disabled (for wake GPEs)
330 ******************************************************************************/
331 acpi_status
acpi_disable_gpe(acpi_handle gpe_device
, u32 gpe_number
)
333 acpi_status status
= AE_BAD_PARAMETER
;
334 struct acpi_gpe_event_info
*gpe_event_info
;
335 acpi_cpu_flags flags
;
337 ACPI_FUNCTION_TRACE(acpi_disable_gpe
);
339 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
341 /* Ensure that we have a valid GPE number */
343 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
344 if (gpe_event_info
) {
345 status
= acpi_raw_disable_gpe(gpe_event_info
) ;
348 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
349 return_ACPI_STATUS(status
);
351 ACPI_EXPORT_SYMBOL(acpi_disable_gpe
)
353 /*******************************************************************************
355 * FUNCTION: acpi_gpe_can_wake
357 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
358 * gpe_number - GPE level within the GPE block
362 * DESCRIPTION: Set the ACPI_GPE_CAN_WAKE flag for the given GPE. If the GPE
363 * has a corresponding method and is currently enabled, disable it
364 * (GPEs with corresponding methods are enabled unconditionally
365 * during initialization, but GPEs that can wake up are expected
366 * to be initially disabled).
368 ******************************************************************************/
369 acpi_status
acpi_gpe_can_wake(acpi_handle gpe_device
, u32 gpe_number
)
371 acpi_status status
= AE_OK
;
372 struct acpi_gpe_event_info
*gpe_event_info
;
373 acpi_cpu_flags flags
;
375 ACPI_FUNCTION_TRACE(acpi_gpe_can_wake
);
377 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
379 /* Ensure that we have a valid GPE number */
381 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
382 if (gpe_event_info
) {
383 gpe_event_info
->flags
|= ACPI_GPE_CAN_WAKE
;
385 status
= AE_BAD_PARAMETER
;
388 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
389 return_ACPI_STATUS(status
);
391 ACPI_EXPORT_SYMBOL(acpi_gpe_can_wake
)
393 /*******************************************************************************
395 * FUNCTION: acpi_disable_event
397 * PARAMETERS: Event - The fixed eventto be enabled
402 * DESCRIPTION: Disable an ACPI event (fixed)
404 ******************************************************************************/
405 acpi_status
acpi_disable_event(u32 event
, u32 flags
)
407 acpi_status status
= AE_OK
;
410 ACPI_FUNCTION_TRACE(acpi_disable_event
);
412 /* Decode the Fixed Event */
414 if (event
> ACPI_EVENT_MAX
) {
415 return_ACPI_STATUS(AE_BAD_PARAMETER
);
419 * Disable the requested fixed event (by writing a zero to the enable
423 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
424 enable_register_id
, ACPI_DISABLE_EVENT
);
425 if (ACPI_FAILURE(status
)) {
426 return_ACPI_STATUS(status
);
430 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
431 enable_register_id
, &value
);
432 if (ACPI_FAILURE(status
)) {
433 return_ACPI_STATUS(status
);
438 "Could not disable %s events",
439 acpi_ut_get_event_name(event
)));
440 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
443 return_ACPI_STATUS(status
);
446 ACPI_EXPORT_SYMBOL(acpi_disable_event
)
448 /*******************************************************************************
450 * FUNCTION: acpi_clear_event
452 * PARAMETERS: Event - The fixed event to be cleared
456 * DESCRIPTION: Clear an ACPI event (fixed)
458 ******************************************************************************/
459 acpi_status
acpi_clear_event(u32 event
)
461 acpi_status status
= AE_OK
;
463 ACPI_FUNCTION_TRACE(acpi_clear_event
);
465 /* Decode the Fixed Event */
467 if (event
> ACPI_EVENT_MAX
) {
468 return_ACPI_STATUS(AE_BAD_PARAMETER
);
472 * Clear the requested fixed event (By writing a one to the status
476 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
477 status_register_id
, ACPI_CLEAR_STATUS
);
479 return_ACPI_STATUS(status
);
482 ACPI_EXPORT_SYMBOL(acpi_clear_event
)
484 /*******************************************************************************
486 * FUNCTION: acpi_clear_gpe
488 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
489 * gpe_number - GPE level within the GPE block
493 * DESCRIPTION: Clear an ACPI event (general purpose)
495 ******************************************************************************/
496 acpi_status
acpi_clear_gpe(acpi_handle gpe_device
, u32 gpe_number
)
498 acpi_status status
= AE_OK
;
499 struct acpi_gpe_event_info
*gpe_event_info
;
500 acpi_cpu_flags flags
;
502 ACPI_FUNCTION_TRACE(acpi_clear_gpe
);
504 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
506 /* Ensure that we have a valid GPE number */
508 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
509 if (!gpe_event_info
) {
510 status
= AE_BAD_PARAMETER
;
511 goto unlock_and_exit
;
514 status
= acpi_hw_clear_gpe(gpe_event_info
);
517 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
518 return_ACPI_STATUS(status
);
521 ACPI_EXPORT_SYMBOL(acpi_clear_gpe
)
522 /*******************************************************************************
524 * FUNCTION: acpi_get_event_status
526 * PARAMETERS: Event - The fixed event
527 * event_status - Where the current status of the event will
532 * DESCRIPTION: Obtains and returns the current status of the event
534 ******************************************************************************/
535 acpi_status
acpi_get_event_status(u32 event
, acpi_event_status
* event_status
)
537 acpi_status status
= AE_OK
;
540 ACPI_FUNCTION_TRACE(acpi_get_event_status
);
543 return_ACPI_STATUS(AE_BAD_PARAMETER
);
546 /* Decode the Fixed Event */
548 if (event
> ACPI_EVENT_MAX
) {
549 return_ACPI_STATUS(AE_BAD_PARAMETER
);
552 /* Get the status of the requested fixed event */
555 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
556 enable_register_id
, &value
);
557 if (ACPI_FAILURE(status
))
558 return_ACPI_STATUS(status
);
560 *event_status
= value
;
563 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
564 status_register_id
, &value
);
565 if (ACPI_FAILURE(status
))
566 return_ACPI_STATUS(status
);
569 *event_status
|= ACPI_EVENT_FLAG_SET
;
571 if (acpi_gbl_fixed_event_handlers
[event
].handler
)
572 *event_status
|= ACPI_EVENT_FLAG_HANDLE
;
574 return_ACPI_STATUS(status
);
577 ACPI_EXPORT_SYMBOL(acpi_get_event_status
)
579 /*******************************************************************************
581 * FUNCTION: acpi_get_gpe_status
583 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
584 * gpe_number - GPE level within the GPE block
585 * event_status - Where the current status of the event will
590 * DESCRIPTION: Get status of an event (general purpose)
592 ******************************************************************************/
594 acpi_get_gpe_status(acpi_handle gpe_device
,
595 u32 gpe_number
, acpi_event_status
*event_status
)
597 acpi_status status
= AE_OK
;
598 struct acpi_gpe_event_info
*gpe_event_info
;
599 acpi_cpu_flags flags
;
601 ACPI_FUNCTION_TRACE(acpi_get_gpe_status
);
603 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
605 /* Ensure that we have a valid GPE number */
607 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
608 if (!gpe_event_info
) {
609 status
= AE_BAD_PARAMETER
;
610 goto unlock_and_exit
;
613 /* Obtain status on the requested GPE number */
615 status
= acpi_hw_get_gpe_status(gpe_event_info
, event_status
);
617 if (gpe_event_info
->flags
& ACPI_GPE_DISPATCH_MASK
)
618 *event_status
|= ACPI_EVENT_FLAG_HANDLE
;
621 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
622 return_ACPI_STATUS(status
);
625 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status
)
626 /*******************************************************************************
628 * FUNCTION: acpi_install_gpe_block
630 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
631 * gpe_block_address - Address and space_iD
632 * register_count - Number of GPE register pairs in the block
633 * interrupt_number - H/W interrupt for the block
637 * DESCRIPTION: Create and Install a block of GPE registers
639 ******************************************************************************/
641 acpi_install_gpe_block(acpi_handle gpe_device
,
642 struct acpi_generic_address
*gpe_block_address
,
643 u32 register_count
, u32 interrupt_number
)
645 acpi_status status
= AE_OK
;
646 union acpi_operand_object
*obj_desc
;
647 struct acpi_namespace_node
*node
;
648 struct acpi_gpe_block_info
*gpe_block
;
650 ACPI_FUNCTION_TRACE(acpi_install_gpe_block
);
652 if ((!gpe_device
) || (!gpe_block_address
) || (!register_count
)) {
653 return_ACPI_STATUS(AE_BAD_PARAMETER
);
656 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
657 if (ACPI_FAILURE(status
)) {
661 node
= acpi_ns_validate_handle(gpe_device
);
663 status
= AE_BAD_PARAMETER
;
664 goto unlock_and_exit
;
668 * For user-installed GPE Block Devices, the gpe_block_base_number
672 acpi_ev_create_gpe_block(node
, gpe_block_address
, register_count
, 0,
673 interrupt_number
, &gpe_block
);
674 if (ACPI_FAILURE(status
)) {
675 goto unlock_and_exit
;
678 /* Install block in the device_object attached to the node */
680 obj_desc
= acpi_ns_get_attached_object(node
);
684 * No object, create a new one (Device nodes do not always have
685 * an attached object)
687 obj_desc
= acpi_ut_create_internal_object(ACPI_TYPE_DEVICE
);
689 status
= AE_NO_MEMORY
;
690 goto unlock_and_exit
;
694 acpi_ns_attach_object(node
, obj_desc
, ACPI_TYPE_DEVICE
);
696 /* Remove local reference to the object */
698 acpi_ut_remove_reference(obj_desc
);
700 if (ACPI_FAILURE(status
)) {
701 goto unlock_and_exit
;
705 /* Now install the GPE block in the device_object */
707 obj_desc
->device
.gpe_block
= gpe_block
;
710 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
711 return_ACPI_STATUS(status
);
714 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block
)
716 /*******************************************************************************
718 * FUNCTION: acpi_remove_gpe_block
720 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
724 * DESCRIPTION: Remove a previously installed block of GPE registers
726 ******************************************************************************/
727 acpi_status
acpi_remove_gpe_block(acpi_handle gpe_device
)
729 union acpi_operand_object
*obj_desc
;
731 struct acpi_namespace_node
*node
;
733 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block
);
736 return_ACPI_STATUS(AE_BAD_PARAMETER
);
739 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
740 if (ACPI_FAILURE(status
)) {
744 node
= acpi_ns_validate_handle(gpe_device
);
746 status
= AE_BAD_PARAMETER
;
747 goto unlock_and_exit
;
750 /* Get the device_object attached to the node */
752 obj_desc
= acpi_ns_get_attached_object(node
);
753 if (!obj_desc
|| !obj_desc
->device
.gpe_block
) {
754 return_ACPI_STATUS(AE_NULL_OBJECT
);
757 /* Delete the GPE block (but not the device_object) */
759 status
= acpi_ev_delete_gpe_block(obj_desc
->device
.gpe_block
);
760 if (ACPI_SUCCESS(status
)) {
761 obj_desc
->device
.gpe_block
= NULL
;
765 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
766 return_ACPI_STATUS(status
);
769 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block
)
771 /*******************************************************************************
773 * FUNCTION: acpi_get_gpe_device
775 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
776 * gpe_device - Where the parent GPE Device is returned
780 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
781 * gpe device indicates that the gpe number is contained in one of
782 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
784 ******************************************************************************/
786 acpi_get_gpe_device(u32 index
, acpi_handle
*gpe_device
)
788 struct acpi_gpe_device_info info
;
791 ACPI_FUNCTION_TRACE(acpi_get_gpe_device
);
794 return_ACPI_STATUS(AE_BAD_PARAMETER
);
797 if (index
>= acpi_current_gpe_count
) {
798 return_ACPI_STATUS(AE_NOT_EXIST
);
801 /* Setup and walk the GPE list */
804 info
.status
= AE_NOT_EXIST
;
805 info
.gpe_device
= NULL
;
806 info
.next_block_base_index
= 0;
808 status
= acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device
, &info
);
809 if (ACPI_FAILURE(status
)) {
810 return_ACPI_STATUS(status
);
813 *gpe_device
= info
.gpe_device
;
814 return_ACPI_STATUS(info
.status
);
817 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device
)
819 /*******************************************************************************
821 * FUNCTION: acpi_ev_get_gpe_device
823 * PARAMETERS: GPE_WALK_CALLBACK
827 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
828 * block device. NULL if the GPE is one of the FADT-defined GPEs.
830 ******************************************************************************/
832 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info
*gpe_xrupt_info
,
833 struct acpi_gpe_block_info
*gpe_block
, void *context
)
835 struct acpi_gpe_device_info
*info
= context
;
837 /* Increment Index by the number of GPEs in this block */
839 info
->next_block_base_index
+= gpe_block
->gpe_count
;
841 if (info
->index
< info
->next_block_base_index
) {
843 * The GPE index is within this block, get the node. Leave the node
844 * NULL for the FADT-defined GPEs
846 if ((gpe_block
->node
)->type
== ACPI_TYPE_DEVICE
) {
847 info
->gpe_device
= gpe_block
->node
;
850 info
->status
= AE_OK
;
851 return (AE_CTRL_END
);
857 /******************************************************************************
859 * FUNCTION: acpi_disable_all_gpes
865 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
867 ******************************************************************************/
869 acpi_status
acpi_disable_all_gpes(void)
873 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes
);
875 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
876 if (ACPI_FAILURE(status
)) {
877 return_ACPI_STATUS(status
);
880 status
= acpi_hw_disable_all_gpes();
881 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
883 return_ACPI_STATUS(status
);
886 /******************************************************************************
888 * FUNCTION: acpi_enable_all_runtime_gpes
894 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
896 ******************************************************************************/
898 acpi_status
acpi_enable_all_runtime_gpes(void)
902 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes
);
904 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
905 if (ACPI_FAILURE(status
)) {
906 return_ACPI_STATUS(status
);
909 status
= acpi_hw_enable_all_runtime_gpes();
910 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
912 return_ACPI_STATUS(status
);
915 /******************************************************************************
917 * FUNCTION: acpi_update_gpes
923 * DESCRIPTION: Enable all GPEs that have associated _Lxx or _Exx methods and
924 * are not pointed to by any device _PRW methods indicating that
925 * these GPEs are generally intended for system or device wakeup
926 * (such GPEs have to be enabled directly when the devices whose
927 * _PRW methods point to them are set up for wakeup signaling).
929 ******************************************************************************/
931 acpi_status
acpi_update_gpes(void)
935 ACPI_FUNCTION_TRACE(acpi_update_gpes
);
937 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
938 if (ACPI_FAILURE(status
)) {
939 return_ACPI_STATUS(status
);
940 } else if (acpi_all_gpes_initialized
) {
944 status
= acpi_ev_walk_gpe_list(acpi_ev_initialize_gpe_block
, NULL
);
945 if (ACPI_SUCCESS(status
)) {
946 acpi_all_gpes_initialized
= TRUE
;
950 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
952 return_ACPI_STATUS(status
);