diff options
-rw-r--r-- | MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 56 | ||||
-rw-r--r-- | MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h | 10 |
2 files changed, 41 insertions, 25 deletions
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index a03b2ce..c1072af 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -1862,43 +1862,47 @@ UfsEnableHostController ( }
}
- //
- // UFS 2.0 spec section 7.1.1 - Host Controller Initialization
- //
- // Reinitialize the UFS host controller if HCE bit of HC register is set.
- //
- Status = UfsMmioRead32 (Private, UFS_HC_ENABLE_OFFSET, &Data);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if ((Data & UFS_HC_HCE_EN) == UFS_HC_HCE_EN) {
+ if ((mUfsHcPlatform == NULL) ||
+ ((mUfsHcPlatform->Version >= 3) && !mUfsHcPlatform->SkipHceReenable))
+ {
//
- // Write a 0 to the HCE register at first to disable the host controller.
+ // UFS 2.0 spec section 7.1.1 - Host Controller Initialization
//
- Status = UfsMmioWrite32 (Private, UFS_HC_ENABLE_OFFSET, 0);
+ // Reinitialize the UFS host controller if HCE bit of HC register is set.
+ //
+ Status = UfsMmioRead32 (Private, UFS_HC_ENABLE_OFFSET, &Data);
if (EFI_ERROR (Status)) {
return Status;
}
+ if ((Data & UFS_HC_HCE_EN) == UFS_HC_HCE_EN) {
+ //
+ // Write a 0 to the HCE register at first to disable the host controller.
+ //
+ Status = UfsMmioWrite32 (Private, UFS_HC_ENABLE_OFFSET, 0);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Wait until HCE is read as '0' before continuing.
+ //
+ Status = UfsWaitMemSet (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN, 0, UFS_TIMEOUT);
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+ }
+
//
- // Wait until HCE is read as '0' before continuing.
+ // Write a 1 to the HCE register to enable the UFS host controller.
//
- Status = UfsWaitMemSet (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN, 0, UFS_TIMEOUT);
+ Status = UfsMmioWrite32 (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN);
if (EFI_ERROR (Status)) {
- return EFI_DEVICE_ERROR;
+ return Status;
}
}
//
- // Write a 1 to the HCE register to enable the UFS host controller.
- //
- Status = UfsMmioWrite32 (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
// Wait until HCE is read as '1' before continuing.
//
Status = UfsWaitMemSet (Private, UFS_HC_ENABLE_OFFSET, UFS_HC_HCE_EN, UFS_HC_HCE_EN, UFS_TIMEOUT);
@@ -1945,6 +1949,10 @@ UfsDeviceDetection ( }
}
+ if ((mUfsHcPlatform != NULL) && (mUfsHcPlatform->Version >= 3) && mUfsHcPlatform->SkipLinkStartup) {
+ return EFI_SUCCESS;
+ }
+
//
// Start UFS device detection.
// Try up to 3 times for establishing data link with device.
diff --git a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h b/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h index 32e9f64..b5b3160 100644 --- a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h +++ b/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h @@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Protocol/UfsHostController.h>
-#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 2
+#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 3
extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid;
@@ -129,6 +129,14 @@ struct _EDKII_UFS_HC_PLATFORM_PROTOCOL { /// Reference Clock Frequency Ufs Card Attribute that need to be set in this Ufs Host Environment.
///
EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE RefClkFreq;
+ ///
+ /// Flag to skip HCE re-enable.
+ ///
+ BOOLEAN SkipHceReenable;
+ ///
+ /// Flag to skip link startup.
+ ///
+ BOOLEAN SkipLinkStartup;
};
#endif
|