Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: evgpe - General Purpose Event handling and dispatch |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | a8357b0 | 2010-01-22 19:07:36 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2010, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
| 46 | #include "acevents.h" |
| 47 | #include "acnamesp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | #define _COMPONENT ACPI_EVENTS |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("evgpe") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 52 | /* Local prototypes */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 53 | static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
| 55 | /******************************************************************************* |
| 56 | * |
Rafael J. Wysocki | a44061a | 2010-07-01 10:11:45 +0800 | [diff] [blame] | 57 | * FUNCTION: acpi_ev_update_gpe_enable_mask |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | * |
| 59 | * PARAMETERS: gpe_event_info - GPE to update |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | * |
| 61 | * RETURN: Status |
| 62 | * |
Rafael J. Wysocki | a44061a | 2010-07-01 10:11:45 +0800 | [diff] [blame] | 63 | * DESCRIPTION: Updates GPE register enable mask based upon whether there are |
| 64 | * runtime references to this GPE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | * |
| 66 | ******************************************************************************/ |
| 67 | |
| 68 | acpi_status |
Rafael J. Wysocki | a44061a | 2010-07-01 10:11:45 +0800 | [diff] [blame] | 69 | acpi_ev_update_gpe_enable_mask(struct acpi_gpe_event_info *gpe_event_info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 71 | struct acpi_gpe_register_info *gpe_register_info; |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 72 | u32 register_bit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Rafael J. Wysocki | a44061a | 2010-07-01 10:11:45 +0800 | [diff] [blame] | 74 | ACPI_FUNCTION_TRACE(ev_update_gpe_enable_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
| 76 | gpe_register_info = gpe_event_info->register_info; |
| 77 | if (!gpe_register_info) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 78 | return_ACPI_STATUS(AE_NOT_EXIST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | } |
Bob Moore | d4913dc | 2009-03-06 10:05:18 +0800 | [diff] [blame] | 80 | |
Lin Ming | b76df67 | 2010-07-01 10:07:17 +0800 | [diff] [blame] | 81 | register_bit = acpi_hw_get_gpe_register_bit(gpe_event_info, |
Rafael J. Wysocki | e4e9a73 | 2010-06-08 10:48:26 +0200 | [diff] [blame] | 82 | gpe_register_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Rafael J. Wysocki | a44061a | 2010-07-01 10:11:45 +0800 | [diff] [blame] | 84 | /* Clear the run bit up front */ |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 85 | |
Rafael J. Wysocki | 9630bdd | 2010-02-17 23:41:07 +0100 | [diff] [blame] | 86 | ACPI_CLEAR_BIT(gpe_register_info->enable_for_run, register_bit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
Rafael J. Wysocki | a44061a | 2010-07-01 10:11:45 +0800 | [diff] [blame] | 88 | /* Set the mask bit only if there are references to this GPE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 90 | if (gpe_event_info->runtime_count) { |
Rafael J. Wysocki | a44061a | 2010-07-01 10:11:45 +0800 | [diff] [blame] | 91 | ACPI_SET_BIT(gpe_register_info->enable_for_run, (u8)register_bit); |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 92 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 94 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Rafael J. Wysocki | 3bd741b | 2010-07-01 11:01:12 +0800 | [diff] [blame] | 97 | /******************************************************************************* |
| 98 | * |
| 99 | * FUNCTION: acpi_ev_enable_gpe |
| 100 | * |
| 101 | * PARAMETERS: gpe_event_info - GPE to enable |
| 102 | * |
| 103 | * RETURN: Status |
| 104 | * |
| 105 | * DESCRIPTION: Clear the given GPE from stale events and enable it. |
| 106 | * |
| 107 | ******************************************************************************/ |
| 108 | acpi_status |
| 109 | acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info) |
| 110 | { |
| 111 | acpi_status status; |
| 112 | |
| 113 | ACPI_FUNCTION_TRACE(ev_enable_gpe); |
| 114 | |
| 115 | /* |
| 116 | * We will only allow a GPE to be enabled if it has either an |
| 117 | * associated method (_Lxx/_Exx) or a handler. Otherwise, the |
| 118 | * GPE will be immediately disabled by acpi_ev_gpe_dispatch the |
| 119 | * first time it fires. |
| 120 | */ |
| 121 | if (!(gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK)) { |
| 122 | return_ACPI_STATUS(AE_NO_HANDLER); |
| 123 | } |
| 124 | |
| 125 | /* Clear the GPE (of stale events) */ |
| 126 | status = acpi_hw_clear_gpe(gpe_event_info); |
| 127 | if (ACPI_FAILURE(status)) { |
| 128 | return_ACPI_STATUS(status); |
| 129 | } |
| 130 | |
| 131 | /* Enable the requested GPE */ |
| 132 | status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_ENABLE); |
| 133 | |
| 134 | return_ACPI_STATUS(status); |
| 135 | } |
| 136 | |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 137 | |
| 138 | /******************************************************************************* |
| 139 | * |
Lin Ming | 3a37898 | 2010-12-13 13:36:15 +0800 | [diff] [blame] | 140 | * FUNCTION: acpi_ev_add_gpe_reference |
Rafael J. Wysocki | 28f4f8a | 2010-08-03 23:55:14 +0200 | [diff] [blame] | 141 | * |
| 142 | * PARAMETERS: gpe_event_info - GPE to enable |
| 143 | * |
| 144 | * RETURN: Status |
| 145 | * |
| 146 | * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is |
| 147 | * hardware-enabled. |
| 148 | * |
| 149 | ******************************************************************************/ |
| 150 | |
Lin Ming | 3a37898 | 2010-12-13 13:36:15 +0800 | [diff] [blame] | 151 | acpi_status acpi_ev_add_gpe_reference(struct acpi_gpe_event_info *gpe_event_info) |
Rafael J. Wysocki | 28f4f8a | 2010-08-03 23:55:14 +0200 | [diff] [blame] | 152 | { |
| 153 | acpi_status status = AE_OK; |
| 154 | |
Lin Ming | 3a37898 | 2010-12-13 13:36:15 +0800 | [diff] [blame] | 155 | ACPI_FUNCTION_TRACE(ev_add_gpe_reference); |
| 156 | |
Rafael J. Wysocki | 28f4f8a | 2010-08-03 23:55:14 +0200 | [diff] [blame] | 157 | if (gpe_event_info->runtime_count == ACPI_UINT8_MAX) { |
| 158 | return_ACPI_STATUS(AE_LIMIT); |
| 159 | } |
| 160 | |
| 161 | gpe_event_info->runtime_count++; |
| 162 | if (gpe_event_info->runtime_count == 1) { |
| 163 | status = acpi_ev_update_gpe_enable_mask(gpe_event_info); |
| 164 | if (ACPI_SUCCESS(status)) { |
| 165 | status = acpi_ev_enable_gpe(gpe_event_info); |
| 166 | } |
| 167 | |
| 168 | if (ACPI_FAILURE(status)) { |
| 169 | gpe_event_info->runtime_count--; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | return_ACPI_STATUS(status); |
| 174 | } |
| 175 | |
| 176 | /******************************************************************************* |
| 177 | * |
Lin Ming | 3a37898 | 2010-12-13 13:36:15 +0800 | [diff] [blame] | 178 | * FUNCTION: acpi_ev_remove_gpe_reference |
Rafael J. Wysocki | 28f4f8a | 2010-08-03 23:55:14 +0200 | [diff] [blame] | 179 | * |
| 180 | * PARAMETERS: gpe_event_info - GPE to disable |
| 181 | * |
| 182 | * RETURN: Status |
| 183 | * |
| 184 | * DESCRIPTION: Remove a reference to a GPE. When the last reference is |
| 185 | * removed, the GPE is hardware-disabled. |
| 186 | * |
| 187 | ******************************************************************************/ |
| 188 | |
Lin Ming | 3a37898 | 2010-12-13 13:36:15 +0800 | [diff] [blame] | 189 | acpi_status acpi_ev_remove_gpe_reference(struct acpi_gpe_event_info *gpe_event_info) |
Rafael J. Wysocki | 28f4f8a | 2010-08-03 23:55:14 +0200 | [diff] [blame] | 190 | { |
| 191 | acpi_status status = AE_OK; |
| 192 | |
Lin Ming | 3a37898 | 2010-12-13 13:36:15 +0800 | [diff] [blame] | 193 | ACPI_FUNCTION_TRACE(ev_remove_gpe_reference); |
| 194 | |
Rafael J. Wysocki | 28f4f8a | 2010-08-03 23:55:14 +0200 | [diff] [blame] | 195 | if (!gpe_event_info->runtime_count) { |
| 196 | return_ACPI_STATUS(AE_LIMIT); |
| 197 | } |
| 198 | |
| 199 | gpe_event_info->runtime_count--; |
| 200 | if (!gpe_event_info->runtime_count) { |
| 201 | status = acpi_ev_update_gpe_enable_mask(gpe_event_info); |
| 202 | if (ACPI_SUCCESS(status)) { |
| 203 | status = acpi_hw_low_set_gpe(gpe_event_info, |
| 204 | ACPI_GPE_DISABLE); |
| 205 | } |
| 206 | |
| 207 | if (ACPI_FAILURE(status)) { |
| 208 | gpe_event_info->runtime_count++; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | return_ACPI_STATUS(status); |
| 213 | } |
| 214 | |
| 215 | /******************************************************************************* |
| 216 | * |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 217 | * FUNCTION: acpi_ev_low_get_gpe_info |
| 218 | * |
| 219 | * PARAMETERS: gpe_number - Raw GPE number |
| 220 | * gpe_block - A GPE info block |
| 221 | * |
| 222 | * RETURN: A GPE event_info struct. NULL if not a valid GPE (The gpe_number |
| 223 | * is not within the specified GPE block) |
| 224 | * |
| 225 | * DESCRIPTION: Returns the event_info struct associated with this GPE. This is |
| 226 | * the low-level implementation of ev_get_gpe_event_info. |
| 227 | * |
| 228 | ******************************************************************************/ |
| 229 | |
| 230 | struct acpi_gpe_event_info *acpi_ev_low_get_gpe_info(u32 gpe_number, |
| 231 | struct acpi_gpe_block_info |
| 232 | *gpe_block) |
| 233 | { |
| 234 | u32 gpe_index; |
| 235 | |
| 236 | /* |
| 237 | * Validate that the gpe_number is within the specified gpe_block. |
| 238 | * (Two steps) |
| 239 | */ |
| 240 | if (!gpe_block || (gpe_number < gpe_block->block_base_number)) { |
| 241 | return (NULL); |
| 242 | } |
| 243 | |
| 244 | gpe_index = gpe_number - gpe_block->block_base_number; |
| 245 | if (gpe_index >= gpe_block->gpe_count) { |
| 246 | return (NULL); |
| 247 | } |
| 248 | |
| 249 | return (&gpe_block->event_info[gpe_index]); |
| 250 | } |
| 251 | |
| 252 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | /******************************************************************************* |
| 254 | * |
| 255 | * FUNCTION: acpi_ev_get_gpe_event_info |
| 256 | * |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 257 | * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | * gpe_number - Raw GPE number |
| 259 | * |
| 260 | * RETURN: A GPE event_info struct. NULL if not a valid GPE |
| 261 | * |
| 262 | * DESCRIPTION: Returns the event_info struct associated with this GPE. |
| 263 | * Validates the gpe_block and the gpe_number |
| 264 | * |
| 265 | * Should be called only when the GPE lists are semaphore locked |
| 266 | * and not subject to change. |
| 267 | * |
| 268 | ******************************************************************************/ |
| 269 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 270 | struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device, |
| 271 | u32 gpe_number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 273 | union acpi_operand_object *obj_desc; |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 274 | struct acpi_gpe_event_info *gpe_info; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 275 | u32 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 277 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
Bob Moore | 186c307 | 2010-04-27 11:32:28 +0800 | [diff] [blame] | 279 | /* A NULL gpe_device means use the FADT-defined GPE block(s) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | |
| 281 | if (!gpe_device) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | /* Examine GPE Block 0 and 1 (These blocks are permanent) */ |
| 284 | |
| 285 | for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 286 | gpe_info = acpi_ev_low_get_gpe_info(gpe_number, |
| 287 | acpi_gbl_gpe_fadt_blocks |
| 288 | [i]); |
| 289 | if (gpe_info) { |
| 290 | return (gpe_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | } |
| 293 | |
| 294 | /* The gpe_number was not in the range of either FADT GPE block */ |
| 295 | |
| 296 | return (NULL); |
| 297 | } |
| 298 | |
| 299 | /* A Non-NULL gpe_device means this is a GPE Block Device */ |
| 300 | |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 301 | obj_desc = acpi_ns_get_attached_object((struct acpi_namespace_node *) |
| 302 | gpe_device); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 303 | if (!obj_desc || !obj_desc->device.gpe_block) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | return (NULL); |
| 305 | } |
| 306 | |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 307 | return (acpi_ev_low_get_gpe_info |
| 308 | (gpe_number, obj_desc->device.gpe_block)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | /******************************************************************************* |
| 312 | * |
| 313 | * FUNCTION: acpi_ev_gpe_detect |
| 314 | * |
| 315 | * PARAMETERS: gpe_xrupt_list - Interrupt block for this interrupt. |
| 316 | * Can have multiple GPE blocks attached. |
| 317 | * |
| 318 | * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED |
| 319 | * |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 320 | * DESCRIPTION: Detect if any GP events have occurred. This function is |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | * executed at interrupt level. |
| 322 | * |
| 323 | ******************************************************************************/ |
| 324 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 325 | u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 327 | acpi_status status; |
| 328 | struct acpi_gpe_block_info *gpe_block; |
Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 329 | struct acpi_gpe_register_info *gpe_register_info; |
| 330 | u32 int_status = ACPI_INTERRUPT_NOT_HANDLED; |
| 331 | u8 enabled_status_byte; |
| 332 | u32 status_reg; |
| 333 | u32 enable_reg; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 334 | acpi_cpu_flags flags; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 335 | u32 i; |
| 336 | u32 j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 338 | ACPI_FUNCTION_NAME(ev_gpe_detect); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
| 340 | /* Check for the case where there are no GPEs */ |
| 341 | |
| 342 | if (!gpe_xrupt_list) { |
| 343 | return (int_status); |
| 344 | } |
| 345 | |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 346 | /* |
| 347 | * We need to obtain the GPE lock for both the data structs and registers |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 348 | * Note: Not necessary to obtain the hardware lock, since the GPE |
| 349 | * registers are owned by the gpe_lock. |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 350 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 351 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
Bob Moore | 4c90ece | 2006-06-08 16:29:00 -0400 | [diff] [blame] | 352 | |
| 353 | /* Examine all GPE blocks attached to this interrupt level */ |
| 354 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | gpe_block = gpe_xrupt_list->gpe_block_list_head; |
| 356 | while (gpe_block) { |
| 357 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 358 | * Read all of the 8-bit GPE status and enable registers in this GPE |
| 359 | * block, saving all of them. Find all currently active GP events. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | */ |
| 361 | for (i = 0; i < gpe_block->register_count; i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 362 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | /* Get the next status/enable pair */ |
| 364 | |
| 365 | gpe_register_info = &gpe_block->register_info[i]; |
| 366 | |
| 367 | /* Read the Status Register */ |
| 368 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 369 | status = |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 370 | acpi_hw_read(&status_reg, |
| 371 | &gpe_register_info->status_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 372 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | goto unlock_and_exit; |
| 374 | } |
| 375 | |
| 376 | /* Read the Enable Register */ |
| 377 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 378 | status = |
Bob Moore | c6b5774 | 2009-06-24 09:44:06 +0800 | [diff] [blame] | 379 | acpi_hw_read(&enable_reg, |
| 380 | &gpe_register_info->enable_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 381 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | goto unlock_and_exit; |
| 383 | } |
| 384 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 385 | ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS, |
| 386 | "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", |
| 387 | gpe_register_info->base_gpe_number, |
| 388 | status_reg, enable_reg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 390 | /* Check if there is anything active at all in this register */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | |
| 392 | enabled_status_byte = (u8) (status_reg & enable_reg); |
| 393 | if (!enabled_status_byte) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | /* No active GPEs in this register, move on */ |
| 396 | |
| 397 | continue; |
| 398 | } |
| 399 | |
| 400 | /* Now look at the individual GPEs in this byte register */ |
| 401 | |
| 402 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 403 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | /* Examine one GPE bit */ |
| 405 | |
Alexey Starikovskiy | 6987416 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 406 | if (enabled_status_byte & (1 << j)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | /* |
| 408 | * Found an active GPE. Dispatch the event to a handler |
| 409 | * or method. |
| 410 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 411 | int_status |= |
Lin Ming | 8b6cd8a | 2010-12-13 13:38:46 +0800 | [diff] [blame^] | 412 | acpi_ev_gpe_dispatch(gpe_block-> |
| 413 | node, |
| 414 | &gpe_block-> |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 415 | event_info[((acpi_size) i * ACPI_GPE_REGISTER_WIDTH) + j], j + gpe_register_info->base_gpe_number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | gpe_block = gpe_block->next; |
| 421 | } |
| 422 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 423 | unlock_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 425 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | return (int_status); |
| 427 | } |
| 428 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | /******************************************************************************* |
| 430 | * |
| 431 | * FUNCTION: acpi_ev_asynch_execute_gpe_method |
| 432 | * |
| 433 | * PARAMETERS: Context (gpe_event_info) - Info for this GPE |
| 434 | * |
| 435 | * RETURN: None |
| 436 | * |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 437 | * DESCRIPTION: Perform the actual execution of a GPE control method. This |
| 438 | * function is called from an invocation of acpi_os_execute and |
| 439 | * therefore does NOT execute at interrupt level - so that |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | * the control method itself is not executed in the context of |
| 441 | * an interrupt handler. |
| 442 | * |
| 443 | ******************************************************************************/ |
Alexey Starikovskiy | 17bc54e | 2007-11-13 13:05:45 +0300 | [diff] [blame] | 444 | static void acpi_ev_asynch_enable_gpe(void *context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 446 | static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 448 | struct acpi_gpe_event_info *gpe_event_info = (void *)context; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 449 | acpi_status status; |
| 450 | struct acpi_gpe_event_info local_gpe_event_info; |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 451 | struct acpi_evaluate_info *info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 453 | ACPI_FUNCTION_TRACE(ev_asynch_execute_gpe_method); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 455 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 456 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | return_VOID; |
| 458 | } |
| 459 | |
| 460 | /* Must revalidate the gpe_number/gpe_block */ |
| 461 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 462 | if (!acpi_ev_valid_gpe_event(gpe_event_info)) { |
| 463 | status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | return_VOID; |
| 465 | } |
| 466 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 468 | * Take a snapshot of the GPE info for this level - we copy the info to |
| 469 | * prevent a race condition with remove_handler/remove_block. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 471 | ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info, |
| 472 | sizeof(struct acpi_gpe_event_info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 474 | status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
| 475 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | return_VOID; |
| 477 | } |
| 478 | |
| 479 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 480 | * Must check for control method type dispatch one more time to avoid a |
| 481 | * race with ev_gpe_install_handler |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 483 | if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 484 | ACPI_GPE_DISPATCH_METHOD) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 486 | /* Allocate the evaluation information block */ |
| 487 | |
| 488 | info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); |
| 489 | if (!info) { |
| 490 | status = AE_NO_MEMORY; |
| 491 | } else { |
| 492 | /* |
| 493 | * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx |
| 494 | * control method that corresponds to this GPE |
| 495 | */ |
| 496 | info->prefix_node = |
| 497 | local_gpe_event_info.dispatch.method_node; |
Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 498 | info->flags = ACPI_IGNORE_RETURN_VALUE; |
| 499 | |
| 500 | status = acpi_ns_evaluate(info); |
| 501 | ACPI_FREE(info); |
| 502 | } |
| 503 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 504 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 505 | ACPI_EXCEPTION((AE_INFO, status, |
Bob Moore | 2e42005 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 506 | "while evaluating GPE method [%4.4s]", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 507 | acpi_ut_get_node_name |
| 508 | (local_gpe_event_info.dispatch. |
Bob Moore | 4c90ece | 2006-06-08 16:29:00 -0400 | [diff] [blame] | 509 | method_node))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | } |
| 511 | } |
Alexey Starikovskiy | 17bc54e | 2007-11-13 13:05:45 +0300 | [diff] [blame] | 512 | /* Defer enabling of GPE until all notify handlers are done */ |
| 513 | acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_asynch_enable_gpe, |
| 514 | gpe_event_info); |
| 515 | return_VOID; |
| 516 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
Alexey Starikovskiy | 17bc54e | 2007-11-13 13:05:45 +0300 | [diff] [blame] | 518 | static void acpi_ev_asynch_enable_gpe(void *context) |
| 519 | { |
| 520 | struct acpi_gpe_event_info *gpe_event_info = context; |
| 521 | acpi_status status; |
| 522 | if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 523 | ACPI_GPE_LEVEL_TRIGGERED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 525 | * GPE is level-triggered, we clear the GPE status bit after handling |
| 526 | * the event. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | */ |
Alexey Starikovskiy | 17bc54e | 2007-11-13 13:05:45 +0300 | [diff] [blame] | 528 | status = acpi_hw_clear_gpe(gpe_event_info); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 529 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | return_VOID; |
| 531 | } |
| 532 | } |
| 533 | |
Bob Moore | de5668f | 2010-07-06 10:30:37 +0800 | [diff] [blame] | 534 | /* |
| 535 | * Enable this GPE, conditionally. This means that the GPE will only be |
| 536 | * physically enabled if the enable_for_run bit is set in the event_info |
| 537 | */ |
Lin Ming | 3a37898 | 2010-12-13 13:36:15 +0800 | [diff] [blame] | 538 | (void)acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_CONDITIONAL_ENABLE); |
Bob Moore | de5668f | 2010-07-06 10:30:37 +0800 | [diff] [blame] | 539 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | return_VOID; |
| 541 | } |
| 542 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | /******************************************************************************* |
| 544 | * |
| 545 | * FUNCTION: acpi_ev_gpe_dispatch |
| 546 | * |
Lin Ming | 8b6cd8a | 2010-12-13 13:38:46 +0800 | [diff] [blame^] | 547 | * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1 |
| 548 | * gpe_event_info - Info for this GPE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | * gpe_number - Number relative to the parent GPE block |
| 550 | * |
| 551 | * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED |
| 552 | * |
| 553 | * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC) |
| 554 | * or method (e.g. _Lxx/_Exx) handler. |
| 555 | * |
| 556 | * This function executes at interrupt level. |
| 557 | * |
| 558 | ******************************************************************************/ |
| 559 | |
| 560 | u32 |
Lin Ming | 8b6cd8a | 2010-12-13 13:38:46 +0800 | [diff] [blame^] | 561 | acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, |
| 562 | struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 564 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 566 | ACPI_FUNCTION_TRACE(ev_gpe_dispatch); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | |
Len Brown | 5229e87 | 2008-02-06 01:26:55 -0500 | [diff] [blame] | 568 | acpi_os_gpe_count(gpe_number); |
Bob Moore | fdffb72 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 569 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 571 | * If edge-triggered, clear the GPE status bit now. Note that |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | * level-triggered events are cleared after the GPE is serviced. |
| 573 | */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 574 | if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 575 | ACPI_GPE_EDGE_TRIGGERED) { |
| 576 | status = acpi_hw_clear_gpe(gpe_event_info); |
| 577 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 578 | ACPI_EXCEPTION((AE_INFO, status, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 579 | "Unable to clear GPE[0x%2X]", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 580 | gpe_number)); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 581 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | } |
| 583 | } |
| 584 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | /* |
Bob Moore | c5a7156 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 586 | * Dispatch the GPE to either an installed handler, or the control method |
| 587 | * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke |
| 588 | * it and do not attempt to run the method. If there is neither a handler |
| 589 | * nor a method, we disable this GPE to prevent further such pointless |
| 590 | * events from firing. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | */ |
| 592 | switch (gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) { |
| 593 | case ACPI_GPE_DISPATCH_HANDLER: |
| 594 | |
| 595 | /* |
| 596 | * Invoke the installed handler (at interrupt level) |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 597 | * Ignore return status for now. |
| 598 | * TBD: leave GPE disabled on error? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | */ |
Lin Ming | 8b6cd8a | 2010-12-13 13:38:46 +0800 | [diff] [blame^] | 600 | (void)gpe_event_info->dispatch.handler->address(gpe_device, |
| 601 | gpe_number, |
| 602 | gpe_event_info-> |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 603 | dispatch. |
| 604 | handler-> |
| 605 | context); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | |
| 607 | /* It is now safe to clear level-triggered events. */ |
| 608 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 609 | if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 610 | ACPI_GPE_LEVEL_TRIGGERED) { |
| 611 | status = acpi_hw_clear_gpe(gpe_event_info); |
| 612 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 613 | ACPI_EXCEPTION((AE_INFO, status, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 614 | "Unable to clear GPE[0x%2X]", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 615 | gpe_number)); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 616 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | } |
| 618 | } |
| 619 | break; |
| 620 | |
| 621 | case ACPI_GPE_DISPATCH_METHOD: |
| 622 | |
| 623 | /* |
Bob Moore | c5a7156 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 624 | * Disable the GPE, so it doesn't keep firing before the method has a |
| 625 | * chance to run (it runs asynchronously with interrupts enabled). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | */ |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 627 | status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 628 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 629 | ACPI_EXCEPTION((AE_INFO, status, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 630 | "Unable to disable GPE[0x%2X]", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 631 | gpe_number)); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 632 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | /* |
| 636 | * Execute the method associated with the GPE |
| 637 | * NOTE: Level-triggered GPEs are cleared after the method completes. |
| 638 | */ |
Bob Moore | 958dd24 | 2006-05-12 17:12:00 -0400 | [diff] [blame] | 639 | status = acpi_os_execute(OSL_GPE_HANDLER, |
| 640 | acpi_ev_asynch_execute_gpe_method, |
| 641 | gpe_event_info); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 642 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 643 | ACPI_EXCEPTION((AE_INFO, status, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 644 | "Unable to queue handler for GPE[0x%2X] - event disabled", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 645 | gpe_number)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | } |
| 647 | break; |
| 648 | |
| 649 | default: |
| 650 | |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 651 | /* |
| 652 | * No handler or method to run! |
| 653 | * 03/2010: This case should no longer be possible. We will not allow |
| 654 | * a GPE to be enabled if it has no handler or method. |
| 655 | */ |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 656 | ACPI_ERROR((AE_INFO, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 657 | "No handler or method for GPE[0x%2X], disabling event", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 658 | gpe_number)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | |
| 660 | /* |
Lin Ming | 0f849d2 | 2010-04-06 14:52:37 +0800 | [diff] [blame] | 661 | * Disable the GPE. The GPE will remain disabled a handler |
| 662 | * is installed or ACPICA is restarted. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | */ |
Rafael J. Wysocki | fd24744 | 2010-06-08 10:49:08 +0200 | [diff] [blame] | 664 | status = acpi_hw_low_set_gpe(gpe_event_info, ACPI_GPE_DISABLE); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 665 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 666 | ACPI_EXCEPTION((AE_INFO, status, |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 667 | "Unable to disable GPE[0x%2X]", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 668 | gpe_number)); |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 669 | return_UINT32(ACPI_INTERRUPT_NOT_HANDLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | } |
| 671 | break; |
| 672 | } |
| 673 | |
Bob Moore | 50eca3e | 2005-09-30 19:03:00 -0400 | [diff] [blame] | 674 | return_UINT32(ACPI_INTERRUPT_HANDLED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | } |