diff options
author | Bob Morgan <bobm@nvidia.com> | 2025-05-02 15:37:11 -0700 |
---|---|---|
committer | Liming Gao <gaoliming@byosoft.com.cn> | 2025-08-08 09:06:56 +0800 |
commit | b58ce4c226768ced972bd49886e20c5ae6dfd8f0 (patch) | |
tree | 08cc75d86ef7a2bc997fdbecff18186790db1e99 /MdeModulePkg | |
parent | 9baa6193c2849e11f3aea91fc08e3bb01198cf12 (diff) | |
download | edk2-master.zip edk2-master.tar.gz edk2-master.tar.bz2 |
Add SkipHceReenable and SkipLinkStartup flags to
the EDKII_UFS_HC_PLATFORM_PROTOCOL to support
using a UFS controller that has already been
initialized.
Signed-off-by: Bob Morgan <bobm@nvidia.com>
Diffstat (limited to 'MdeModulePkg')
-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
|