summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus
diff options
context:
space:
mode:
authorAlbecki, Mateusz <mateusz.albecki@intel.com>2019-06-21 23:27:02 +0800
committerHao A Wu <hao.a.wu@intel.com>2019-06-27 09:09:07 +0800
commitf426d8744f3f5321cd88b23cf6e93865d5d18e00 (patch)
tree319c0e3b6240aa02351cd4a47918da960fd707b9 /MdeModulePkg/Bus
parentc78008b4b29527f40a98f8da0022e9f55559fdd6 (diff)
downloadedk2-f426d8744f3f5321cd88b23cf6e93865d5d18e00.tar.gz
edk2-f426d8744f3f5321cd88b23cf6e93865d5d18e00.tar.bz2
edk2-f426d8744f3f5321cd88b23cf6e93865d5d18e00.zip
MdeModulePkg/UfsPassThruDxe: Refactor UFS device presence detection
In current implementation we are checking for device presence every time we execute UIC command. To make UfsExecUicCommands more generic checking device presence has been moved to UfsDeviceDetection. Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Diffstat (limited to 'MdeModulePkg/Bus')
-rw-r--r--MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c50
1 files changed, 18 insertions, 32 deletions
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index 4b93821f38..633f975e30 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -1534,7 +1534,7 @@ Exit1:
/**
- Sent UIC DME_LINKSTARTUP command to start the link startup procedure.
+ Send UIC command.
@param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
@param[in] UicOpcode The opcode of the UIC command.
@@ -1544,7 +1544,6 @@ Exit1:
@return EFI_SUCCESS Successfully execute this UIC command and detect attached UFS device.
@return EFI_DEVICE_ERROR Fail to execute this UIC command and detect attached UFS device.
- @return EFI_NOT_FOUND The presence of the UFS device isn't detected.
**/
EFI_STATUS
@@ -1629,24 +1628,6 @@ UfsExecUicCommands (
}
}
- //
- // Check value of HCS.DP and make sure that there is a device attached to the Link.
- //
- Status = UfsMmioRead32 (Private, UFS_HC_STATUS_OFFSET, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if ((Data & UFS_HC_HCS_DP) == 0) {
- Status = UfsWaitMemSet (Private, UFS_HC_IS_OFFSET, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UFS_TIMEOUT);
- if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
- }
- return EFI_NOT_FOUND;
- }
-
- DEBUG ((DEBUG_INFO, "UfsPassThruDxe: found a attached UFS device\n"));
-
return EFI_SUCCESS;
}
@@ -1820,8 +1801,9 @@ UfsDeviceDetection (
IN UFS_PASS_THRU_PRIVATE_DATA *Private
)
{
- UINTN Retry;
- EFI_STATUS Status;
+ UINTN Retry;
+ EFI_STATUS Status;
+ UINT32 Data;
//
// Start UFS device detection.
@@ -1829,22 +1811,26 @@ UfsDeviceDetection (
//
for (Retry = 0; Retry < 3; Retry++) {
Status = UfsExecUicCommands (Private, UfsUicDmeLinkStartup, 0, 0, 0);
- if (!EFI_ERROR (Status)) {
- break;
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
}
- if (Status == EFI_NOT_FOUND) {
- continue;
+ Status = UfsMmioRead32 (Private, UFS_HC_STATUS_OFFSET, &Data);
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
}
- return EFI_DEVICE_ERROR;
- }
-
- if (Retry == 3) {
- return EFI_NOT_FOUND;
+ if ((Data & UFS_HC_HCS_DP) == 0) {
+ Status = UfsWaitMemSet (Private, UFS_HC_IS_OFFSET, UFS_HC_IS_ULSS, UFS_HC_IS_ULSS, UFS_TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ } else {
+ return EFI_SUCCESS;
+ }
}
- return EFI_SUCCESS;
+ return EFI_NOT_FOUND;
}
/**