]> git.proxmox.com Git - mirror_edk2.git/blob - DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.c
5c2386c4bf17a85f98ec22889bc27fe15f6ce3bb
[mirror_edk2.git] / DuetPkg / PciBusNoEnumerationDxe / PciPowerManagement.c
1 /*++
2
3 Copyright (c) 2005 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 PciPowerManagement.c
15
16 Abstract:
17
18 PCI Bus Driver
19
20 Revision History
21
22 --*/
23
24 #include "Pcibus.h"
25
26 EFI_STATUS
27 ResetPowerManagementFeature (
28 IN PCI_IO_DEVICE *PciIoDevice
29 )
30 /*++
31
32 Routine Description:
33
34 This function is intended to turn off PWE assertion and
35 put the device to D0 state if the device supports
36 PCI Power Management.
37
38 Arguments:
39
40 Returns:
41
42 None
43
44 --*/
45 {
46 EFI_STATUS Status;
47 UINT8 PowerManagementRegBlock;
48 UINT16 PMCSR;
49
50 PowerManagementRegBlock = 0;
51
52 Status = LocateCapabilityRegBlock (
53 PciIoDevice,
54 EFI_PCI_CAPABILITY_ID_PMI,
55 &PowerManagementRegBlock,
56 NULL
57 );
58
59 if (EFI_ERROR (Status)) {
60 return EFI_UNSUPPORTED;
61 }
62
63 //
64 // Turn off the PWE assertion and put the device into D0 State
65 //
66 PMCSR = 0x8000;
67
68 //
69 // Write PMCSR
70 //
71 PciIoDevice->PciIo.Pci.Write (
72 &PciIoDevice->PciIo,
73 EfiPciIoWidthUint16,
74 PowerManagementRegBlock + 4,
75 1,
76 &PMCSR
77 );
78
79 return EFI_SUCCESS;
80 }