blob: 2872be2b9be58668ded47c51a0051bc9e0396076 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: evgpeblk - GPE block creation and initialization.
4 *
5 *****************************************************************************/
6
7/*
Len Brown75a44ce2008-04-23 23:00:13 -04008 * Copyright (C) 2000 - 2008, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("evgpeblk")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Robert Moore44f6c012005-04-18 22:49:35 -040051/* Local prototypes */
Len Brown4be44fc2005-08-05 00:44:28 -040052static acpi_status
53acpi_ev_save_method_info(acpi_handle obj_handle,
54 u32 level, void *obj_desc, void **return_value);
Robert Moore44f6c012005-04-18 22:49:35 -040055
56static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040057acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
58 u32 level, void *info, void **return_value);
59
60static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
61 interrupt_number);
Robert Moore44f6c012005-04-18 22:49:35 -040062
63static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040064acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt);
Robert Moore44f6c012005-04-18 22:49:35 -040065
66static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040067acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
68 u32 interrupt_number);
Robert Moore44f6c012005-04-18 22:49:35 -040069
70static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040071acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
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 Moore96db2552005-11-02 00:00:00 -050081 * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL.
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 * Should be called only when the GPE lists are semaphore locked
83 * and not subject to change.
84 *
85 ******************************************************************************/
86
Len Brown4be44fc2005-08-05 00:44:28 -040087u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088{
Len Brown4be44fc2005-08-05 00:44:28 -040089 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
90 struct acpi_gpe_block_info *gpe_block;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Len Brown4be44fc2005-08-05 00:44:28 -040092 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
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 Brown4be44fc2005-08-05 00:44:28 -0400106 (&gpe_block->
107 event_info[((acpi_size) gpe_block->
108 register_count) * 8] >
109 gpe_event_info)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 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 Torvalds1da177e2005-04-16 15:20:36 -0700122/*******************************************************************************
123 *
124 * FUNCTION: acpi_ev_walk_gpe_list
125 *
126 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block
Bob Mooree97d6bf2008-12-30 09:45:17 +0800127 * Context - Value passed to callback
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 *
129 * RETURN: Status
130 *
131 * DESCRIPTION: Walk the GPE lists.
132 *
133 ******************************************************************************/
134
Bob Mooree97d6bf2008-12-30 09:45:17 +0800135acpi_status
136acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137{
Len Brown4be44fc2005-08-05 00:44:28 -0400138 struct acpi_gpe_block_info *gpe_block;
139 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
140 acpi_status status = AE_OK;
Bob Mooreb8e4d892006-01-27 16:43:00 -0500141 acpi_cpu_flags flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Bob Mooreb229cf92006-04-21 17:15:00 -0400143 ACPI_FUNCTION_TRACE(ev_walk_gpe_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Len Brown4be44fc2005-08-05 00:44:28 -0400145 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147 /* Walk the interrupt level descriptor list */
148
149 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
150 while (gpe_xrupt_info) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 /* 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 Moore52fc0b02006-10-02 00:00:00 -0400156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 /* One callback per GPE block */
158
Bob Mooree97d6bf2008-12-30 09:45:17 +0800159 status =
160 gpe_walk_callback(gpe_xrupt_info, gpe_block,
161 context);
Len Brown4be44fc2005-08-05 00:44:28 -0400162 if (ACPI_FAILURE(status)) {
Bob Mooree97d6bf2008-12-30 09:45:17 +0800163 if (status == AE_CTRL_END) { /* Callback abort */
164 status = AE_OK;
165 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 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 Brown4be44fc2005-08-05 00:44:28 -0400175 unlock_and_exit:
176 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
177 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178}
179
Robert Moore44f6c012005-04-18 22:49:35 -0400180/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 *
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
194acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400195acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
Bob Mooree97d6bf2008-12-30 09:45:17 +0800196 struct acpi_gpe_block_info *gpe_block,
197 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198{
Len Brown4be44fc2005-08-05 00:44:28 -0400199 struct acpi_gpe_event_info *gpe_event_info;
Bob Moore67a119f2008-06-10 13:42:13 +0800200 u32 i;
201 u32 j;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Bob Mooreb229cf92006-04-21 17:15:00 -0400203 ACPI_FUNCTION_TRACE(ev_delete_gpe_handlers);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
205 /* Examine each GPE Register within the block */
206
207 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 /* Now look at the individual GPEs in this byte register */
210
211 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
Len Brown4be44fc2005-08-05 00:44:28 -0400212 gpe_event_info =
213 &gpe_block->
Bob Moore67a119f2008-06-10 13:42:13 +0800214 event_info[((acpi_size) i *
215 ACPI_GPE_REGISTER_WIDTH) + j];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Robert Moore44f6c012005-04-18 22:49:35 -0400217 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
Len Brown4be44fc2005-08-05 00:44:28 -0400218 ACPI_GPE_DISPATCH_HANDLER) {
Bob Moore83135242006-10-03 00:00:00 -0400219 ACPI_FREE(gpe_event_info->dispatch.handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 gpe_event_info->dispatch.handler = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400221 gpe_event_info->flags &=
222 ~ACPI_GPE_DISPATCH_MASK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 }
224 }
225 }
226
Len Brown4be44fc2005-08-05 00:44:28 -0400227 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228}
229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230/*******************************************************************************
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
252static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400253acpi_ev_save_method_info(acpi_handle obj_handle,
254 u32 level, void *obj_desc, void **return_value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255{
Len Brown4be44fc2005-08-05 00:44:28 -0400256 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 Torvalds1da177e2005-04-16 15:20:36 -0700262
Bob Mooreb229cf92006-04-21 17:15:00 -0400263 ACPI_FUNCTION_TRACE(ev_save_method_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264
265 /*
266 * _Lxx and _Exx GPE method support
267 *
268 * 1) Extract the name from the object and convert to a string
269 */
Len Brown4be44fc2005-08-05 00:44:28 -0400270 ACPI_MOVE_32_TO_32(name,
271 &((struct acpi_namespace_node *)obj_handle)->name.
272 integer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 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 Moore96db2552005-11-02 00:00:00 -0500279 * NOTE: Default GPE type is RUNTIME. May be changed later to WAKE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 * 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 Mooreb229cf92006-04-21 17:15:00 -0400294 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
295 "Ignoring unknown GPE method type: %s (name not of form _Lxx or _Exx)",
296 name));
Len Brown4be44fc2005-08-05 00:44:28 -0400297 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 }
299
300 /* Convert the last two characters of the name to the GPE Number */
301
Len Brown4be44fc2005-08-05 00:44:28 -0400302 gpe_number = ACPI_STRTOUL(&name[2], NULL, 16);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 if (gpe_number == ACPI_UINT32_MAX) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 /* Conversion failed; invalid method, just ignore it */
306
Bob Mooreb229cf92006-04-21 17:15:00 -0400307 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 Brown4be44fc2005-08-05 00:44:28 -0400310 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 }
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 Brown4be44fc2005-08-05 00:44:28 -0400316 (gpe_number >=
317 (gpe_block->block_base_number +
318 (gpe_block->register_count * 8)))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 /*
Bob Moore9f15fc62008-11-12 16:01:56 +0800320 * 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 Torvalds1da177e2005-04-16 15:20:36 -0700323 */
Len Brown4be44fc2005-08-05 00:44:28 -0400324 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 }
326
327 /*
Bob Moore9f15fc62008-11-12 16:01:56 +0800328 * 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 Torvalds1da177e2005-04-16 15:20:36 -0700331 */
Len Brown4be44fc2005-08-05 00:44:28 -0400332 gpe_event_info =
333 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334
Bob Moore96db2552005-11-02 00:00:00 -0500335 gpe_event_info->flags = (u8)
336 (type | ACPI_GPE_DISPATCH_METHOD | ACPI_GPE_TYPE_RUNTIME);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
Len Brown4be44fc2005-08-05 00:44:28 -0400338 gpe_event_info->dispatch.method_node =
339 (struct acpi_namespace_node *)obj_handle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
341 /* Update enable mask, but don't enable the HW GPE as of yet */
342
Len Brown4be44fc2005-08-05 00:44:28 -0400343 status = acpi_ev_enable_gpe(gpe_event_info, FALSE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
Len Brown4be44fc2005-08-05 00:44:28 -0400345 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 Torvalds1da177e2005-04-16 15:20:36 -0700349}
350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351/*******************************************************************************
352 *
353 * FUNCTION: acpi_ev_match_prw_and_gpe
354 *
355 * PARAMETERS: Callback from walk_namespace
356 *
Bob Moore96db2552005-11-02 00:00:00 -0500357 * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 * not aborted on a single _PRW failure.
359 *
360 * DESCRIPTION: Called from acpi_walk_namespace. Expects each object to be a
Bob Moore96db2552005-11-02 00:00:00 -0500361 * Device. Run the _PRW method. If present, extract the GPE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 * number and mark the GPE as a WAKE GPE.
363 *
364 ******************************************************************************/
365
366static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400367acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
368 u32 level, void *info, void **return_value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369{
Len Brown4be44fc2005-08-05 00:44:28 -0400370 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 Torvalds1da177e2005-04-16 15:20:36 -0700379
Bob Mooreb229cf92006-04-21 17:15:00 -0400380 ACPI_FUNCTION_TRACE(ev_match_prw_and_gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
382 /* Check for a _PRW method under this device */
383
Len Brown4be44fc2005-08-05 00:44:28 -0400384 status = acpi_ut_evaluate_object(obj_handle, METHOD_NAME__PRW,
385 ACPI_BTYPE_PACKAGE, &pkg_desc);
386 if (ACPI_FAILURE(status)) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400387
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 /* Ignore all errors from _PRW, we don't want to abort the subsystem */
389
Len Brown4be44fc2005-08-05 00:44:28 -0400390 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 }
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 Moore9f15fc62008-11-12 16:01:56 +0800405 * The _PRW object must return a package, we are only interested in the
406 * first element
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 */
408 obj_desc = pkg_desc->package.elements[0];
409
Len Brown4be44fc2005-08-05 00:44:28 -0400410 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400411
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 /* 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 Brown4be44fc2005-08-05 00:44:28 -0400419 } else if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400420
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 /* Package contains a GPE reference and GPE number within a GPE block */
422
423 if ((obj_desc->package.count < 2) ||
Len Brown4be44fc2005-08-05 00:44:28 -0400424 (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 Torvalds1da177e2005-04-16 15:20:36 -0700428 goto cleanup;
429 }
430
431 /* Get GPE block reference and decode */
432
Len Brown4be44fc2005-08-05 00:44:28 -0400433 target_gpe_device =
434 obj_desc->package.elements[0]->reference.node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 gpe_number = (u32) obj_desc->package.elements[1]->integer.value;
Len Brown4be44fc2005-08-05 00:44:28 -0400436 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 /* Unknown type, just ignore it */
438
439 goto cleanup;
440 }
441
442 /*
443 * Is this GPE within this block?
444 *
Bob Moore9f15fc62008-11-12 16:01:56 +0800445 * TRUE if and only if these conditions are true:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 * 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 Brown4be44fc2005-08-05 00:44:28 -0400451 (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 Torvalds1da177e2005-04-16 15:20:36 -0700457
458 /* Mark GPE for WAKE-ONLY but WAKE_DISABLED */
459
Len Brown4be44fc2005-08-05 00:44:28 -0400460 gpe_event_info->flags &=
461 ~(ACPI_GPE_WAKE_ENABLED | ACPI_GPE_RUN_ENABLED);
Bob Moore96db2552005-11-02 00:00:00 -0500462
Len Brown4be44fc2005-08-05 00:44:28 -0400463 status =
464 acpi_ev_set_gpe_type(gpe_event_info, ACPI_GPE_TYPE_WAKE);
465 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 goto cleanup;
467 }
Bob Moore9f15fc62008-11-12 16:01:56 +0800468
Len Brown4be44fc2005-08-05 00:44:28 -0400469 status =
470 acpi_ev_update_gpe_enable_masks(gpe_event_info,
471 ACPI_GPE_DISABLE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 }
473
Len Brown4be44fc2005-08-05 00:44:28 -0400474 cleanup:
475 acpi_ut_remove_reference(pkg_desc);
476 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477}
478
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479/*******************************************************************************
480 *
481 * FUNCTION: acpi_ev_get_gpe_xrupt_block
482 *
Robert Moore6f42ccf2005-05-13 00:00:00 -0400483 * PARAMETERS: interrupt_number - Interrupt for a GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 *
485 * RETURN: A GPE interrupt block
486 *
Bob Moore96db2552005-11-02 00:00:00 -0500487 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
Bob Moore9f15fc62008-11-12 16:01:56 +0800488 * 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 Torvalds1da177e2005-04-16 15:20:36 -0700491 *
492 ******************************************************************************/
493
Len Brown4be44fc2005-08-05 00:44:28 -0400494static struct acpi_gpe_xrupt_info *acpi_ev_get_gpe_xrupt_block(u32
495 interrupt_number)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496{
Len Brown4be44fc2005-08-05 00:44:28 -0400497 struct acpi_gpe_xrupt_info *next_gpe_xrupt;
498 struct acpi_gpe_xrupt_info *gpe_xrupt;
499 acpi_status status;
Bob Mooreb8e4d892006-01-27 16:43:00 -0500500 acpi_cpu_flags flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501
Bob Mooreb229cf92006-04-21 17:15:00 -0400502 ACPI_FUNCTION_TRACE(ev_get_gpe_xrupt_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
Robert Moore44f6c012005-04-18 22:49:35 -0400504 /* No need for lock since we are not changing any list elements here */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505
506 next_gpe_xrupt = acpi_gbl_gpe_xrupt_list_head;
507 while (next_gpe_xrupt) {
Robert Moore6f42ccf2005-05-13 00:00:00 -0400508 if (next_gpe_xrupt->interrupt_number == interrupt_number) {
Len Brown4be44fc2005-08-05 00:44:28 -0400509 return_PTR(next_gpe_xrupt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 }
511
512 next_gpe_xrupt = next_gpe_xrupt->next;
513 }
514
515 /* Not found, must allocate a new xrupt descriptor */
516
Bob Moore83135242006-10-03 00:00:00 -0400517 gpe_xrupt = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_xrupt_info));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 if (!gpe_xrupt) {
Len Brown4be44fc2005-08-05 00:44:28 -0400519 return_PTR(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 }
521
Robert Moore6f42ccf2005-05-13 00:00:00 -0400522 gpe_xrupt->interrupt_number = interrupt_number;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523
524 /* Install new interrupt descriptor with spin lock */
525
Len Brown4be44fc2005-08-05 00:44:28 -0400526 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 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 Brown4be44fc2005-08-05 00:44:28 -0400535 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt;
537 }
Len Brown4be44fc2005-08-05 00:44:28 -0400538 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539
540 /* Install new interrupt handler if not SCI_INT */
541
Bob Mooref3d2e782007-02-02 19:48:18 +0300542 if (interrupt_number != acpi_gbl_FADT.sci_interrupt) {
Len Brown4be44fc2005-08-05 00:44:28 -0400543 status = acpi_os_install_interrupt_handler(interrupt_number,
544 acpi_ev_gpe_xrupt_handler,
545 gpe_xrupt);
546 if (ACPI_FAILURE(status)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500547 ACPI_ERROR((AE_INFO,
548 "Could not install GPE interrupt handler at level 0x%X",
549 interrupt_number));
Len Brown4be44fc2005-08-05 00:44:28 -0400550 return_PTR(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 }
552 }
553
Len Brown4be44fc2005-08-05 00:44:28 -0400554 return_PTR(gpe_xrupt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555}
556
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557/*******************************************************************************
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
570static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400571acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572{
Len Brown4be44fc2005-08-05 00:44:28 -0400573 acpi_status status;
Bob Mooreb8e4d892006-01-27 16:43:00 -0500574 acpi_cpu_flags flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575
Bob Mooreb229cf92006-04-21 17:15:00 -0400576 ACPI_FUNCTION_TRACE(ev_delete_gpe_xrupt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577
578 /* We never want to remove the SCI interrupt handler */
579
Bob Mooref3d2e782007-02-02 19:48:18 +0300580 if (gpe_xrupt->interrupt_number == acpi_gbl_FADT.sci_interrupt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 gpe_xrupt->gpe_block_list_head = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400582 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 }
584
585 /* Disable this interrupt */
586
Bob Moore96db2552005-11-02 00:00:00 -0500587 status =
588 acpi_os_remove_interrupt_handler(gpe_xrupt->interrupt_number,
589 acpi_ev_gpe_xrupt_handler);
Len Brown4be44fc2005-08-05 00:44:28 -0400590 if (ACPI_FAILURE(status)) {
591 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 }
593
594 /* Unlink the interrupt block with lock */
595
Len Brown4be44fc2005-08-05 00:44:28 -0400596 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 if (gpe_xrupt->previous) {
598 gpe_xrupt->previous->next = gpe_xrupt->next;
Bob Mooree0b910502007-04-03 20:00:29 -0400599 } else {
600 /* No previous, update list head */
601
602 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt->next;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 }
604
605 if (gpe_xrupt->next) {
606 gpe_xrupt->next->previous = gpe_xrupt->previous;
607 }
Len Brown4be44fc2005-08-05 00:44:28 -0400608 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609
610 /* Free the block */
611
Bob Moore83135242006-10-03 00:00:00 -0400612 ACPI_FREE(gpe_xrupt);
Len Brown4be44fc2005-08-05 00:44:28 -0400613 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614}
615
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616/*******************************************************************************
617 *
618 * FUNCTION: acpi_ev_install_gpe_block
619 *
Bob Moore9f15fc62008-11-12 16:01:56 +0800620 * PARAMETERS: gpe_block - New GPE block
621 * interrupt_number - Xrupt to be associated with this
622 * GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 *
624 * RETURN: Status
625 *
626 * DESCRIPTION: Install new GPE block with mutex support
627 *
628 ******************************************************************************/
629
630static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400631acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
632 u32 interrupt_number)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633{
Len Brown4be44fc2005-08-05 00:44:28 -0400634 struct acpi_gpe_block_info *next_gpe_block;
635 struct acpi_gpe_xrupt_info *gpe_xrupt_block;
636 acpi_status status;
Bob Mooreb8e4d892006-01-27 16:43:00 -0500637 acpi_cpu_flags flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
Bob Mooreb229cf92006-04-21 17:15:00 -0400639 ACPI_FUNCTION_TRACE(ev_install_gpe_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640
Len Brown4be44fc2005-08-05 00:44:28 -0400641 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
642 if (ACPI_FAILURE(status)) {
643 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 }
645
Len Brown4be44fc2005-08-05 00:44:28 -0400646 gpe_xrupt_block = acpi_ev_get_gpe_xrupt_block(interrupt_number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 if (!gpe_xrupt_block) {
648 status = AE_NO_MEMORY;
649 goto unlock_and_exit;
650 }
651
Robert Moore44f6c012005-04-18 22:49:35 -0400652 /* Install the new block at the end of the list with lock */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653
Len Brown4be44fc2005-08-05 00:44:28 -0400654 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 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 Brown4be44fc2005-08-05 00:44:28 -0400663 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 gpe_xrupt_block->gpe_block_list_head = gpe_block;
665 }
666
667 gpe_block->xrupt_block = gpe_xrupt_block;
Len Brown4be44fc2005-08-05 00:44:28 -0400668 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669
Len Brown4be44fc2005-08-05 00:44:28 -0400670 unlock_and_exit:
671 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
672 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673}
674
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675/*******************************************************************************
676 *
677 * FUNCTION: acpi_ev_delete_gpe_block
678 *
Bob Moore9f15fc62008-11-12 16:01:56 +0800679 * PARAMETERS: gpe_block - Existing GPE block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 *
681 * RETURN: Status
682 *
683 * DESCRIPTION: Remove a GPE block
684 *
685 ******************************************************************************/
686
Len Brown4be44fc2005-08-05 00:44:28 -0400687acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688{
Len Brown4be44fc2005-08-05 00:44:28 -0400689 acpi_status status;
Bob Mooreb8e4d892006-01-27 16:43:00 -0500690 acpi_cpu_flags flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691
Bob Mooreb229cf92006-04-21 17:15:00 -0400692 ACPI_FUNCTION_TRACE(ev_install_gpe_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693
Len Brown4be44fc2005-08-05 00:44:28 -0400694 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
695 if (ACPI_FAILURE(status)) {
696 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 }
698
699 /* Disable all GPEs in this block */
700
Bob Mooree97d6bf2008-12-30 09:45:17 +0800701 status =
702 acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703
704 if (!gpe_block->previous && !gpe_block->next) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400705
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 /* This is the last gpe_block on this interrupt */
707
Len Brown4be44fc2005-08-05 00:44:28 -0400708 status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block);
709 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 goto unlock_and_exit;
711 }
Len Brown4be44fc2005-08-05 00:44:28 -0400712 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 /* Remove the block on this interrupt with lock */
714
Len Brown4be44fc2005-08-05 00:44:28 -0400715 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 if (gpe_block->previous) {
717 gpe_block->previous->next = gpe_block->next;
Len Brown4be44fc2005-08-05 00:44:28 -0400718 } else {
719 gpe_block->xrupt_block->gpe_block_list_head =
720 gpe_block->next;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 }
722
723 if (gpe_block->next) {
724 gpe_block->next->previous = gpe_block->previous;
725 }
Len Brown4be44fc2005-08-05 00:44:28 -0400726 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 }
728
Bob Mooree97d6bf2008-12-30 09:45:17 +0800729 acpi_current_gpe_count -=
730 gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH;
731
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 /* Free the gpe_block */
733
Bob Moore83135242006-10-03 00:00:00 -0400734 ACPI_FREE(gpe_block->register_info);
735 ACPI_FREE(gpe_block->event_info);
736 ACPI_FREE(gpe_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737
Len Brown4be44fc2005-08-05 00:44:28 -0400738 unlock_and_exit:
739 status = acpi_ut_release_mutex(ACPI_MTX_EVENTS);
740 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741}
742
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743/*******************************************************************************
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
755static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400756acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757{
Len Brown4be44fc2005-08-05 00:44:28 -0400758 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 Moore67a119f2008-06-10 13:42:13 +0800762 u32 i;
763 u32 j;
Len Brown4be44fc2005-08-05 00:44:28 -0400764 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765
Bob Mooreb229cf92006-04-21 17:15:00 -0400766 ACPI_FUNCTION_TRACE(ev_create_gpe_info_blocks);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767
768 /* Allocate the GPE register information block */
769
Bob Moore83135242006-10-03 00:00:00 -0400770 gpe_register_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block->
771 register_count *
772 sizeof(struct
773 acpi_gpe_register_info));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 if (!gpe_register_info) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500775 ACPI_ERROR((AE_INFO,
Bob Mooreb229cf92006-04-21 17:15:00 -0400776 "Could not allocate the GpeRegisterInfo table"));
Len Brown4be44fc2005-08-05 00:44:28 -0400777 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 }
779
780 /*
781 * Allocate the GPE event_info block. There are eight distinct GPEs
Bob Moore96db2552005-11-02 00:00:00 -0500782 * per register. Initialization to zeros is sufficient.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 */
Bob Moore83135242006-10-03 00:00:00 -0400784 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 Torvalds1da177e2005-04-16 15:20:36 -0700789 if (!gpe_event_info) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500790 ACPI_ERROR((AE_INFO,
Bob Mooreb229cf92006-04-21 17:15:00 -0400791 "Could not allocate the GpeEventInfo table"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 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 Brown4be44fc2005-08-05 00:44:28 -0400799 gpe_block->event_info = gpe_event_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800
801 /*
Bob Moore96db2552005-11-02 00:00:00 -0500802 * Initialize the GPE Register and Event structures. A goal of these
Bob Moore9f15fc62008-11-12 16:01:56 +0800803 * 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 Torvalds1da177e2005-04-16 15:20:36 -0700806 */
807 this_register = gpe_register_info;
Len Brown4be44fc2005-08-05 00:44:28 -0400808 this_event = gpe_event_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809
810 for (i = 0; i < gpe_block->register_count; i++) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400811
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 /* Init the register_info for this GPE register (8 GPEs) */
813
Len Brown4be44fc2005-08-05 00:44:28 -0400814 this_register->base_gpe_number =
815 (u8) (gpe_block->block_base_number +
816 (i * ACPI_GPE_REGISTER_WIDTH));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817
Bob Moore59fa8502007-02-02 19:48:23 +0300818 this_register->status_address.address =
819 gpe_block->block_address.address + i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820
Bob Moore59fa8502007-02-02 19:48:23 +0300821 this_register->enable_address.address =
822 gpe_block->block_address.address + i +
823 gpe_block->register_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824
Bob Mooref3d2e782007-02-02 19:48:18 +0300825 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 Brown4be44fc2005-08-05 00:44:28 -0400830 ACPI_GPE_REGISTER_WIDTH;
Bob Mooref3d2e782007-02-02 19:48:18 +0300831 this_register->enable_address.bit_width =
Len Brown4be44fc2005-08-05 00:44:28 -0400832 ACPI_GPE_REGISTER_WIDTH;
Bob Mooref3d2e782007-02-02 19:48:18 +0300833 this_register->status_address.bit_offset =
Len Brown4be44fc2005-08-05 00:44:28 -0400834 ACPI_GPE_REGISTER_WIDTH;
Bob Mooref3d2e782007-02-02 19:48:18 +0300835 this_register->enable_address.bit_offset =
Len Brown4be44fc2005-08-05 00:44:28 -0400836 ACPI_GPE_REGISTER_WIDTH;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837
838 /* Init the event_info for each GPE within this register */
839
840 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) {
Alexey Starikovskiy69874162007-02-02 19:48:19 +0300841 this_event->gpe_number =
842 (u8) (this_register->base_gpe_number + j);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 this_event->register_info = this_register;
844 this_event++;
845 }
846
Bob Moore96db2552005-11-02 00:00:00 -0500847 /* Disable all GPEs within this register */
848
Len Brown4be44fc2005-08-05 00:44:28 -0400849 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00,
850 &this_register->
851 enable_address);
852 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 goto error_exit;
854 }
855
Bob Moore96db2552005-11-02 00:00:00 -0500856 /* Clear any pending GPE events within this register */
857
Len Brown4be44fc2005-08-05 00:44:28 -0400858 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF,
859 &this_register->
860 status_address);
861 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 goto error_exit;
863 }
864
865 this_register++;
866 }
867
Len Brown4be44fc2005-08-05 00:44:28 -0400868 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869
Len Brown4be44fc2005-08-05 00:44:28 -0400870 error_exit:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 if (gpe_register_info) {
Bob Moore83135242006-10-03 00:00:00 -0400872 ACPI_FREE(gpe_register_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 }
874 if (gpe_event_info) {
Bob Moore83135242006-10-03 00:00:00 -0400875 ACPI_FREE(gpe_event_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 }
877
Len Brown4be44fc2005-08-05 00:44:28 -0400878 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879}
880
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881/*******************************************************************************
882 *
883 * FUNCTION: acpi_ev_create_gpe_block
884 *
885 * PARAMETERS: gpe_device - Handle to the parent GPE block
886 * gpe_block_address - Address and space_iD
887 * register_count - Number of GPE register pairs in the block
888 * gpe_block_base_number - Starting GPE number for the block
Robert Moore6f42ccf2005-05-13 00:00:00 -0400889 * interrupt_number - H/W interrupt for the block
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 * return_gpe_block - Where the new block descriptor is returned
891 *
892 * RETURN: Status
893 *
Bob Moore96db2552005-11-02 00:00:00 -0500894 * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within
895 * the block are disabled at exit.
896 * Note: Assumes namespace is locked.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 *
898 ******************************************************************************/
899
900acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400901acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
902 struct acpi_generic_address *gpe_block_address,
903 u32 register_count,
904 u8 gpe_block_base_number,
905 u32 interrupt_number,
906 struct acpi_gpe_block_info **return_gpe_block)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907{
Len Brown4be44fc2005-08-05 00:44:28 -0400908 acpi_status status;
Bob Moore96db2552005-11-02 00:00:00 -0500909 struct acpi_gpe_block_info *gpe_block;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910
Bob Mooreb229cf92006-04-21 17:15:00 -0400911 ACPI_FUNCTION_TRACE(ev_create_gpe_block);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912
913 if (!register_count) {
Len Brown4be44fc2005-08-05 00:44:28 -0400914 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 }
916
917 /* Allocate a new GPE block */
918
Bob Moore83135242006-10-03 00:00:00 -0400919 gpe_block = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_block_info));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 if (!gpe_block) {
Len Brown4be44fc2005-08-05 00:44:28 -0400921 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922 }
923
924 /* Initialize the new GPE block */
925
Bob Moore96db2552005-11-02 00:00:00 -0500926 gpe_block->node = gpe_device;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 gpe_block->register_count = register_count;
928 gpe_block->block_base_number = gpe_block_base_number;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929
Len Brown4be44fc2005-08-05 00:44:28 -0400930 ACPI_MEMCPY(&gpe_block->block_address, gpe_block_address,
931 sizeof(struct acpi_generic_address));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932
Bob Moore96db2552005-11-02 00:00:00 -0500933 /*
934 * Create the register_info and event_info sub-structures
935 * Note: disables and clears all GPEs in the block
936 */
Len Brown4be44fc2005-08-05 00:44:28 -0400937 status = acpi_ev_create_gpe_info_blocks(gpe_block);
938 if (ACPI_FAILURE(status)) {
Bob Moore83135242006-10-03 00:00:00 -0400939 ACPI_FREE(gpe_block);
Len Brown4be44fc2005-08-05 00:44:28 -0400940 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 }
942
Bob Moore96db2552005-11-02 00:00:00 -0500943 /* Install the new block in the global lists */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944
Len Brown4be44fc2005-08-05 00:44:28 -0400945 status = acpi_ev_install_gpe_block(gpe_block, interrupt_number);
946 if (ACPI_FAILURE(status)) {
Bob Moore83135242006-10-03 00:00:00 -0400947 ACPI_FREE(gpe_block);
Len Brown4be44fc2005-08-05 00:44:28 -0400948 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 }
950
951 /* Find all GPE methods (_Lxx, _Exx) for this block */
952
Len Brown4be44fc2005-08-05 00:44:28 -0400953 status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device,
954 ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
955 acpi_ev_save_method_info, gpe_block,
956 NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957
Bob Moore96db2552005-11-02 00:00:00 -0500958 /* Return the new block */
959
960 if (return_gpe_block) {
961 (*return_gpe_block) = gpe_block;
962 }
963
964 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
965 "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
966 (u32) gpe_block->block_base_number,
967 (u32) (gpe_block->block_base_number +
968 ((gpe_block->register_count *
969 ACPI_GPE_REGISTER_WIDTH) - 1)),
970 gpe_device->name.ascii, gpe_block->register_count,
971 interrupt_number));
972
Bob Mooree97d6bf2008-12-30 09:45:17 +0800973 /* Update global count of currently available GPEs */
974
975 acpi_current_gpe_count += register_count * ACPI_GPE_REGISTER_WIDTH;
Bob Moore96db2552005-11-02 00:00:00 -0500976 return_ACPI_STATUS(AE_OK);
977}
978
979/*******************************************************************************
980 *
981 * FUNCTION: acpi_ev_initialize_gpe_block
982 *
983 * PARAMETERS: gpe_device - Handle to the parent GPE block
984 * gpe_block - Gpe Block info
985 *
986 * RETURN: Status
987 *
988 * DESCRIPTION: Initialize and enable a GPE block. First find and run any
989 * _PRT methods associated with the block, then enable the
990 * appropriate GPEs.
991 * Note: Assumes namespace is locked.
992 *
993 ******************************************************************************/
994
995acpi_status
996acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
997 struct acpi_gpe_block_info *gpe_block)
998{
999 acpi_status status;
1000 struct acpi_gpe_event_info *gpe_event_info;
1001 struct acpi_gpe_walk_info gpe_info;
1002 u32 wake_gpe_count;
1003 u32 gpe_enabled_count;
Bob Moore67a119f2008-06-10 13:42:13 +08001004 u32 i;
1005 u32 j;
Bob Moore96db2552005-11-02 00:00:00 -05001006
Bob Mooreb229cf92006-04-21 17:15:00 -04001007 ACPI_FUNCTION_TRACE(ev_initialize_gpe_block);
Bob Moore96db2552005-11-02 00:00:00 -05001008
1009 /* Ignore a null GPE block (e.g., if no GPE block 1 exists) */
1010
1011 if (!gpe_block) {
1012 return_ACPI_STATUS(AE_OK);
1013 }
1014
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 /*
Bob Moore96db2552005-11-02 00:00:00 -05001016 * Runtime option: Should wake GPEs be enabled at runtime? The default
1017 * is no, they should only be enabled just as the machine goes to sleep.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 */
1019 if (acpi_gbl_leave_wake_gpes_disabled) {
1020 /*
Bob Moore96db2552005-11-02 00:00:00 -05001021 * Differentiate runtime vs wake GPEs, via the _PRW control methods.
1022 * Each GPE that has one or more _PRWs that reference it is by
1023 * definition a wake GPE and will not be enabled while the machine
1024 * is running.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025 */
1026 gpe_info.gpe_block = gpe_block;
1027 gpe_info.gpe_device = gpe_device;
1028
Len Brown4be44fc2005-08-05 00:44:28 -04001029 status =
1030 acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1031 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
1032 acpi_ev_match_prw_and_gpe, &gpe_info,
1033 NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 }
1035
1036 /*
Bob Moore96db2552005-11-02 00:00:00 -05001037 * Enable all GPEs in this block that have these attributes:
1038 * 1) are "runtime" or "run/wake" GPEs, and
1039 * 2) have a corresponding _Lxx or _Exx method
1040 *
1041 * Any other GPEs within this block must be enabled via the acpi_enable_gpe()
1042 * external interface.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 */
1044 wake_gpe_count = 0;
1045 gpe_enabled_count = 0;
1046
1047 for (i = 0; i < gpe_block->register_count; i++) {
1048 for (j = 0; j < 8; j++) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001049
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 /* Get the info block for this particular GPE */
1051
Len Brown4be44fc2005-08-05 00:44:28 -04001052 gpe_event_info =
1053 &gpe_block->
Bob Moore67a119f2008-06-10 13:42:13 +08001054 event_info[((acpi_size) i *
1055 ACPI_GPE_REGISTER_WIDTH) + j];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056
Len Brown4be44fc2005-08-05 00:44:28 -04001057 if (((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
1058 ACPI_GPE_DISPATCH_METHOD)
Len Brownfd350942007-05-09 23:34:35 -04001059 && (gpe_event_info->flags & ACPI_GPE_TYPE_RUNTIME)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 gpe_enabled_count++;
1061 }
1062
1063 if (gpe_event_info->flags & ACPI_GPE_TYPE_WAKE) {
1064 wake_gpe_count++;
1065 }
1066 }
1067 }
1068
Len Brown4be44fc2005-08-05 00:44:28 -04001069 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1070 "Found %u Wake, Enabled %u Runtime GPEs in this block\n",
1071 wake_gpe_count, gpe_enabled_count));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072
Bob Moore96db2552005-11-02 00:00:00 -05001073 /* Enable all valid runtime GPEs found above */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074
Bob Mooree97d6bf2008-12-30 09:45:17 +08001075 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block, NULL);
Bob Moore96db2552005-11-02 00:00:00 -05001076 if (ACPI_FAILURE(status)) {
Bob Mooreb229cf92006-04-21 17:15:00 -04001077 ACPI_ERROR((AE_INFO, "Could not enable GPEs in GpeBlock %p",
Bob Mooreb8e4d892006-01-27 16:43:00 -05001078 gpe_block));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079 }
1080
Bob Moore96db2552005-11-02 00:00:00 -05001081 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082}
1083
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084/*******************************************************************************
1085 *
1086 * FUNCTION: acpi_ev_gpe_initialize
1087 *
1088 * PARAMETERS: None
1089 *
1090 * RETURN: Status
1091 *
1092 * DESCRIPTION: Initialize the GPE data structures
1093 *
1094 ******************************************************************************/
1095
Len Brown4be44fc2005-08-05 00:44:28 -04001096acpi_status acpi_ev_gpe_initialize(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097{
Len Brown4be44fc2005-08-05 00:44:28 -04001098 u32 register_count0 = 0;
1099 u32 register_count1 = 0;
1100 u32 gpe_number_max = 0;
1101 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102
Bob Mooreb229cf92006-04-21 17:15:00 -04001103 ACPI_FUNCTION_TRACE(ev_gpe_initialize);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104
Len Brown4be44fc2005-08-05 00:44:28 -04001105 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
1106 if (ACPI_FAILURE(status)) {
1107 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 }
1109
1110 /*
1111 * Initialize the GPE Block(s) defined in the FADT
1112 *
1113 * Why the GPE register block lengths are divided by 2: From the ACPI Spec,
1114 * section "General-Purpose Event Registers", we have:
1115 *
1116 * "Each register block contains two registers of equal length
1117 * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
1118 * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
1119 * The length of the GPE1_STS and GPE1_EN registers is equal to
1120 * half the GPE1_LEN. If a generic register block is not supported
1121 * then its respective block pointer and block length values in the
1122 * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
1123 * to be the same size."
1124 */
1125
1126 /*
1127 * Determine the maximum GPE number for this machine.
1128 *
1129 * Note: both GPE0 and GPE1 are optional, and either can exist without
1130 * the other.
1131 *
1132 * If EITHER the register length OR the block address are zero, then that
1133 * particular block is not supported.
1134 */
Bob Mooref3d2e782007-02-02 19:48:18 +03001135 if (acpi_gbl_FADT.gpe0_block_length &&
1136 acpi_gbl_FADT.xgpe0_block.address) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001137
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 /* GPE block 0 exists (has both length and address > 0) */
1139
Bob Mooref3d2e782007-02-02 19:48:18 +03001140 register_count0 = (u16) (acpi_gbl_FADT.gpe0_block_length / 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141
Len Brown4be44fc2005-08-05 00:44:28 -04001142 gpe_number_max =
1143 (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144
1145 /* Install GPE Block 0 */
1146
Len Brown4be44fc2005-08-05 00:44:28 -04001147 status = acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
Bob Mooref3d2e782007-02-02 19:48:18 +03001148 &acpi_gbl_FADT.xgpe0_block,
Len Brown4be44fc2005-08-05 00:44:28 -04001149 register_count0, 0,
Bob Mooref3d2e782007-02-02 19:48:18 +03001150 acpi_gbl_FADT.sci_interrupt,
Len Brown4be44fc2005-08-05 00:44:28 -04001151 &acpi_gbl_gpe_fadt_blocks[0]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152
Len Brown4be44fc2005-08-05 00:44:28 -04001153 if (ACPI_FAILURE(status)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -05001154 ACPI_EXCEPTION((AE_INFO, status,
1155 "Could not create GPE Block 0"));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 }
1157 }
1158
Bob Mooref3d2e782007-02-02 19:48:18 +03001159 if (acpi_gbl_FADT.gpe1_block_length &&
1160 acpi_gbl_FADT.xgpe1_block.address) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001161
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 /* GPE block 1 exists (has both length and address > 0) */
1163
Bob Mooref3d2e782007-02-02 19:48:18 +03001164 register_count1 = (u16) (acpi_gbl_FADT.gpe1_block_length / 2);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165
1166 /* Check for GPE0/GPE1 overlap (if both banks exist) */
1167
1168 if ((register_count0) &&
Bob Mooref3d2e782007-02-02 19:48:18 +03001169 (gpe_number_max >= acpi_gbl_FADT.gpe1_base)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -05001170 ACPI_ERROR((AE_INFO,
1171 "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1",
Bob Mooref3d2e782007-02-02 19:48:18 +03001172 gpe_number_max, acpi_gbl_FADT.gpe1_base,
1173 acpi_gbl_FADT.gpe1_base +
Bob Mooreb8e4d892006-01-27 16:43:00 -05001174 ((register_count1 *
1175 ACPI_GPE_REGISTER_WIDTH) - 1)));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176
1177 /* Ignore GPE1 block by setting the register count to zero */
1178
1179 register_count1 = 0;
Len Brown4be44fc2005-08-05 00:44:28 -04001180 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 /* Install GPE Block 1 */
1182
Len Brown4be44fc2005-08-05 00:44:28 -04001183 status =
1184 acpi_ev_create_gpe_block(acpi_gbl_fadt_gpe_device,
Bob Mooref3d2e782007-02-02 19:48:18 +03001185 &acpi_gbl_FADT.xgpe1_block,
Len Brown4be44fc2005-08-05 00:44:28 -04001186 register_count1,
Bob Mooref3d2e782007-02-02 19:48:18 +03001187 acpi_gbl_FADT.gpe1_base,
1188 acpi_gbl_FADT.
1189 sci_interrupt,
Len Brown4be44fc2005-08-05 00:44:28 -04001190 &acpi_gbl_gpe_fadt_blocks
1191 [1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192
Len Brown4be44fc2005-08-05 00:44:28 -04001193 if (ACPI_FAILURE(status)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -05001194 ACPI_EXCEPTION((AE_INFO, status,
1195 "Could not create GPE Block 1"));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 }
1197
1198 /*
1199 * GPE0 and GPE1 do not have to be contiguous in the GPE number
1200 * space. However, GPE0 always starts at GPE number zero.
1201 */
Bob Mooref3d2e782007-02-02 19:48:18 +03001202 gpe_number_max = acpi_gbl_FADT.gpe1_base +
Len Brown4be44fc2005-08-05 00:44:28 -04001203 ((register_count1 * ACPI_GPE_REGISTER_WIDTH) - 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001204 }
1205 }
1206
1207 /* Exit if there are no GPE registers */
1208
1209 if ((register_count0 + register_count1) == 0) {
Bob Moore52fc0b02006-10-02 00:00:00 -04001210
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 /* GPEs are not required by ACPI, this is OK */
1212
Len Brown4be44fc2005-08-05 00:44:28 -04001213 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
1214 "There are no GPE blocks defined in the FADT\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 status = AE_OK;
1216 goto cleanup;
1217 }
1218
1219 /* Check for Max GPE number out-of-range */
1220
1221 if (gpe_number_max > ACPI_GPE_MAX) {
Bob Mooreb8e4d892006-01-27 16:43:00 -05001222 ACPI_ERROR((AE_INFO,
1223 "Maximum GPE number from FADT is too large: 0x%X",
1224 gpe_number_max));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 status = AE_BAD_VALUE;
1226 goto cleanup;
1227 }
1228
Len Brown4be44fc2005-08-05 00:44:28 -04001229 cleanup:
1230 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
1231 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232}