On Tue, Nov 06, 2007 at 02:33:53AM -0800, akpm@linux-foundation.org wrote:
[mmotm.git] / drivers / acpi / acpica / evxfevnt.c
blob4721f58fe42c0653d6a6c14aee384ffbab2e708a
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 "accommon.h"
46 #include "acevents.h"
47 #include "acnamesp.h"
48 #include "actables.h"
50 #define _COMPONENT ACPI_EVENTS
51 ACPI_MODULE_NAME("evxfevnt")
53 /* Local prototypes */
54 static acpi_status
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
62 * PARAMETERS: None
64 * RETURN: Status
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"));
87 } else {
88 /* Transition to ACPI mode */
90 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
91 if (ACPI_FAILURE(status)) {
92 ACPI_ERROR((AE_INFO,
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
110 * PARAMETERS: None
112 * RETURN: Status
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"));
126 } else {
127 /* Transition to LEGACY mode */
129 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
131 if (ACPI_FAILURE(status)) {
132 ACPI_ERROR((AE_INFO,
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
150 * Flags - Reserved
152 * RETURN: Status
154 * DESCRIPTION: Enable an ACPI event (fixed)
156 ******************************************************************************/
157 acpi_status acpi_enable_event(u32 event, u32 flags)
159 acpi_status status = AE_OK;
160 u32 value;
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
172 * register bit)
174 status =
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 */
183 status =
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);
190 if (value != 1) {
191 ACPI_ERROR((AE_INFO,
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_type
206 * PARAMETERS: gpe_device - Parent GPE Device
207 * gpe_number - GPE level within the GPE block
208 * Type - New GPE type
210 * RETURN: Status
212 * DESCRIPTION: Set the type of an individual GPE
214 ******************************************************************************/
215 acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
217 acpi_status status = AE_OK;
218 struct acpi_gpe_event_info *gpe_event_info;
220 ACPI_FUNCTION_TRACE(acpi_set_gpe_type);
222 /* Ensure that we have a valid GPE number */
224 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
225 if (!gpe_event_info) {
226 status = AE_BAD_PARAMETER;
227 goto unlock_and_exit;
230 if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
231 return_ACPI_STATUS(AE_OK);
234 /* Set the new type (will disable GPE if currently enabled) */
236 status = acpi_ev_set_gpe_type(gpe_event_info, type);
238 unlock_and_exit:
239 return_ACPI_STATUS(status);
242 ACPI_EXPORT_SYMBOL(acpi_set_gpe_type)
244 /*******************************************************************************
246 * FUNCTION: acpi_enable_gpe
248 * PARAMETERS: gpe_device - Parent GPE Device
249 * gpe_number - GPE level within the GPE block
250 * Flags - Just enable, or also wake enable?
251 * Called from ISR or not
253 * RETURN: Status
255 * DESCRIPTION: Enable an ACPI event (general purpose)
257 ******************************************************************************/
258 acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number)
260 acpi_status status = AE_OK;
261 acpi_cpu_flags flags;
262 struct acpi_gpe_event_info *gpe_event_info;
264 ACPI_FUNCTION_TRACE(acpi_enable_gpe);
266 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
268 /* Ensure that we have a valid GPE number */
270 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
271 if (!gpe_event_info) {
272 status = AE_BAD_PARAMETER;
273 goto unlock_and_exit;
276 /* Perform the enable */
278 status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
280 unlock_and_exit:
281 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
282 return_ACPI_STATUS(status);
285 ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
287 /*******************************************************************************
289 * FUNCTION: acpi_disable_gpe
291 * PARAMETERS: gpe_device - Parent GPE Device
292 * gpe_number - GPE level within the GPE block
293 * Flags - Just disable, or also wake disable?
294 * Called from ISR or not
296 * RETURN: Status
298 * DESCRIPTION: Disable an ACPI event (general purpose)
300 ******************************************************************************/
301 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number)
303 acpi_status status = AE_OK;
304 acpi_cpu_flags flags;
305 struct acpi_gpe_event_info *gpe_event_info;
307 ACPI_FUNCTION_TRACE(acpi_disable_gpe);
309 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
310 /* Ensure that we have a valid GPE number */
312 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
313 if (!gpe_event_info) {
314 status = AE_BAD_PARAMETER;
315 goto unlock_and_exit;
318 status = acpi_ev_disable_gpe(gpe_event_info);
320 unlock_and_exit:
321 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
322 return_ACPI_STATUS(status);
325 ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
327 /*******************************************************************************
329 * FUNCTION: acpi_disable_event
331 * PARAMETERS: Event - The fixed eventto be enabled
332 * Flags - Reserved
334 * RETURN: Status
336 * DESCRIPTION: Disable an ACPI event (fixed)
338 ******************************************************************************/
339 acpi_status acpi_disable_event(u32 event, u32 flags)
341 acpi_status status = AE_OK;
342 u32 value;
344 ACPI_FUNCTION_TRACE(acpi_disable_event);
346 /* Decode the Fixed Event */
348 if (event > ACPI_EVENT_MAX) {
349 return_ACPI_STATUS(AE_BAD_PARAMETER);
353 * Disable the requested fixed event (by writing a zero to the enable
354 * register bit)
356 status =
357 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
358 enable_register_id, ACPI_DISABLE_EVENT);
359 if (ACPI_FAILURE(status)) {
360 return_ACPI_STATUS(status);
363 status =
364 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
365 enable_register_id, &value);
366 if (ACPI_FAILURE(status)) {
367 return_ACPI_STATUS(status);
370 if (value != 0) {
371 ACPI_ERROR((AE_INFO,
372 "Could not disable %s events",
373 acpi_ut_get_event_name(event)));
374 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
377 return_ACPI_STATUS(status);
380 ACPI_EXPORT_SYMBOL(acpi_disable_event)
382 /*******************************************************************************
384 * FUNCTION: acpi_clear_event
386 * PARAMETERS: Event - The fixed event to be cleared
388 * RETURN: Status
390 * DESCRIPTION: Clear an ACPI event (fixed)
392 ******************************************************************************/
393 acpi_status acpi_clear_event(u32 event)
395 acpi_status status = AE_OK;
397 ACPI_FUNCTION_TRACE(acpi_clear_event);
399 /* Decode the Fixed Event */
401 if (event > ACPI_EVENT_MAX) {
402 return_ACPI_STATUS(AE_BAD_PARAMETER);
406 * Clear the requested fixed event (By writing a one to the status
407 * register bit)
409 status =
410 acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
411 status_register_id, ACPI_CLEAR_STATUS);
413 return_ACPI_STATUS(status);
416 ACPI_EXPORT_SYMBOL(acpi_clear_event)
418 /*******************************************************************************
420 * FUNCTION: acpi_clear_gpe
422 * PARAMETERS: gpe_device - Parent GPE Device
423 * gpe_number - GPE level within the GPE block
424 * Flags - Called from an ISR or not
426 * RETURN: Status
428 * DESCRIPTION: Clear an ACPI event (general purpose)
430 ******************************************************************************/
431 acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
433 acpi_status status = AE_OK;
434 struct acpi_gpe_event_info *gpe_event_info;
436 ACPI_FUNCTION_TRACE(acpi_clear_gpe);
438 /* Use semaphore lock if not executing at interrupt level */
440 if (flags & ACPI_NOT_ISR) {
441 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
442 if (ACPI_FAILURE(status)) {
443 return_ACPI_STATUS(status);
447 /* Ensure that we have a valid GPE number */
449 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
450 if (!gpe_event_info) {
451 status = AE_BAD_PARAMETER;
452 goto unlock_and_exit;
455 status = acpi_hw_clear_gpe(gpe_event_info);
457 unlock_and_exit:
458 if (flags & ACPI_NOT_ISR) {
459 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
461 return_ACPI_STATUS(status);
464 ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
465 /*******************************************************************************
467 * FUNCTION: acpi_get_event_status
469 * PARAMETERS: Event - The fixed event
470 * event_status - Where the current status of the event will
471 * be returned
473 * RETURN: Status
475 * DESCRIPTION: Obtains and returns the current status of the event
477 ******************************************************************************/
478 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
480 acpi_status status = AE_OK;
481 u32 value;
483 ACPI_FUNCTION_TRACE(acpi_get_event_status);
485 if (!event_status) {
486 return_ACPI_STATUS(AE_BAD_PARAMETER);
489 /* Decode the Fixed Event */
491 if (event > ACPI_EVENT_MAX) {
492 return_ACPI_STATUS(AE_BAD_PARAMETER);
495 /* Get the status of the requested fixed event */
497 status =
498 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
499 enable_register_id, &value);
500 if (ACPI_FAILURE(status))
501 return_ACPI_STATUS(status);
503 *event_status = value;
505 status =
506 acpi_read_bit_register(acpi_gbl_fixed_event_info[event].
507 status_register_id, &value);
508 if (ACPI_FAILURE(status))
509 return_ACPI_STATUS(status);
511 if (value)
512 *event_status |= ACPI_EVENT_FLAG_SET;
514 if (acpi_gbl_fixed_event_handlers[event].handler)
515 *event_status |= ACPI_EVENT_FLAG_HANDLE;
517 return_ACPI_STATUS(status);
520 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
522 /*******************************************************************************
524 * FUNCTION: acpi_get_gpe_status
526 * PARAMETERS: gpe_device - Parent GPE Device
527 * gpe_number - GPE level within the GPE block
528 * Flags - Called from an ISR or not
529 * event_status - Where the current status of the event will
530 * be returned
532 * RETURN: Status
534 * DESCRIPTION: Get status of an event (general purpose)
536 ******************************************************************************/
537 acpi_status
538 acpi_get_gpe_status(acpi_handle gpe_device,
539 u32 gpe_number, u32 flags, acpi_event_status * event_status)
541 acpi_status status = AE_OK;
542 struct acpi_gpe_event_info *gpe_event_info;
544 ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
546 /* Use semaphore lock if not executing at interrupt level */
548 if (flags & ACPI_NOT_ISR) {
549 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
550 if (ACPI_FAILURE(status)) {
551 return_ACPI_STATUS(status);
555 /* Ensure that we have a valid GPE number */
557 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
558 if (!gpe_event_info) {
559 status = AE_BAD_PARAMETER;
560 goto unlock_and_exit;
563 /* Obtain status on the requested GPE number */
565 status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
567 if (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)
568 *event_status |= ACPI_EVENT_FLAG_HANDLE;
570 unlock_and_exit:
571 if (flags & ACPI_NOT_ISR) {
572 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
574 return_ACPI_STATUS(status);
577 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
578 /*******************************************************************************
580 * FUNCTION: acpi_install_gpe_block
582 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
583 * gpe_block_address - Address and space_iD
584 * register_count - Number of GPE register pairs in the block
585 * interrupt_number - H/W interrupt for the block
587 * RETURN: Status
589 * DESCRIPTION: Create and Install a block of GPE registers
591 ******************************************************************************/
592 acpi_status
593 acpi_install_gpe_block(acpi_handle gpe_device,
594 struct acpi_generic_address *gpe_block_address,
595 u32 register_count, u32 interrupt_number)
597 acpi_status status;
598 union acpi_operand_object *obj_desc;
599 struct acpi_namespace_node *node;
600 struct acpi_gpe_block_info *gpe_block;
602 ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
604 if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
605 return_ACPI_STATUS(AE_BAD_PARAMETER);
608 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
609 if (ACPI_FAILURE(status)) {
610 return (status);
613 node = acpi_ns_map_handle_to_node(gpe_device);
614 if (!node) {
615 status = AE_BAD_PARAMETER;
616 goto unlock_and_exit;
620 * For user-installed GPE Block Devices, the gpe_block_base_number
621 * is always zero
623 status =
624 acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
625 interrupt_number, &gpe_block);
626 if (ACPI_FAILURE(status)) {
627 goto unlock_and_exit;
630 /* Run the _PRW methods and enable the GPEs */
632 status = acpi_ev_initialize_gpe_block(node, gpe_block);
633 if (ACPI_FAILURE(status)) {
634 goto unlock_and_exit;
637 /* Get the device_object attached to the node */
639 obj_desc = acpi_ns_get_attached_object(node);
640 if (!obj_desc) {
642 /* No object, create a new one */
644 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
645 if (!obj_desc) {
646 status = AE_NO_MEMORY;
647 goto unlock_and_exit;
650 status =
651 acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
653 /* Remove local reference to the object */
655 acpi_ut_remove_reference(obj_desc);
657 if (ACPI_FAILURE(status)) {
658 goto unlock_and_exit;
662 /* Install the GPE block in the device_object */
664 obj_desc->device.gpe_block = gpe_block;
666 unlock_and_exit:
667 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
668 return_ACPI_STATUS(status);
671 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
673 /*******************************************************************************
675 * FUNCTION: acpi_remove_gpe_block
677 * PARAMETERS: gpe_device - Handle to the parent GPE Block Device
679 * RETURN: Status
681 * DESCRIPTION: Remove a previously installed block of GPE registers
683 ******************************************************************************/
684 acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
686 union acpi_operand_object *obj_desc;
687 acpi_status status;
688 struct acpi_namespace_node *node;
690 ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
692 if (!gpe_device) {
693 return_ACPI_STATUS(AE_BAD_PARAMETER);
696 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
697 if (ACPI_FAILURE(status)) {
698 return (status);
701 node = acpi_ns_map_handle_to_node(gpe_device);
702 if (!node) {
703 status = AE_BAD_PARAMETER;
704 goto unlock_and_exit;
707 /* Get the device_object attached to the node */
709 obj_desc = acpi_ns_get_attached_object(node);
710 if (!obj_desc || !obj_desc->device.gpe_block) {
711 return_ACPI_STATUS(AE_NULL_OBJECT);
714 /* Delete the GPE block (but not the device_object) */
716 status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
717 if (ACPI_SUCCESS(status)) {
718 obj_desc->device.gpe_block = NULL;
721 unlock_and_exit:
722 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
723 return_ACPI_STATUS(status);
726 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
728 /*******************************************************************************
730 * FUNCTION: acpi_get_gpe_device
732 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
733 * gpe_device - Where the parent GPE Device is returned
735 * RETURN: Status
737 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
738 * gpe device indicates that the gpe number is contained in one of
739 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
741 ******************************************************************************/
742 acpi_status
743 acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
745 struct acpi_gpe_device_info info;
746 acpi_status status;
748 ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
750 if (!gpe_device) {
751 return_ACPI_STATUS(AE_BAD_PARAMETER);
754 if (index >= acpi_current_gpe_count) {
755 return_ACPI_STATUS(AE_NOT_EXIST);
758 /* Setup and walk the GPE list */
760 info.index = index;
761 info.status = AE_NOT_EXIST;
762 info.gpe_device = NULL;
763 info.next_block_base_index = 0;
765 status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
766 if (ACPI_FAILURE(status)) {
767 return_ACPI_STATUS(status);
770 *gpe_device = info.gpe_device;
771 return_ACPI_STATUS(info.status);
774 ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
776 /*******************************************************************************
778 * FUNCTION: acpi_ev_get_gpe_device
780 * PARAMETERS: GPE_WALK_CALLBACK
782 * RETURN: Status
784 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
785 * block device. NULL if the GPE is one of the FADT-defined GPEs.
787 ******************************************************************************/
788 static acpi_status
789 acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
790 struct acpi_gpe_block_info *gpe_block, void *context)
792 struct acpi_gpe_device_info *info = context;
794 /* Increment Index by the number of GPEs in this block */
796 info->next_block_base_index +=
797 (gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH);
799 if (info->index < info->next_block_base_index) {
801 * The GPE index is within this block, get the node. Leave the node
802 * NULL for the FADT-defined GPEs
804 if ((gpe_block->node)->type == ACPI_TYPE_DEVICE) {
805 info->gpe_device = gpe_block->node;
808 info->status = AE_OK;
809 return (AE_CTRL_END);
812 return (AE_OK);
815 /******************************************************************************
817 * FUNCTION: acpi_disable_all_gpes
819 * PARAMETERS: None
821 * RETURN: Status
823 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
825 ******************************************************************************/
827 acpi_status acpi_disable_all_gpes(void)
829 acpi_status status;
831 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
833 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
834 if (ACPI_FAILURE(status)) {
835 return_ACPI_STATUS(status);
838 status = acpi_hw_disable_all_gpes();
839 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
841 return_ACPI_STATUS(status);
844 /******************************************************************************
846 * FUNCTION: acpi_enable_all_runtime_gpes
848 * PARAMETERS: None
850 * RETURN: Status
852 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
854 ******************************************************************************/
856 acpi_status acpi_enable_all_runtime_gpes(void)
858 acpi_status status;
860 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
862 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
863 if (ACPI_FAILURE(status)) {
864 return_ACPI_STATUS(status);
867 status = acpi_hw_enable_all_runtime_gpes();
868 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
870 return_ACPI_STATUS(status);