]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/PciBusDxe/PciPowerManagement.c
860d427f352a7b652169267066864ba63b472db2
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciPowerManagement.c
1 /** @file
2 Power management support fucntions implementation for PCI Bus module.
3
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "PciBus.h"
16
17 /**
18 This function is intended to turn off PWE assertion and
19 put the device to D0 state if the device supports
20 PCI Power Management.
21
22 @param PciIoDevice PCI device instance.
23
24 @retval EFI_UNSUPPORTED PCI Device does not support power management.
25 @retval EFI_SUCCESS Turned off PWE successfully.
26
27 **/
28 EFI_STATUS
29 ResetPowerManagementFeature (
30 IN PCI_IO_DEVICE *PciIoDevice
31 )
32 {
33 EFI_STATUS Status;
34 UINT8 PowerManagementRegBlock;
35 UINT16 PowerManagementCSR;
36
37 PowerManagementRegBlock = 0;
38
39 Status = LocateCapabilityRegBlock (
40 PciIoDevice,
41 EFI_PCI_CAPABILITY_ID_PMI,
42 &PowerManagementRegBlock,
43 NULL
44 );
45
46 if (EFI_ERROR (Status)) {
47 return EFI_UNSUPPORTED;
48 }
49
50 //
51 // Turn off the PWE assertion and put the device into D0 State
52 //
53 PowerManagementCSR = 0x8000;
54
55 //
56 // Write PMCSR
57 //
58 PciIoDevice->PciIo.Pci.Write (
59 &PciIoDevice->PciIo,
60 EfiPciIoWidthUint16,
61 PowerManagementRegBlock + 4,
62 1,
63 &PowerManagementCSR
64 );
65
66 return EFI_SUCCESS;
67 }
68