]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / DuetPkg / PciBusNoEnumerationDxe / PciPowerManagement.c
CommitLineData
10590588 1/*++\r
2\r
7e242786 3Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>\r
b1f700a8 4This program and the accompanying materials \r
10590588 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 PciPowerManagement.c\r
15 \r
16Abstract:\r
17\r
18 PCI Bus Driver\r
19\r
20Revision History\r
21\r
22--*/\r
23\r
d8bee43c 24#include "PciBus.h"\r
10590588 25\r
26EFI_STATUS\r
d8bee43c 27EFIAPI\r
10590588 28ResetPowerManagementFeature (\r
29 IN PCI_IO_DEVICE *PciIoDevice\r
30 )\r
31/*++\r
32\r
33Routine Description:\r
34\r
35 This function is intended to turn off PWE assertion and\r
36 put the device to D0 state if the device supports\r
37 PCI Power Management.\r
38\r
39Arguments:\r
40\r
41Returns:\r
42 \r
43 None\r
44\r
45--*/\r
46{\r
47 EFI_STATUS Status;\r
48 UINT8 PowerManagementRegBlock;\r
7e242786 49 UINT16 PowerManagementCSR;\r
10590588 50\r
51 PowerManagementRegBlock = 0;\r
52\r
53 Status = LocateCapabilityRegBlock (\r
54 PciIoDevice,\r
55 EFI_PCI_CAPABILITY_ID_PMI,\r
56 &PowerManagementRegBlock,\r
57 NULL\r
58 );\r
59\r
60 if (EFI_ERROR (Status)) {\r
61 return EFI_UNSUPPORTED;\r
62 }\r
63\r
64 //\r
65 // Turn off the PWE assertion and put the device into D0 State\r
66 //\r
10590588 67\r
68 //\r
7e242786 69 // Read PMCSR\r
10590588 70 //\r
7e242786 71 Status = PciIoDevice->PciIo.Pci.Read (\r
72 &PciIoDevice->PciIo,\r
73 EfiPciIoWidthUint16,\r
74 PowerManagementRegBlock + 4,\r
75 1,\r
76 &PowerManagementCSR\r
77 );\r
78 if (!EFI_ERROR (Status)) {\r
79 //\r
80 // Clear PME_Status bit\r
81 //\r
82 PowerManagementCSR |= BIT15;\r
83 //\r
84 // Clear PME_En bit. PowerState = D0.\r
85 //\r
86 PowerManagementCSR &= ~(BIT8 | BIT1 | BIT0);\r
87\r
88 //\r
89 // Write PMCSR\r
90 //\r
91 Status = PciIoDevice->PciIo.Pci.Write (\r
92 &PciIoDevice->PciIo,\r
93 EfiPciIoWidthUint16,\r
94 PowerManagementRegBlock + 4,\r
95 1,\r
96 &PowerManagementCSR\r
97 );\r
98 }\r
99 return Status;\r
10590588 100}\r