Revision: 16436
          http://sourceforge.net/p/edk2/code/16436
Author:   vanjeff
Date:     2014-11-25 07:35:29 +0000 (Tue, 25 Nov 2014)
Log Message:
-----------
Sync patch r16321 from main trunk.

MdeModulePkg/AtaAtapiPassThru: don't write read-only AHCI MMIO register

Per AHCI 1.1 spec, AE bit of GHC register is read-only if CAP.SAM is 1

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <[email protected]>
Reviewed-by: Star Zeng <[email protected]>

(cherry picked from commit 88a6b93f82a756e94d782acaaeacc9f3d74ab319)

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/16321

Modified Paths:
--------------
    branches/UDK2014.SP1/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
    branches/UDK2014.SP1/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h

Modified: branches/UDK2014.SP1/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
===================================================================
--- branches/UDK2014.SP1/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c       
2014-11-25 07:34:36 UTC (rev 16435)
+++ branches/UDK2014.SP1/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c       
2014-11-25 07:35:29 UTC (rev 16436)
@@ -1425,8 +1425,19 @@
 {
   UINT64                 Delay;
   UINT32                 Value;
+  UINT32                 Capability;
 
-  AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
+  //
+  // Collect AHCI controller information
+  //
+  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
+  
+  //
+  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only 
is not set
+  //
+  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
+    AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
+  }
 
   AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_RESET);
 
@@ -2230,15 +2241,17 @@
   }
 
   //
-  // Enable AE before accessing any AHCI registers
+  // Collect AHCI controller information
   //
-  AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
-
+  Capability = AhciReadReg (PciIo, EFI_AHCI_CAPABILITY_OFFSET);
+  
   //
-  // Collect AHCI controller information
+  // Enable AE before accessing any AHCI registers if Supports AHCI Mode Only 
is not set
   //
-  Capability           = AhciReadReg(PciIo, EFI_AHCI_CAPABILITY_OFFSET);
-
+  if ((Capability & EFI_AHCI_CAP_SAM) == 0) {
+    AhciOrReg (PciIo, EFI_AHCI_GHC_OFFSET, EFI_AHCI_GHC_ENABLE);
+  }
+  
   //
   // Get the number of command slots per port supported by this HBA.
   //

Modified: branches/UDK2014.SP1/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h
===================================================================
--- branches/UDK2014.SP1/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h       
2014-11-25 07:34:36 UTC (rev 16435)
+++ branches/UDK2014.SP1/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.h       
2014-11-25 07:35:29 UTC (rev 16436)
@@ -1,7 +1,7 @@
 /** @file
   Header file for AHCI mode of ATA host controller.
   
-  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials                          
   are licensed and made available under the terms and conditions of the BSD 
License         
   which accompanies this distribution.  The full text of the license may be 
found at        
@@ -17,6 +17,7 @@
 #define EFI_AHCI_BAR_INDEX                     0x05
 
 #define EFI_AHCI_CAPABILITY_OFFSET             0x0000
+#define   EFI_AHCI_CAP_SAM                     BIT18
 #define   EFI_AHCI_CAP_SSS                     BIT27
 #define   EFI_AHCI_CAP_S64A                    BIT31
 #define EFI_AHCI_GHC_OFFSET                    0x0004


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to