Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: evgpeblk - GPE block creation and initialization. |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Len Brown | 75a44ce | 2008-04-23 23:00:13 -0400 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2008, 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> |
| 45 | #include <acpi/acevents.h> |
| 46 | #include <acpi/acnamesp.h> |
| 47 | |
| 48 | #define _COMPONENT ACPI_EVENTS |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("evgpeblk") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 51 | /* Local prototypes */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | static acpi_status |
| 53 | acpi_ev_save_method_info(acpi_handle obj_handle, |
| 54 | u32 level, void *obj_desc, void **return_value); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 55 | |
| 56 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 57 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, |
| 58 | u32 level, void *info, void **return_value); |
| 59 | |
| 60 | static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 |
| 61 | interrupt_number); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 62 | |
| 63 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 64 | acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 65 | |
| 66 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 67 | acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, |
| 68 | u32 interrupt_number); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 69 | |
| 70 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 71 | acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | /******************************************************************************* |
| 74 | * |
| 75 | * FUNCTION: acpi_ev_valid_gpe_event |
| 76 | * |
| 77 | * PARAMETERS: gpe_event_info - Info for this GPE |
| 78 | * |
| 79 | * RETURN: TRUE if the gpe_event is valid |
| 80 | * |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 81 | * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | * Should be called only when the GPE lists are semaphore locked |
| 83 | * and not subject to change. |
| 84 | * |
| 85 | ******************************************************************************/ |
| 86 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 87 | u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 89 | struct acpi_gpe_xrupt_info *gpe_xrupt_block; |
| 90 | struct acpi_gpe_block_info *gpe_block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 92 | ACPI_FUNCTION_ENTRY(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | |
| 94 | /* No need for spin lock since we are not changing any list elements */ |
| 95 | |
| 96 | /* Walk the GPE interrupt levels */ |
| 97 | |
| 98 | gpe_xrupt_block = acpi_gbl_gpe_xrupt_list_head; |
| 99 | while (gpe_xrupt_block) { |
| 100 | gpe_block = gpe_xrupt_block->gpe_block_list_head; |
| 101 | |
| 102 | /* Walk the GPE blocks on this interrupt level */ |
| 103 | |
| 104 | while (gpe_block) { |
| 105 | if ((&gpe_block->event_info[0] <= gpe_event_info) && |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 106 | (&gpe_block-> |
| 107 | event_info[((acpi_size) gpe_block-> |
| 108 | register_count) * 8] > |
| 109 | gpe_event_info)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | return (TRUE); |
| 111 | } |
| 112 | |
| 113 | gpe_block = gpe_block->next; |
| 114 | } |
| 115 | |
| 116 | gpe_xrupt_block = gpe_xrupt_block->next; |
| 117 | } |
| 118 | |
| 119 | return (FALSE); |
| 120 | } |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | /******************************************************************************* |
| 123 | * |
| 124 | * FUNCTION: acpi_ev_walk_gpe_list |
| 125 | * |
| 126 | * PARAMETERS: gpe_walk_callback - Routine called for each GPE block |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 127 | * Context - Value passed to callback |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | * |
| 129 | * RETURN: Status |
| 130 | * |
| 131 | * DESCRIPTION: Walk the GPE lists. |
| 132 | * |
| 133 | ******************************************************************************/ |
| 134 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 135 | acpi_status |
| 136 | acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 138 | struct acpi_gpe_block_info *gpe_block; |
| 139 | struct acpi_gpe_xrupt_info *gpe_xrupt_info; |
| 140 | acpi_status status = AE_OK; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 141 | acpi_cpu_flags flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 143 | ACPI_FUNCTION_TRACE(ev_walk_gpe_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 145 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
| 147 | /* Walk the interrupt level descriptor list */ |
| 148 | |
| 149 | gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; |
| 150 | while (gpe_xrupt_info) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | /* Walk all Gpe Blocks attached to this interrupt level */ |
| 153 | |
| 154 | gpe_block = gpe_xrupt_info->gpe_block_list_head; |
| 155 | while (gpe_block) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 156 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | /* One callback per GPE block */ |
| 158 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 159 | status = |
| 160 | gpe_walk_callback(gpe_xrupt_info, gpe_block, |
| 161 | context); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 162 | if (ACPI_FAILURE(status)) { |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 163 | if (status == AE_CTRL_END) { /* Callback abort */ |
| 164 | status = AE_OK; |
| 165 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | goto unlock_and_exit; |
| 167 | } |
| 168 | |
| 169 | gpe_block = gpe_block->next; |
| 170 | } |
| 171 | |
| 172 | gpe_xrupt_info = gpe_xrupt_info->next; |
| 173 | } |
| 174 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 175 | unlock_and_exit: |
| 176 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
| 177 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 180 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | * |
| 182 | * FUNCTION: acpi_ev_delete_gpe_handlers |
| 183 | * |
| 184 | * PARAMETERS: gpe_xrupt_info - GPE Interrupt info |
| 185 | * gpe_block - Gpe Block info |
| 186 | * |
| 187 | * RETURN: Status |
| 188 | * |
| 189 | * DESCRIPTION: Delete all Handler objects found in the GPE data structs. |
| 190 | * Used only prior to termination. |
| 191 | * |
| 192 | ******************************************************************************/ |
| 193 | |
| 194 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 195 | acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 196 | struct acpi_gpe_block_info *gpe_block, |
| 197 | void *context) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 199 | struct acpi_gpe_event_info *gpe_event_info; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 200 | u32 i; |
| 201 | u32 j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 203 | ACPI_FUNCTION_TRACE(ev_delete_gpe_handlers); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | |
| 205 | /* Examine each GPE Register within the block */ |
| 206 | |
| 207 | for (i = 0; i < gpe_block->register_count; i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 208 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | /* Now look at the individual GPEs in this byte register */ |
| 210 | |
| 211 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 212 | gpe_event_info = |
| 213 | &gpe_block-> |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 214 | event_info[((acpi_size) i * |
| 215 | ACPI_GPE_REGISTER_WIDTH) + j]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 217 | if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 218 | ACPI_GPE_DISPATCH_HANDLER) { |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 219 | ACPI_FREE(gpe_event_info->dispatch.handler); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | gpe_event_info->dispatch.handler = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 221 | gpe_event_info->flags &= |
| 222 | ~ACPI_GPE_DISPATCH_MASK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 227 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | /******************************************************************************* |
| 231 | * |
| 232 | * FUNCTION: acpi_ev_save_method_info |
| 233 | * |
| 234 | * PARAMETERS: Callback from walk_namespace |
| 235 | * |
| 236 | * RETURN: Status |
| 237 | * |
| 238 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a |
| 239 | * control method under the _GPE portion of the namespace. |
| 240 | * Extract the name and GPE type from the object, saving this |
| 241 | * information for quick lookup during GPE dispatch |
| 242 | * |
| 243 | * The name of each GPE control method is of the form: |
| 244 | * "_Lxx" or "_Exx" |
| 245 | * Where: |
| 246 | * L - means that the GPE is level triggered |
| 247 | * E - means that the GPE is edge triggered |
| 248 | * xx - is the GPE number [in HEX] |
| 249 | * |
| 250 | ******************************************************************************/ |
| 251 | |
| 252 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 253 | acpi_ev_save_method_info(acpi_handle obj_handle, |
| 254 | u32 level, void *obj_desc, void **return_value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 256 | struct acpi_gpe_block_info *gpe_block = (void *)obj_desc; |
| 257 | struct acpi_gpe_event_info *gpe_event_info; |
| 258 | u32 gpe_number; |
| 259 | char name[ACPI_NAME_SIZE + 1]; |
| 260 | u8 type; |
| 261 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 263 | ACPI_FUNCTION_TRACE(ev_save_method_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | |
| 265 | /* |
| 266 | * _Lxx and _Exx GPE method support |
| 267 | * |
| 268 | * 1) Extract the name from the object and convert to a string |
| 269 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 270 | ACPI_MOVE_32_TO_32(name, |
| 271 | &((struct acpi_namespace_node *)obj_handle)->name. |
| 272 | integer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | name[ACPI_NAME_SIZE] = 0; |
| 274 | |
| 275 | /* |
| 276 | * 2) Edge/Level determination is based on the 2nd character |
| 277 | * of the method name |
| 278 | * |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 279 | * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | * if a _PRW object is found that points to this GPE. |
| 281 | */ |
| 282 | switch (name[1]) { |
| 283 | case 'L': |
| 284 | type = ACPI_GPE_LEVEL_TRIGGERED; |
| 285 | break; |
| 286 | |
| 287 | case 'E': |
| 288 | type = ACPI_GPE_EDGE_TRIGGERED; |
| 289 | break; |
| 290 | |
| 291 | default: |
| 292 | /* Unknown method type, just ignore it! */ |
| 293 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 294 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, |
| 295 | "Ignoring unknown GPE method type: %s (name not of form _Lxx or _Exx)", |
| 296 | name)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 297 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /* Convert the last two characters of the name to the GPE Number */ |
| 301 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 302 | gpe_number = ACPI_STRTOUL(&name[2], NULL, 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | if (gpe_number == ACPI_UINT32_MAX) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 304 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | /* Conversion failed; invalid method, just ignore it */ |
| 306 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 307 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, |
| 308 | "Could not extract GPE number from name: %s (name is not of form _Lxx or _Exx)", |
| 309 | name)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 310 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | /* Ensure that we have a valid GPE number for this GPE block */ |
| 314 | |
| 315 | if ((gpe_number < gpe_block->block_base_number) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 316 | (gpe_number >= |
| 317 | (gpe_block->block_base_number + |
| 318 | (gpe_block->register_count * 8)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 320 | * Not valid for this GPE block, just ignore it. However, it may be |
| 321 | * valid for a different GPE block, since GPE0 and GPE1 methods both |
| 322 | * appear under \_GPE. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 324 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 328 | * Now we can add this information to the gpe_event_info block for use |
| 329 | * during dispatch of this GPE. Default type is RUNTIME, although this may |
| 330 | * change when the _PRW methods are executed later. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 332 | gpe_event_info = |
| 333 | &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 335 | gpe_event_info->flags = (u8) |
| 336 | (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 338 | gpe_event_info->dispatch.method_node = |
| 339 | (struct acpi_namespace_node *)obj_handle; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
| 341 | /* Update enable mask, but don't enable the HW GPE as of yet */ |
| 342 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 343 | status = acpi_ev_enable_gpe(gpe_event_info, FALSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 345 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, |
| 346 | "Registered GPE method %s as GPE number 0x%.2X\n", |
| 347 | name, gpe_number)); |
| 348 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | /******************************************************************************* |
| 352 | * |
| 353 | * FUNCTION: acpi_ev_match_prw_and_gpe |
| 354 | * |
| 355 | * PARAMETERS: Callback from walk_namespace |
| 356 | * |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 357 | * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | * not aborted on a single _PRW failure. |
| 359 | * |
| 360 | * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 361 | * Device. Run the _PRW method. If present, extract the GPE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | * number and mark the GPE as a WAKE GPE. |
| 363 | * |
| 364 | ******************************************************************************/ |
| 365 | |
| 366 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 367 | acpi_ev_match_prw_and_gpe(acpi_handle obj_handle, |
| 368 | u32 level, void *info, void **return_value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 370 | struct acpi_gpe_walk_info *gpe_info = (void *)info; |
| 371 | struct acpi_namespace_node *gpe_device; |
| 372 | struct acpi_gpe_block_info *gpe_block; |
| 373 | struct acpi_namespace_node *target_gpe_device; |
| 374 | struct acpi_gpe_event_info *gpe_event_info; |
| 375 | union acpi_operand_object *pkg_desc; |
| 376 | union acpi_operand_object *obj_desc; |
| 377 | u32 gpe_number; |
| 378 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 380 | ACPI_FUNCTION_TRACE(ev_match_prw_and_gpe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
| 382 | /* Check for a _PRW method under this device */ |
| 383 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 384 | status = acpi_ut_evaluate_object(obj_handle, METHOD_NAME__PRW, |
| 385 | ACPI_BTYPE_PACKAGE, &pkg_desc); |
| 386 | if (ACPI_FAILURE(status)) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 387 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | /* Ignore all errors from _PRW, we don't want to abort the subsystem */ |
| 389 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 390 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | /* The returned _PRW package must have at least two elements */ |
| 394 | |
| 395 | if (pkg_desc->package.count < 2) { |
| 396 | goto cleanup; |
| 397 | } |
| 398 | |
| 399 | /* Extract pointers from the input context */ |
| 400 | |
| 401 | gpe_device = gpe_info->gpe_device; |
| 402 | gpe_block = gpe_info->gpe_block; |
| 403 | |
| 404 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 405 | * The _PRW object must return a package, we are only interested in the |
| 406 | * first element |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | */ |
| 408 | obj_desc = pkg_desc->package.elements[0]; |
| 409 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 410 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 411 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | /* Use FADT-defined GPE device (from definition of _PRW) */ |
| 413 | |
| 414 | target_gpe_device = acpi_gbl_fadt_gpe_device; |
| 415 | |
| 416 | /* Integer is the GPE number in the FADT described GPE blocks */ |
| 417 | |
| 418 | gpe_number = (u32) obj_desc->integer.value; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 419 | } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 420 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | /* Package contains a GPE reference and GPE number within a GPE block */ |
| 422 | |
| 423 | if ((obj_desc->package.count < 2) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 424 | (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[0]) != |
| 425 | ACPI_TYPE_LOCAL_REFERENCE) |
| 426 | || (ACPI_GET_OBJECT_TYPE(obj_desc->package.elements[1]) != |
| 427 | ACPI_TYPE_INTEGER)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | goto cleanup; |
| 429 | } |
| 430 | |
| 431 | /* Get GPE block reference and decode */ |
| 432 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 433 | target_gpe_device = |
| 434 | obj_desc->package.elements[0]->reference.node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | gpe_number = (u32) obj_desc->package.elements[1]->integer.value; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 436 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | /* Unknown type, just ignore it */ |
| 438 | |
| 439 | goto cleanup; |
| 440 | } |
| 441 | |
| 442 | /* |
| 443 | * Is this GPE within this block? |
| 444 | * |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 445 | * TRUE if and only if these conditions are true: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | * 1) The GPE devices match. |
| 447 | * 2) The GPE index(number) is within the range of the Gpe Block |
| 448 | * associated with the GPE device. |
| 449 | */ |
| 450 | if ((gpe_device == target_gpe_device) && |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 451 | (gpe_number >= gpe_block->block_base_number) && |
| 452 | (gpe_number < |
| 453 | gpe_block->block_base_number + (gpe_block->register_count * 8))) { |
| 454 | gpe_event_info = |
| 455 | &gpe_block->event_info[gpe_number - |
| 456 | gpe_block->block_base_number]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | |
| 458 | /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */ |
| 459 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 460 | gpe_event_info->flags &= |
| 461 | ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 462 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 463 | status = |
| 464 | acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE); |
| 465 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | goto cleanup; |
| 467 | } |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 468 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 469 | status = |
| 470 | acpi_ev_update_gpe_enable_masks(gpe_event_info, |
| 471 | ACPI_GPE_DISABLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | } |
| 473 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 474 | cleanup: |
| 475 | acpi_ut_remove_reference(pkg_desc); |
| 476 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | /******************************************************************************* |
| 480 | * |
| 481 | * FUNCTION: acpi_ev_get_gpe_xrupt_block |
| 482 | * |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 483 | * PARAMETERS: interrupt_number - Interrupt for a GPE block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | * |
| 485 | * RETURN: A GPE interrupt block |
| 486 | * |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 487 | * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 488 | * block per unique interrupt level used for GPEs. Should be |
| 489 | * called only when the GPE lists are semaphore locked and not |
| 490 | * subject to change. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | * |
| 492 | ******************************************************************************/ |
| 493 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 494 | static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32 |
| 495 | interrupt_number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 497 | struct acpi_gpe_xrupt_info *next_gpe_xrupt; |
| 498 | struct acpi_gpe_xrupt_info *gpe_xrupt; |
| 499 | acpi_status status; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 500 | acpi_cpu_flags flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 502 | ACPI_FUNCTION_TRACE(ev_get_gpe_xrupt_block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 504 | /* No need for lock since we are not changing any list elements here */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; |
| 507 | while (next_gpe_xrupt) { |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 508 | if (next_gpe_xrupt->interrupt_number == interrupt_number) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 509 | return_PTR(next_gpe_xrupt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | next_gpe_xrupt = next_gpe_xrupt->next; |
| 513 | } |
| 514 | |
| 515 | /* Not found, must allocate a new xrupt descriptor */ |
| 516 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 517 | gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | if (!gpe_xrupt) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 519 | return_PTR(NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | } |
| 521 | |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 522 | gpe_xrupt->interrupt_number = interrupt_number; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | |
| 524 | /* Install new interrupt descriptor with spin lock */ |
| 525 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 526 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | if (acpi_gbl_gpe_xrupt_list_head) { |
| 528 | next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head; |
| 529 | while (next_gpe_xrupt->next) { |
| 530 | next_gpe_xrupt = next_gpe_xrupt->next; |
| 531 | } |
| 532 | |
| 533 | next_gpe_xrupt->next = gpe_xrupt; |
| 534 | gpe_xrupt->previous = next_gpe_xrupt; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 535 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt; |
| 537 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 538 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | |
| 540 | /* Install new interrupt handler if not SCI_INT */ |
| 541 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 542 | if (interrupt_number != acpi_gbl_FADT.sci_interrupt) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 543 | status = acpi_os_install_interrupt_handler(interrupt_number, |
| 544 | acpi_ev_gpe_xrupt_handler, |
| 545 | gpe_xrupt); |
| 546 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 547 | ACPI_ERROR((AE_INFO, |
| 548 | "Could not install GPE interrupt handler at level 0x%X", |
| 549 | interrupt_number)); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 550 | return_PTR(NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | } |
| 552 | } |
| 553 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 554 | return_PTR(gpe_xrupt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | } |
| 556 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | /******************************************************************************* |
| 558 | * |
| 559 | * FUNCTION: acpi_ev_delete_gpe_xrupt |
| 560 | * |
| 561 | * PARAMETERS: gpe_xrupt - A GPE interrupt info block |
| 562 | * |
| 563 | * RETURN: Status |
| 564 | * |
| 565 | * DESCRIPTION: Remove and free a gpe_xrupt block. Remove an associated |
| 566 | * interrupt handler if not the SCI interrupt. |
| 567 | * |
| 568 | ******************************************************************************/ |
| 569 | |
| 570 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 571 | acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 573 | acpi_status status; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 574 | acpi_cpu_flags flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 576 | ACPI_FUNCTION_TRACE(ev_delete_gpe_xrupt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | |
| 578 | /* We never want to remove the SCI interrupt handler */ |
| 579 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 580 | if (gpe_xrupt->interrupt_number == acpi_gbl_FADT.sci_interrupt) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | gpe_xrupt->gpe_block_list_head = NULL; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 582 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | /* Disable this interrupt */ |
| 586 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 587 | status = |
| 588 | acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number, |
| 589 | acpi_ev_gpe_xrupt_handler); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 590 | if (ACPI_FAILURE(status)) { |
| 591 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | } |
| 593 | |
| 594 | /* Unlink the interrupt block with lock */ |
| 595 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 596 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | if (gpe_xrupt->previous) { |
| 598 | gpe_xrupt->previous->next = gpe_xrupt->next; |
Bob Moore | e0b91050 | 2007-04-03 20:00:29 -0400 | [diff] [blame] | 599 | } else { |
| 600 | /* No previous, update list head */ |
| 601 | |
| 602 | acpi_gbl_gpe_xrupt_list_head = gpe_xrupt->next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | if (gpe_xrupt->next) { |
| 606 | gpe_xrupt->next->previous = gpe_xrupt->previous; |
| 607 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 608 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | |
| 610 | /* Free the block */ |
| 611 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 612 | ACPI_FREE(gpe_xrupt); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 613 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | } |
| 615 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | /******************************************************************************* |
| 617 | * |
| 618 | * FUNCTION: acpi_ev_install_gpe_block |
| 619 | * |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 620 | * PARAMETERS: gpe_block - New GPE block |
| 621 | * interrupt_number - Xrupt to be associated with this |
| 622 | * GPE block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 623 | * |
| 624 | * RETURN: Status |
| 625 | * |
| 626 | * DESCRIPTION: Install new GPE block with mutex support |
| 627 | * |
| 628 | ******************************************************************************/ |
| 629 | |
| 630 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 631 | acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, |
| 632 | u32 interrupt_number) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 634 | struct acpi_gpe_block_info *next_gpe_block; |
| 635 | struct acpi_gpe_xrupt_info *gpe_xrupt_block; |
| 636 | acpi_status status; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 637 | acpi_cpu_flags flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 639 | ACPI_FUNCTION_TRACE(ev_install_gpe_block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 641 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 642 | if (ACPI_FAILURE(status)) { |
| 643 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 644 | } |
| 645 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 646 | gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | if (!gpe_xrupt_block) { |
| 648 | status = AE_NO_MEMORY; |
| 649 | goto unlock_and_exit; |
| 650 | } |
| 651 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 652 | /* Install the new block at the end of the list with lock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 654 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | if (gpe_xrupt_block->gpe_block_list_head) { |
| 656 | next_gpe_block = gpe_xrupt_block->gpe_block_list_head; |
| 657 | while (next_gpe_block->next) { |
| 658 | next_gpe_block = next_gpe_block->next; |
| 659 | } |
| 660 | |
| 661 | next_gpe_block->next = gpe_block; |
| 662 | gpe_block->previous = next_gpe_block; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 663 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | gpe_xrupt_block->gpe_block_list_head = gpe_block; |
| 665 | } |
| 666 | |
| 667 | gpe_block->xrupt_block = gpe_xrupt_block; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 668 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 670 | unlock_and_exit: |
| 671 | status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
| 672 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | } |
| 674 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | /******************************************************************************* |
| 676 | * |
| 677 | * FUNCTION: acpi_ev_delete_gpe_block |
| 678 | * |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 679 | * PARAMETERS: gpe_block - Existing GPE block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | * |
| 681 | * RETURN: Status |
| 682 | * |
| 683 | * DESCRIPTION: Remove a GPE block |
| 684 | * |
| 685 | ******************************************************************************/ |
| 686 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 687 | acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 689 | acpi_status status; |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 690 | acpi_cpu_flags flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 692 | ACPI_FUNCTION_TRACE(ev_install_gpe_block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 694 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
| 695 | if (ACPI_FAILURE(status)) { |
| 696 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | /* Disable all GPEs in this block */ |
| 700 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 701 | status = |
| 702 | acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
| 704 | if (!gpe_block->previous && !gpe_block->next) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 705 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | /* This is the last gpe_block on this interrupt */ |
| 707 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 708 | status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block); |
| 709 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | goto unlock_and_exit; |
| 711 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 712 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | /* Remove the block on this interrupt with lock */ |
| 714 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 715 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | if (gpe_block->previous) { |
| 717 | gpe_block->previous->next = gpe_block->next; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 718 | } else { |
| 719 | gpe_block->xrupt_block->gpe_block_list_head = |
| 720 | gpe_block->next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | if (gpe_block->next) { |
| 724 | gpe_block->next->previous = gpe_block->previous; |
| 725 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 726 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | } |
| 728 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 729 | acpi_current_gpe_count -= |
| 730 | gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH; |
| 731 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | /* Free the gpe_block */ |
| 733 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 734 | ACPI_FREE(gpe_block->register_info); |
| 735 | ACPI_FREE(gpe_block->event_info); |
| 736 | ACPI_FREE(gpe_block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 738 | unlock_and_exit: |
| 739 | status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
| 740 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | } |
| 742 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | /******************************************************************************* |
| 744 | * |
| 745 | * FUNCTION: acpi_ev_create_gpe_info_blocks |
| 746 | * |
| 747 | * PARAMETERS: gpe_block - New GPE block |
| 748 | * |
| 749 | * RETURN: Status |
| 750 | * |
| 751 | * DESCRIPTION: Create the register_info and event_info blocks for this GPE block |
| 752 | * |
| 753 | ******************************************************************************/ |
| 754 | |
| 755 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 756 | acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 758 | struct acpi_gpe_register_info *gpe_register_info = NULL; |
| 759 | struct acpi_gpe_event_info *gpe_event_info = NULL; |
| 760 | struct acpi_gpe_event_info *this_event; |
| 761 | struct acpi_gpe_register_info *this_register; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 762 | u32 i; |
| 763 | u32 j; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 764 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 766 | ACPI_FUNCTION_TRACE(ev_create_gpe_info_blocks); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | |
| 768 | /* Allocate the GPE register information block */ |
| 769 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 770 | gpe_register_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block-> |
| 771 | register_count * |
| 772 | sizeof(struct |
| 773 | acpi_gpe_register_info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | if (!gpe_register_info) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 775 | ACPI_ERROR((AE_INFO, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 776 | "Could not allocate the GpeRegisterInfo table")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 777 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | /* |
| 781 | * Allocate the GPE event_info block. There are eight distinct GPEs |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 782 | * per register. Initialization to zeros is sufficient. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | */ |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 784 | gpe_event_info = ACPI_ALLOCATE_ZEROED(((acpi_size) gpe_block-> |
| 785 | register_count * |
| 786 | ACPI_GPE_REGISTER_WIDTH) * |
| 787 | sizeof(struct |
| 788 | acpi_gpe_event_info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | if (!gpe_event_info) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 790 | ACPI_ERROR((AE_INFO, |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 791 | "Could not allocate the GpeEventInfo table")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 792 | status = AE_NO_MEMORY; |
| 793 | goto error_exit; |
| 794 | } |
| 795 | |
| 796 | /* Save the new Info arrays in the GPE block */ |
| 797 | |
| 798 | gpe_block->register_info = gpe_register_info; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 799 | gpe_block->event_info = gpe_event_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | |
| 801 | /* |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 802 | * Initialize the GPE Register and Event structures. A goal of these |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 803 | * tables is to hide the fact that there are two separate GPE register |
| 804 | * sets in a given GPE hardware block, the status registers occupy the |
| 805 | * first half, and the enable registers occupy the second half. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | */ |
| 807 | this_register = gpe_register_info; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 808 | this_event = gpe_event_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | |
| 810 | for (i = 0; i < gpe_block->register_count; i++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 811 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | /* Init the register_info for this GPE register (8 GPEs) */ |
| 813 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 814 | this_register->base_gpe_number = |
| 815 | (u8) (gpe_block->block_base_number + |
| 816 | (i * ACPI_GPE_REGISTER_WIDTH)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
Bob Moore | 59fa850 | 2007-02-02 19:48:23 +0300 | [diff] [blame] | 818 | this_register->status_address.address = |
| 819 | gpe_block->block_address.address + i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | |
Bob Moore | 59fa850 | 2007-02-02 19:48:23 +0300 | [diff] [blame] | 821 | this_register->enable_address.address = |
| 822 | gpe_block->block_address.address + i + |
| 823 | gpe_block->register_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 825 | this_register->status_address.space_id = |
| 826 | gpe_block->block_address.space_id; |
| 827 | this_register->enable_address.space_id = |
| 828 | gpe_block->block_address.space_id; |
| 829 | this_register->status_address.bit_width = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 830 | ACPI_GPE_REGISTER_WIDTH; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 831 | this_register->enable_address.bit_width = |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 832 | ACPI_GPE_REGISTER_WIDTH; |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 833 | this_register->status_address.bit_offset = 0; |
| 834 | this_register->enable_address.bit_offset = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | |
| 836 | /* Init the event_info for each GPE within this register */ |
| 837 | |
| 838 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { |
Alexey Starikovskiy | 6987416 | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 839 | this_event->gpe_number = |
| 840 | (u8) (this_register->base_gpe_number + j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | this_event->register_info = this_register; |
| 842 | this_event++; |
| 843 | } |
| 844 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 845 | /* Disable all GPEs within this register */ |
| 846 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 847 | status = acpi_write(0x00, &this_register->enable_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 848 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | goto error_exit; |
| 850 | } |
| 851 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 852 | /* Clear any pending GPE events within this register */ |
| 853 | |
Bob Moore | ecfbbc7 | 2008-12-31 02:55:32 +0800 | [diff] [blame^] | 854 | status = acpi_write(0xFF, &this_register->status_address); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 855 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | goto error_exit; |
| 857 | } |
| 858 | |
| 859 | this_register++; |
| 860 | } |
| 861 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 862 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 864 | error_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | if (gpe_register_info) { |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 866 | ACPI_FREE(gpe_register_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | } |
| 868 | if (gpe_event_info) { |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 869 | ACPI_FREE(gpe_event_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | } |
| 871 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 872 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | } |
| 874 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 875 | /******************************************************************************* |
| 876 | * |
| 877 | * FUNCTION: acpi_ev_create_gpe_block |
| 878 | * |
| 879 | * PARAMETERS: gpe_device - Handle to the parent GPE block |
| 880 | * gpe_block_address - Address and space_iD |
| 881 | * register_count - Number of GPE register pairs in the block |
| 882 | * gpe_block_base_number - Starting GPE number for the block |
Robert Moore | 6f42ccf | 2005-05-13 00:00:00 -0400 | [diff] [blame] | 883 | * interrupt_number - H/W interrupt for the block |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 884 | * return_gpe_block - Where the new block descriptor is returned |
| 885 | * |
| 886 | * RETURN: Status |
| 887 | * |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 888 | * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within |
| 889 | * the block are disabled at exit. |
| 890 | * Note: Assumes namespace is locked. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | * |
| 892 | ******************************************************************************/ |
| 893 | |
| 894 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 895 | acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, |
| 896 | struct acpi_generic_address *gpe_block_address, |
| 897 | u32 register_count, |
| 898 | u8 gpe_block_base_number, |
| 899 | u32 interrupt_number, |
| 900 | struct acpi_gpe_block_info **return_gpe_block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 902 | acpi_status status; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 903 | struct acpi_gpe_block_info *gpe_block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 905 | ACPI_FUNCTION_TRACE(ev_create_gpe_block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | |
| 907 | if (!register_count) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 908 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | /* Allocate a new GPE block */ |
| 912 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 913 | gpe_block = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_block_info)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | if (!gpe_block) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 915 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | } |
| 917 | |
| 918 | /* Initialize the new GPE block */ |
| 919 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 920 | gpe_block->node = gpe_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 921 | gpe_block->register_count = register_count; |
| 922 | gpe_block->block_base_number = gpe_block_base_number; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 924 | ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address, |
| 925 | sizeof(struct acpi_generic_address)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 927 | /* |
| 928 | * Create the register_info and event_info sub-structures |
| 929 | * Note: disables and clears all GPEs in the block |
| 930 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 931 | status = acpi_ev_create_gpe_info_blocks(gpe_block); |
| 932 | if (ACPI_FAILURE(status)) { |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 933 | ACPI_FREE(gpe_block); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 934 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | } |
| 936 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 937 | /* Install the new block in the global lists */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 939 | status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); |
| 940 | if (ACPI_FAILURE(status)) { |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 941 | ACPI_FREE(gpe_block); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 942 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | /* Find all GPE methods (_Lxx, _Exx) for this block */ |
| 946 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 947 | status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device, |
| 948 | ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, |
| 949 | acpi_ev_save_method_info, gpe_block, |
| 950 | NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 952 | /* Return the new block */ |
| 953 | |
| 954 | if (return_gpe_block) { |
| 955 | (*return_gpe_block) = gpe_block; |
| 956 | } |
| 957 | |
| 958 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 959 | "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", |
| 960 | (u32) gpe_block->block_base_number, |
| 961 | (u32) (gpe_block->block_base_number + |
| 962 | ((gpe_block->register_count * |
| 963 | ACPI_GPE_REGISTER_WIDTH) - 1)), |
| 964 | gpe_device->name.ascii, gpe_block->register_count, |
| 965 | interrupt_number)); |
| 966 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 967 | /* Update global count of currently available GPEs */ |
| 968 | |
| 969 | acpi_current_gpe_count += register_count * ACPI_GPE_REGISTER_WIDTH; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 970 | return_ACPI_STATUS(AE_OK); |
| 971 | } |
| 972 | |
| 973 | /******************************************************************************* |
| 974 | * |
| 975 | * FUNCTION: acpi_ev_initialize_gpe_block |
| 976 | * |
| 977 | * PARAMETERS: gpe_device - Handle to the parent GPE block |
| 978 | * gpe_block - Gpe Block info |
| 979 | * |
| 980 | * RETURN: Status |
| 981 | * |
| 982 | * DESCRIPTION: Initialize and enable a GPE block. First find and run any |
| 983 | * _PRT methods associated with the block, then enable the |
| 984 | * appropriate GPEs. |
| 985 | * Note: Assumes namespace is locked. |
| 986 | * |
| 987 | ******************************************************************************/ |
| 988 | |
| 989 | acpi_status |
| 990 | acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device, |
| 991 | struct acpi_gpe_block_info *gpe_block) |
| 992 | { |
| 993 | acpi_status status; |
| 994 | struct acpi_gpe_event_info *gpe_event_info; |
| 995 | struct acpi_gpe_walk_info gpe_info; |
| 996 | u32 wake_gpe_count; |
| 997 | u32 gpe_enabled_count; |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 998 | u32 i; |
| 999 | u32 j; |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1000 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1001 | ACPI_FUNCTION_TRACE(ev_initialize_gpe_block); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1002 | |
| 1003 | /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */ |
| 1004 | |
| 1005 | if (!gpe_block) { |
| 1006 | return_ACPI_STATUS(AE_OK); |
| 1007 | } |
| 1008 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | /* |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1010 | * Runtime option: Should wake GPEs be enabled at runtime? The default |
| 1011 | * is no, they should only be enabled just as the machine goes to sleep. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | */ |
| 1013 | if (acpi_gbl_leave_wake_gpes_disabled) { |
| 1014 | /* |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1015 | * Differentiate runtime vs wake GPEs, via the _PRW control methods. |
| 1016 | * Each GPE that has one or more _PRWs that reference it is by |
| 1017 | * definition a wake GPE and will not be enabled while the machine |
| 1018 | * is running. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1019 | */ |
| 1020 | gpe_info.gpe_block = gpe_block; |
| 1021 | gpe_info.gpe_device = gpe_device; |
| 1022 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1023 | status = |
| 1024 | acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
| 1025 | ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, |
| 1026 | acpi_ev_match_prw_and_gpe, &gpe_info, |
| 1027 | NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1028 | } |
| 1029 | |
| 1030 | /* |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1031 | * Enable all GPEs in this block that have these attributes: |
| 1032 | * 1) are "runtime" or "run/wake" GPEs, and |
| 1033 | * 2) have a corresponding _Lxx or _Exx method |
| 1034 | * |
| 1035 | * Any other GPEs within this block must be enabled via the acpi_enable_gpe() |
| 1036 | * external interface. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | */ |
| 1038 | wake_gpe_count = 0; |
| 1039 | gpe_enabled_count = 0; |
| 1040 | |
| 1041 | for (i = 0; i < gpe_block->register_count; i++) { |
| 1042 | for (j = 0; j < 8; j++) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 1043 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | /* Get the info block for this particular GPE */ |
| 1045 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1046 | gpe_event_info = |
| 1047 | &gpe_block-> |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 1048 | event_info[((acpi_size) i * |
| 1049 | ACPI_GPE_REGISTER_WIDTH) + j]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1050 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1051 | if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == |
| 1052 | ACPI_GPE_DISPATCH_METHOD) |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 1053 | && (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1054 | gpe_enabled_count++; |
| 1055 | } |
| 1056 | |
| 1057 | if (gpe_event_info->flags & ACPI_GPE_TYPE_WAKE) { |
| 1058 | wake_gpe_count++; |
| 1059 | } |
| 1060 | } |
| 1061 | } |
| 1062 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1063 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 1064 | "Found %u Wake, Enabled %u Runtime GPEs in this block\n", |
| 1065 | wake_gpe_count, gpe_enabled_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1067 | /* Enable all valid runtime GPEs found above */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | |
Bob Moore | e97d6bf | 2008-12-30 09:45:17 +0800 | [diff] [blame] | 1069 | status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block, NULL); |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1070 | if (ACPI_FAILURE(status)) { |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1071 | ACPI_ERROR((AE_INFO, "Could not enable GPEs in GpeBlock %p", |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1072 | gpe_block)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | } |
| 1074 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 1075 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | } |
| 1077 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1078 | /******************************************************************************* |
| 1079 | * |
| 1080 | * FUNCTION: acpi_ev_gpe_initialize |
| 1081 | * |
| 1082 | * PARAMETERS: None |
| 1083 | * |
| 1084 | * RETURN: Status |
| 1085 | * |
| 1086 | * DESCRIPTION: Initialize the GPE data structures |
| 1087 | * |
| 1088 | ******************************************************************************/ |
| 1089 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1090 | acpi_status acpi_ev_gpe_initialize(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1091 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1092 | u32 register_count0 = 0; |
| 1093 | u32 register_count1 = 0; |
| 1094 | u32 gpe_number_max = 0; |
| 1095 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 1097 | ACPI_FUNCTION_TRACE(ev_gpe_initialize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1098 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1099 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 1100 | if (ACPI_FAILURE(status)) { |
| 1101 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | } |
| 1103 | |
| 1104 | /* |
| 1105 | * Initialize the GPE Block(s) defined in the FADT |
| 1106 | * |
| 1107 | * Why the GPE register block lengths are divided by 2: From the ACPI Spec, |
| 1108 | * section "General-Purpose Event Registers", we have: |
| 1109 | * |
| 1110 | * "Each register block contains two registers of equal length |
| 1111 | * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the |
| 1112 | * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN |
| 1113 | * The length of the GPE1_STS and GPE1_EN registers is equal to |
| 1114 | * half the GPE1_LEN. If a generic register block is not supported |
| 1115 | * then its respective block pointer and block length values in the |
| 1116 | * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need |
| 1117 | * to be the same size." |
| 1118 | */ |
| 1119 | |
| 1120 | /* |
| 1121 | * Determine the maximum GPE number for this machine. |
| 1122 | * |
| 1123 | * Note: both GPE0 and GPE1 are optional, and either can exist without |
| 1124 | * the other. |
| 1125 | * |
| 1126 | * If EITHER the register length OR the block address are zero, then that |
| 1127 | * particular block is not supported. |
| 1128 | */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1129 | if (acpi_gbl_FADT.gpe0_block_length && |
| 1130 | acpi_gbl_FADT.xgpe0_block.address) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 1131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | /* GPE block 0 exists (has both length and address > 0) */ |
| 1133 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1134 | register_count0 = (u16) (acpi_gbl_FADT.gpe0_block_length / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1136 | gpe_number_max = |
| 1137 | (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | |
| 1139 | /* Install GPE Block 0 */ |
| 1140 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1141 | status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1142 | &acpi_gbl_FADT.xgpe0_block, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1143 | register_count0, 0, |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1144 | acpi_gbl_FADT.sci_interrupt, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1145 | &acpi_gbl_gpe_fadt_blocks[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1147 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1148 | ACPI_EXCEPTION((AE_INFO, status, |
| 1149 | "Could not create GPE Block 0")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | } |
| 1151 | } |
| 1152 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1153 | if (acpi_gbl_FADT.gpe1_block_length && |
| 1154 | acpi_gbl_FADT.xgpe1_block.address) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 1155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | /* GPE block 1 exists (has both length and address > 0) */ |
| 1157 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1158 | register_count1 = (u16) (acpi_gbl_FADT.gpe1_block_length / 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | |
| 1160 | /* Check for GPE0/GPE1 overlap (if both banks exist) */ |
| 1161 | |
| 1162 | if ((register_count0) && |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1163 | (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1164 | ACPI_ERROR((AE_INFO, |
| 1165 | "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1", |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1166 | gpe_number_max, acpi_gbl_FADT.gpe1_base, |
| 1167 | acpi_gbl_FADT.gpe1_base + |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1168 | ((register_count1 * |
| 1169 | ACPI_GPE_REGISTER_WIDTH) - 1))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | |
| 1171 | /* Ignore GPE1 block by setting the register count to zero */ |
| 1172 | |
| 1173 | register_count1 = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1174 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1175 | /* Install GPE Block 1 */ |
| 1176 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1177 | status = |
| 1178 | acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device, |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1179 | &acpi_gbl_FADT.xgpe1_block, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1180 | register_count1, |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1181 | acpi_gbl_FADT.gpe1_base, |
| 1182 | acpi_gbl_FADT. |
| 1183 | sci_interrupt, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1184 | &acpi_gbl_gpe_fadt_blocks |
| 1185 | [1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1187 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1188 | ACPI_EXCEPTION((AE_INFO, status, |
| 1189 | "Could not create GPE Block 1")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1190 | } |
| 1191 | |
| 1192 | /* |
| 1193 | * GPE0 and GPE1 do not have to be contiguous in the GPE number |
| 1194 | * space. However, GPE0 always starts at GPE number zero. |
| 1195 | */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1196 | gpe_number_max = acpi_gbl_FADT.gpe1_base + |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1197 | ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | } |
| 1199 | } |
| 1200 | |
| 1201 | /* Exit if there are no GPE registers */ |
| 1202 | |
| 1203 | if ((register_count0 + register_count1) == 0) { |
Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 1204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | /* GPEs are not required by ACPI, this is OK */ |
| 1206 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1207 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 1208 | "There are no GPE blocks defined in the FADT\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | status = AE_OK; |
| 1210 | goto cleanup; |
| 1211 | } |
| 1212 | |
| 1213 | /* Check for Max GPE number out-of-range */ |
| 1214 | |
| 1215 | if (gpe_number_max > ACPI_GPE_MAX) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 1216 | ACPI_ERROR((AE_INFO, |
| 1217 | "Maximum GPE number from FADT is too large: 0x%X", |
| 1218 | gpe_number_max)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | status = AE_BAD_VALUE; |
| 1220 | goto cleanup; |
| 1221 | } |
| 1222 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1223 | cleanup: |
| 1224 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
| 1225 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | } |