Deleted Added
full compact
hwgpe.c (128212) hwgpe.c (129684)
1
2/******************************************************************************
3 *
4 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
1
2/******************************************************************************
3 *
4 * Module Name: hwgpe - Low level GPE enable/disable/clear functions
5 * $Revision: 57 $
5 * $Revision: 62 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.

--- 105 unchanged lines hidden (view full) ---

119#include "acevents.h"
120
121#define _COMPONENT ACPI_HARDWARE
122 ACPI_MODULE_NAME ("hwgpe")
123
124
125/******************************************************************************
126 *
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.

--- 105 unchanged lines hidden (view full) ---

119#include "acevents.h"
120
121#define _COMPONENT ACPI_HARDWARE
122 ACPI_MODULE_NAME ("hwgpe")
123
124
125/******************************************************************************
126 *
127 * FUNCTION: AcpiHwEnableGpe
127 * FUNCTION: AcpiHwWriteGpeEnableReg
128 *
129 * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled
130 *
131 * RETURN: Status
132 *
128 *
129 * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled
130 *
131 * RETURN: Status
132 *
133 * DESCRIPTION: Enable a single GPE.
133 * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must
134 * already be cleared or set in the parent register
135 * EnableForRun mask.
134 *
135 ******************************************************************************/
136
137ACPI_STATUS
136 *
137 ******************************************************************************/
138
139ACPI_STATUS
138AcpiHwEnableGpe (
140AcpiHwWriteGpeEnableReg (
139 ACPI_GPE_EVENT_INFO *GpeEventInfo)
140{
141 ACPI_GPE_EVENT_INFO *GpeEventInfo)
142{
141 UINT32 InByte;
142 ACPI_STATUS Status;
143
144
145 ACPI_FUNCTION_ENTRY ();
146
147
148 /*
149 * Read the current value of the register, set the appropriate bit
150 * to enable the GPE, and write out the new register.
151 */
152 Status = AcpiHwLowLevelRead (8, &InByte,
153 &GpeEventInfo->RegisterInfo->EnableAddress);
154 if (ACPI_FAILURE (Status))
155 {
156 return (Status);
157 }
158
159 /* Write with the new GPE bit enabled */
160
161 Status = AcpiHwLowLevelWrite (8, (InByte | GpeEventInfo->BitMask),
162 &GpeEventInfo->RegisterInfo->EnableAddress);
163
164 return (Status);
165}
166
167
168/******************************************************************************
169 *
170 * FUNCTION: AcpiHwEnableGpeForWakeup
171 *
172 * PARAMETERS: GpeEventInfo - Info block for the GPE to be enabled
173 *
174 * RETURN: None
175 *
176 * DESCRIPTION: Keep track of which GPEs the OS has requested not be
177 * disabled when going to sleep.
178 *
179 ******************************************************************************/
180
181void
182AcpiHwEnableGpeForWakeup (
183 ACPI_GPE_EVENT_INFO *GpeEventInfo)
184{
185 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
143 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
186
187
188 ACPI_FUNCTION_ENTRY ();
189
190
191 /* Get the info block for the entire GPE register */
192
193 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
194 if (!GpeRegisterInfo)
195 {
196 return;
197 }
198
199 /*
200 * Set the bit so we will not enable this GPE when sleeping (and disable
201 * it upon wake)
202 */
203 GpeRegisterInfo->WakeEnable |= GpeEventInfo->BitMask;
204 GpeEventInfo->Flags |= (ACPI_GPE_TYPE_WAKE | ACPI_GPE_ENABLED);
205}
206
207
208/******************************************************************************
209 *
210 * FUNCTION: AcpiHwDisableGpe
211 *
212 * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled
213 *
214 * RETURN: Status
215 *
216 * DESCRIPTION: Disable a single GPE.
217 *
218 ******************************************************************************/
219
220ACPI_STATUS
221AcpiHwDisableGpe (
222 ACPI_GPE_EVENT_INFO *GpeEventInfo)
223{
224 UINT32 InByte;
225 ACPI_STATUS Status;
144 ACPI_STATUS Status;
226 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
227
228
229 ACPI_FUNCTION_ENTRY ();
230
231
232 /* Get the info block for the entire GPE register */
233
234 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
235 if (!GpeRegisterInfo)
236 {
145
146
147 ACPI_FUNCTION_ENTRY ();
148
149
150 /* Get the info block for the entire GPE register */
151
152 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
153 if (!GpeRegisterInfo)
154 {
237 return (AE_BAD_PARAMETER);
155 return (AE_NOT_EXIST);
238 }
239
156 }
157
240 /*
241 * Read the current value of the register, clear the appropriate bit,
242 * and write out the new register value to disable the GPE.
243 */
244 Status = AcpiHwLowLevelRead (8, &InByte,
245 &GpeRegisterInfo->EnableAddress);
246 if (ACPI_FAILURE (Status))
247 {
248 return (Status);
249 }
158 /* Write the entire GPE (runtime) enable register */
250
159
251 /* Write the byte with this GPE bit cleared */
252
253 Status = AcpiHwLowLevelWrite (8, (InByte & ~(GpeEventInfo->BitMask)),
160 Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->EnableForRun,
254 &GpeRegisterInfo->EnableAddress);
161 &GpeRegisterInfo->EnableAddress);
255 if (ACPI_FAILURE (Status))
256 {
257 return (Status);
258 }
259
162
260 /* Make sure this GPE is disabled for wake, also */
261
262 AcpiHwDisableGpeForWakeup (GpeEventInfo);
263 return (AE_OK);
163 return (Status);
264}
265
266
267/******************************************************************************
268 *
164}
165
166
167/******************************************************************************
168 *
269 * FUNCTION: AcpiHwDisableGpeForWakeup
270 *
271 * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled
272 *
273 * RETURN: None
274 *
275 * DESCRIPTION: Keep track of which GPEs the OS has requested not be
276 * disabled when going to sleep.
277 *
278 ******************************************************************************/
279
280void
281AcpiHwDisableGpeForWakeup (
282 ACPI_GPE_EVENT_INFO *GpeEventInfo)
283{
284 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
285
286
287 ACPI_FUNCTION_ENTRY ();
288
289
290 /* Get the info block for the entire GPE register */
291
292 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
293 if (!GpeRegisterInfo)
294 {
295 return;
296 }
297
298 /* Clear the bit so we will disable this when sleeping */
299
300 GpeRegisterInfo->WakeEnable &= ~(GpeEventInfo->BitMask);
301}
302
303
304/******************************************************************************
305 *
306 * FUNCTION: AcpiHwClearGpe
307 *
308 * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared
309 *
310 * RETURN: StatusStatus
311 *
312 * DESCRIPTION: Clear the status bit for a single GPE.
313 *

--- 8 unchanged lines hidden (view full) ---

322
323 ACPI_FUNCTION_ENTRY ();
324
325
326 /*
327 * Write a one to the appropriate bit in the status register to
328 * clear this GPE.
329 */
169 * FUNCTION: AcpiHwClearGpe
170 *
171 * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared
172 *
173 * RETURN: StatusStatus
174 *
175 * DESCRIPTION: Clear the status bit for a single GPE.
176 *

--- 8 unchanged lines hidden (view full) ---

185
186 ACPI_FUNCTION_ENTRY ();
187
188
189 /*
190 * Write a one to the appropriate bit in the status register to
191 * clear this GPE.
192 */
330 Status = AcpiHwLowLevelWrite (8, GpeEventInfo->BitMask,
193 Status = AcpiHwLowLevelWrite (8, GpeEventInfo->RegisterBit,
331 &GpeEventInfo->RegisterInfo->StatusAddress);
332
333 return (Status);
334}
335
336
337/******************************************************************************
338 *

--- 9 unchanged lines hidden (view full) ---

348 ******************************************************************************/
349
350ACPI_STATUS
351AcpiHwGetGpeStatus (
352 ACPI_GPE_EVENT_INFO *GpeEventInfo,
353 ACPI_EVENT_STATUS *EventStatus)
354{
355 UINT32 InByte;
194 &GpeEventInfo->RegisterInfo->StatusAddress);
195
196 return (Status);
197}
198
199
200/******************************************************************************
201 *

--- 9 unchanged lines hidden (view full) ---

211 ******************************************************************************/
212
213ACPI_STATUS
214AcpiHwGetGpeStatus (
215 ACPI_GPE_EVENT_INFO *GpeEventInfo,
216 ACPI_EVENT_STATUS *EventStatus)
217{
218 UINT32 InByte;
356 UINT8 BitMask;
219 UINT8 RegisterBit;
357 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
358 ACPI_STATUS Status;
359 ACPI_EVENT_STATUS LocalEventStatus = 0;
360
361
362 ACPI_FUNCTION_ENTRY ();
363
364
365 if (!EventStatus)
366 {
367 return (AE_BAD_PARAMETER);
368 }
369
370 /* Get the info block for the entire GPE register */
371
372 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
373
374 /* Get the register bitmask for this GPE */
375
220 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
221 ACPI_STATUS Status;
222 ACPI_EVENT_STATUS LocalEventStatus = 0;
223
224
225 ACPI_FUNCTION_ENTRY ();
226
227
228 if (!EventStatus)
229 {
230 return (AE_BAD_PARAMETER);
231 }
232
233 /* Get the info block for the entire GPE register */
234
235 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
236
237 /* Get the register bitmask for this GPE */
238
376 BitMask = GpeEventInfo->BitMask;
239 RegisterBit = GpeEventInfo->RegisterBit;
377
240
378 /* GPE Enabled? */
241 /* GPE currently enabled? (enabled for runtime?) */
379
242
380 Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->EnableAddress);
381 if (ACPI_FAILURE (Status))
243 if (RegisterBit & GpeRegisterInfo->EnableForRun)
382 {
244 {
383 goto UnlockAndExit;
384 }
385
386 if (BitMask & InByte)
387 {
388 LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
389 }
390
245 LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
246 }
247
391 /* GPE Enabled for wake? */
248 /* GPE enabled for wake? */
392
249
393 if (BitMask & GpeRegisterInfo->WakeEnable)
250 if (RegisterBit & GpeRegisterInfo->EnableForWake)
394 {
395 LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
396 }
397
251 {
252 LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
253 }
254
398 /* GPE active (set)? */
255 /* GPE currently active (status bit == 1)? */
399
400 Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress);
401 if (ACPI_FAILURE (Status))
402 {
403 goto UnlockAndExit;
404 }
405
256
257 Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress);
258 if (ACPI_FAILURE (Status))
259 {
260 goto UnlockAndExit;
261 }
262
406 if (BitMask & InByte)
263 if (RegisterBit & InByte)
407 {
408 LocalEventStatus |= ACPI_EVENT_FLAG_SET;
409 }
410
411 /* Set return value */
412
413 (*EventStatus) = LocalEventStatus;
414

--- 80 unchanged lines hidden (view full) ---

495 }
496
497 return (AE_OK);
498}
499
500
501/******************************************************************************
502 *
264 {
265 LocalEventStatus |= ACPI_EVENT_FLAG_SET;
266 }
267
268 /* Set return value */
269
270 (*EventStatus) = LocalEventStatus;
271

--- 80 unchanged lines hidden (view full) ---

352 }
353
354 return (AE_OK);
355}
356
357
358/******************************************************************************
359 *
503 * FUNCTION: AcpiHwPrepareGpeBlockForSleep
360 * FUNCTION: AcpiHwEnableRuntimeGpeBlock
504 *
505 * PARAMETERS: GpeXruptInfo - GPE Interrupt info
506 * GpeBlock - Gpe Block info
507 *
508 * RETURN: Status
509 *
361 *
362 * PARAMETERS: GpeXruptInfo - GPE Interrupt info
363 * GpeBlock - Gpe Block info
364 *
365 * RETURN: Status
366 *
510 * DESCRIPTION: Disable all runtime GPEs and enable all wakeup GPEs -- within
511 * a single GPE block
367 * DESCRIPTION: Enable all "runtime" GPEs within a GPE block. (Includes
368 * combination wake/run GPEs.)
512 *
513 ******************************************************************************/
514
369 *
370 ******************************************************************************/
371
515static ACPI_STATUS
516AcpiHwPrepareGpeBlockForSleep (
372ACPI_STATUS
373AcpiHwEnableRuntimeGpeBlock (
517 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
518 ACPI_GPE_BLOCK_INFO *GpeBlock)
519{
520 UINT32 i;
374 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
375 ACPI_GPE_BLOCK_INFO *GpeBlock)
376{
377 UINT32 i;
521 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
522 UINT32 InValue;
523 ACPI_STATUS Status;
524
525
378 ACPI_STATUS Status;
379
380
526 /* Get the register info for the entire GPE block */
381 /* NOTE: assumes that all GPEs are currently disabled */
527
382
528 GpeRegisterInfo = GpeBlock->RegisterInfo;
529
530 /* Examine each GPE Register within the block */
531
532 for (i = 0; i < GpeBlock->RegisterCount; i++)
533 {
383 /* Examine each GPE Register within the block */
384
385 for (i = 0; i < GpeBlock->RegisterCount; i++)
386 {
534 /*
535 * Read the enabled/disabled status of all GPEs. We
536 * will be using it to restore all the GPEs later.
537 *
538 * NOTE: Wake GPEs are are ALL disabled at this time, so when we wake
539 * and restore this register, they will be automatically disabled.
540 */
541 Status = AcpiHwLowLevelRead (8, &InValue,
542 &GpeRegisterInfo->EnableAddress);
543 if (ACPI_FAILURE (Status))
387 if (!GpeBlock->RegisterInfo[i].EnableForRun)
544 {
388 {
545 return (Status);
389 continue;
546 }
547
390 }
391
548 GpeRegisterInfo->Enable = (UINT8) InValue;
392 /* Enable all "runtime" GPEs in this register */
549
393
550 /*
551 * 1) Disable all runtime GPEs
552 * 2) Enable all wakeup GPEs
553 */
554 Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable,
555 &GpeRegisterInfo->EnableAddress);
394 Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForRun,
395 &GpeBlock->RegisterInfo[i].EnableAddress);
556 if (ACPI_FAILURE (Status))
557 {
558 return (Status);
559 }
396 if (ACPI_FAILURE (Status))
397 {
398 return (Status);
399 }
560
561 /* Point to next GPE register */
562
563 GpeRegisterInfo++;
564 }
565
566 return (AE_OK);
567}
568
569
570/******************************************************************************
571 *
400 }
401
402 return (AE_OK);
403}
404
405
406/******************************************************************************
407 *
572 * FUNCTION: AcpiHwPrepareGpesForSleep
408 * FUNCTION: AcpiHwEnableWakeupGpeBlock
573 *
409 *
574 * PARAMETERS: None
410 * PARAMETERS: GpeXruptInfo - GPE Interrupt info
411 * GpeBlock - Gpe Block info
575 *
576 * RETURN: Status
577 *
412 *
413 * RETURN: Status
414 *
578 * DESCRIPTION: Disable all runtime GPEs, enable all wake GPEs.
579 * Called with interrupts disabled. The interrupt handler also
580 * modifies GpeRegisterInfo->Enable, so it should not be
581 * given the chance to run until after the runtime GPEs are
582 * re-enabled.
415 * DESCRIPTION: Enable all "wake" GPEs within a GPE block. (Includes
416 * combination wake/run GPEs.)
583 *
584 ******************************************************************************/
585
586ACPI_STATUS
417 *
418 ******************************************************************************/
419
420ACPI_STATUS
587AcpiHwPrepareGpesForSleep (
588 void)
421AcpiHwEnableWakeupGpeBlock (
422 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
423 ACPI_GPE_BLOCK_INFO *GpeBlock)
589{
424{
425 UINT32 i;
590 ACPI_STATUS Status;
591
592
426 ACPI_STATUS Status;
427
428
593 ACPI_FUNCTION_ENTRY ();
429 /* Examine each GPE Register within the block */
594
430
431 for (i = 0; i < GpeBlock->RegisterCount; i++)
432 {
433 if (!GpeBlock->RegisterInfo[i].EnableForWake)
434 {
435 continue;
436 }
595
437
596 Status = AcpiEvWalkGpeList (AcpiHwPrepareGpeBlockForSleep);
597 return (Status);
438 /* Enable all "wake" GPEs in this register */
439
440 Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForWake,
441 &GpeBlock->RegisterInfo[i].EnableAddress);
442 if (ACPI_FAILURE (Status))
443 {
444 return (Status);
445 }
446 }
447
448 return (AE_OK);
598}
599
600
601/******************************************************************************
602 *
449}
450
451
452/******************************************************************************
453 *
603 * FUNCTION: AcpiHwRestoreGpeBlockOnWake
454 * FUNCTION: AcpiHwDisableAllGpes
604 *
455 *
605 * PARAMETERS: GpeXruptInfo - GPE Interrupt info
606 * GpeBlock - Gpe Block info
456 * PARAMETERS: None
607 *
608 * RETURN: Status
609 *
457 *
458 * RETURN: Status
459 *
610 * DESCRIPTION: Enable all runtime GPEs and disable all wake GPEs -- in one
611 * GPE block
460 * DESCRIPTION: Disable and clear all GPEs
612 *
613 ******************************************************************************/
614
461 *
462 ******************************************************************************/
463
615static ACPI_STATUS
616AcpiHwRestoreGpeBlockOnWake (
617 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
618 ACPI_GPE_BLOCK_INFO *GpeBlock)
464ACPI_STATUS
465AcpiHwDisableAllGpes (
466 void)
619{
467{
620 UINT32 i;
621 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
622 ACPI_STATUS Status;
623
624
468 ACPI_STATUS Status;
469
470
625 /* This callback processes one entire GPE block */
471 ACPI_FUNCTION_TRACE ("HwDisableAllGpes");
626
472
627 /* Get the register info for the entire GPE block */
628
473
629 GpeRegisterInfo = GpeBlock->RegisterInfo;
474 Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock);
475 Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock);
476 return_ACPI_STATUS (Status);
477}
630
478
631 /* Examine each GPE register within the block */
632
479
633 for (i = 0; i < GpeBlock->RegisterCount; i++)
634 {
635 /* Clear the entire status register */
480/******************************************************************************
481 *
482 * FUNCTION: AcpiHwEnableAllRuntimeGpes
483 *
484 * PARAMETERS: None
485 *
486 * RETURN: Status
487 *
488 * DESCRIPTION: Enable all GPEs of the given type
489 *
490 ******************************************************************************/
636
491
637 Status = AcpiHwLowLevelWrite (8, 0xFF,
638 &GpeBlock->RegisterInfo[i].StatusAddress);
639 if (ACPI_FAILURE (Status))
640 {
641 return (Status);
642 }
492ACPI_STATUS
493AcpiHwEnableAllRuntimeGpes (
494 void)
495{
496 ACPI_STATUS Status;
643
497
644 /*
645 * Restore the GPE Enable register, which will do the following:
646 *
647 * 1) Disable all wakeup GPEs
648 * 2) Enable all runtime GPEs
649 *
650 * (On sleep, we saved the enabled status of all GPEs)
651 */
652 Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable,
653 &GpeRegisterInfo->EnableAddress);
654 if (ACPI_FAILURE (Status))
655 {
656 return (Status);
657 }
658
498
659 /* Point to next GPE register */
499 ACPI_FUNCTION_TRACE ("HwEnableAllRuntimeGpes");
660
500
661 GpeRegisterInfo++;
662 }
663
501
664 return (AE_OK);
502 Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock);
503 return_ACPI_STATUS (Status);
665}
666
667
668/******************************************************************************
669 *
504}
505
506
507/******************************************************************************
508 *
670 * FUNCTION: AcpiHwRestoreGpesOnWake
509 * FUNCTION: AcpiHwEnableAllWakeupGpes
671 *
672 * PARAMETERS: None
673 *
674 * RETURN: Status
675 *
510 *
511 * PARAMETERS: None
512 *
513 * RETURN: Status
514 *
676 * DESCRIPTION: Enable all runtime GPEs and disable all wake GPEs -- in all
677 * GPE blocks
515 * DESCRIPTION: Enable all GPEs of the given type
678 *
679 ******************************************************************************/
680
681ACPI_STATUS
516 *
517 ******************************************************************************/
518
519ACPI_STATUS
682AcpiHwRestoreGpesOnWake (
520AcpiHwEnableAllWakeupGpes (
683 void)
684{
685 ACPI_STATUS Status;
686
687
521 void)
522{
523 ACPI_STATUS Status;
524
525
688 ACPI_FUNCTION_ENTRY ();
526 ACPI_FUNCTION_TRACE ("HwEnableAllWakeupGpes");
689
690
527
528
691 Status = AcpiEvWalkGpeList (AcpiHwRestoreGpeBlockOnWake);
692 return (Status);
529 Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock);
530 return_ACPI_STATUS (Status);
693}
531}
532