TianoCore EDK2 master
Loading...
Searching...
No Matches
PciPowerManagement.c
Go to the documentation of this file.
1
9#include "PciBus.h"
10
24 IN PCI_IO_DEVICE *PciIoDevice
25 )
26{
27 EFI_STATUS Status;
28 UINT8 PowerManagementRegBlock;
29 UINT16 PowerManagementCSR;
30
31 PowerManagementRegBlock = 0;
32
34 PciIoDevice,
35 EFI_PCI_CAPABILITY_ID_PMI,
36 &PowerManagementRegBlock,
37 NULL
38 );
39
40 if (EFI_ERROR (Status)) {
41 return EFI_UNSUPPORTED;
42 }
43
44 //
45 // Turn off the PWE assertion and put the device into D0 State
46 //
47
48 //
49 // Read PMCSR
50 //
51 Status = PciIoDevice->PciIo.Pci.Read (
52 &PciIoDevice->PciIo,
53 EfiPciIoWidthUint16,
54 PowerManagementRegBlock + 4,
55 1,
56 &PowerManagementCSR
57 );
58
59 if (!EFI_ERROR (Status)) {
60 //
61 // Clear PME_Status bit
62 //
63 PowerManagementCSR |= BIT15;
64 //
65 // Clear PME_En bit. PowerState = D0.
66 //
67 PowerManagementCSR &= ~(BIT8 | BIT1 | BIT0);
68
69 //
70 // Write PMCSR
71 //
72 Status = PciIoDevice->PciIo.Pci.Write (
73 &PciIoDevice->PciIo,
74 EfiPciIoWidthUint16,
75 PowerManagementRegBlock + 4,
76 1,
77 &PowerManagementCSR
78 );
79 }
80
81 return Status;
82}
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
EFI_STATUS LocateCapabilityRegBlock(IN PCI_IO_DEVICE *PciIoDevice, IN UINT8 CapId, IN OUT UINT8 *Offset, OUT UINT8 *NextRegBlock OPTIONAL)
Definition: PciCommand.c:106
EFI_STATUS ResetPowerManagementFeature(IN PCI_IO_DEVICE *PciIoDevice)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29