From: Jan Dąbroś <[email protected]>

This patch adds IsDmaEnabled function to EFI_SD_MMC_PASS_THRU_PROTOCOL.
It returns information, if controller supports DMA transfer modes. New
interface is necessary in order to allow BlockIo layer to perform
transfers in PIO mode.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jan Dabros <[email protected]>
Signed-off-by: Marcin Wojtas <[email protected]>
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 39 +++++++++++++++++++++-
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 21 ++++++++++++
 MdePkg/Include/Protocol/SdMmcPassThru.h            | 22 ++++++++++++
 3 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
index ed6b557..ba6e69a 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c
@@ -42,7 +42,8 @@ SD_MMC_HC_PRIVATE_DATA gSdMmcPciHcTemplate = {
     SdMmcPassThruGetNextSlot,
     SdMmcPassThruBuildDevicePath,
     SdMmcPassThruGetSlotNumber,
-    SdMmcPassThruResetDevice
+    SdMmcPassThruResetDevice,
+    SdMmcPassThruIsDmaEnabled
   },
   0,                                // PciAttributes
   0,                                // PreviousSlot
@@ -1291,3 +1292,39 @@ SdMmcPassThruResetDevice (
   return EFI_SUCCESS;
 }
 
+/**
+  Checks if this SD controller supports DMA transfer according to capabilities 
register.
+
+  If controller supports ADMA or SDMA, EFI_SUCCESS is returned.
+
+  If controller does not support ADMA nor SDMA, EFI_UNSUPPORTED is returned.
+
+  @param[in]  This              A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL 
instance.
+  @param[in]  Slot              Specifies the slot, whose DMA-support will be 
checked.
+
+  @retval EFI_SUCCESS           SD controller supports DMA operations.
+  @retval EFI_UNSUPPORTED       SD controller does not support DMA operations.
+
+**/
+EFI_STATUS
+EFIAPI
+SdMmcPassThruIsDmaEnabled (
+  IN EFI_SD_MMC_PASS_THRU_PROTOCOL           *This,
+  IN UINT8                                   Slot
+  )
+{
+  SD_MMC_HC_PRIVATE_DATA *Private;
+
+  if (This == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Private = SD_MMC_HC_PRIVATE_FROM_THIS (This);
+
+  if (Private->Capability[Slot].Adma2 == 0 &&
+      Private->Capability[Slot].Sdma == 0) {
+    return EFI_UNSUPPORTED;
+  }
+
+  return EFI_SUCCESS;
+}
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h
index 6a2a279..7856b4e 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h
@@ -372,6 +372,27 @@ SdMmcPassThruResetDevice (
   IN UINT8                                   Slot
   );
 
+/**
+  Checks if this SD controller supports DMA transfer according to capabilities 
register.
+
+  If controller supports ADMA or SDMA, EFI_SUCCESS is returned.
+
+  If controller does not support ADMA nor SDMA, EFI_UNSUPPORTED is returned.
+
+  @param[in]  This              A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL 
instance.
+  @param[in]  Slot              Specifies the slot, whose DMA-support will be 
checked.
+
+  @retval EFI_SUCCESS           SD controller supports DMA operations.
+  @retval EFI_UNSUPPORTED       SD controller does not support DMA operations.
+
+**/
+EFI_STATUS
+EFIAPI
+SdMmcPassThruIsDmaEnabled (
+  IN EFI_SD_MMC_PASS_THRU_PROTOCOL           *This,
+  IN UINT8                                   Slot
+  );
+
 //
 // Driver model protocol interfaces
 //
diff --git a/MdePkg/Include/Protocol/SdMmcPassThru.h 
b/MdePkg/Include/Protocol/SdMmcPassThru.h
index e22456c..7abe40a 100644
--- a/MdePkg/Include/Protocol/SdMmcPassThru.h
+++ b/MdePkg/Include/Protocol/SdMmcPassThru.h
@@ -250,6 +250,27 @@ EFI_STATUS
   IN UINT8                                   Slot
 );
 
+/**
+  Checks if this SD controller supports DMA transfer according to capabilities 
register.
+
+  If controller supports ADMA or SDMA, EFI_SUCCESS is returned.
+
+  If controller does not support ADMA nor SDMA, EFI_UNSUPPORTED is returned.
+
+  @param[in]  This              A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL 
instance.
+  @param[in]  Slot              Specifies the slot, whose DMA-support will be 
checked.
+
+  @retval EFI_SUCCESS           SD controller supports DMA operations.
+  @retval EFI_UNSUPPORTED       SD controller does not support DMA operations.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SD_MMC_PASS_THRU_IS_DMA_ENABLED) (
+  IN EFI_SD_MMC_PASS_THRU_PROTOCOL           *This,
+  IN UINT8                                   Slot
+);
+
 struct _EFI_SD_MMC_PASS_THRU_PROTOCOL {
   UINT32                                     IoAlign;
   EFI_SD_MMC_PASS_THRU_PASSTHRU              PassThru;
@@ -257,6 +278,7 @@ struct _EFI_SD_MMC_PASS_THRU_PROTOCOL {
   EFI_SD_MMC_PASS_THRU_BUILD_DEVICE_PATH     BuildDevicePath;
   EFI_SD_MMC_PASS_THRU_GET_SLOT_NUMBER       GetSlotNumber;
   EFI_SD_MMC_PASS_THRU_RESET_DEVICE          ResetDevice;
+  EFI_SD_MMC_PASS_THRU_IS_DMA_ENABLED        IsDmaEnabled;
 };
 
 extern EFI_GUID gEfiSdMmcPassThruProtocolGuid;
-- 
1.8.3.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to