Skip to content

Commit

Permalink
MdeModulePkg/UfsPassThruDxe: Migrate UFS Initial Completion Timeout t…
Browse files Browse the repository at this point in the history
…o PCD

- Remove the hardcoded definition (UFS_INIT_COMPLETION_TIMEOUT)
- Migrate the UFS initial completion timeout into PCD value

Signed-off-by: Jason1 Lin <[email protected]>
  • Loading branch information
linjaso1 authored and mergify[bot] committed Jul 30, 2024
1 parent 5289ad1 commit f8f34ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 1 addition & 4 deletions MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ UfsFinishDeviceInitialization (
UINT32 Timeout;

DeviceInitStatus = 0xFF;
Timeout = PcdGet32 (PcdUfsInitialCompletionTimeout);

//
// The host enables the device initialization completion by setting fDeviceInit flag.
Expand All @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h>
#include <Library/PcdLib.h>
#include <Library/TimerLib.h>

#include "UfsPassThruHci.h"
Expand All @@ -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];
Expand Down
4 changes: 4 additions & 0 deletions MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
UefiDriverEntryPoint
DebugLib
DevicePathLib
PcdLib
TimerLib

[Protocols]
Expand All @@ -56,5 +57,8 @@
gEdkiiUfsHostControllerProtocolGuid ## TO_START
gEdkiiUfsHcPlatformProtocolGuid ## SOMETIMES_CONSUMES

[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdUfsInitialCompletionTimeout ## CONSUMES

[UserExtensions.TianoCore."ExtraFiles"]
UfsPassThruExtra.uni

0 comments on commit f8f34ed

Please sign in to comment.