]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / SdMmcPciHcDxe / SdMmcPciHcDxe.c
index a87f8deb8c9f96a89ee3dbddd49252764934c822..4881ee44ccb791252be2ff247497e3010440465e 100644 (file)
@@ -1,17 +1,14 @@
 /** @file\r
   This driver is used to manage SD/MMC PCI host controllers which are compliance\r
-  with SD Host Controller Simplified Specification version 3.00.\r
+  with SD Host Controller Simplified Specification version 3.00 plus the 64-bit\r
+  System Addressing support in SD Host Controller Simplified Specification version\r
+  4.20.\r
 \r
   It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use.\r
 \r
-  Copyright (c) 2015 - 2016, 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
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.\r
+  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -62,7 +59,9 @@ SD_MMC_HC_PRIVATE_DATA gSdMmcPciHcTemplate = {
   {                                 // MaxCurrent\r
     0,\r
   },\r
-  0                                 // ControllerVersion\r
+  {\r
+    0                               // ControllerVersion\r
+  }\r
 };\r
 \r
 SD_DEVICE_PATH    mSdDpTemplate = {\r
@@ -621,6 +620,14 @@ SdMmcPciHcDriverBindingStart (
   for (Slot = FirstBar; Slot < (FirstBar + SlotNum); Slot++) {\r
     Private->Slot[Slot].Enable = TRUE;\r
 \r
+    //\r
+    // Get SD/MMC Pci Host Controller Version\r
+    //\r
+    Status = SdMmcHcGetControllerVersion (PciIo, Slot, &Private->ControllerVersion[Slot]);\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
+\r
     Status = SdMmcHcGetCapability (PciIo, Slot, &Private->Capability[Slot]);\r
     if (EFI_ERROR (Status)) {\r
       continue;\r
@@ -649,7 +656,18 @@ SdMmcPciHcDriverBindingStart (
       Private->BaseClkFreq[Slot]\r
       ));\r
 \r
-    Support64BitDma &= Private->Capability[Slot].SysBus64;\r
+    //\r
+    // If any of the slots does not support 64b system bus\r
+    // do not enable 64b DMA in the PCI layer.\r
+    //\r
+    if ((Private->ControllerVersion[Slot] == SD_MMC_HC_CTRL_VER_300 &&\r
+         Private->Capability[Slot].SysBus64V3 == 0) ||\r
+        (Private->ControllerVersion[Slot] == SD_MMC_HC_CTRL_VER_400 &&\r
+         Private->Capability[Slot].SysBus64V3 == 0) ||\r
+        (Private->ControllerVersion[Slot] >= SD_MMC_HC_CTRL_VER_410 &&\r
+         Private->Capability[Slot].SysBus64V4 == 0)) {\r
+      Support64BitDma = FALSE;\r
+    }\r
 \r
     Status = SdMmcHcGetMaxCurrent (PciIo, Slot, &Private->MaxCurrent[Slot]);\r
     if (EFI_ERROR (Status)) {\r