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. NULL for GPE0/GPE1
207 * gpe_number - GPE level within the GPE block
208 * action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
212 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
213 * the reference count mechanism used in the acpi_enable_gpe and
214 * acpi_disable_gpe interfaces -- and should be used with care.
216 * Note: Typically used to disable a runtime GPE for short period of time,
217 * then re-enable it, without disturbing the existing reference counts. This
218 * is useful, for example, in the Embedded Controller (EC) driver.
220 ******************************************************************************/
221 acpi_status
acpi_set_gpe(acpi_handle gpe_device
, u32 gpe_number
, u8 action
)
223 struct acpi_gpe_event_info
*gpe_event_info
;
225 acpi_cpu_flags flags
;
227 ACPI_FUNCTION_TRACE(acpi_set_gpe
);
229 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
231 /* Ensure that we have a valid GPE number */
233 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
234 if (!gpe_event_info
) {
235 status
= AE_BAD_PARAMETER
;
236 goto unlock_and_exit
;
239 /* Perform the action */
242 case ACPI_GPE_ENABLE
:
243 status
= acpi_ev_enable_gpe(gpe_event_info
);
246 case ACPI_GPE_DISABLE
:
247 status
= acpi_ev_disable_gpe(gpe_event_info
);
251 status
= AE_BAD_PARAMETER
;
256 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
257 return_ACPI_STATUS(status
);
260 ACPI_EXPORT_SYMBOL(acpi_set_gpe
)
262 /*******************************************************************************
264 * FUNCTION: acpi_enable_gpe
266 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
267 * gpe_number - GPE level within the GPE block
268 * gpe_type - ACPI_GPE_TYPE_RUNTIME or ACPI_GPE_TYPE_WAKE
273 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
274 * hardware-enabled (for runtime GPEs), or the GPE register mask
275 * is updated (for wake GPEs).
277 ******************************************************************************/
278 acpi_status
acpi_enable_gpe(acpi_handle gpe_device
, u32 gpe_number
, u8 gpe_type
)
280 acpi_status status
= AE_OK
;
281 struct acpi_gpe_event_info
*gpe_event_info
;
282 acpi_cpu_flags flags
;
284 ACPI_FUNCTION_TRACE(acpi_enable_gpe
);
286 /* Parameter validation */
288 if (!gpe_type
|| (gpe_type
& ~ACPI_GPE_TYPE_WAKE_RUN
)) {
289 return_ACPI_STATUS(AE_BAD_PARAMETER
);
292 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
294 /* Ensure that we have a valid GPE number */
296 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
297 if (!gpe_event_info
) {
298 status
= AE_BAD_PARAMETER
;
299 goto unlock_and_exit
;
302 if (gpe_type
& ACPI_GPE_TYPE_RUNTIME
) {
303 if (gpe_event_info
->runtime_count
== ACPI_UINT8_MAX
) {
304 status
= AE_LIMIT
; /* Too many references */
305 goto unlock_and_exit
;
308 gpe_event_info
->runtime_count
++;
309 if (gpe_event_info
->runtime_count
== 1) {
310 status
= acpi_ev_enable_gpe(gpe_event_info
);
311 if (ACPI_FAILURE(status
)) {
312 gpe_event_info
->runtime_count
--;
313 goto unlock_and_exit
;
318 if (gpe_type
& ACPI_GPE_TYPE_WAKE
) {
319 /* The GPE must have the ability to wake the system */
321 if (!(gpe_event_info
->flags
& ACPI_GPE_CAN_WAKE
)) {
323 goto unlock_and_exit
;
326 if (gpe_event_info
->wakeup_count
== ACPI_UINT8_MAX
) {
327 status
= AE_LIMIT
; /* Too many references */
328 goto unlock_and_exit
;
332 * Update the enable mask on the first wakeup reference. Wake GPEs
333 * are only hardware-enabled just before sleeping.
335 gpe_event_info
->wakeup_count
++;
336 if (gpe_event_info
->wakeup_count
== 1) {
337 (void)acpi_ev_update_gpe_enable_masks(gpe_event_info
);
342 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
343 return_ACPI_STATUS(status
);
345 ACPI_EXPORT_SYMBOL(acpi_enable_gpe
)
347 /*******************************************************************************
349 * FUNCTION: acpi_disable_gpe
351 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
352 * gpe_number - GPE level within the GPE block
353 * gpe_type - ACPI_GPE_TYPE_RUNTIME or ACPI_GPE_TYPE_WAKE
358 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
359 * removed, only then is the GPE disabled (for runtime GPEs), or
360 * the GPE mask bit disabled (for wake GPEs)
362 ******************************************************************************/
363 acpi_status
acpi_disable_gpe(acpi_handle gpe_device
, u32 gpe_number
, u8 gpe_type
)
365 acpi_status status
= AE_OK
;
366 struct acpi_gpe_event_info
*gpe_event_info
;
367 acpi_cpu_flags flags
;
369 ACPI_FUNCTION_TRACE(acpi_disable_gpe
);
371 /* Parameter validation */
373 if (!gpe_type
|| (gpe_type
& ~ACPI_GPE_TYPE_WAKE_RUN
)) {
374 return_ACPI_STATUS(AE_BAD_PARAMETER
);
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 status
= AE_BAD_PARAMETER
;
384 goto unlock_and_exit
;
387 /* Hardware-disable a runtime GPE on removal of the last reference */
389 if (gpe_type
& ACPI_GPE_TYPE_RUNTIME
) {
390 if (!gpe_event_info
->runtime_count
) {
391 status
= AE_LIMIT
; /* There are no references to remove */
392 goto unlock_and_exit
;
395 gpe_event_info
->runtime_count
--;
396 if (!gpe_event_info
->runtime_count
) {
397 status
= acpi_ev_disable_gpe(gpe_event_info
);
398 if (ACPI_FAILURE(status
)) {
399 gpe_event_info
->runtime_count
++;
400 goto unlock_and_exit
;
406 * Update masks for wake GPE on removal of the last reference.
407 * No need to hardware-disable wake GPEs here, they are not currently
410 if (gpe_type
& ACPI_GPE_TYPE_WAKE
) {
411 if (!gpe_event_info
->wakeup_count
) {
412 status
= AE_LIMIT
; /* There are no references to remove */
413 goto unlock_and_exit
;
416 gpe_event_info
->wakeup_count
--;
417 if (!gpe_event_info
->wakeup_count
) {
418 (void)acpi_ev_update_gpe_enable_masks(gpe_event_info
);
423 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
424 return_ACPI_STATUS(status
);
426 ACPI_EXPORT_SYMBOL(acpi_disable_gpe
)
428 /*******************************************************************************
430 * FUNCTION: acpi_disable_event
432 * PARAMETERS: Event - The fixed eventto be enabled
437 * DESCRIPTION: Disable an ACPI event (fixed)
439 ******************************************************************************/
440 acpi_status
acpi_disable_event(u32 event
, u32 flags
)
442 acpi_status status
= AE_OK
;
445 ACPI_FUNCTION_TRACE(acpi_disable_event
);
447 /* Decode the Fixed Event */
449 if (event
> ACPI_EVENT_MAX
) {
450 return_ACPI_STATUS(AE_BAD_PARAMETER
);
454 * Disable the requested fixed event (by writing a zero to the enable
458 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
459 enable_register_id
, ACPI_DISABLE_EVENT
);
460 if (ACPI_FAILURE(status
)) {
461 return_ACPI_STATUS(status
);
465 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
466 enable_register_id
, &value
);
467 if (ACPI_FAILURE(status
)) {
468 return_ACPI_STATUS(status
);
473 "Could not disable %s events",
474 acpi_ut_get_event_name(event
)));
475 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE
);
478 return_ACPI_STATUS(status
);
481 ACPI_EXPORT_SYMBOL(acpi_disable_event
)
483 /*******************************************************************************
485 * FUNCTION: acpi_clear_event
487 * PARAMETERS: Event - The fixed event to be cleared
491 * DESCRIPTION: Clear an ACPI event (fixed)
493 ******************************************************************************/
494 acpi_status
acpi_clear_event(u32 event
)
496 acpi_status status
= AE_OK
;
498 ACPI_FUNCTION_TRACE(acpi_clear_event
);
500 /* Decode the Fixed Event */
502 if (event
> ACPI_EVENT_MAX
) {
503 return_ACPI_STATUS(AE_BAD_PARAMETER
);
507 * Clear the requested fixed event (By writing a one to the status
511 acpi_write_bit_register(acpi_gbl_fixed_event_info
[event
].
512 status_register_id
, ACPI_CLEAR_STATUS
);
514 return_ACPI_STATUS(status
);
517 ACPI_EXPORT_SYMBOL(acpi_clear_event
)
519 /*******************************************************************************
521 * FUNCTION: acpi_clear_gpe
523 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
524 * gpe_number - GPE level within the GPE block
528 * DESCRIPTION: Clear an ACPI event (general purpose)
530 ******************************************************************************/
531 acpi_status
acpi_clear_gpe(acpi_handle gpe_device
, u32 gpe_number
)
533 acpi_status status
= AE_OK
;
534 struct acpi_gpe_event_info
*gpe_event_info
;
535 acpi_cpu_flags flags
;
537 ACPI_FUNCTION_TRACE(acpi_clear_gpe
);
539 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
541 /* Ensure that we have a valid GPE number */
543 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
544 if (!gpe_event_info
) {
545 status
= AE_BAD_PARAMETER
;
546 goto unlock_and_exit
;
549 status
= acpi_hw_clear_gpe(gpe_event_info
);
552 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
553 return_ACPI_STATUS(status
);
556 ACPI_EXPORT_SYMBOL(acpi_clear_gpe
)
557 /*******************************************************************************
559 * FUNCTION: acpi_get_event_status
561 * PARAMETERS: Event - The fixed event
562 * event_status - Where the current status of the event will
567 * DESCRIPTION: Obtains and returns the current status of the event
569 ******************************************************************************/
570 acpi_status
acpi_get_event_status(u32 event
, acpi_event_status
* event_status
)
572 acpi_status status
= AE_OK
;
575 ACPI_FUNCTION_TRACE(acpi_get_event_status
);
578 return_ACPI_STATUS(AE_BAD_PARAMETER
);
581 /* Decode the Fixed Event */
583 if (event
> ACPI_EVENT_MAX
) {
584 return_ACPI_STATUS(AE_BAD_PARAMETER
);
587 /* Get the status of the requested fixed event */
590 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
591 enable_register_id
, &value
);
592 if (ACPI_FAILURE(status
))
593 return_ACPI_STATUS(status
);
595 *event_status
= value
;
598 acpi_read_bit_register(acpi_gbl_fixed_event_info
[event
].
599 status_register_id
, &value
);
600 if (ACPI_FAILURE(status
))
601 return_ACPI_STATUS(status
);
604 *event_status
|= ACPI_EVENT_FLAG_SET
;
606 if (acpi_gbl_fixed_event_handlers
[event
].handler
)
607 *event_status
|= ACPI_EVENT_FLAG_HANDLE
;
609 return_ACPI_STATUS(status
);
612 ACPI_EXPORT_SYMBOL(acpi_get_event_status
)
614 /*******************************************************************************
616 * FUNCTION: acpi_get_gpe_status
618 * PARAMETERS: gpe_device - Parent GPE Device. NULL for GPE0/GPE1
619 * gpe_number - GPE level within the GPE block
620 * event_status - Where the current status of the event will
625 * DESCRIPTION: Get status of an event (general purpose)
627 ******************************************************************************/
629 acpi_get_gpe_status(acpi_handle gpe_device
,
630 u32 gpe_number
, acpi_event_status
*event_status
)
632 acpi_status status
= AE_OK
;
633 struct acpi_gpe_event_info
*gpe_event_info
;
634 acpi_cpu_flags flags
;
636 ACPI_FUNCTION_TRACE(acpi_get_gpe_status
);
638 flags
= acpi_os_acquire_lock(acpi_gbl_gpe_lock
);
640 /* Ensure that we have a valid GPE number */
642 gpe_event_info
= acpi_ev_get_gpe_event_info(gpe_device
, gpe_number
);
643 if (!gpe_event_info
) {
644 status
= AE_BAD_PARAMETER
;
645 goto unlock_and_exit
;
648 /* Obtain status on the requested GPE number */
650 status
= acpi_hw_get_gpe_status(gpe_event_info
, event_status
);
652 if (gpe_event_info
->flags
& ACPI_GPE_DISPATCH_MASK
)
653 *event_status
|= ACPI_EVENT_FLAG_HANDLE
;
656 acpi_os_release_lock(acpi_gbl_gpe_lock
, flags
);
657 return_ACPI_STATUS(status
);
660 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status
)
661 /*******************************************************************************
663 * FUNCTION: acpi_install_gpe_block
665 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
666 * gpe_block_address - Address and space_iD
667 * register_count - Number of GPE register pairs in the block
668 * interrupt_number - H/W interrupt for the block
672 * DESCRIPTION: Create and Install a block of GPE registers
674 ******************************************************************************/
676 acpi_install_gpe_block(acpi_handle gpe_device
,
677 struct acpi_generic_address
*gpe_block_address
,
678 u32 register_count
, u32 interrupt_number
)
681 union acpi_operand_object
*obj_desc
;
682 struct acpi_namespace_node
*node
;
683 struct acpi_gpe_block_info
*gpe_block
;
685 ACPI_FUNCTION_TRACE(acpi_install_gpe_block
);
687 if ((!gpe_device
) || (!gpe_block_address
) || (!register_count
)) {
688 return_ACPI_STATUS(AE_BAD_PARAMETER
);
691 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
692 if (ACPI_FAILURE(status
)) {
696 node
= acpi_ns_validate_handle(gpe_device
);
698 status
= AE_BAD_PARAMETER
;
699 goto unlock_and_exit
;
703 * For user-installed GPE Block Devices, the gpe_block_base_number
707 acpi_ev_create_gpe_block(node
, gpe_block_address
, register_count
, 0,
708 interrupt_number
, &gpe_block
);
709 if (ACPI_FAILURE(status
)) {
710 goto unlock_and_exit
;
713 /* Install block in the device_object attached to the node */
715 obj_desc
= acpi_ns_get_attached_object(node
);
719 * No object, create a new one (Device nodes do not always have
720 * an attached object)
722 obj_desc
= acpi_ut_create_internal_object(ACPI_TYPE_DEVICE
);
724 status
= AE_NO_MEMORY
;
725 goto unlock_and_exit
;
729 acpi_ns_attach_object(node
, obj_desc
, ACPI_TYPE_DEVICE
);
731 /* Remove local reference to the object */
733 acpi_ut_remove_reference(obj_desc
);
735 if (ACPI_FAILURE(status
)) {
736 goto unlock_and_exit
;
740 /* Now install the GPE block in the device_object */
742 obj_desc
->device
.gpe_block
= gpe_block
;
744 /* Run the _PRW methods and enable the runtime GPEs in the new block */
746 status
= acpi_ev_initialize_gpe_block(node
, gpe_block
);
749 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
750 return_ACPI_STATUS(status
);
753 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block
)
755 /*******************************************************************************
757 * FUNCTION: acpi_remove_gpe_block
759 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
763 * DESCRIPTION: Remove a previously installed block of GPE registers
765 ******************************************************************************/
766 acpi_status
acpi_remove_gpe_block(acpi_handle gpe_device
)
768 union acpi_operand_object
*obj_desc
;
770 struct acpi_namespace_node
*node
;
772 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block
);
775 return_ACPI_STATUS(AE_BAD_PARAMETER
);
778 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
779 if (ACPI_FAILURE(status
)) {
783 node
= acpi_ns_validate_handle(gpe_device
);
785 status
= AE_BAD_PARAMETER
;
786 goto unlock_and_exit
;
789 /* Get the device_object attached to the node */
791 obj_desc
= acpi_ns_get_attached_object(node
);
792 if (!obj_desc
|| !obj_desc
->device
.gpe_block
) {
793 return_ACPI_STATUS(AE_NULL_OBJECT
);
796 /* Delete the GPE block (but not the device_object) */
798 status
= acpi_ev_delete_gpe_block(obj_desc
->device
.gpe_block
);
799 if (ACPI_SUCCESS(status
)) {
800 obj_desc
->device
.gpe_block
= NULL
;
804 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
805 return_ACPI_STATUS(status
);
808 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block
)
810 /*******************************************************************************
812 * FUNCTION: acpi_get_gpe_device
814 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
815 * gpe_device - Where the parent GPE Device is returned
819 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
820 * gpe device indicates that the gpe number is contained in one of
821 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
823 ******************************************************************************/
825 acpi_get_gpe_device(u32 index
, acpi_handle
*gpe_device
)
827 struct acpi_gpe_device_info info
;
830 ACPI_FUNCTION_TRACE(acpi_get_gpe_device
);
833 return_ACPI_STATUS(AE_BAD_PARAMETER
);
836 if (index
>= acpi_current_gpe_count
) {
837 return_ACPI_STATUS(AE_NOT_EXIST
);
840 /* Setup and walk the GPE list */
843 info
.status
= AE_NOT_EXIST
;
844 info
.gpe_device
= NULL
;
845 info
.next_block_base_index
= 0;
847 status
= acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device
, &info
);
848 if (ACPI_FAILURE(status
)) {
849 return_ACPI_STATUS(status
);
852 *gpe_device
= info
.gpe_device
;
853 return_ACPI_STATUS(info
.status
);
856 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device
)
858 /*******************************************************************************
860 * FUNCTION: acpi_ev_get_gpe_device
862 * PARAMETERS: GPE_WALK_CALLBACK
866 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
867 * block device. NULL if the GPE is one of the FADT-defined GPEs.
869 ******************************************************************************/
871 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info
*gpe_xrupt_info
,
872 struct acpi_gpe_block_info
*gpe_block
, void *context
)
874 struct acpi_gpe_device_info
*info
= context
;
876 /* Increment Index by the number of GPEs in this block */
878 info
->next_block_base_index
+= gpe_block
->gpe_count
;
880 if (info
->index
< info
->next_block_base_index
) {
882 * The GPE index is within this block, get the node. Leave the node
883 * NULL for the FADT-defined GPEs
885 if ((gpe_block
->node
)->type
== ACPI_TYPE_DEVICE
) {
886 info
->gpe_device
= gpe_block
->node
;
889 info
->status
= AE_OK
;
890 return (AE_CTRL_END
);
896 /******************************************************************************
898 * FUNCTION: acpi_disable_all_gpes
904 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
906 ******************************************************************************/
908 acpi_status
acpi_disable_all_gpes(void)
912 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes
);
914 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
915 if (ACPI_FAILURE(status
)) {
916 return_ACPI_STATUS(status
);
919 status
= acpi_hw_disable_all_gpes();
920 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
922 return_ACPI_STATUS(status
);
925 /******************************************************************************
927 * FUNCTION: acpi_enable_all_runtime_gpes
933 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
935 ******************************************************************************/
937 acpi_status
acpi_enable_all_runtime_gpes(void)
941 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes
);
943 status
= acpi_ut_acquire_mutex(ACPI_MTX_EVENTS
);
944 if (ACPI_FAILURE(status
)) {
945 return_ACPI_STATUS(status
);
948 status
= acpi_hw_enable_all_runtime_gpes();
949 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS
);
951 return_ACPI_STATUS(status
);