From f8f34edd9db82882fd70f14cb97ab28e9bb0b9a3 Mon Sep 17 00:00:00 2001 From: Jason1 Lin Date: Sat, 27 Jul 2024 18:38:13 +0800 Subject: [PATCH] MdeModulePkg/UfsPassThruDxe: Migrate UFS Initial Completion Timeout to PCD - Remove the hardcoded definition (UFS_INIT_COMPLETION_TIMEOUT) - Migrate the UFS initial completion timeout into PCD value Signed-off-by: Jason1 Lin --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 5 +---- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 6 +++--- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf | 4 ++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 880e7d8511..816532d20e 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -759,6 +759,7 @@ UfsFinishDeviceInitialization ( UINT32 Timeout; DeviceInitStatus = 0xFF; + Timeout = PcdGet32 (PcdUfsInitialCompletionTimeout); // // The host enables the device initialization completion by setting fDeviceInit flag. @@ -768,10 +769,6 @@ UfsFinishDeviceInitialization ( return Status; } - // - // There are cards that can take upto 600ms to clear fDeviceInit flag. - // - Timeout = UFS_INIT_COMPLETION_TIMEOUT; do { Status = UfsReadFlag (Private, UfsFlagDevInit, &DeviceInitStatus); if (EFI_ERROR (Status)) { diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index bc1139da6e..d380650319 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "UfsPassThruHci.h" @@ -38,9 +39,8 @@ // Lun 10: BOOT // Lun 11: RPMB // -#define UFS_MAX_LUNS 12 -#define UFS_WLUN_PREFIX 0xC1 -#define UFS_INIT_COMPLETION_TIMEOUT 600000 +#define UFS_MAX_LUNS 12 +#define UFS_WLUN_PREFIX 0xC1 typedef struct { UINT8 Lun[UFS_MAX_LUNS]; diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf index 92dc25714b..0e12b7a8b4 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf @@ -48,6 +48,7 @@ UefiDriverEntryPoint DebugLib DevicePathLib + PcdLib TimerLib [Protocols] @@ -56,5 +57,8 @@ gEdkiiUfsHostControllerProtocolGuid ## TO_START gEdkiiUfsHcPlatformProtocolGuid ## SOMETIMES_CONSUMES +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdUfsInitialCompletionTimeout ## CONSUMES + [UserExtensions.TianoCore."ExtraFiles"] UfsPassThruExtra.uni