]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PciBusDxe and DuetPkg PciBusNoEnumerationDxe: Update ResetPowerManagemen...
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 12 Apr 2012 01:49:27 +0000 (01:49 +0000)
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 12 Apr 2012 01:49:27 +0000 (01:49 +0000)
Signed-off-by: Sun Rui <rui.sun@intel.com>
Reviewed-by: Fan Jeff <jeff.fan@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13189 6f19259b-4bc3-4df7-8a09-765794883524

DuetPkg/PciBusNoEnumerationDxe/PciPowerManagement.c
MdeModulePkg/Bus/Pci/PciBusDxe/PciPowerManagement.c

index 2d9b87ab09bcaeb9ec812042dc8cb63afe00b904..eaeaeb762dcac28ee5cb10cee1ea77e3c1722ef3 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2012, 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
@@ -46,7 +46,7 @@ Returns:
 {\r
   EFI_STATUS  Status;\r
   UINT8       PowerManagementRegBlock;\r
-  UINT16      PMCSR;\r
+  UINT16      PowerManagementCSR;\r
 \r
   PowerManagementRegBlock = 0;\r
 \r
@@ -64,18 +64,37 @@ Returns:
   //\r
   // Turn off the PWE assertion and put the device into D0 State\r
   //\r
-  PMCSR = 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
-                          &PMCSR\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
+  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
index d9fbaf7e1275f3d39dc3c3b36bf205278e585609..ab655e76573504882ddd40006b650e44b0e73297 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Power management support fucntions implementation for PCI Bus module.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, 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
@@ -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