]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciPowerManagement.c
MdeModulePkg/PciBus: Correct typos
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciPowerManagement.c
index 860d427f352a7b652169267066864ba63b472db2..3043f3c4aa2c6970e89a64e0a992f5f1dc4b8ac1 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
-  Power management support fucntions implementation for PCI Bus module.\r
+  Power management support functions implementation for PCI Bus module.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -50,19 +50,39 @@ ResetPowerManagementFeature (
   //\r
   // Turn off the PWE assertion and put the device into D0 State\r
   //\r
-  PowerManagementCSR = 0x8000;\r
 \r
   //\r
-  // Write PMCSR\r
+  // Read PMCSR\r
   //\r
-  PciIoDevice->PciIo.Pci.Write (\r
-                           &PciIoDevice->PciIo,\r
-                           EfiPciIoWidthUint16,\r
-                           PowerManagementRegBlock + 4,\r
-                           1,\r
-                           &PowerManagementCSR\r
-                           );\r
-\r
-  return EFI_SUCCESS;\r
+  Status = PciIoDevice->PciIo.Pci.Read (\r
+                                    &PciIoDevice->PciIo,\r
+                                    EfiPciIoWidthUint16,\r
+                                    PowerManagementRegBlock + 4,\r
+                                    1,\r
+                                    &PowerManagementCSR\r
+                                    );\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Clear PME_Status bit\r
+    //\r
+    PowerManagementCSR |= BIT15;\r
+    //\r
+    // Clear PME_En bit. PowerState = D0.\r
+    //\r
+    PowerManagementCSR &= ~(BIT8 | BIT1 | BIT0);\r
+\r
+    //\r
+    // Write PMCSR\r
+    //\r
+    Status = PciIoDevice->PciIo.Pci.Write (\r
+                                      &PciIoDevice->PciIo,\r
+                                      EfiPciIoWidthUint16,\r
+                                      PowerManagementRegBlock + 4,\r
+                                      1,\r
+                                      &PowerManagementCSR\r
+                                      );\r
+  }\r
+  return Status;\r
 }\r
 \r