ACPICA 20050617-0624 from Bob Moore <robert.moore@intel.com>
[safe/jmp/linux-2.6] / drivers / acpi / events / evgpe.c
1 /******************************************************************************
2  *
3  * Module Name: evgpe - General Purpose Event handling and dispatch
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2005, R. Byron Moore
9  * All rights reserved.
10  *
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.
25  *
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.
29  *
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.
42  */
43
44 #include <acpi/acpi.h>
45 #include <acpi/acevents.h>
46 #include <acpi/acnamesp.h>
47
48 #define _COMPONENT          ACPI_EVENTS
49          ACPI_MODULE_NAME    ("evgpe")
50
51 /* Local prototypes */
52
53 static void ACPI_SYSTEM_XFACE
54 acpi_ev_asynch_execute_gpe_method (
55         void                            *context);
56
57
58 /*******************************************************************************
59  *
60  * FUNCTION:    acpi_ev_set_gpe_type
61  *
62  * PARAMETERS:  gpe_event_info          - GPE to set
63  *              Type                    - New type
64  *
65  * RETURN:      Status
66  *
67  * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run)
68  *
69  ******************************************************************************/
70
71 acpi_status
72 acpi_ev_set_gpe_type (
73         struct acpi_gpe_event_info      *gpe_event_info,
74         u8                              type)
75 {
76         acpi_status                     status;
77
78
79         ACPI_FUNCTION_TRACE ("ev_set_gpe_type");
80
81
82         /* Validate type and update register enable masks */
83
84         switch (type) {
85         case ACPI_GPE_TYPE_WAKE:
86         case ACPI_GPE_TYPE_RUNTIME:
87         case ACPI_GPE_TYPE_WAKE_RUN:
88                 break;
89
90         default:
91                 return_ACPI_STATUS (AE_BAD_PARAMETER);
92         }
93
94         /* Disable the GPE if currently enabled */
95
96         status = acpi_ev_disable_gpe (gpe_event_info);
97
98         /* Type was validated above */
99
100         gpe_event_info->flags &= ~ACPI_GPE_TYPE_MASK; /* Clear type bits */
101         gpe_event_info->flags |= type;              /* Insert type */
102         return_ACPI_STATUS (status);
103 }
104
105
106 /*******************************************************************************
107  *
108  * FUNCTION:    acpi_ev_update_gpe_enable_masks
109  *
110  * PARAMETERS:  gpe_event_info          - GPE to update
111  *              Type                    - What to do: ACPI_GPE_DISABLE or
112  *                                        ACPI_GPE_ENABLE
113  *
114  * RETURN:      Status
115  *
116  * DESCRIPTION: Updates GPE register enable masks based on the GPE type
117  *
118  ******************************************************************************/
119
120 acpi_status
121 acpi_ev_update_gpe_enable_masks (
122         struct acpi_gpe_event_info      *gpe_event_info,
123         u8                              type)
124 {
125         struct acpi_gpe_register_info   *gpe_register_info;
126         u8                              register_bit;
127
128
129         ACPI_FUNCTION_TRACE ("ev_update_gpe_enable_masks");
130
131
132         gpe_register_info = gpe_event_info->register_info;
133         if (!gpe_register_info) {
134                 return_ACPI_STATUS (AE_NOT_EXIST);
135         }
136         register_bit = gpe_event_info->register_bit;
137
138         /* 1) Disable case.  Simply clear all enable bits */
139
140         if (type == ACPI_GPE_DISABLE) {
141                 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit);
142                 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit);
143                 return_ACPI_STATUS (AE_OK);
144         }
145
146         /* 2) Enable case.  Set/Clear the appropriate enable bits */
147
148         switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
149         case ACPI_GPE_TYPE_WAKE:
150                 ACPI_SET_BIT   (gpe_register_info->enable_for_wake, register_bit);
151                 ACPI_CLEAR_BIT (gpe_register_info->enable_for_run, register_bit);
152                 break;
153
154         case ACPI_GPE_TYPE_RUNTIME:
155                 ACPI_CLEAR_BIT (gpe_register_info->enable_for_wake, register_bit);
156                 ACPI_SET_BIT   (gpe_register_info->enable_for_run, register_bit);
157                 break;
158
159         case ACPI_GPE_TYPE_WAKE_RUN:
160                 ACPI_SET_BIT   (gpe_register_info->enable_for_wake, register_bit);
161                 ACPI_SET_BIT   (gpe_register_info->enable_for_run, register_bit);
162                 break;
163
164         default:
165                 return_ACPI_STATUS (AE_BAD_PARAMETER);
166         }
167
168         return_ACPI_STATUS (AE_OK);
169 }
170
171
172 /*******************************************************************************
173  *
174  * FUNCTION:    acpi_ev_enable_gpe
175  *
176  * PARAMETERS:  gpe_event_info          - GPE to enable
177  *              write_to_hardware       - Enable now, or just mark data structs
178  *                                        (WAKE GPEs should be deferred)
179  *
180  * RETURN:      Status
181  *
182  * DESCRIPTION: Enable a GPE based on the GPE type
183  *
184  ******************************************************************************/
185
186 acpi_status
187 acpi_ev_enable_gpe (
188         struct acpi_gpe_event_info      *gpe_event_info,
189         u8                              write_to_hardware)
190 {
191         acpi_status                     status;
192
193
194         ACPI_FUNCTION_TRACE ("ev_enable_gpe");
195
196
197         /* Make sure HW enable masks are updated */
198
199         status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_ENABLE);
200         if (ACPI_FAILURE (status)) {
201                 return_ACPI_STATUS (status);
202         }
203
204         /* Mark wake-enabled or HW enable, or both */
205
206         switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
207         case ACPI_GPE_TYPE_WAKE:
208
209                 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
210                 break;
211
212         case ACPI_GPE_TYPE_WAKE_RUN:
213
214                 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
215
216                 /*lint -fallthrough */
217
218         case ACPI_GPE_TYPE_RUNTIME:
219
220                 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
221
222                 if (write_to_hardware) {
223                         /* Clear the GPE (of stale events), then enable it */
224
225                         status = acpi_hw_clear_gpe (gpe_event_info);
226                         if (ACPI_FAILURE (status)) {
227                                 return_ACPI_STATUS (status);
228                         }
229
230                         /* Enable the requested runtime GPE */
231
232                         status = acpi_hw_write_gpe_enable_reg (gpe_event_info);
233                 }
234                 break;
235
236         default:
237                 return_ACPI_STATUS (AE_BAD_PARAMETER);
238         }
239
240         return_ACPI_STATUS (AE_OK);
241 }
242
243
244 /*******************************************************************************
245  *
246  * FUNCTION:    acpi_ev_disable_gpe
247  *
248  * PARAMETERS:  gpe_event_info          - GPE to disable
249  *
250  * RETURN:      Status
251  *
252  * DESCRIPTION: Disable a GPE based on the GPE type
253  *
254  ******************************************************************************/
255
256 acpi_status
257 acpi_ev_disable_gpe (
258         struct acpi_gpe_event_info      *gpe_event_info)
259 {
260         acpi_status                     status;
261
262
263         ACPI_FUNCTION_TRACE ("ev_disable_gpe");
264
265
266         if (!(gpe_event_info->flags & ACPI_GPE_ENABLE_MASK)) {
267                 return_ACPI_STATUS (AE_OK);
268         }
269
270         /* Make sure HW enable masks are updated */
271
272         status = acpi_ev_update_gpe_enable_masks (gpe_event_info, ACPI_GPE_DISABLE);
273         if (ACPI_FAILURE (status)) {
274                 return_ACPI_STATUS (status);
275         }
276
277         /* Mark wake-disabled or HW disable, or both */
278
279         switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
280         case ACPI_GPE_TYPE_WAKE:
281                 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
282                 break;
283
284         case ACPI_GPE_TYPE_WAKE_RUN:
285                 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_WAKE_ENABLED);
286
287                 /*lint -fallthrough */
288
289         case ACPI_GPE_TYPE_RUNTIME:
290
291                 /* Disable the requested runtime GPE */
292
293                 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_RUN_ENABLED);
294                 status = acpi_hw_write_gpe_enable_reg (gpe_event_info);
295                 break;
296
297         default:
298                 return_ACPI_STATUS (AE_BAD_PARAMETER);
299         }
300
301         return_ACPI_STATUS (AE_OK);
302 }
303
304
305 /*******************************************************************************
306  *
307  * FUNCTION:    acpi_ev_get_gpe_event_info
308  *
309  * PARAMETERS:  gpe_device          - Device node.  NULL for GPE0/GPE1
310  *              gpe_number          - Raw GPE number
311  *
312  * RETURN:      A GPE event_info struct. NULL if not a valid GPE
313  *
314  * DESCRIPTION: Returns the event_info struct associated with this GPE.
315  *              Validates the gpe_block and the gpe_number
316  *
317  *              Should be called only when the GPE lists are semaphore locked
318  *              and not subject to change.
319  *
320  ******************************************************************************/
321
322 struct acpi_gpe_event_info *
323 acpi_ev_get_gpe_event_info (
324         acpi_handle                     gpe_device,
325         u32                             gpe_number)
326 {
327         union acpi_operand_object       *obj_desc;
328         struct acpi_gpe_block_info      *gpe_block;
329         acpi_native_uint                i;
330
331
332         ACPI_FUNCTION_ENTRY ();
333
334
335         /* A NULL gpe_block means use the FADT-defined GPE block(s) */
336
337         if (!gpe_device) {
338                 /* Examine GPE Block 0 and 1 (These blocks are permanent) */
339
340                 for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) {
341                         gpe_block = acpi_gbl_gpe_fadt_blocks[i];
342                         if (gpe_block) {
343                                 if ((gpe_number >= gpe_block->block_base_number) &&
344                                         (gpe_number < gpe_block->block_base_number +
345                                                 (gpe_block->register_count * 8))) {
346                                         return (&gpe_block->event_info[gpe_number -
347                                                 gpe_block->block_base_number]);
348                                 }
349                         }
350                 }
351
352                 /* The gpe_number was not in the range of either FADT GPE block */
353
354                 return (NULL);
355         }
356
357         /* A Non-NULL gpe_device means this is a GPE Block Device */
358
359         obj_desc = acpi_ns_get_attached_object ((struct acpi_namespace_node *) gpe_device);
360         if (!obj_desc ||
361                 !obj_desc->device.gpe_block) {
362                 return (NULL);
363         }
364
365         gpe_block = obj_desc->device.gpe_block;
366
367         if ((gpe_number >= gpe_block->block_base_number) &&
368                 (gpe_number < gpe_block->block_base_number + (gpe_block->register_count * 8))) {
369                 return (&gpe_block->event_info[gpe_number - gpe_block->block_base_number]);
370         }
371
372         return (NULL);
373 }
374
375
376 /*******************************************************************************
377  *
378  * FUNCTION:    acpi_ev_gpe_detect
379  *
380  * PARAMETERS:  gpe_xrupt_list      - Interrupt block for this interrupt.
381  *                                    Can have multiple GPE blocks attached.
382  *
383  * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
384  *
385  * DESCRIPTION: Detect if any GP events have occurred.  This function is
386  *              executed at interrupt level.
387  *
388  ******************************************************************************/
389
390 u32
391 acpi_ev_gpe_detect (
392         struct acpi_gpe_xrupt_info      *gpe_xrupt_list)
393 {
394         u32                             int_status = ACPI_INTERRUPT_NOT_HANDLED;
395         u8                              enabled_status_byte;
396         struct acpi_gpe_register_info   *gpe_register_info;
397         u32                             status_reg;
398         u32                             enable_reg;
399         u32                             flags;
400         acpi_status                     status;
401         struct acpi_gpe_block_info      *gpe_block;
402         acpi_native_uint                i;
403         acpi_native_uint                j;
404
405
406         ACPI_FUNCTION_NAME ("ev_gpe_detect");
407
408         /* Check for the case where there are no GPEs */
409
410         if (!gpe_xrupt_list) {
411                 return (int_status);
412         }
413
414         /* Examine all GPE blocks attached to this interrupt level */
415
416         flags = acpi_os_acquire_lock (acpi_gbl_gpe_lock);
417         gpe_block = gpe_xrupt_list->gpe_block_list_head;
418         while (gpe_block) {
419                 /*
420                  * Read all of the 8-bit GPE status and enable registers
421                  * in this GPE block, saving all of them.
422                  * Find all currently active GP events.
423                  */
424                 for (i = 0; i < gpe_block->register_count; i++) {
425                         /* Get the next status/enable pair */
426
427                         gpe_register_info = &gpe_block->register_info[i];
428
429                         /* Read the Status Register */
430
431                         status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &status_reg,
432                                          &gpe_register_info->status_address);
433                         if (ACPI_FAILURE (status)) {
434                                 goto unlock_and_exit;
435                         }
436
437                         /* Read the Enable Register */
438
439                         status = acpi_hw_low_level_read (ACPI_GPE_REGISTER_WIDTH, &enable_reg,
440                                          &gpe_register_info->enable_address);
441                         if (ACPI_FAILURE (status)) {
442                                 goto unlock_and_exit;
443                         }
444
445                         ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
446                                 "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n",
447                                 gpe_register_info->base_gpe_number, status_reg, enable_reg));
448
449                         /* Check if there is anything active at all in this register */
450
451                         enabled_status_byte = (u8) (status_reg & enable_reg);
452                         if (!enabled_status_byte) {
453                                 /* No active GPEs in this register, move on */
454
455                                 continue;
456                         }
457
458                         /* Now look at the individual GPEs in this byte register */
459
460                         for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
461                                 /* Examine one GPE bit */
462
463                                 if (enabled_status_byte & acpi_gbl_decode_to8bit[j]) {
464                                         /*
465                                          * Found an active GPE. Dispatch the event to a handler
466                                          * or method.
467                                          */
468                                         int_status |= acpi_ev_gpe_dispatch (
469                                                 &gpe_block->event_info[(i * ACPI_GPE_REGISTER_WIDTH) + j],
470                                                 (u32) j + gpe_register_info->base_gpe_number);
471                                 }
472                         }
473                 }
474
475                 gpe_block = gpe_block->next;
476         }
477
478 unlock_and_exit:
479
480         acpi_os_release_lock (acpi_gbl_gpe_lock, flags);
481         return (int_status);
482 }
483
484
485 /*******************************************************************************
486  *
487  * FUNCTION:    acpi_ev_asynch_execute_gpe_method
488  *
489  * PARAMETERS:  Context (gpe_event_info) - Info for this GPE
490  *
491  * RETURN:      None
492  *
493  * DESCRIPTION: Perform the actual execution of a GPE control method.  This
494  *              function is called from an invocation of acpi_os_queue_for_execution
495  *              (and therefore does NOT execute at interrupt level) so that
496  *              the control method itself is not executed in the context of
497  *              an interrupt handler.
498  *
499  ******************************************************************************/
500
501 static void ACPI_SYSTEM_XFACE
502 acpi_ev_asynch_execute_gpe_method (
503         void                            *context)
504 {
505         struct acpi_gpe_event_info      *gpe_event_info = (void *) context;
506         u32                             gpe_number = 0;
507         acpi_status                     status;
508         struct acpi_gpe_event_info      local_gpe_event_info;
509         struct acpi_parameter_info      info;
510
511
512         ACPI_FUNCTION_TRACE ("ev_asynch_execute_gpe_method");
513
514
515         status = acpi_ut_acquire_mutex (ACPI_MTX_EVENTS);
516         if (ACPI_FAILURE (status)) {
517                 return_VOID;
518         }
519
520         /* Must revalidate the gpe_number/gpe_block */
521
522         if (!acpi_ev_valid_gpe_event (gpe_event_info)) {
523                 status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
524                 return_VOID;
525         }
526
527         /* Set the GPE flags for return to enabled state */
528
529         (void) acpi_ev_enable_gpe (gpe_event_info, FALSE);
530
531         /*
532          * Take a snapshot of the GPE info for this level - we copy the
533          * info to prevent a race condition with remove_handler/remove_block.
534          */
535         ACPI_MEMCPY (&local_gpe_event_info, gpe_event_info,
536                 sizeof (struct acpi_gpe_event_info));
537
538         status = acpi_ut_release_mutex (ACPI_MTX_EVENTS);
539         if (ACPI_FAILURE (status)) {
540                 return_VOID;
541         }
542
543         /*
544          * Must check for control method type dispatch one more
545          * time to avoid race with ev_gpe_install_handler
546          */
547         if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
548                         ACPI_GPE_DISPATCH_METHOD) {
549                 /*
550                  * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
551                  * control method that corresponds to this GPE
552                  */
553                 info.node = local_gpe_event_info.dispatch.method_node;
554                 info.parameters = ACPI_CAST_PTR (union acpi_operand_object *, gpe_event_info);
555                 info.parameter_type = ACPI_PARAM_GPE;
556
557                 status = acpi_ns_evaluate_by_handle (&info);
558                 if (ACPI_FAILURE (status)) {
559                         ACPI_REPORT_ERROR ((
560                                 "%s while evaluating method [%4.4s] for GPE[%2X]\n",
561                                 acpi_format_exception (status),
562                                 acpi_ut_get_node_name (local_gpe_event_info.dispatch.method_node),
563                                 gpe_number));
564                 }
565         }
566
567         if ((local_gpe_event_info.flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
568                         ACPI_GPE_LEVEL_TRIGGERED) {
569                 /*
570                  * GPE is level-triggered, we clear the GPE status bit after
571                  * handling the event.
572                  */
573                 status = acpi_hw_clear_gpe (&local_gpe_event_info);
574                 if (ACPI_FAILURE (status)) {
575                         return_VOID;
576                 }
577         }
578
579         /* Enable this GPE */
580
581         (void) acpi_hw_write_gpe_enable_reg (&local_gpe_event_info);
582         return_VOID;
583 }
584
585
586 /*******************************************************************************
587  *
588  * FUNCTION:    acpi_ev_gpe_dispatch
589  *
590  * PARAMETERS:  gpe_event_info  - Info for this GPE
591  *              gpe_number      - Number relative to the parent GPE block
592  *
593  * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
594  *
595  * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
596  *              or method (e.g. _Lxx/_Exx) handler.
597  *
598  *              This function executes at interrupt level.
599  *
600  ******************************************************************************/
601
602 u32
603 acpi_ev_gpe_dispatch (
604         struct acpi_gpe_event_info      *gpe_event_info,
605         u32                             gpe_number)
606 {
607         acpi_status                     status;
608
609
610         ACPI_FUNCTION_TRACE ("ev_gpe_dispatch");
611
612
613         /*
614          * If edge-triggered, clear the GPE status bit now.  Note that
615          * level-triggered events are cleared after the GPE is serviced.
616          */
617         if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
618                         ACPI_GPE_EDGE_TRIGGERED) {
619                 status = acpi_hw_clear_gpe (gpe_event_info);
620                 if (ACPI_FAILURE (status)) {
621                         ACPI_REPORT_ERROR ((
622                                 "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
623                                 acpi_format_exception (status), gpe_number));
624                         return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
625                 }
626         }
627
628         /* Save current system state */
629
630         if (acpi_gbl_system_awake_and_running) {
631                 ACPI_SET_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
632         }
633         else {
634                 ACPI_CLEAR_BIT (gpe_event_info->flags, ACPI_GPE_SYSTEM_RUNNING);
635         }
636
637         /*
638          * Dispatch the GPE to either an installed handler, or the control
639          * method associated with this GPE (_Lxx or _Exx).
640          * If a handler exists, we invoke it and do not attempt to run the method.
641          * If there is neither a handler nor a method, we disable the level to
642          * prevent further events from coming in here.
643          */
644         switch (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) {
645         case ACPI_GPE_DISPATCH_HANDLER:
646
647                 /*
648                  * Invoke the installed handler (at interrupt level)
649                  * Ignore return status for now.  TBD: leave GPE disabled on error?
650                  */
651                 (void) gpe_event_info->dispatch.handler->address (
652                                   gpe_event_info->dispatch.handler->context);
653
654                 /* It is now safe to clear level-triggered events. */
655
656                 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
657                                 ACPI_GPE_LEVEL_TRIGGERED) {
658                         status = acpi_hw_clear_gpe (gpe_event_info);
659                         if (ACPI_FAILURE (status)) {
660                                 ACPI_REPORT_ERROR ((
661                                         "acpi_ev_gpe_dispatch: %s, Unable to clear GPE[%2X]\n",
662                                         acpi_format_exception (status), gpe_number));
663                                 return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
664                         }
665                 }
666                 break;
667
668         case ACPI_GPE_DISPATCH_METHOD:
669
670                 /*
671                  * Disable GPE, so it doesn't keep firing before the method has a
672                  * chance to run.
673                  */
674                 status = acpi_ev_disable_gpe (gpe_event_info);
675                 if (ACPI_FAILURE (status)) {
676                         ACPI_REPORT_ERROR ((
677                                 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n",
678                                 acpi_format_exception (status), gpe_number));
679                         return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
680                 }
681
682                 /*
683                  * Execute the method associated with the GPE
684                  * NOTE: Level-triggered GPEs are cleared after the method completes.
685                  */
686                 status = acpi_os_queue_for_execution (OSD_PRIORITY_GPE,
687                                  acpi_ev_asynch_execute_gpe_method, gpe_event_info);
688                 if (ACPI_FAILURE (status)) {
689                         ACPI_REPORT_ERROR ((
690                                 "acpi_ev_gpe_dispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n",
691                                 acpi_format_exception (status), gpe_number));
692                 }
693                 break;
694
695         default:
696
697                 /* No handler or method to run! */
698
699                 ACPI_REPORT_ERROR ((
700                         "acpi_ev_gpe_dispatch: No handler or method for GPE[%2X], disabling event\n",
701                         gpe_number));
702
703                 /*
704                  * Disable the GPE.  The GPE will remain disabled until the ACPI
705                  * Core Subsystem is restarted, or a handler is installed.
706                  */
707                 status = acpi_ev_disable_gpe (gpe_event_info);
708                 if (ACPI_FAILURE (status)) {
709                         ACPI_REPORT_ERROR ((
710                                 "acpi_ev_gpe_dispatch: %s, Unable to disable GPE[%2X]\n",
711                                 acpi_format_exception (status), gpe_number));
712                         return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
713                 }
714                 break;
715         }
716
717         return_VALUE (ACPI_INTERRUPT_HANDLED);
718 }
719
720
721 #ifdef ACPI_GPE_NOTIFY_CHECK
722 /*******************************************************************************
723  * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
724  *
725  * FUNCTION:    acpi_ev_check_for_wake_only_gpe
726  *
727  * PARAMETERS:  gpe_event_info  - info for this GPE
728  *
729  * RETURN:      Status
730  *
731  * DESCRIPTION: Determine if a a GPE is "wake-only".
732  *
733  *              Called from Notify() code in interpreter when a "device_wake"
734  *              Notify comes in.
735  *
736  ******************************************************************************/
737
738 acpi_status
739 acpi_ev_check_for_wake_only_gpe (
740         struct acpi_gpe_event_info      *gpe_event_info)
741 {
742         acpi_status                     status;
743
744
745         ACPI_FUNCTION_TRACE ("ev_check_for_wake_only_gpe");
746
747
748         if ((gpe_event_info) &&  /* Only >0 for _Lxx/_Exx */
749            ((gpe_event_info->flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */ {
750                 /* This must be a wake-only GPE, disable it */
751
752                 status = acpi_ev_disable_gpe (gpe_event_info);
753
754                 /* Set GPE to wake-only.  Do not change wake disabled/enabled status */
755
756                 acpi_ev_set_gpe_type (gpe_event_info, ACPI_GPE_TYPE_WAKE);
757
758                 ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n",
759                                 gpe_event_info));
760
761                 /* This was a wake-only GPE */
762
763                 return_ACPI_STATUS (AE_WAKE_ONLY_GPE);
764         }
765
766         return_ACPI_STATUS (AE_OK);
767 }
768 #endif
769
770