]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: evgpeblk - GPE block creation and initialization. | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
c8100dc4 | 8 | * Copyright (C) 2000 - 2016, Intel Corp. |
1da177e4 LT |
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> | |
e2f7a777 LB |
45 | #include "accommon.h" |
46 | #include "acevents.h" | |
47 | #include "acnamesp.h" | |
1da177e4 LT |
48 | |
49 | #define _COMPONENT ACPI_EVENTS | |
4be44fcd | 50 | ACPI_MODULE_NAME("evgpeblk") |
33620c54 | 51 | #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ |
44f6c012 | 52 | /* Local prototypes */ |
44f6c012 | 53 | static acpi_status |
4be44fcd LB |
54 | acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, |
55 | u32 interrupt_number); | |
44f6c012 RM |
56 | |
57 | static acpi_status | |
4be44fcd | 58 | acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block); |
1da177e4 | 59 | |
1da177e4 LT |
60 | /******************************************************************************* |
61 | * | |
62 | * FUNCTION: acpi_ev_install_gpe_block | |
63 | * | |
9f15fc66 BM |
64 | * PARAMETERS: gpe_block - New GPE block |
65 | * interrupt_number - Xrupt to be associated with this | |
66 | * GPE block | |
1da177e4 LT |
67 | * |
68 | * RETURN: Status | |
69 | * | |
70 | * DESCRIPTION: Install new GPE block with mutex support | |
71 | * | |
72 | ******************************************************************************/ | |
73 | ||
74 | static acpi_status | |
4be44fcd LB |
75 | acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, |
76 | u32 interrupt_number) | |
1da177e4 | 77 | { |
4be44fcd LB |
78 | struct acpi_gpe_block_info *next_gpe_block; |
79 | struct acpi_gpe_xrupt_info *gpe_xrupt_block; | |
80 | acpi_status status; | |
b8e4d893 | 81 | acpi_cpu_flags flags; |
1da177e4 | 82 | |
b229cf92 | 83 | ACPI_FUNCTION_TRACE(ev_install_gpe_block); |
1da177e4 | 84 | |
4be44fcd LB |
85 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
86 | if (ACPI_FAILURE(status)) { | |
87 | return_ACPI_STATUS(status); | |
1da177e4 LT |
88 | } |
89 | ||
4bec3d80 BM |
90 | status = |
91 | acpi_ev_get_gpe_xrupt_block(interrupt_number, &gpe_xrupt_block); | |
92 | if (ACPI_FAILURE(status)) { | |
1da177e4 LT |
93 | goto unlock_and_exit; |
94 | } | |
95 | ||
44f6c012 | 96 | /* Install the new block at the end of the list with lock */ |
1da177e4 | 97 | |
4be44fcd | 98 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
1da177e4 LT |
99 | if (gpe_xrupt_block->gpe_block_list_head) { |
100 | next_gpe_block = gpe_xrupt_block->gpe_block_list_head; | |
101 | while (next_gpe_block->next) { | |
102 | next_gpe_block = next_gpe_block->next; | |
103 | } | |
104 | ||
105 | next_gpe_block->next = gpe_block; | |
106 | gpe_block->previous = next_gpe_block; | |
4be44fcd | 107 | } else { |
1da177e4 LT |
108 | gpe_xrupt_block->gpe_block_list_head = gpe_block; |
109 | } | |
110 | ||
111 | gpe_block->xrupt_block = gpe_xrupt_block; | |
4be44fcd | 112 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
1da177e4 | 113 | |
10622bf8 | 114 | unlock_and_exit: |
4bec3d80 | 115 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
4be44fcd | 116 | return_ACPI_STATUS(status); |
1da177e4 LT |
117 | } |
118 | ||
1da177e4 LT |
119 | /******************************************************************************* |
120 | * | |
121 | * FUNCTION: acpi_ev_delete_gpe_block | |
122 | * | |
9f15fc66 | 123 | * PARAMETERS: gpe_block - Existing GPE block |
1da177e4 LT |
124 | * |
125 | * RETURN: Status | |
126 | * | |
127 | * DESCRIPTION: Remove a GPE block | |
128 | * | |
129 | ******************************************************************************/ | |
130 | ||
4be44fcd | 131 | acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block) |
1da177e4 | 132 | { |
4be44fcd | 133 | acpi_status status; |
b8e4d893 | 134 | acpi_cpu_flags flags; |
1da177e4 | 135 | |
b229cf92 | 136 | ACPI_FUNCTION_TRACE(ev_install_gpe_block); |
1da177e4 | 137 | |
4be44fcd LB |
138 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); |
139 | if (ACPI_FAILURE(status)) { | |
140 | return_ACPI_STATUS(status); | |
1da177e4 LT |
141 | } |
142 | ||
143 | /* Disable all GPEs in this block */ | |
144 | ||
e97d6bf1 BM |
145 | status = |
146 | acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block, NULL); | |
1da177e4 LT |
147 | |
148 | if (!gpe_block->previous && !gpe_block->next) { | |
52fc0b02 | 149 | |
1da177e4 LT |
150 | /* This is the last gpe_block on this interrupt */ |
151 | ||
4be44fcd LB |
152 | status = acpi_ev_delete_gpe_xrupt(gpe_block->xrupt_block); |
153 | if (ACPI_FAILURE(status)) { | |
1da177e4 LT |
154 | goto unlock_and_exit; |
155 | } | |
4be44fcd | 156 | } else { |
1da177e4 LT |
157 | /* Remove the block on this interrupt with lock */ |
158 | ||
4be44fcd | 159 | flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); |
1da177e4 LT |
160 | if (gpe_block->previous) { |
161 | gpe_block->previous->next = gpe_block->next; | |
4be44fcd LB |
162 | } else { |
163 | gpe_block->xrupt_block->gpe_block_list_head = | |
164 | gpe_block->next; | |
1da177e4 LT |
165 | } |
166 | ||
167 | if (gpe_block->next) { | |
168 | gpe_block->next->previous = gpe_block->previous; | |
169 | } | |
1fad8738 | 170 | |
4be44fcd | 171 | acpi_os_release_lock(acpi_gbl_gpe_lock, flags); |
1da177e4 LT |
172 | } |
173 | ||
0f849d2c | 174 | acpi_current_gpe_count -= gpe_block->gpe_count; |
e97d6bf1 | 175 | |
1da177e4 LT |
176 | /* Free the gpe_block */ |
177 | ||
8313524a BM |
178 | ACPI_FREE(gpe_block->register_info); |
179 | ACPI_FREE(gpe_block->event_info); | |
180 | ACPI_FREE(gpe_block); | |
1da177e4 | 181 | |
10622bf8 | 182 | unlock_and_exit: |
4be44fcd LB |
183 | status = acpi_ut_release_mutex(ACPI_MTX_EVENTS); |
184 | return_ACPI_STATUS(status); | |
1da177e4 LT |
185 | } |
186 | ||
1da177e4 LT |
187 | /******************************************************************************* |
188 | * | |
189 | * FUNCTION: acpi_ev_create_gpe_info_blocks | |
190 | * | |
191 | * PARAMETERS: gpe_block - New GPE block | |
192 | * | |
193 | * RETURN: Status | |
194 | * | |
195 | * DESCRIPTION: Create the register_info and event_info blocks for this GPE block | |
196 | * | |
197 | ******************************************************************************/ | |
198 | ||
199 | static acpi_status | |
4be44fcd | 200 | acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block) |
1da177e4 | 201 | { |
4be44fcd LB |
202 | struct acpi_gpe_register_info *gpe_register_info = NULL; |
203 | struct acpi_gpe_event_info *gpe_event_info = NULL; | |
204 | struct acpi_gpe_event_info *this_event; | |
205 | struct acpi_gpe_register_info *this_register; | |
67a119f9 BM |
206 | u32 i; |
207 | u32 j; | |
4be44fcd | 208 | acpi_status status; |
1da177e4 | 209 | |
b229cf92 | 210 | ACPI_FUNCTION_TRACE(ev_create_gpe_info_blocks); |
1da177e4 LT |
211 | |
212 | /* Allocate the GPE register information block */ | |
213 | ||
8313524a BM |
214 | gpe_register_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block-> |
215 | register_count * | |
216 | sizeof(struct | |
217 | acpi_gpe_register_info)); | |
1da177e4 | 218 | if (!gpe_register_info) { |
b8e4d893 | 219 | ACPI_ERROR((AE_INFO, |
b229cf92 | 220 | "Could not allocate the GpeRegisterInfo table")); |
4be44fcd | 221 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
222 | } |
223 | ||
224 | /* | |
225 | * Allocate the GPE event_info block. There are eight distinct GPEs | |
96db255c | 226 | * per register. Initialization to zeros is sufficient. |
1da177e4 | 227 | */ |
0f849d2c | 228 | gpe_event_info = ACPI_ALLOCATE_ZEROED((acpi_size) gpe_block->gpe_count * |
8313524a BM |
229 | sizeof(struct |
230 | acpi_gpe_event_info)); | |
1da177e4 | 231 | if (!gpe_event_info) { |
b8e4d893 | 232 | ACPI_ERROR((AE_INFO, |
b229cf92 | 233 | "Could not allocate the GpeEventInfo table")); |
1da177e4 LT |
234 | status = AE_NO_MEMORY; |
235 | goto error_exit; | |
236 | } | |
237 | ||
238 | /* Save the new Info arrays in the GPE block */ | |
239 | ||
240 | gpe_block->register_info = gpe_register_info; | |
4be44fcd | 241 | gpe_block->event_info = gpe_event_info; |
1da177e4 LT |
242 | |
243 | /* | |
96db255c | 244 | * Initialize the GPE Register and Event structures. A goal of these |
9f15fc66 BM |
245 | * tables is to hide the fact that there are two separate GPE register |
246 | * sets in a given GPE hardware block, the status registers occupy the | |
247 | * first half, and the enable registers occupy the second half. | |
1da177e4 LT |
248 | */ |
249 | this_register = gpe_register_info; | |
4be44fcd | 250 | this_event = gpe_event_info; |
1da177e4 LT |
251 | |
252 | for (i = 0; i < gpe_block->register_count; i++) { | |
52fc0b02 | 253 | |
1da177e4 LT |
254 | /* Init the register_info for this GPE register (8 GPEs) */ |
255 | ||
7505da4c BM |
256 | this_register->base_gpe_number = (u16) |
257 | (gpe_block->block_base_number + | |
258 | (i * ACPI_GPE_REGISTER_WIDTH)); | |
4be44fcd | 259 | |
7505da4c | 260 | this_register->status_address.address = gpe_block->address + i; |
4be44fcd | 261 | |
59fa8505 | 262 | this_register->enable_address.address = |
7505da4c | 263 | gpe_block->address + i + gpe_block->register_count; |
4be44fcd | 264 | |
7505da4c BM |
265 | this_register->status_address.space_id = gpe_block->space_id; |
266 | this_register->enable_address.space_id = gpe_block->space_id; | |
f3d2e786 | 267 | this_register->status_address.bit_width = |
4be44fcd | 268 | ACPI_GPE_REGISTER_WIDTH; |
f3d2e786 | 269 | this_register->enable_address.bit_width = |
4be44fcd | 270 | ACPI_GPE_REGISTER_WIDTH; |
ecfbbc7b BM |
271 | this_register->status_address.bit_offset = 0; |
272 | this_register->enable_address.bit_offset = 0; | |
1da177e4 LT |
273 | |
274 | /* Init the event_info for each GPE within this register */ | |
275 | ||
276 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { | |
69874165 AS |
277 | this_event->gpe_number = |
278 | (u8) (this_register->base_gpe_number + j); | |
1da177e4 LT |
279 | this_event->register_info = this_register; |
280 | this_event++; | |
281 | } | |
282 | ||
96db255c BM |
283 | /* Disable all GPEs within this register */ |
284 | ||
c6b5774c | 285 | status = acpi_hw_write(0x00, &this_register->enable_address); |
4be44fcd | 286 | if (ACPI_FAILURE(status)) { |
1da177e4 LT |
287 | goto error_exit; |
288 | } | |
289 | ||
96db255c BM |
290 | /* Clear any pending GPE events within this register */ |
291 | ||
c6b5774c | 292 | status = acpi_hw_write(0xFF, &this_register->status_address); |
4be44fcd | 293 | if (ACPI_FAILURE(status)) { |
1da177e4 LT |
294 | goto error_exit; |
295 | } | |
296 | ||
297 | this_register++; | |
298 | } | |
299 | ||
4be44fcd | 300 | return_ACPI_STATUS(AE_OK); |
1da177e4 | 301 | |
10622bf8 | 302 | error_exit: |
1da177e4 | 303 | if (gpe_register_info) { |
8313524a | 304 | ACPI_FREE(gpe_register_info); |
1da177e4 LT |
305 | } |
306 | if (gpe_event_info) { | |
8313524a | 307 | ACPI_FREE(gpe_event_info); |
1da177e4 LT |
308 | } |
309 | ||
4be44fcd | 310 | return_ACPI_STATUS(status); |
1da177e4 LT |
311 | } |
312 | ||
1da177e4 LT |
313 | /******************************************************************************* |
314 | * | |
315 | * FUNCTION: acpi_ev_create_gpe_block | |
316 | * | |
317 | * PARAMETERS: gpe_device - Handle to the parent GPE block | |
ba494bee | 318 | * gpe_block_address - Address and space_ID |
1da177e4 LT |
319 | * register_count - Number of GPE register pairs in the block |
320 | * gpe_block_base_number - Starting GPE number for the block | |
6f42ccf2 | 321 | * interrupt_number - H/W interrupt for the block |
1da177e4 LT |
322 | * return_gpe_block - Where the new block descriptor is returned |
323 | * | |
324 | * RETURN: Status | |
325 | * | |
96db255c BM |
326 | * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within |
327 | * the block are disabled at exit. | |
328 | * Note: Assumes namespace is locked. | |
1da177e4 LT |
329 | * |
330 | ******************************************************************************/ | |
331 | ||
332 | acpi_status | |
4be44fcd | 333 | acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device, |
7505da4c BM |
334 | u64 address, |
335 | u8 space_id, | |
4be44fcd | 336 | u32 register_count, |
7505da4c | 337 | u16 gpe_block_base_number, |
4be44fcd LB |
338 | u32 interrupt_number, |
339 | struct acpi_gpe_block_info **return_gpe_block) | |
1da177e4 | 340 | { |
4be44fcd | 341 | acpi_status status; |
96db255c | 342 | struct acpi_gpe_block_info *gpe_block; |
186c307f | 343 | struct acpi_gpe_walk_info walk_info; |
1da177e4 | 344 | |
b229cf92 | 345 | ACPI_FUNCTION_TRACE(ev_create_gpe_block); |
1da177e4 LT |
346 | |
347 | if (!register_count) { | |
4be44fcd | 348 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
349 | } |
350 | ||
351 | /* Allocate a new GPE block */ | |
352 | ||
8313524a | 353 | gpe_block = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_gpe_block_info)); |
1da177e4 | 354 | if (!gpe_block) { |
4be44fcd | 355 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
356 | } |
357 | ||
358 | /* Initialize the new GPE block */ | |
359 | ||
7505da4c BM |
360 | gpe_block->address = address; |
361 | gpe_block->space_id = space_id; | |
96db255c | 362 | gpe_block->node = gpe_device; |
0f849d2c | 363 | gpe_block->gpe_count = (u16)(register_count * ACPI_GPE_REGISTER_WIDTH); |
da503373 | 364 | gpe_block->initialized = FALSE; |
1da177e4 LT |
365 | gpe_block->register_count = register_count; |
366 | gpe_block->block_base_number = gpe_block_base_number; | |
1da177e4 | 367 | |
96db255c BM |
368 | /* |
369 | * Create the register_info and event_info sub-structures | |
370 | * Note: disables and clears all GPEs in the block | |
371 | */ | |
4be44fcd LB |
372 | status = acpi_ev_create_gpe_info_blocks(gpe_block); |
373 | if (ACPI_FAILURE(status)) { | |
8313524a | 374 | ACPI_FREE(gpe_block); |
4be44fcd | 375 | return_ACPI_STATUS(status); |
1da177e4 LT |
376 | } |
377 | ||
96db255c | 378 | /* Install the new block in the global lists */ |
1da177e4 | 379 | |
4be44fcd LB |
380 | status = acpi_ev_install_gpe_block(gpe_block, interrupt_number); |
381 | if (ACPI_FAILURE(status)) { | |
b739f106 TN |
382 | ACPI_FREE(gpe_block->register_info); |
383 | ACPI_FREE(gpe_block->event_info); | |
8313524a | 384 | ACPI_FREE(gpe_block); |
4be44fcd | 385 | return_ACPI_STATUS(status); |
1da177e4 LT |
386 | } |
387 | ||
3a37898d | 388 | acpi_gbl_all_gpes_initialized = FALSE; |
a2100801 | 389 | |
186c307f BM |
390 | /* Find all GPE methods (_Lxx or_Exx) for this block */ |
391 | ||
392 | walk_info.gpe_block = gpe_block; | |
393 | walk_info.gpe_device = gpe_device; | |
186c307f | 394 | walk_info.execute_by_owner_id = FALSE; |
1da177e4 | 395 | |
4be44fcd LB |
396 | status = acpi_ns_walk_namespace(ACPI_TYPE_METHOD, gpe_device, |
397 | ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, | |
0f849d2c | 398 | acpi_ev_match_gpe_method, NULL, |
186c307f | 399 | &walk_info, NULL); |
1da177e4 | 400 | |
96db255c BM |
401 | /* Return the new block */ |
402 | ||
403 | if (return_gpe_block) { | |
404 | (*return_gpe_block) = gpe_block; | |
405 | } | |
406 | ||
3e5621a7 | 407 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, |
7505da4c | 408 | " Initialized GPE %02X to %02X [%4.4s] %u regs on interrupt 0x%X%s\n", |
3e5621a7 BM |
409 | (u32)gpe_block->block_base_number, |
410 | (u32)(gpe_block->block_base_number + | |
411 | (gpe_block->gpe_count - 1)), | |
412 | gpe_device->name.ascii, gpe_block->register_count, | |
7505da4c BM |
413 | interrupt_number, |
414 | interrupt_number == | |
415 | acpi_gbl_FADT.sci_interrupt ? " (SCI)" : "")); | |
96db255c | 416 | |
e97d6bf1 BM |
417 | /* Update global count of currently available GPEs */ |
418 | ||
0f849d2c | 419 | acpi_current_gpe_count += gpe_block->gpe_count; |
96db255c BM |
420 | return_ACPI_STATUS(AE_OK); |
421 | } | |
422 | ||
423 | /******************************************************************************* | |
424 | * | |
425 | * FUNCTION: acpi_ev_initialize_gpe_block | |
426 | * | |
da503373 | 427 | * PARAMETERS: acpi_gpe_callback |
96db255c BM |
428 | * |
429 | * RETURN: Status | |
430 | * | |
da503373 LM |
431 | * DESCRIPTION: Initialize and enable a GPE block. Enable GPEs that have |
432 | * associated methods. | |
96db255c BM |
433 | * Note: Assumes namespace is locked. |
434 | * | |
435 | ******************************************************************************/ | |
436 | ||
437 | acpi_status | |
a2100801 RW |
438 | acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, |
439 | struct acpi_gpe_block_info *gpe_block, | |
440 | void *ignored) | |
96db255c | 441 | { |
0f849d2c | 442 | acpi_status status; |
96db255c | 443 | struct acpi_gpe_event_info *gpe_event_info; |
96db255c | 444 | u32 gpe_enabled_count; |
0f849d2c | 445 | u32 gpe_index; |
67a119f9 BM |
446 | u32 i; |
447 | u32 j; | |
96db255c | 448 | |
b229cf92 | 449 | ACPI_FUNCTION_TRACE(ev_initialize_gpe_block); |
96db255c | 450 | |
a2100801 | 451 | /* |
da503373 LM |
452 | * Ignore a null GPE block (e.g., if no GPE block 1 exists), and |
453 | * any GPE blocks that have been initialized already. | |
a2100801 RW |
454 | */ |
455 | if (!gpe_block || gpe_block->initialized) { | |
96db255c BM |
456 | return_ACPI_STATUS(AE_OK); |
457 | } | |
458 | ||
1da177e4 | 459 | /* |
a2100801 | 460 | * Enable all GPEs that have a corresponding method and have the |
da503373 LM |
461 | * ACPI_GPE_CAN_WAKE flag unset. Any other GPEs within this block |
462 | * must be enabled via the acpi_enable_gpe() interface. | |
1da177e4 | 463 | */ |
1da177e4 | 464 | gpe_enabled_count = 0; |
0f849d2c | 465 | |
1da177e4 | 466 | for (i = 0; i < gpe_block->register_count; i++) { |
9630bdd9 | 467 | for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) { |
52fc0b02 | 468 | |
1da177e4 | 469 | /* Get the info block for this particular GPE */ |
0f849d2c LM |
470 | |
471 | gpe_index = (i * ACPI_GPE_REGISTER_WIDTH) + j; | |
9630bdd9 | 472 | gpe_event_info = &gpe_block->event_info[gpe_index]; |
ce43ace0 | 473 | |
bba63a29 LM |
474 | /* |
475 | * Ignore GPEs that have no corresponding _Lxx/_Exx method | |
476 | * and GPEs that are used to wake the system | |
477 | */ | |
7c43312a | 478 | if ((ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
bba63a29 | 479 | ACPI_GPE_DISPATCH_NONE) |
7c43312a LZ |
480 | || (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
481 | ACPI_GPE_DISPATCH_HANDLER) | |
0d0988af LZ |
482 | || (ACPI_GPE_DISPATCH_TYPE(gpe_event_info->flags) == |
483 | ACPI_GPE_DISPATCH_RAW_HANDLER) | |
a2100801 | 484 | || (gpe_event_info->flags & ACPI_GPE_CAN_WAKE)) { |
9630bdd9 | 485 | continue; |
0f849d2c LM |
486 | } |
487 | ||
3a37898d | 488 | status = acpi_ev_add_gpe_reference(gpe_event_info); |
0f849d2c LM |
489 | if (ACPI_FAILURE(status)) { |
490 | ACPI_EXCEPTION((AE_INFO, status, | |
a2100801 | 491 | "Could not enable GPE 0x%02X", |
1f86e8c1 LZ |
492 | gpe_index + |
493 | gpe_block->block_base_number)); | |
0f849d2c LM |
494 | continue; |
495 | } | |
496 | ||
497 | gpe_enabled_count++; | |
1da177e4 LT |
498 | } |
499 | } | |
500 | ||
9874647b | 501 | if (gpe_enabled_count) { |
3e5621a7 BM |
502 | ACPI_INFO((AE_INFO, |
503 | "Enabled %u GPEs in block %02X to %02X", | |
504 | gpe_enabled_count, (u32)gpe_block->block_base_number, | |
505 | (u32)(gpe_block->block_base_number + | |
506 | (gpe_block->gpe_count - 1)))); | |
186c307f | 507 | } |
1da177e4 | 508 | |
a2100801 RW |
509 | gpe_block->initialized = TRUE; |
510 | ||
9630bdd9 | 511 | return_ACPI_STATUS(AE_OK); |
1da177e4 | 512 | } |
33620c54 BM |
513 | |
514 | #endif /* !ACPI_REDUCED_HARDWARE */ |