ACPICA: New: Public GPE group enable/disable interfaces
[linux-2.6/mini2440.git] / drivers / acpi / events / evxfevnt.c
blobf7550da85d348d9605d2ad0c9886d25c0cfa328e
1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
30 * NO WARRANTY
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>
45 #include <acpi/acevents.h>
46 #include <acpi/acnamesp.h>
47 #include <acpi/actables.h>
49 #define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME("evxfevnt")
52 /* Local prototypes */
53 acpi_status
54 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
55 struct acpi_gpe_block_info *gpe_block, void *context);
57 /*******************************************************************************
59 * FUNCTION: acpi_enable
61 * PARAMETERS: None
63 * RETURN: Status
65 * DESCRIPTION: Transfers the system into ACPI mode.
67 ******************************************************************************/
69 acpi_status acpi_enable(void)
71 acpi_status status = AE_OK;
73 ACPI_FUNCTION_TRACE(acpi_enable);
75 /* ACPI tables must be present */
77 if (!acpi_tb_tables_loaded()) {
78 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
81 /* Check current mode */
83 if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
84 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
85 "System is already in ACPI mode\n"));
86 } else {
87 /* Transition to ACPI mode */
89 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
90 if (ACPI_FAILURE(status)) {
91 ACPI_ERROR((AE_INFO,
92 "Could not transition to ACPI mode"));
93 return_ACPI_STATUS(status);
96 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
97 "Transition to ACPI mode successful\n"));
100 return_ACPI_STATUS(status);
103 ACPI_EXPORT_SYMBOL(acpi_enable)
105 /*******************************************************************************
107 * FUNCTION: acpi_disable
109 * PARAMETERS: None
111 * RETURN: Status
113 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
115 ******************************************************************************/
116 acpi_status acpi_disable(void)
118 acpi_status status = AE_OK;
120 ACPI_FUNCTION_TRACE(acpi_disable);
122 if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
123 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
124 "System is already in legacy (non-ACPI) mode\n"));
125 } else {
126 /* Transition to LEGACY mode */
128 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
130 if (ACPI_FAILURE(status)) {
131 ACPI_ERROR((AE_INFO,
132 "Could not exit ACPI mode to legacy mode"));
133 return_ACPI_STATUS(status);
136 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
139 return_ACPI_STATUS(status);
142 ACPI_EXPORT_SYMBOL(acpi_disable)
144 /*******************************************************************************
146 * FUNCTION: acpi_enable_event
148 * PARAMETERS: Event - The fixed eventto be enabled
149 * Flags - Reserved
151 * RETURN: Status
153 * DESCRIPTION: Enable an ACPI event (fixed)
155 ******************************************************************************/
156 acpi_status acpi_enable_event(u32 event, u32 flags)
158 acpi_status status = AE_OK;
159 u32 value;
161 ACPI_FUNCTION_TRACE(acpi_enable_event);
163 /* Decode the Fixed Event */
165 if (event > ACPI_EVENT_MAX) {
166 return_ACPI_STATUS(AE_BAD_PARAMETER);
170 * Enable the requested fixed event (by writing a one to the enable
171 * register bit)
173 status =
174 acpi_set_register(acpi_gbl_fixed_event_info[event].
175 enable_register_id, 1);
176 if (ACPI_FAILURE(status)) {
177 return_ACPI_STATUS(status);
180 /* Make sure that the hardware responded */
182 status =
183 acpi_get_register(acpi_gbl_fixed_event_info[event].
184 enable_register_id, &value);
185 if (ACPI_FAILURE(status)) {
186 return_ACPI_STATUS(status);
189 if (value != 1) {
190 ACPI_ERROR((AE_INFO,
191 "Could not enable %s event",
192 acpi_ut_get_event_name(event)));
193 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
196 return_ACPI_STATUS(status);
199 ACPI_EXPORT_SYMBOL(acpi_enable_event)
201 /*******************************************************************************
203 * FUNCTION: acpi_set_gpe_type
205 * PARAMETERS: gpe_device - Parent GPE Device
206 * gpe_number - GPE level within the GPE block
207 * Type - New GPE type
209 * RETURN: Status
211 * DESCRIPTION: Set the type of an individual GPE
213 ******************************************************************************/
214 acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
216 acpi_status status = AE_OK;
217 struct acpi_gpe_event_info *gpe_event_info;
219 ACPI_FUNCTION_TRACE(acpi_set_gpe_type);
221 /* Ensure that we have a valid GPE number */
223 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
224 if (!gpe_event_info) {
225 status = AE_BAD_PARAMETER;
226 goto unlock_and_exit;
229 if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
230 return_ACPI_STATUS(AE_OK);
233 /* Set the new type (will disable GPE if currently enabled) */
235 status = acpi_ev_set_gpe_type(gpe_event_info, type);
237 unlock_and_exit:
238 return_ACPI_STATUS(status);
241 ACPI_EXPORT_SYMBOL(acpi_set_gpe_type)
243 /*******************************************************************************
245 * FUNCTION: acpi_enable_gpe
247 * PARAMETERS: gpe_device - Parent GPE Device
248 * gpe_number - GPE level within the GPE block
249 * Flags - Just enable, or also wake enable?
250 * Called from ISR or not
252 * RETURN: Status
254 * DESCRIPTION: Enable an ACPI event (general purpose)
256 ******************************************************************************/
257 acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
259 acpi_status status = AE_OK;
260 acpi_cpu_flags flags;
261 struct acpi_gpe_event_info *gpe_event_info;
263 ACPI_FUNCTION_TRACE(acpi_enable_gpe);
265 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
267 /* Ensure that we have a valid GPE number */
269 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
270 if (!gpe_event_info) {
271 status = AE_BAD_PARAMETER;
272 goto unlock_and_exit;
275 /* Perform the enable */
277 status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
279 unlock_and_exit:
280 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
281 return_ACPI_STATUS(status);
284 ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
286 /*******************************************************************************
288 * FUNCTION: acpi_disable_gpe
290 * PARAMETERS: gpe_device - Parent GPE Device
291 * gpe_number - GPE level within the GPE block
292 * Flags - Just disable, or also wake disable?
293 * Called from ISR or not
295 * RETURN: Status
297 * DESCRIPTION: Disable an ACPI event (general purpose)
299 ******************************************************************************/
300 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
302 acpi_status status = AE_OK;
303 acpi_cpu_flags flags;
304 struct acpi_gpe_event_info *gpe_event_info;
306 ACPI_FUNCTION_TRACE(acpi_disable_gpe);
308 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
309 /* Ensure that we have a valid GPE number */
311 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
312 if (!gpe_event_info) {
313 status = AE_BAD_PARAMETER;
314 goto unlock_and_exit;
317 status = acpi_ev_disable_gpe(gpe_event_info);
319 unlock_and_exit:
320 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
321 return_ACPI_STATUS(status);
324 ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
326 /*******************************************************************************
328 * FUNCTION: acpi_disable_event
330 * PARAMETERS: Event - The fixed eventto be enabled
331 * Flags - Reserved
333 * RETURN: Status
335 * DESCRIPTION: Disable an ACPI event (fixed)
337 ******************************************************************************/
338 acpi_status acpi_disable_event(u32 event, u32 flags)
340 acpi_status status = AE_OK;
341 u32 value;
343 ACPI_FUNCTION_TRACE(acpi_disable_event);
345 /* Decode the Fixed Event */
347 if (event > ACPI_EVENT_MAX) {
348 return_ACPI_STATUS(AE_BAD_PARAMETER);
352 * Disable the requested fixed event (by writing a zero to the enable
353 * register bit)
355 status =
356 acpi_set_register(acpi_gbl_fixed_event_info[event].
357 enable_register_id, 0);
358 if (ACPI_FAILURE(status)) {
359 return_ACPI_STATUS(status);
362 status =
363 acpi_get_register(acpi_gbl_fixed_event_info[event].
364 enable_register_id, &value);
365 if (ACPI_FAILURE(status)) {
366 return_ACPI_STATUS(status);
369 if (value != 0) {
370 ACPI_ERROR((AE_INFO,
371 "Could not disable %s events",
372 acpi_ut_get_event_name(event)));
373 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
376 return_ACPI_STATUS(status);
379 ACPI_EXPORT_SYMBOL(acpi_disable_event)
381 /*******************************************************************************
383 * FUNCTION: acpi_clear_event
385 * PARAMETERS: Event - The fixed event to be cleared
387 * RETURN: Status
389 * DESCRIPTION: Clear an ACPI event (fixed)
391 ******************************************************************************/
392 acpi_status acpi_clear_event(u32 event)
394 acpi_status status = AE_OK;
396 ACPI_FUNCTION_TRACE(acpi_clear_event);
398 /* Decode the Fixed Event */
400 if (event > ACPI_EVENT_MAX) {
401 return_ACPI_STATUS(AE_BAD_PARAMETER);
405 * Clear the requested fixed event (By writing a one to the status
406 * register bit)
408 status =
409 acpi_set_register(acpi_gbl_fixed_event_info[event].
410 status_register_id, 1);
412 return_ACPI_STATUS(status);
415 ACPI_EXPORT_SYMBOL(acpi_clear_event)
417 /*******************************************************************************
419 * FUNCTION: acpi_clear_gpe
421 * PARAMETERS: gpe_device - Parent GPE Device
422 * gpe_number - GPE level within the GPE block
423 * Flags - Called from an ISR or not
425 * RETURN: Status
427 * DESCRIPTION: Clear an ACPI event (general purpose)
429 ******************************************************************************/
430 acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
432 acpi_status status = AE_OK;
433 struct acpi_gpe_event_info *gpe_event_info;
435 ACPI_FUNCTION_TRACE(acpi_clear_gpe);
437 /* Use semaphore lock if not executing at interrupt level */
439 if (flags & ACPI_NOT_ISR) {
440 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
441 if (ACPI_FAILURE(status)) {
442 return_ACPI_STATUS(status);
446 /* Ensure that we have a valid GPE number */
448 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
449 if (!gpe_event_info) {
450 status = AE_BAD_PARAMETER;
451 goto unlock_and_exit;
454 status = acpi_hw_clear_gpe(gpe_event_info);
456 unlock_and_exit:
457 if (flags & ACPI_NOT_ISR) {
458 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
460 return_ACPI_STATUS(status);
463 ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
464 /*******************************************************************************
466 * FUNCTION: acpi_get_event_status
468 * PARAMETERS: Event - The fixed event
469 * event_status - Where the current status of the event will
470 * be returned
472 * RETURN: Status
474 * DESCRIPTION: Obtains and returns the current status of the event
476 ******************************************************************************/
477 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
479 acpi_status status = AE_OK;
480 u32 value;
482 ACPI_FUNCTION_TRACE(acpi_get_event_status);
484 if (!event_status) {
485 return_ACPI_STATUS(AE_BAD_PARAMETER);
488 /* Decode the Fixed Event */
490 if (event > ACPI_EVENT_MAX) {
491 return_ACPI_STATUS(AE_BAD_PARAMETER);
494 /* Get the status of the requested fixed event */
496 status =
497 acpi_get_register(acpi_gbl_fixed_event_info[event].
498 enable_register_id, &value);
499 if (ACPI_FAILURE(status))
500 return_ACPI_STATUS(status);
502 *event_status = value;
504 status =
505 acpi_get_register(acpi_gbl_fixed_event_info[event].
506 status_register_id, &value);
507 if (ACPI_FAILURE(status))
508 return_ACPI_STATUS(status);
510 if (value)
511 *event_status |= ACPI_EVENT_FLAG_SET;
513 if (acpi_gbl_fixed_event_handlers[event].handler)
514 *event_status |= ACPI_EVENT_FLAG_HANDLE;
516 return_ACPI_STATUS(status);
519 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
521 /*******************************************************************************
523 * FUNCTION: acpi_get_gpe_status
525 * PARAMETERS: gpe_device - Parent GPE Device
526 * gpe_number - GPE level within the GPE block
527 * Flags - Called from an ISR or not
528 * event_status - Where the current status of the event will
529 * be returned
531 * RETURN: Status
533 * DESCRIPTION: Get status of an event (general purpose)
535 ******************************************************************************/
536 acpi_status
537 acpi_get_gpe_status(acpi_handle gpe_device,
538 u32 gpe_number, u32 flags, acpi_event_status * event_status)
540 acpi_status status = AE_OK;
541 struct acpi_gpe_event_info *gpe_event_info;
543 ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
545 /* Use semaphore lock if not executing at interrupt level */
547 if (flags & ACPI_NOT_ISR) {
548 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
549 if (ACPI_FAILURE(status)) {
550 return_ACPI_STATUS(status);
554 /* Ensure that we have a valid GPE number */
556 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
557 if (!gpe_event_info) {
558 status = AE_BAD_PARAMETER;
559 goto unlock_and_exit;
562 /* Obtain status on the requested GPE number */
564 status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
566 if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)
567 *event_status |= ACPI_EVENT_FLAG_HANDLE;
569 unlock_and_exit:
570 if (flags & ACPI_NOT_ISR) {
571 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
573 return_ACPI_STATUS(status);
576 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
577 /*******************************************************************************
579 * FUNCTION: acpi_install_gpe_block
581 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
582 * gpe_block_address - Address and space_iD
583 * register_count - Number of GPE register pairs in the block
584 * interrupt_number - H/W interrupt for the block
586 * RETURN: Status
588 * DESCRIPTION: Create and Install a block of GPE registers
590 ******************************************************************************/
591 acpi_status
592 acpi_install_gpe_block(acpi_handle gpe_device,
593 struct acpi_generic_address *gpe_block_address,
594 u32 register_count, u32 interrupt_number)
596 acpi_status status;
597 union acpi_operand_object *obj_desc;
598 struct acpi_namespace_node *node;
599 struct acpi_gpe_block_info *gpe_block;
601 ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
603 if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
604 return_ACPI_STATUS(AE_BAD_PARAMETER);
607 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
608 if (ACPI_FAILURE(status)) {
609 return (status);
612 node = acpi_ns_map_handle_to_node(gpe_device);
613 if (!node) {
614 status = AE_BAD_PARAMETER;
615 goto unlock_and_exit;
619 * For user-installed GPE Block Devices, the gpe_block_base_number
620 * is always zero
622 status =
623 acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
624 interrupt_number, &gpe_block);
625 if (ACPI_FAILURE(status)) {
626 goto unlock_and_exit;
629 /* Run the _PRW methods and enable the GPEs */
631 status = acpi_ev_initialize_gpe_block(node, gpe_block);
632 if (ACPI_FAILURE(status)) {
633 goto unlock_and_exit;
636 /* Get the device_object attached to the node */
638 obj_desc = acpi_ns_get_attached_object(node);
639 if (!obj_desc) {
641 /* No object, create a new one */
643 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
644 if (!obj_desc) {
645 status = AE_NO_MEMORY;
646 goto unlock_and_exit;
649 status =
650 acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
652 /* Remove local reference to the object */
654 acpi_ut_remove_reference(obj_desc);
656 if (ACPI_FAILURE(status)) {
657 goto unlock_and_exit;
661 /* Install the GPE block in the device_object */
663 obj_desc->device.gpe_block = gpe_block;
665 unlock_and_exit:
666 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
667 return_ACPI_STATUS(status);
670 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
672 /*******************************************************************************
674 * FUNCTION: acpi_remove_gpe_block
676 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
678 * RETURN: Status
680 * DESCRIPTION: Remove a previously installed block of GPE registers
682 ******************************************************************************/
683 acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
685 union acpi_operand_object *obj_desc;
686 acpi_status status;
687 struct acpi_namespace_node *node;
689 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
691 if (!gpe_device) {
692 return_ACPI_STATUS(AE_BAD_PARAMETER);
695 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
696 if (ACPI_FAILURE(status)) {
697 return (status);
700 node = acpi_ns_map_handle_to_node(gpe_device);
701 if (!node) {
702 status = AE_BAD_PARAMETER;
703 goto unlock_and_exit;
706 /* Get the device_object attached to the node */
708 obj_desc = acpi_ns_get_attached_object(node);
709 if (!obj_desc || !obj_desc->device.gpe_block) {
710 return_ACPI_STATUS(AE_NULL_OBJECT);
713 /* Delete the GPE block (but not the device_object) */
715 status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
716 if (ACPI_SUCCESS(status)) {
717 obj_desc->device.gpe_block = NULL;
720 unlock_and_exit:
721 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
722 return_ACPI_STATUS(status);
725 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
727 /*******************************************************************************
729 * FUNCTION: acpi_get_gpe_device
731 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
732 * gpe_device - Where the parent GPE Device is returned
734 * RETURN: Status
736 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
737 * gpe device indicates that the gpe number is contained in one of
738 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
740 ******************************************************************************/
741 acpi_status
742 acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
744 struct acpi_gpe_device_info info;
745 acpi_status status;
747 ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
749 if (!gpe_device) {
750 return_ACPI_STATUS(AE_BAD_PARAMETER);
753 if (index >= acpi_current_gpe_count) {
754 return_ACPI_STATUS(AE_NOT_EXIST);
757 /* Setup and walk the GPE list */
759 info.index = index;
760 info.status = AE_NOT_EXIST;
761 info.gpe_device = NULL;
762 info.next_block_base_index = 0;
764 status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
765 if (ACPI_FAILURE(status)) {
766 return_ACPI_STATUS(status);
769 *gpe_device = info.gpe_device;
770 return_ACPI_STATUS(info.status);
773 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
775 /*******************************************************************************
777 * FUNCTION: acpi_ev_get_gpe_device
779 * PARAMETERS: GPE_WALK_CALLBACK
781 * RETURN: Status
783 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
784 * block device. NULL if the GPE is one of the FADT-defined GPEs.
786 ******************************************************************************/
787 acpi_status
788 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
789 struct acpi_gpe_block_info *gpe_block, void *context)
791 struct acpi_gpe_device_info *info = context;
793 /* Increment Index by the number of GPEs in this block */
795 info->next_block_base_index +=
796 (gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH);
798 if (info->index < info->next_block_base_index) {
800 * The GPE index is within this block, get the node. Leave the node
801 * NULL for the FADT-defined GPEs
803 if ((gpe_block->node)->type == ACPI_TYPE_DEVICE) {
804 info->gpe_device = gpe_block->node;
807 info->status = AE_OK;
808 return (AE_CTRL_END);
811 return (AE_OK);
814 /******************************************************************************
816 * FUNCTION: acpi_disable_all_gpes
818 * PARAMETERS: None
820 * RETURN: Status
822 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
824 ******************************************************************************/
826 acpi_status acpi_disable_all_gpes(void)
828 acpi_status status;
830 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
832 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
833 if (ACPI_FAILURE(status)) {
834 return_ACPI_STATUS(status);
837 status = acpi_hw_disable_all_gpes();
838 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
840 return_ACPI_STATUS(status);
843 /******************************************************************************
845 * FUNCTION: acpi_enable_all_runtime_gpes
847 * PARAMETERS: None
849 * RETURN: Status
851 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
853 ******************************************************************************/
855 acpi_status acpi_enable_all_runtime_gpes(void)
857 acpi_status status;
859 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
861 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
862 if (ACPI_FAILURE(status)) {
863 return_ACPI_STATUS(status);
866 status = acpi_hw_enable_all_runtime_gpes();
867 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
869 return_ACPI_STATUS(status);