Rev 1498 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | 6 | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
Line 116... | Line 116... | ||
116 | 116 | ||
Line 117... | Line 117... | ||
117 | #define __EVXFEVNT_C__ |
117 | #define __EVXFEVNT_C__ |
118 | 118 | ||
119 | #include "acpi.h" |
- | |
120 | #include "accommon.h" |
- | |
121 | #include "acevents.h" |
119 | #include "acpi.h" |
Line 122... | Line 120... | ||
122 | #include "acnamesp.h" |
120 | #include "accommon.h" |
123 | #include "actables.h" |
121 | #include "actables.h" |
Line 124... | Line -... | ||
124 | - | ||
125 | #define _COMPONENT ACPI_EVENTS |
- | |
126 | ACPI_MODULE_NAME ("evxfevnt") |
- | |
127 | - | ||
128 | /* Local prototypes */ |
- | |
129 | - | ||
130 | static ACPI_STATUS |
- | |
131 | AcpiEvGetGpeDevice ( |
- | |
Line 132... | Line 122... | ||
132 | ACPI_GPE_XRUPT_INFO *GpeXruptInfo, |
122 | |
133 | ACPI_GPE_BLOCK_INFO *GpeBlock, |
123 | #define _COMPONENT ACPI_EVENTS |
134 | void *Context); |
124 | ACPI_MODULE_NAME ("evxfevnt") |
135 | 125 | ||
Line 305... | Line 295... | ||
305 | ACPI_EXPORT_SYMBOL (AcpiEnableEvent) |
295 | ACPI_EXPORT_SYMBOL (AcpiEnableEvent) |
Line 306... | Line 296... | ||
306 | 296 | ||
307 | 297 | ||
308 | /******************************************************************************* |
- | |
309 | * |
- | |
310 | * FUNCTION: AcpiEnableGpe |
- | |
311 | * |
- | |
312 | * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 |
- | |
313 | * GpeNumber - GPE level within the GPE block |
- | |
314 | * GpeType - ACPI_GPE_TYPE_RUNTIME or ACPI_GPE_TYPE_WAKE |
- | |
315 | * or both |
- | |
316 | * |
- | |
317 | * RETURN: Status |
- | |
318 | * |
- | |
319 | * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is |
- | |
320 | * hardware-enabled (for runtime GPEs), or the GPE register mask |
- | |
321 | * is updated (for wake GPEs). |
- | |
322 | * |
- | |
323 | ******************************************************************************/ |
- | |
324 | - | ||
325 | ACPI_STATUS |
- | |
326 | AcpiEnableGpe ( |
- | |
327 | ACPI_HANDLE GpeDevice, |
- | |
328 | UINT32 GpeNumber, |
- | |
329 | UINT8 GpeType) |
- | |
330 | { |
- | |
331 | ACPI_STATUS Status = AE_OK; |
- | |
332 | ACPI_GPE_EVENT_INFO *GpeEventInfo; |
- | |
333 | ACPI_CPU_FLAGS Flags; |
- | |
334 | - | ||
335 | - | ||
336 | ACPI_FUNCTION_TRACE (AcpiEnableGpe); |
- | |
337 | - | ||
338 | - | ||
339 | /* Parameter validation */ |
- | |
340 | - | ||
341 | if (!GpeType || (GpeType & ~ACPI_GPE_TYPE_WAKE_RUN)) |
- | |
342 | { |
- | |
343 | return_ACPI_STATUS (AE_BAD_PARAMETER); |
- | |
344 | } |
- | |
345 | - | ||
346 | Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); |
- | |
347 | - | ||
348 | /* Ensure that we have a valid GPE number */ |
- | |
349 | - | ||
350 | GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); |
- | |
351 | if (!GpeEventInfo) |
- | |
352 | { |
- | |
353 | Status = AE_BAD_PARAMETER; |
- | |
354 | goto UnlockAndExit; |
- | |
355 | } |
- | |
356 | - | ||
357 | if (GpeType & ACPI_GPE_TYPE_RUNTIME) |
- | |
358 | { |
- | |
359 | if (GpeEventInfo->RuntimeCount == ACPI_UINT8_MAX) |
- | |
360 | { |
- | |
361 | Status = AE_LIMIT; /* Too many references */ |
- | |
362 | goto UnlockAndExit; |
- | |
363 | } |
- | |
364 | - | ||
365 | GpeEventInfo->RuntimeCount++; |
- | |
366 | if (GpeEventInfo->RuntimeCount == 1) |
- | |
367 | { |
- | |
368 | Status = AcpiEvEnableGpe (GpeEventInfo); |
- | |
369 | if (ACPI_FAILURE (Status)) |
- | |
370 | { |
- | |
371 | GpeEventInfo->RuntimeCount--; |
- | |
372 | goto UnlockAndExit; |
- | |
373 | } |
- | |
374 | } |
- | |
375 | } |
- | |
376 | - | ||
377 | if (GpeType & ACPI_GPE_TYPE_WAKE) |
- | |
378 | { |
- | |
379 | /* The GPE must have the ability to wake the system */ |
- | |
380 | - | ||
381 | if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)) |
- | |
382 | { |
- | |
383 | Status = AE_TYPE; |
- | |
384 | goto UnlockAndExit; |
- | |
385 | } |
- | |
386 | - | ||
387 | if (GpeEventInfo->WakeupCount == ACPI_UINT8_MAX) |
- | |
388 | { |
- | |
389 | Status = AE_LIMIT; /* Too many references */ |
- | |
390 | goto UnlockAndExit; |
- | |
391 | } |
- | |
392 | - | ||
393 | /* |
- | |
394 | * Update the enable mask on the first wakeup reference. Wake GPEs |
- | |
395 | * are only hardware-enabled just before sleeping. |
- | |
396 | */ |
- | |
397 | GpeEventInfo->WakeupCount++; |
- | |
398 | if (GpeEventInfo->WakeupCount == 1) |
- | |
399 | { |
- | |
400 | (void) AcpiEvUpdateGpeEnableMasks (GpeEventInfo); |
- | |
401 | } |
- | |
402 | } |
- | |
403 | - | ||
404 | UnlockAndExit: |
- | |
405 | AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); |
- | |
406 | return_ACPI_STATUS (Status); |
- | |
407 | } |
- | |
408 | - | ||
409 | ACPI_EXPORT_SYMBOL (AcpiEnableGpe) |
- | |
410 | - | ||
411 | - | ||
412 | /******************************************************************************* |
- | |
413 | * |
- | |
414 | * FUNCTION: AcpiDisableGpe |
- | |
415 | * |
- | |
416 | * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 |
- | |
417 | * GpeNumber - GPE level within the GPE block |
- | |
418 | * GpeType - ACPI_GPE_TYPE_RUNTIME or ACPI_GPE_TYPE_WAKE |
- | |
419 | * or both |
- | |
420 | * |
- | |
421 | * RETURN: Status |
- | |
422 | * |
- | |
423 | * DESCRIPTION: Remove a reference to a GPE. When the last reference is |
- | |
424 | * removed, only then is the GPE disabled (for runtime GPEs), or |
- | |
425 | * the GPE mask bit disabled (for wake GPEs) |
- | |
426 | * |
- | |
427 | ******************************************************************************/ |
- | |
428 | - | ||
429 | ACPI_STATUS |
- | |
430 | AcpiDisableGpe ( |
- | |
431 | ACPI_HANDLE GpeDevice, |
- | |
432 | UINT32 GpeNumber, |
- | |
433 | UINT8 GpeType) |
- | |
434 | { |
- | |
435 | ACPI_STATUS Status = AE_OK; |
- | |
436 | ACPI_GPE_EVENT_INFO *GpeEventInfo; |
- | |
437 | ACPI_CPU_FLAGS Flags; |
- | |
438 | - | ||
439 | - | ||
440 | ACPI_FUNCTION_TRACE (AcpiDisableGpe); |
- | |
441 | - | ||
442 | - | ||
443 | /* Parameter validation */ |
- | |
444 | - | ||
445 | if (!GpeType || (GpeType & ~ACPI_GPE_TYPE_WAKE_RUN)) |
- | |
446 | { |
- | |
447 | return_ACPI_STATUS (AE_BAD_PARAMETER); |
- | |
448 | } |
- | |
449 | - | ||
450 | Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); |
- | |
451 | - | ||
452 | /* Ensure that we have a valid GPE number */ |
- | |
453 | - | ||
454 | GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); |
- | |
455 | if (!GpeEventInfo) |
- | |
456 | { |
- | |
457 | Status = AE_BAD_PARAMETER; |
- | |
458 | goto UnlockAndExit; |
- | |
459 | } |
- | |
460 | - | ||
461 | /* Hardware-disable a runtime GPE on removal of the last reference */ |
- | |
462 | - | ||
463 | if (GpeType & ACPI_GPE_TYPE_RUNTIME) |
- | |
464 | { |
- | |
465 | if (!GpeEventInfo->RuntimeCount) |
- | |
466 | { |
- | |
467 | Status = AE_LIMIT; /* There are no references to remove */ |
- | |
468 | goto UnlockAndExit; |
- | |
469 | } |
- | |
470 | - | ||
471 | GpeEventInfo->RuntimeCount--; |
- | |
472 | if (!GpeEventInfo->RuntimeCount) |
- | |
473 | { |
- | |
474 | Status = AcpiEvDisableGpe (GpeEventInfo); |
- | |
475 | if (ACPI_FAILURE (Status)) |
- | |
476 | { |
- | |
477 | GpeEventInfo->RuntimeCount++; |
- | |
478 | goto UnlockAndExit; |
- | |
479 | } |
- | |
480 | } |
- | |
481 | } |
- | |
482 | - | ||
483 | /* |
- | |
484 | * Update masks for wake GPE on removal of the last reference. |
- | |
485 | * No need to hardware-disable wake GPEs here, they are not currently |
- | |
486 | * enabled. |
- | |
487 | */ |
- | |
488 | if (GpeType & ACPI_GPE_TYPE_WAKE) |
- | |
489 | { |
- | |
490 | if (!GpeEventInfo->WakeupCount) |
- | |
491 | { |
- | |
492 | Status = AE_LIMIT; /* There are no references to remove */ |
- | |
493 | goto UnlockAndExit; |
- | |
494 | } |
- | |
495 | - | ||
496 | GpeEventInfo->WakeupCount--; |
- | |
497 | if (!GpeEventInfo->WakeupCount) |
- | |
498 | { |
- | |
499 | (void) AcpiEvUpdateGpeEnableMasks (GpeEventInfo); |
- | |
500 | } |
- | |
501 | } |
- | |
502 | - | ||
503 | - | ||
504 | UnlockAndExit: |
- | |
505 | AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); |
- | |
506 | return_ACPI_STATUS (Status); |
- | |
507 | } |
- | |
508 | - | ||
509 | ACPI_EXPORT_SYMBOL (AcpiDisableGpe) |
- | |
510 | - | ||
511 | - | ||
512 | /******************************************************************************* |
- | |
513 | * |
- | |
514 | * FUNCTION: AcpiSetGpe |
- | |
515 | * |
- | |
516 | * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 |
- | |
517 | * GpeNumber - GPE level within the GPE block |
- | |
518 | * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE |
- | |
519 | * |
- | |
520 | * RETURN: Status |
- | |
521 | * |
- | |
522 | * DESCRIPTION: Enable or disable an individual GPE. This function bypasses |
- | |
523 | * the reference count mechanism used in the AcpiEnableGpe and |
- | |
524 | * AcpiDisableGpe interfaces -- and should be used with care. |
- | |
525 | * |
- | |
526 | * Note: Typically used to disable a runtime GPE for short period of time, |
- | |
527 | * then re-enable it, without disturbing the existing reference counts. This |
- | |
528 | * is useful, for example, in the Embedded Controller (EC) driver. |
- | |
529 | * |
- | |
530 | ******************************************************************************/ |
- | |
531 | - | ||
532 | ACPI_STATUS |
- | |
533 | AcpiSetGpe ( |
- | |
534 | ACPI_HANDLE GpeDevice, |
- | |
535 | UINT32 GpeNumber, |
- | |
536 | UINT8 Action) |
- | |
537 | { |
- | |
538 | ACPI_GPE_EVENT_INFO *GpeEventInfo; |
- | |
539 | ACPI_STATUS Status; |
- | |
540 | ACPI_CPU_FLAGS Flags; |
- | |
541 | - | ||
542 | - | ||
543 | ACPI_FUNCTION_TRACE (AcpiSetGpe); |
- | |
544 | - | ||
545 | - | ||
546 | Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); |
- | |
547 | - | ||
548 | /* Ensure that we have a valid GPE number */ |
- | |
549 | - | ||
550 | GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); |
- | |
551 | if (!GpeEventInfo) |
- | |
552 | { |
- | |
553 | Status = AE_BAD_PARAMETER; |
- | |
554 | goto UnlockAndExit; |
- | |
555 | } |
- | |
556 | - | ||
557 | /* Perform the action */ |
- | |
558 | - | ||
559 | switch (Action) |
- | |
560 | { |
- | |
561 | case ACPI_GPE_ENABLE: |
- | |
562 | Status = AcpiEvEnableGpe (GpeEventInfo); |
- | |
563 | break; |
- | |
564 | - | ||
565 | case ACPI_GPE_DISABLE: |
- | |
566 | Status = AcpiEvDisableGpe (GpeEventInfo); |
- | |
567 | break; |
- | |
568 | - | ||
569 | default: |
- | |
570 | Status = AE_BAD_PARAMETER; |
- | |
571 | break; |
- | |
572 | } |
- | |
573 | - | ||
574 | UnlockAndExit: |
- | |
575 | AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); |
- | |
576 | return_ACPI_STATUS (Status); |
- | |
577 | } |
- | |
578 | - | ||
579 | ACPI_EXPORT_SYMBOL (AcpiSetGpe) |
- | |
580 | - | ||
581 | - | ||
582 | /******************************************************************************* |
298 | /******************************************************************************* |
583 | * |
299 | * |
584 | * FUNCTION: AcpiDisableEvent |
300 | * FUNCTION: AcpiDisableEvent |
585 | * |
301 | * |
586 | * PARAMETERS: Event - The fixed eventto be enabled |
302 | * PARAMETERS: Event - The fixed event to be disabled |
587 | * Flags - Reserved |
303 | * Flags - Reserved |
588 | * |
304 | * |
589 | * RETURN: Status |
305 | * RETURN: Status |
Line 686... | Line 402... | ||
686 | ACPI_EXPORT_SYMBOL (AcpiClearEvent) |
402 | ACPI_EXPORT_SYMBOL (AcpiClearEvent) |
Line 687... | Line 403... | ||
687 | 403 | ||
688 | 404 | ||
689 | /******************************************************************************* |
- | |
690 | * |
- | |
691 | * FUNCTION: AcpiClearGpe |
- | |
692 | * |
- | |
693 | * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 |
- | |
694 | * GpeNumber - GPE level within the GPE block |
- | |
695 | * |
- | |
696 | * RETURN: Status |
- | |
697 | * |
- | |
698 | * DESCRIPTION: Clear an ACPI event (general purpose) |
- | |
699 | * |
- | |
700 | ******************************************************************************/ |
- | |
701 | - | ||
702 | ACPI_STATUS |
- | |
703 | AcpiClearGpe ( |
- | |
704 | ACPI_HANDLE GpeDevice, |
- | |
705 | UINT32 GpeNumber) |
- | |
706 | { |
- | |
707 | ACPI_STATUS Status = AE_OK; |
- | |
708 | ACPI_GPE_EVENT_INFO *GpeEventInfo; |
- | |
709 | ACPI_CPU_FLAGS Flags; |
- | |
710 | - | ||
711 | - | ||
712 | ACPI_FUNCTION_TRACE (AcpiClearGpe); |
- | |
713 | - | ||
714 | - | ||
715 | Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); |
- | |
716 | - | ||
717 | /* Ensure that we have a valid GPE number */ |
- | |
718 | - | ||
719 | GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); |
- | |
720 | if (!GpeEventInfo) |
- | |
721 | { |
- | |
722 | Status = AE_BAD_PARAMETER; |
- | |
723 | goto UnlockAndExit; |
- | |
724 | } |
- | |
725 | - | ||
726 | Status = AcpiHwClearGpe (GpeEventInfo); |
- | |
727 | - | ||
728 | UnlockAndExit: |
- | |
729 | AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); |
- | |
730 | return_ACPI_STATUS (Status); |
- | |
731 | } |
- | |
732 | - | ||
733 | ACPI_EXPORT_SYMBOL (AcpiClearGpe) |
- | |
734 | - | ||
735 | - | ||
736 | /******************************************************************************* |
405 | /******************************************************************************* |
737 | * |
406 | * |
738 | * FUNCTION: AcpiGetEventStatus |
407 | * FUNCTION: AcpiGetEventStatus |
739 | * |
408 | * |
740 | * PARAMETERS: Event - The fixed event |
409 | * PARAMETERS: Event - The fixed event |
Line 779... | Line 448... | ||
779 | } |
448 | } |
Line 780... | Line 449... | ||
780 | 449 | ||
Line 781... | Line -... | ||
781 | ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) |
- | |
782 | - | ||
783 | - | ||
784 | /******************************************************************************* |
- | |
785 | * |
- | |
786 | * FUNCTION: AcpiGetGpeStatus |
- | |
787 | * |
- | |
788 | * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1 |
- | |
789 | * GpeNumber - GPE level within the GPE block |
- | |
790 | * EventStatus - Where the current status of the event will |
- | |
791 | * be returned |
- | |
792 | * |
- | |
793 | * RETURN: Status |
- | |
794 | * |
- | |
795 | * DESCRIPTION: Get status of an event (general purpose) |
- | |
796 | * |
- | |
797 | ******************************************************************************/ |
- | |
798 | - | ||
799 | ACPI_STATUS |
- | |
800 | AcpiGetGpeStatus ( |
- | |
801 | ACPI_HANDLE GpeDevice, |
- | |
802 | UINT32 GpeNumber, |
- | |
803 | ACPI_EVENT_STATUS *EventStatus) |
- | |
804 | { |
- | |
805 | ACPI_STATUS Status = AE_OK; |
- | |
806 | ACPI_GPE_EVENT_INFO *GpeEventInfo; |
- | |
807 | ACPI_CPU_FLAGS Flags; |
- | |
808 | - | ||
809 | - | ||
810 | ACPI_FUNCTION_TRACE (AcpiGetGpeStatus); |
- | |
811 | - | ||
812 | - | ||
813 | Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); |
- | |
814 | - | ||
815 | /* Ensure that we have a valid GPE number */ |
- | |
816 | - | ||
817 | GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); |
- | |
818 | if (!GpeEventInfo) |
- | |
819 | { |
- | |
820 | Status = AE_BAD_PARAMETER; |
- | |
821 | goto UnlockAndExit; |
- | |
822 | } |
- | |
823 | - | ||
824 | /* Obtain status on the requested GPE number */ |
- | |
825 | - | ||
826 | Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus); |
- | |
827 | - | ||
828 | UnlockAndExit: |
- | |
829 | AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); |
- | |
830 | return_ACPI_STATUS (Status); |
- | |
831 | } |
- | |
832 | - | ||
833 | ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus) |
- | |
834 | - | ||
835 | - | ||
836 | /******************************************************************************* |
- | |
837 | * |
- | |
838 | * FUNCTION: AcpiInstallGpeBlock |
- | |
839 | * |
- | |
840 | * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device |
- | |
841 | * GpeBlockAddress - Address and SpaceID |
- | |
842 | * RegisterCount - Number of GPE register pairs in the block |
- | |
843 | * InterruptNumber - H/W interrupt for the block |
- | |
844 | * |
- | |
845 | * RETURN: Status |
- | |
846 | * |
- | |
847 | * DESCRIPTION: Create and Install a block of GPE registers |
- | |
848 | * |
- | |
849 | ******************************************************************************/ |
- | |
850 | - | ||
851 | ACPI_STATUS |
- | |
852 | AcpiInstallGpeBlock ( |
- | |
853 | ACPI_HANDLE GpeDevice, |
- | |
854 | ACPI_GENERIC_ADDRESS *GpeBlockAddress, |
- | |
855 | UINT32 RegisterCount, |
- | |
856 | UINT32 InterruptNumber) |
- | |
857 | { |
- | |
858 | ACPI_STATUS Status; |
- | |
859 | ACPI_OPERAND_OBJECT *ObjDesc; |
- | |
860 | ACPI_NAMESPACE_NODE *Node; |
- | |
861 | ACPI_GPE_BLOCK_INFO *GpeBlock; |
- | |
862 | - | ||
863 | - | ||
864 | ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock); |
- | |
865 | - | ||
866 | - | ||
867 | if ((!GpeDevice) || |
- | |
868 | (!GpeBlockAddress) || |
- | |
869 | (!RegisterCount)) |
- | |
870 | { |
- | |
871 | return_ACPI_STATUS (AE_BAD_PARAMETER); |
- | |
872 | } |
- | |
873 | - | ||
874 | Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); |
- | |
875 | if (ACPI_FAILURE (Status)) |
- | |
876 | { |
- | |
877 | return (Status); |
- | |
878 | } |
- | |
879 | - | ||
880 | Node = AcpiNsValidateHandle (GpeDevice); |
- | |
881 | if (!Node) |
- | |
882 | { |
- | |
883 | Status = AE_BAD_PARAMETER; |
- | |
884 | goto UnlockAndExit; |
- | |
885 | } |
- | |
886 | - | ||
887 | /* |
- | |
888 | * For user-installed GPE Block Devices, the GpeBlockBaseNumber |
- | |
889 | * is always zero |
- | |
890 | */ |
- | |
891 | Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount, |
- | |
892 | 0, InterruptNumber, &GpeBlock); |
- | |
893 | if (ACPI_FAILURE (Status)) |
- | |
894 | { |
- | |
895 | goto UnlockAndExit; |
- | |
896 | } |
- | |
897 | - | ||
898 | /* Install block in the DeviceObject attached to the node */ |
- | |
899 | - | ||
900 | ObjDesc = AcpiNsGetAttachedObject (Node); |
- | |
901 | if (!ObjDesc) |
- | |
902 | { |
- | |
903 | /* |
- | |
904 | * No object, create a new one (Device nodes do not always have |
- | |
905 | * an attached object) |
- | |
906 | */ |
- | |
907 | ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE); |
- | |
908 | if (!ObjDesc) |
- | |
909 | { |
- | |
910 | Status = AE_NO_MEMORY; |
- | |
911 | goto UnlockAndExit; |
- | |
912 | } |
- | |
913 | - | ||
914 | Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE); |
- | |
915 | - | ||
916 | /* Remove local reference to the object */ |
- | |
917 | - | ||
918 | AcpiUtRemoveReference (ObjDesc); |
- | |
919 | if (ACPI_FAILURE (Status)) |
- | |
920 | { |
- | |
921 | goto UnlockAndExit; |
- | |
922 | } |
- | |
923 | } |
- | |
924 | - | ||
925 | /* Now install the GPE block in the DeviceObject */ |
- | |
926 | - | ||
927 | ObjDesc->Device.GpeBlock = GpeBlock; |
- | |
928 | - | ||
929 | /* Run the _PRW methods and enable the runtime GPEs in the new block */ |
- | |
930 | - | ||
931 | Status = AcpiEvInitializeGpeBlock (Node, GpeBlock); |
- | |
932 | - | ||
933 | - | ||
934 | UnlockAndExit: |
- | |
935 | (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); |
- | |
936 | return_ACPI_STATUS (Status); |
- | |
937 | } |
- | |
938 | - | ||
939 | ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock) |
- | |
940 | - | ||
941 | - | ||
942 | /******************************************************************************* |
- | |
943 | * |
- | |
944 | * FUNCTION: AcpiRemoveGpeBlock |
- | |
945 | * |
- | |
946 | * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device |
- | |
947 | * |
- | |
948 | * RETURN: Status |
- | |
949 | * |
- | |
950 | * DESCRIPTION: Remove a previously installed block of GPE registers |
- | |
951 | * |
- | |
952 | ******************************************************************************/ |
- | |
953 | - | ||
954 | ACPI_STATUS |
- | |
955 | AcpiRemoveGpeBlock ( |
- | |
956 | ACPI_HANDLE GpeDevice) |
- | |
957 | { |
- | |
958 | ACPI_OPERAND_OBJECT *ObjDesc; |
- | |
959 | ACPI_STATUS Status; |
- | |
960 | ACPI_NAMESPACE_NODE *Node; |
- | |
961 | - | ||
962 | - | ||
963 | ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock); |
- | |
964 | - | ||
965 | - | ||
966 | if (!GpeDevice) |
- | |
967 | { |
- | |
968 | return_ACPI_STATUS (AE_BAD_PARAMETER); |
- | |
969 | } |
- | |
970 | - | ||
971 | Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); |
- | |
972 | if (ACPI_FAILURE (Status)) |
- | |
973 | { |
- | |
974 | return (Status); |
- | |
975 | } |
- | |
976 | - | ||
977 | Node = AcpiNsValidateHandle (GpeDevice); |
- | |
978 | if (!Node) |
- | |
979 | { |
- | |
980 | Status = AE_BAD_PARAMETER; |
- | |
981 | goto UnlockAndExit; |
- | |
982 | } |
- | |
983 | - | ||
984 | /* Get the DeviceObject attached to the node */ |
- | |
985 | - | ||
986 | ObjDesc = AcpiNsGetAttachedObject (Node); |
- | |
987 | if (!ObjDesc || |
- | |
988 | !ObjDesc->Device.GpeBlock) |
- | |
989 | { |
- | |
990 | return_ACPI_STATUS (AE_NULL_OBJECT); |
- | |
991 | } |
- | |
992 | - | ||
993 | /* Delete the GPE block (but not the DeviceObject) */ |
- | |
994 | - | ||
995 | Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock); |
- | |
996 | if (ACPI_SUCCESS (Status)) |
- | |
997 | { |
- | |
998 | ObjDesc->Device.GpeBlock = NULL; |
- | |
999 | } |
- | |
1000 | - | ||
1001 | UnlockAndExit: |
- | |
1002 | (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); |
- | |
1003 | return_ACPI_STATUS (Status); |
- | |
1004 | } |
- | |
1005 | - | ||
1006 | ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock) |
- | |
1007 | - | ||
1008 | - | ||
1009 | /******************************************************************************* |
- | |
1010 | * |
- | |
1011 | * FUNCTION: AcpiGetGpeDevice |
- | |
1012 | * |
- | |
1013 | * PARAMETERS: Index - System GPE index (0-CurrentGpeCount) |
- | |
1014 | * GpeDevice - Where the parent GPE Device is returned |
- | |
1015 | * |
- | |
1016 | * RETURN: Status |
- | |
1017 | * |
- | |
1018 | * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL |
- | |
1019 | * gpe device indicates that the gpe number is contained in one of |
- | |
1020 | * the FADT-defined gpe blocks. Otherwise, the GPE block device. |
- | |
1021 | * |
- | |
1022 | ******************************************************************************/ |
- | |
1023 | - | ||
1024 | ACPI_STATUS |
- | |
1025 | AcpiGetGpeDevice ( |
- | |
1026 | UINT32 Index, |
- | |
1027 | ACPI_HANDLE *GpeDevice) |
- | |
1028 | { |
- | |
1029 | ACPI_GPE_DEVICE_INFO Info; |
- | |
1030 | ACPI_STATUS Status; |
- | |
1031 | - | ||
1032 | - | ||
1033 | ACPI_FUNCTION_TRACE (AcpiGetGpeDevice); |
- | |
1034 | - | ||
1035 | - | ||
1036 | if (!GpeDevice) |
- | |
1037 | { |
- | |
1038 | return_ACPI_STATUS (AE_BAD_PARAMETER); |
- | |
1039 | } |
- | |
1040 | - | ||
1041 | if (Index >= AcpiCurrentGpeCount) |
- | |
1042 | { |
- | |
1043 | return_ACPI_STATUS (AE_NOT_EXIST); |
- | |
1044 | } |
- | |
1045 | - | ||
1046 | /* Setup and walk the GPE list */ |
- | |
1047 | - | ||
1048 | Info.Index = Index; |
- | |
1049 | Info.Status = AE_NOT_EXIST; |
- | |
1050 | Info.GpeDevice = NULL; |
- | |
1051 | Info.NextBlockBaseIndex = 0; |
- | |
1052 | - | ||
1053 | Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info); |
- | |
1054 | if (ACPI_FAILURE (Status)) |
- | |
1055 | { |
- | |
1056 | return_ACPI_STATUS (Status); |
- | |
1057 | } |
- | |
1058 | - | ||
1059 | *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice); |
- | |
1060 | return_ACPI_STATUS (Info.Status); |
- | |
1061 | } |
- | |
1062 | - | ||
1063 | ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice) |
- | |
1064 | - | ||
1065 | - | ||
1066 | /******************************************************************************* |
- | |
1067 | * |
- | |
1068 | * FUNCTION: AcpiEvGetGpeDevice |
- | |
1069 | * |
- | |
1070 | * PARAMETERS: GPE_WALK_CALLBACK |
- | |
1071 | * |
- | |
1072 | * RETURN: Status |
- | |
1073 | * |
- | |
1074 | * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE |
- | |
1075 | * block device. NULL if the GPE is one of the FADT-defined GPEs. |
- | |
1076 | * |
- | |
1077 | ******************************************************************************/ |
- | |
1078 | - | ||
1079 | static ACPI_STATUS |
- | |
1080 | AcpiEvGetGpeDevice ( |
- | |
1081 | ACPI_GPE_XRUPT_INFO *GpeXruptInfo, |
- | |
1082 | ACPI_GPE_BLOCK_INFO *GpeBlock, |
- | |
1083 | void *Context) |
- | |
1084 | { |
- | |
1085 | ACPI_GPE_DEVICE_INFO *Info = Context; |
- | |
1086 | - | ||
1087 | - | ||
1088 | /* Increment Index by the number of GPEs in this block */ |
- | |
1089 | - | ||
1090 | Info->NextBlockBaseIndex += GpeBlock->GpeCount; |
- | |
1091 | - | ||
1092 | if (Info->Index < Info->NextBlockBaseIndex) |
- | |
1093 | { |
- | |
1094 | /* |
- | |
1095 | * The GPE index is within this block, get the node. Leave the node |
- | |
1096 | * NULL for the FADT-defined GPEs |
- | |
1097 | */ |
- | |
1098 | if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE) |
- | |
1099 | { |
- | |
1100 | Info->GpeDevice = GpeBlock->Node; |
- | |
1101 | } |
- | |
1102 | - | ||
1103 | Info->Status = AE_OK; |
- | |
1104 | return (AE_CTRL_END); |
- | |
1105 | } |
- | |
1106 | - | ||
1107 | return (AE_OK); |
- | |
1108 | } |
- | |
1109 | - | ||
1110 | - | ||
1111 | /****************************************************************************** |
- | |
1112 | * |
- | |
1113 | * FUNCTION: AcpiDisableAllGpes |
- | |
1114 | * |
- | |
1115 | * PARAMETERS: None |
- | |
1116 | * |
- | |
1117 | * RETURN: Status |
- | |
1118 | * |
- | |
1119 | * DESCRIPTION: Disable and clear all GPEs in all GPE blocks |
- | |
1120 | * |
- | |
1121 | ******************************************************************************/ |
- | |
1122 | - | ||
1123 | ACPI_STATUS |
- | |
1124 | AcpiDisableAllGpes ( |
- | |
1125 | void) |
- | |
1126 | { |
- | |
1127 | ACPI_STATUS Status; |
- | |
1128 | - | ||
1129 | - | ||
1130 | ACPI_FUNCTION_TRACE (AcpiDisableAllGpes); |
- | |
1131 | - | ||
1132 | - | ||
1133 | Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); |
- | |
1134 | if (ACPI_FAILURE (Status)) |
- | |
1135 | { |
- | |
1136 | return_ACPI_STATUS (Status); |
- | |
1137 | } |
- | |
1138 | - | ||
1139 | Status = AcpiHwDisableAllGpes (); |
- | |
1140 | (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); |
- | |
1141 | - | ||
1142 | return_ACPI_STATUS (Status); |
- | |
1143 | } |
- | |
1144 | - | ||
1145 | - | ||
1146 | /****************************************************************************** |
- | |
1147 | * |
- | |
1148 | * FUNCTION: AcpiEnableAllRuntimeGpes |
- | |
1149 | * |
- | |
1150 | * PARAMETERS: None |
- | |
1151 | * |
- | |
1152 | * RETURN: Status |
- | |
1153 | * |
- | |
1154 | * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks |
- | |
1155 | * |
- | |
1156 | ******************************************************************************/ |
- | |
1157 | - | ||
1158 | ACPI_STATUS |
- | |
1159 | AcpiEnableAllRuntimeGpes ( |
- | |
1160 | void) |
- | |
1161 | { |
- | |
1162 | ACPI_STATUS Status; |
- | |
1163 | - | ||
1164 | - | ||
1165 | ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes); |
- | |
1166 | - | ||
1167 | - | ||
1168 | Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); |
- | |
1169 | if (ACPI_FAILURE (Status)) |
- | |
1170 | { |
- | |
1171 | return_ACPI_STATUS (Status); |
- | |
1172 | } |
- | |
1173 | - | ||
1174 | Status = AcpiHwEnableAllRuntimeGpes (); |
- | |
1175 | (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); |
- | |
1176 | - | ||
1177 | return_ACPI_STATUS (Status); |
- |