dt-bindings: mtd: ingenic: Use standard ecc-engine property
[linux/fpc-iii.git] / drivers / acpi / acpica / evgpe.c
blob62d3aa74277b4d03cb4bd1e7d5cee705864bd41b
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /******************************************************************************
4 * Module Name: evgpe - General Purpose Event handling and dispatch
6 * Copyright (C) 2000 - 2019, Intel Corp.
8 *****************************************************************************/
10 #include <acpi/acpi.h>
11 #include "accommon.h"
12 #include "acevents.h"
13 #include "acnamesp.h"
15 #define _COMPONENT ACPI_EVENTS
16 ACPI_MODULE_NAME("evgpe")
17 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
18 /* Local prototypes */
19 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
21 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_enable_gpe(void *context);
23 /*******************************************************************************
25 * FUNCTION: acpi_ev_update_gpe_enable_mask
27 * PARAMETERS: gpe_event_info - GPE to update
29 * RETURN: Status
31 * DESCRIPTION: Updates GPE register enable mask based upon whether there are
32 * runtime references to this GPE
34 ******************************************************************************/
36 acpi_status
37 acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info)
39 struct acpi_gpe_register_info *gpe_register_info;
40 u32 register_bit;
42 ACPI_FUNCTION_TRACE(ev_update_gpe_enable_mask);
44 gpe_register_info = gpe_event_info->register_info;
45 if (!gpe_register_info) {
46 return_ACPI_STATUS(AE_NOT_EXIST);
49 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
51 /* Clear the run bit up front */
53 ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit);
55 /* Set the mask bit only if there are references to this GPE */
57 if (gpe_event_info->runtime_count) {
58 ACPI_SET_BIT(gpe_register_info->enable_for_run,
59 (u8)register_bit);
62 gpe_register_info->enable_mask = gpe_register_info->enable_for_run;
63 return_ACPI_STATUS(AE_OK);
66 /*******************************************************************************
68 * FUNCTION: acpi_ev_enable_gpe
70 * PARAMETERS: gpe_event_info - GPE to enable
72 * RETURN: Status
74 * DESCRIPTION: Enable a GPE.
76 ******************************************************************************/
78 acpi_status acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info)
80 acpi_status status;
82 ACPI_FUNCTION_TRACE(ev_enable_gpe);
84 /* Enable the requested GPE */
86 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE);
87 return_ACPI_STATUS(status);
90 /*******************************************************************************
92 * FUNCTION: acpi_ev_mask_gpe
94 * PARAMETERS: gpe_event_info - GPE to be blocked/unblocked
95 * is_masked - Whether the GPE is masked or not
97 * RETURN: Status
99 * DESCRIPTION: Unconditionally mask/unmask a GPE during runtime.
101 ******************************************************************************/
103 acpi_status
104 acpi_ev_mask_gpe(struct acpi_gpe_event_info *gpe_event_info, u8 is_masked)
106 struct acpi_gpe_register_info *gpe_register_info;
107 u32 register_bit;
109 ACPI_FUNCTION_TRACE(ev_mask_gpe);
111 gpe_register_info = gpe_event_info->register_info;
112 if (!gpe_register_info) {
113 return_ACPI_STATUS(AE_NOT_EXIST);
116 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
118 /* Perform the action */
120 if (is_masked) {
121 if (register_bit & gpe_register_info->mask_for_run) {
122 return_ACPI_STATUS(AE_BAD_PARAMETER);
125 (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
126 ACPI_SET_BIT(gpe_register_info->mask_for_run, (u8)register_bit);
127 } else {
128 if (!(register_bit & gpe_register_info->mask_for_run)) {
129 return_ACPI_STATUS(AE_BAD_PARAMETER);
132 ACPI_CLEAR_BIT(gpe_register_info->mask_for_run,
133 (u8)register_bit);
134 if (gpe_event_info->runtime_count
135 && !gpe_event_info->disable_for_dispatch) {
136 (void)acpi_hw_low_set_gpe(gpe_event_info,
137 ACPI_GPE_ENABLE);
141 return_ACPI_STATUS(AE_OK);
144 /*******************************************************************************
146 * FUNCTION: acpi_ev_add_gpe_reference
148 * PARAMETERS: gpe_event_info - Add a reference to this GPE
150 * RETURN: Status
152 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
153 * hardware-enabled.
155 ******************************************************************************/
157 acpi_status
158 acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
160 acpi_status status = AE_OK;
162 ACPI_FUNCTION_TRACE(ev_add_gpe_reference);
164 if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) {
165 return_ACPI_STATUS(AE_LIMIT);
168 gpe_event_info->runtime_count++;
169 if (gpe_event_info->runtime_count == 1) {
171 /* Enable on first reference */
173 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
174 if (ACPI_SUCCESS(status)) {
175 status = acpi_ev_enable_gpe(gpe_event_info);
178 if (ACPI_FAILURE(status)) {
179 gpe_event_info->runtime_count--;
183 return_ACPI_STATUS(status);
186 /*******************************************************************************
188 * FUNCTION: acpi_ev_remove_gpe_reference
190 * PARAMETERS: gpe_event_info - Remove a reference to this GPE
192 * RETURN: Status
194 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
195 * removed, the GPE is hardware-disabled.
197 ******************************************************************************/
199 acpi_status
200 acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info)
202 acpi_status status = AE_OK;
204 ACPI_FUNCTION_TRACE(ev_remove_gpe_reference);
206 if (!gpe_event_info->runtime_count) {
207 return_ACPI_STATUS(AE_LIMIT);
210 gpe_event_info->runtime_count--;
211 if (!gpe_event_info->runtime_count) {
213 /* Disable on last reference */
215 status = acpi_ev_update_gpe_enable_mask(gpe_event_info);
216 if (ACPI_SUCCESS(status)) {
217 status =
218 acpi_hw_low_set_gpe(gpe_event_info,
219 ACPI_GPE_DISABLE);
222 if (ACPI_FAILURE(status)) {
223 gpe_event_info->runtime_count++;
227 return_ACPI_STATUS(status);
230 /*******************************************************************************
232 * FUNCTION: acpi_ev_low_get_gpe_info
234 * PARAMETERS: gpe_number - Raw GPE number
235 * gpe_block - A GPE info block
237 * RETURN: A GPE event_info struct. NULL if not a valid GPE (The gpe_number
238 * is not within the specified GPE block)
240 * DESCRIPTION: Returns the event_info struct associated with this GPE. This is
241 * the low-level implementation of ev_get_gpe_event_info.
243 ******************************************************************************/
245 struct acpi_gpe_event_info *acpi_ev_low_get_gpe_info(u32 gpe_number,
246 struct acpi_gpe_block_info
247 *gpe_block)
249 u32 gpe_index;
252 * Validate that the gpe_number is within the specified gpe_block.
253 * (Two steps)
255 if (!gpe_block || (gpe_number < gpe_block->block_base_number)) {
256 return (NULL);
259 gpe_index = gpe_number - gpe_block->block_base_number;
260 if (gpe_index >= gpe_block->gpe_count) {
261 return (NULL);
264 return (&gpe_block->event_info[gpe_index]);
268 /*******************************************************************************
270 * FUNCTION: acpi_ev_get_gpe_event_info
272 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
273 * gpe_number - Raw GPE number
275 * RETURN: A GPE event_info struct. NULL if not a valid GPE
277 * DESCRIPTION: Returns the event_info struct associated with this GPE.
278 * Validates the gpe_block and the gpe_number
280 * Should be called only when the GPE lists are semaphore locked
281 * and not subject to change.
283 ******************************************************************************/
285 struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
286 u32 gpe_number)
288 union acpi_operand_object *obj_desc;
289 struct acpi_gpe_event_info *gpe_info;
290 u32 i;
292 ACPI_FUNCTION_ENTRY();
294 /* A NULL gpe_device means use the FADT-defined GPE block(s) */
296 if (!gpe_device) {
298 /* Examine GPE Block 0 and 1 (These blocks are permanent) */
300 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
301 gpe_info = acpi_ev_low_get_gpe_info(gpe_number,
302 acpi_gbl_gpe_fadt_blocks
303 [i]);
304 if (gpe_info) {
305 return (gpe_info);
309 /* The gpe_number was not in the range of either FADT GPE block */
311 return (NULL);
314 /* A Non-NULL gpe_device means this is a GPE Block Device */
316 obj_desc =
317 acpi_ns_get_attached_object((struct acpi_namespace_node *)
318 gpe_device);
319 if (!obj_desc || !obj_desc->device.gpe_block) {
320 return (NULL);
323 return (acpi_ev_low_get_gpe_info
324 (gpe_number, obj_desc->device.gpe_block));
327 /*******************************************************************************
329 * FUNCTION: acpi_ev_gpe_detect
331 * PARAMETERS: gpe_xrupt_list - Interrupt block for this interrupt.
332 * Can have multiple GPE blocks attached.
334 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
336 * DESCRIPTION: Detect if any GP events have occurred. This function is
337 * executed at interrupt level.
339 ******************************************************************************/
341 u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list)
343 struct acpi_gpe_block_info *gpe_block;
344 struct acpi_namespace_node *gpe_device;
345 struct acpi_gpe_register_info *gpe_register_info;
346 struct acpi_gpe_event_info *gpe_event_info;
347 u32 gpe_number;
348 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
349 acpi_cpu_flags flags;
350 u32 i;
351 u32 j;
353 ACPI_FUNCTION_NAME(ev_gpe_detect);
355 /* Check for the case where there are no GPEs */
357 if (!gpe_xrupt_list) {
358 return (int_status);
362 * We need to obtain the GPE lock for both the data structs and registers
363 * Note: Not necessary to obtain the hardware lock, since the GPE
364 * registers are owned by the gpe_lock.
366 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
368 /* Examine all GPE blocks attached to this interrupt level */
370 gpe_block = gpe_xrupt_list->gpe_block_list_head;
371 while (gpe_block) {
372 gpe_device = gpe_block->node;
375 * Read all of the 8-bit GPE status and enable registers in this GPE
376 * block, saving all of them. Find all currently active GP events.
378 for (i = 0; i < gpe_block->register_count; i++) {
380 /* Get the next status/enable pair */
382 gpe_register_info = &gpe_block->register_info[i];
385 * Optimization: If there are no GPEs enabled within this
386 * register, we can safely ignore the entire register.
388 if (!(gpe_register_info->enable_for_run |
389 gpe_register_info->enable_for_wake)) {
390 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
391 "Ignore disabled registers for GPE %02X-%02X: "
392 "RunEnable=%02X, WakeEnable=%02X\n",
393 gpe_register_info->
394 base_gpe_number,
395 gpe_register_info->
396 base_gpe_number +
397 (ACPI_GPE_REGISTER_WIDTH - 1),
398 gpe_register_info->
399 enable_for_run,
400 gpe_register_info->
401 enable_for_wake));
402 continue;
405 /* Now look at the individual GPEs in this byte register */
407 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
409 /* Detect and dispatch one GPE bit */
411 gpe_event_info =
412 &gpe_block->
413 event_info[((acpi_size)i *
414 ACPI_GPE_REGISTER_WIDTH) + j];
415 gpe_number =
416 j + gpe_register_info->base_gpe_number;
417 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
418 int_status |=
419 acpi_ev_detect_gpe(gpe_device,
420 gpe_event_info,
421 gpe_number);
422 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
426 gpe_block = gpe_block->next;
429 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
430 return (int_status);
433 /*******************************************************************************
435 * FUNCTION: acpi_ev_asynch_execute_gpe_method
437 * PARAMETERS: Context (gpe_event_info) - Info for this GPE
439 * RETURN: None
441 * DESCRIPTION: Perform the actual execution of a GPE control method. This
442 * function is called from an invocation of acpi_os_execute and
443 * therefore does NOT execute at interrupt level - so that
444 * the control method itself is not executed in the context of
445 * an interrupt handler.
447 ******************************************************************************/
449 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
451 struct acpi_gpe_event_info *gpe_event_info = context;
452 acpi_status status = AE_OK;
453 struct acpi_evaluate_info *info;
454 struct acpi_gpe_notify_info *notify;
456 ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method);
458 /* Do the correct dispatch - normal method or implicit notify */
460 switch (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags)) {
461 case ACPI_GPE_DISPATCH_NOTIFY:
463 * Implicit notify.
464 * Dispatch a DEVICE_WAKE notify to the appropriate handler.
465 * NOTE: the request is queued for execution after this method
466 * completes. The notify handlers are NOT invoked synchronously
467 * from this thread -- because handlers may in turn run other
468 * control methods.
470 * June 2012: Expand implicit notify mechanism to support
471 * notifies on multiple device objects.
473 notify = gpe_event_info->dispatch.notify_list;
474 while (ACPI_SUCCESS(status) && notify) {
475 status =
476 acpi_ev_queue_notify_request(notify->device_node,
477 ACPI_NOTIFY_DEVICE_WAKE);
479 notify = notify->next;
482 break;
484 case ACPI_GPE_DISPATCH_METHOD:
486 /* Allocate the evaluation information block */
488 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
489 if (!info) {
490 status = AE_NO_MEMORY;
491 } else {
493 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the
494 * _Lxx/_Exx control method that corresponds to this GPE
496 info->prefix_node =
497 gpe_event_info->dispatch.method_node;
498 info->flags = ACPI_IGNORE_RETURN_VALUE;
500 status = acpi_ns_evaluate(info);
501 ACPI_FREE(info);
504 if (ACPI_FAILURE(status)) {
505 ACPI_EXCEPTION((AE_INFO, status,
506 "while evaluating GPE method [%4.4s]",
507 acpi_ut_get_node_name(gpe_event_info->
508 dispatch.
509 method_node)));
511 break;
513 default:
515 goto error_exit; /* Should never happen */
518 /* Defer enabling of GPE until all notify handlers are done */
520 status = acpi_os_execute(OSL_NOTIFY_HANDLER,
521 acpi_ev_asynch_enable_gpe, gpe_event_info);
522 if (ACPI_SUCCESS(status)) {
523 return_VOID;
526 error_exit:
527 acpi_ev_asynch_enable_gpe(gpe_event_info);
528 return_VOID;
532 /*******************************************************************************
534 * FUNCTION: acpi_ev_asynch_enable_gpe
536 * PARAMETERS: Context (gpe_event_info) - Info for this GPE
537 * Callback from acpi_os_execute
539 * RETURN: None
541 * DESCRIPTION: Asynchronous clear/enable for GPE. This allows the GPE to
542 * complete (i.e., finish execution of Notify)
544 ******************************************************************************/
546 static void ACPI_SYSTEM_XFACE acpi_ev_asynch_enable_gpe(void *context)
548 struct acpi_gpe_event_info *gpe_event_info = context;
549 acpi_cpu_flags flags;
551 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
552 (void)acpi_ev_finish_gpe(gpe_event_info);
553 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
555 return;
559 /*******************************************************************************
561 * FUNCTION: acpi_ev_finish_gpe
563 * PARAMETERS: gpe_event_info - Info for this GPE
565 * RETURN: Status
567 * DESCRIPTION: Clear/Enable a GPE. Common code that is used after execution
568 * of a GPE method or a synchronous or asynchronous GPE handler.
570 ******************************************************************************/
572 acpi_status acpi_ev_finish_gpe(struct acpi_gpe_event_info *gpe_event_info)
574 acpi_status status;
576 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
577 ACPI_GPE_LEVEL_TRIGGERED) {
579 * GPE is level-triggered, we clear the GPE status bit after
580 * handling the event.
582 status = acpi_hw_clear_gpe(gpe_event_info);
583 if (ACPI_FAILURE(status)) {
584 return (status);
589 * Enable this GPE, conditionally. This means that the GPE will
590 * only be physically enabled if the enable_mask bit is set
591 * in the event_info.
593 (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_CONDITIONAL_ENABLE);
594 gpe_event_info->disable_for_dispatch = FALSE;
595 return (AE_OK);
599 /*******************************************************************************
601 * FUNCTION: acpi_ev_detect_gpe
603 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
604 * gpe_event_info - Info for this GPE
605 * gpe_number - Number relative to the parent GPE block
607 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
609 * DESCRIPTION: Detect and dispatch a General Purpose Event to either a function
610 * (e.g. EC) or method (e.g. _Lxx/_Exx) handler.
611 * NOTE: GPE is W1C, so it is possible to handle a single GPE from both
612 * task and irq context in parallel as long as the process to
613 * detect and mask the GPE is atomic.
614 * However the atomicity of ACPI_GPE_DISPATCH_RAW_HANDLER is
615 * dependent on the raw handler itself.
617 ******************************************************************************/
620 acpi_ev_detect_gpe(struct acpi_namespace_node *gpe_device,
621 struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
623 u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
624 u8 enabled_status_byte;
625 u64 status_reg;
626 u64 enable_reg;
627 u32 register_bit;
628 struct acpi_gpe_register_info *gpe_register_info;
629 struct acpi_gpe_handler_info *gpe_handler_info;
630 acpi_cpu_flags flags;
631 acpi_status status;
633 ACPI_FUNCTION_TRACE(ev_gpe_detect);
635 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
637 if (!gpe_event_info) {
638 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
639 if (!gpe_event_info)
640 goto error_exit;
643 /* Get the info block for the entire GPE register */
645 gpe_register_info = gpe_event_info->register_info;
647 /* Get the register bitmask for this GPE */
649 register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info);
651 /* GPE currently enabled (enable bit == 1)? */
653 status = acpi_hw_read(&enable_reg, &gpe_register_info->enable_address);
654 if (ACPI_FAILURE(status)) {
655 goto error_exit;
658 /* GPE currently active (status bit == 1)? */
660 status = acpi_hw_read(&status_reg, &gpe_register_info->status_address);
661 if (ACPI_FAILURE(status)) {
662 goto error_exit;
665 /* Check if there is anything active at all in this GPE */
667 ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
668 "Read registers for GPE %02X: Status=%02X, Enable=%02X, "
669 "RunEnable=%02X, WakeEnable=%02X\n",
670 gpe_number,
671 (u32)(status_reg & register_bit),
672 (u32)(enable_reg & register_bit),
673 gpe_register_info->enable_for_run,
674 gpe_register_info->enable_for_wake));
676 enabled_status_byte = (u8)(status_reg & enable_reg);
677 if (!(enabled_status_byte & register_bit)) {
678 goto error_exit;
681 /* Invoke global event handler if present */
683 acpi_gpe_count++;
684 if (acpi_gbl_global_event_handler) {
685 acpi_gbl_global_event_handler(ACPI_EVENT_TYPE_GPE,
686 gpe_device, gpe_number,
687 acpi_gbl_global_event_handler_context);
690 /* Found an active GPE */
692 if (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) ==
693 ACPI_GPE_DISPATCH_RAW_HANDLER) {
695 /* Dispatch the event to a raw handler */
697 gpe_handler_info = gpe_event_info->dispatch.handler;
700 * There is no protection around the namespace node
701 * and the GPE handler to ensure a safe destruction
702 * because:
703 * 1. The namespace node is expected to always
704 * exist after loading a table.
705 * 2. The GPE handler is expected to be flushed by
706 * acpi_os_wait_events_complete() before the
707 * destruction.
709 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
710 int_status |=
711 gpe_handler_info->address(gpe_device, gpe_number,
712 gpe_handler_info->context);
713 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
714 } else {
715 /* Dispatch the event to a standard handler or method. */
717 int_status |= acpi_ev_gpe_dispatch(gpe_device,
718 gpe_event_info, gpe_number);
721 error_exit:
722 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
723 return (int_status);
726 /*******************************************************************************
728 * FUNCTION: acpi_ev_gpe_dispatch
730 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
731 * gpe_event_info - Info for this GPE
732 * gpe_number - Number relative to the parent GPE block
734 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
736 * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
737 * or method (e.g. _Lxx/_Exx) handler.
739 ******************************************************************************/
742 acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
743 struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
745 acpi_status status;
746 u32 return_value;
748 ACPI_FUNCTION_TRACE(ev_gpe_dispatch);
751 * Always disable the GPE so that it does not keep firing before
752 * any asynchronous activity completes (either from the execution
753 * of a GPE method or an asynchronous GPE handler.)
755 * If there is no handler or method to run, just disable the
756 * GPE and leave it disabled permanently to prevent further such
757 * pointless events from firing.
759 status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE);
760 if (ACPI_FAILURE(status)) {
761 ACPI_EXCEPTION((AE_INFO, status,
762 "Unable to disable GPE %02X", gpe_number));
763 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
767 * If edge-triggered, clear the GPE status bit now. Note that
768 * level-triggered events are cleared after the GPE is serviced.
770 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
771 ACPI_GPE_EDGE_TRIGGERED) {
772 status = acpi_hw_clear_gpe(gpe_event_info);
773 if (ACPI_FAILURE(status)) {
774 ACPI_EXCEPTION((AE_INFO, status,
775 "Unable to clear GPE %02X",
776 gpe_number));
777 (void)acpi_hw_low_set_gpe(gpe_event_info,
778 ACPI_GPE_CONDITIONAL_ENABLE);
779 return_UINT32(ACPI_INTERRUPT_NOT_HANDLED);
783 gpe_event_info->disable_for_dispatch = TRUE;
786 * Dispatch the GPE to either an installed handler or the control
787 * method associated with this GPE (_Lxx or _Exx). If a handler
788 * exists, we invoke it and do not attempt to run the method.
789 * If there is neither a handler nor a method, leave the GPE
790 * disabled.
792 switch (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags)) {
793 case ACPI_GPE_DISPATCH_HANDLER:
795 /* Invoke the installed handler (at interrupt level) */
797 return_value =
798 gpe_event_info->dispatch.handler->address(gpe_device,
799 gpe_number,
800 gpe_event_info->
801 dispatch.handler->
802 context);
804 /* If requested, clear (if level-triggered) and re-enable the GPE */
806 if (return_value & ACPI_REENABLE_GPE) {
807 (void)acpi_ev_finish_gpe(gpe_event_info);
809 break;
811 case ACPI_GPE_DISPATCH_METHOD:
812 case ACPI_GPE_DISPATCH_NOTIFY:
814 * Execute the method associated with the GPE
815 * NOTE: Level-triggered GPEs are cleared after the method completes.
817 status = acpi_os_execute(OSL_GPE_HANDLER,
818 acpi_ev_asynch_execute_gpe_method,
819 gpe_event_info);
820 if (ACPI_FAILURE(status)) {
821 ACPI_EXCEPTION((AE_INFO, status,
822 "Unable to queue handler for GPE %02X - event disabled",
823 gpe_number));
825 break;
827 default:
829 * No handler or method to run!
830 * 03/2010: This case should no longer be possible. We will not allow
831 * a GPE to be enabled if it has no handler or method.
833 ACPI_ERROR((AE_INFO,
834 "No handler or method for GPE %02X, disabling event",
835 gpe_number));
837 break;
840 return_UINT32(ACPI_INTERRUPT_HANDLED);
843 #endif /* !ACPI_REDUCED_HARDWARE */