mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
MdeModulePkg: Support conditional UFS initialization
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>
This commit is contained in:
parent
9baa6193c2
commit
b58ce4c226
2 changed files with 44 additions and 28 deletions
|
|
@ -1862,40 +1862,44 @@ 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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 '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;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue