]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: introduce SD/MMC override protocol
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 7 Dec 2017 22:43:21 +0000 (22:43 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 30 Jan 2018 09:25:13 +0000 (09:25 +0000)
Many ARM based SoCs have integrated SDHCI controllers, and often,
these implementations deviate in subtle ways from the pertinent
specifications. On the one hand, these deviations are quite easy
to work around, but on the other hand, having a collection of SoC
specific workarounds in the generic driver stack is undesirable.

So let's introduce an optional SD/MMC override protocol that we
can invoke at the appropriate moments in the device initialization.
That way, the workaround itself remains platform specific, but we
can still use the generic driver stack on such platforms.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
​Reviewed-by: Star Zeng <star.zeng@intel.com>

MdeModulePkg/Include/Protocol/SdMmcOverride.h [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec

diff --git a/MdeModulePkg/Include/Protocol/SdMmcOverride.h b/MdeModulePkg/Include/Protocol/SdMmcOverride.h
new file mode 100644 (file)
index 0000000..0766252
--- /dev/null
@@ -0,0 +1,97 @@
+/** @file\r
+  Protocol to describe overrides required to support non-standard SDHCI\r
+  implementations\r
+\r
+  Copyright (c) 2017 - 2018, Linaro, Ltd. All rights reserved.<BR>\r
+\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
+\r
+**/\r
+\r
+#ifndef __SD_MMC_OVERRIDE_H__\r
+#define __SD_MMC_OVERRIDE_H__\r
+\r
+#include <Protocol/SdMmcPassThru.h>\r
+\r
+#define EDKII_SD_MMC_OVERRIDE_PROTOCOL_GUID \\r
+  { 0xeaf9e3c1, 0xc9cd, 0x46db, { 0xa5, 0xe5, 0x5a, 0x12, 0x4c, 0x83, 0x23, 0x23 } }\r
+\r
+#define EDKII_SD_MMC_OVERRIDE_PROTOCOL_VERSION    0x1\r
+\r
+typedef struct _EDKII_SD_MMC_OVERRIDE EDKII_SD_MMC_OVERRIDE;\r
+\r
+typedef enum {\r
+  EdkiiSdMmcResetPre,\r
+  EdkiiSdMmcResetPost,\r
+  EdkiiSdMmcInitHostPre,\r
+  EdkiiSdMmcInitHostPost,\r
+} EDKII_SD_MMC_PHASE_TYPE;\r
+\r
+/**\r
+\r
+  Override function for SDHCI capability bits\r
+\r
+  @param[in]      ControllerHandle      The EFI_HANDLE of the controller.\r
+  @param[in]      Slot                  The 0 based slot index.\r
+  @param[in,out]  SdMmcHcSlotCapability The SDHCI capability structure.\r
+\r
+  @retval EFI_SUCCESS           The override function completed successfully.\r
+  @retval EFI_NOT_FOUND         The specified controller or slot does not exist.\r
+  @retval EFI_INVALID_PARAMETER SdMmcHcSlotCapability is NULL\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EDKII_SD_MMC_CAPABILITY) (\r
+  IN      EFI_HANDLE                      ControllerHandle,\r
+  IN      UINT8                           Slot,\r
+  IN  OUT VOID                            *SdMmcHcSlotCapability\r
+  );\r
+\r
+/**\r
+\r
+  Override function for SDHCI controller operations\r
+\r
+  @param[in]      ControllerHandle      The EFI_HANDLE of the controller.\r
+  @param[in]      Slot                  The 0 based slot index.\r
+  @param[in]      PhaseType             The type of operation and whether the\r
+                                        hook is invoked right before (pre) or\r
+                                        right after (post)\r
+\r
+  @retval EFI_SUCCESS           The override function completed successfully.\r
+  @retval EFI_NOT_FOUND         The specified controller or slot does not exist.\r
+  @retval EFI_INVALID_PARAMETER PhaseType is invalid\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI * EDKII_SD_MMC_NOTIFY_PHASE) (\r
+  IN      EFI_HANDLE                      ControllerHandle,\r
+  IN      UINT8                           Slot,\r
+  IN      EDKII_SD_MMC_PHASE_TYPE         PhaseType\r
+  );\r
+\r
+struct _EDKII_SD_MMC_OVERRIDE {\r
+  //\r
+  // Protocol version of this implementation\r
+  //\r
+  UINTN                         Version;\r
+  //\r
+  // Callback to override SD/MMC host controller capability bits\r
+  //\r
+  EDKII_SD_MMC_CAPABILITY       Capability;\r
+  //\r
+  // Callback to invoke SD/MMC override hooks\r
+  //\r
+  EDKII_SD_MMC_NOTIFY_PHASE     NotifyPhase;\r
+};\r
+\r
+extern EFI_GUID gEdkiiSdMmcOverrideProtocolGuid;\r
+\r
+#endif\r
index 0298bed6e3175fc677f1547b60d6ab7a076f89d9..61d034fba85e3a088fddd61180d2ba31788dfc37 100644 (file)
   ## Include/Protocol/SmmMemoryAttribute.h\r
   gEdkiiSmmMemoryAttributeProtocolGuid = { 0x69b792ea, 0x39ce, 0x402d, { 0xa2, 0xa6, 0xf7, 0x21, 0xde, 0x35, 0x1d, 0xfe } }\r
 \r
+  ## Include/Protocol/SdMmcOverride.h\r
+  gEdkiiSdMmcOverrideProtocolGuid = { 0xeaf9e3c1, 0xc9cd, 0x46db, { 0xa5, 0xe5, 0x5a, 0x12, 0x4c, 0x83, 0x23, 0x23 } }\r
+\r
 #\r
 # [Error.gEfiMdeModulePkgTokenSpaceGuid]\r
 #   0x80000001 | Invalid value provided.\r