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