mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/UfsPassThruDxe: Implement EDKII_UFS_HC_PLATFORM_PROTOCOL
https://bugzilla.tianocore.org/show_bug.cgi?id=1343 This commit adds EDKII_UFS_HC_PLATFORM_PROTOCOL implementation in UfsPassThruDxe driver in version 1. Driver assumes that at most one instance of the protocol exists in the system. Presence of the protocol is not mandatory. Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
parent
a71272ed7a
commit
ecc32c90ee
|
@ -36,6 +36,7 @@ UFS_PASS_THRU_PRIVATE_DATA gUfsPassThruTemplate = {
|
||||||
0, // UfsHostController
|
0, // UfsHostController
|
||||||
0, // UfsHcBase
|
0, // UfsHcBase
|
||||||
{0, 0}, // UfsHcInfo
|
{0, 0}, // UfsHcInfo
|
||||||
|
{NULL, NULL}, // UfsHcDriverInterface
|
||||||
0, // TaskTag
|
0, // TaskTag
|
||||||
0, // UtpTrlBase
|
0, // UtpTrlBase
|
||||||
0, // Nutrs
|
0, // Nutrs
|
||||||
|
@ -92,6 +93,8 @@ UFS_DEVICE_PATH mUfsDevicePathTemplate = {
|
||||||
|
|
||||||
UINT8 mUfsTargetId[TARGET_MAX_BYTES];
|
UINT8 mUfsTargetId[TARGET_MAX_BYTES];
|
||||||
|
|
||||||
|
GLOBAL_REMOVE_IF_UNREFERENCED EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function
|
Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function
|
||||||
supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the
|
supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the
|
||||||
|
@ -864,7 +867,21 @@ UfsPassThruDriverBindingStart (
|
||||||
Private->ExtScsiPassThru.Mode = &Private->ExtScsiPassThruMode;
|
Private->ExtScsiPassThru.Mode = &Private->ExtScsiPassThruMode;
|
||||||
Private->UfsHostController = UfsHc;
|
Private->UfsHostController = UfsHc;
|
||||||
Private->UfsHcBase = UfsHcBase;
|
Private->UfsHcBase = UfsHcBase;
|
||||||
|
Private->Handle = Controller;
|
||||||
|
Private->UfsHcDriverInterface.UfsHcProtocol = UfsHc;
|
||||||
|
Private->UfsHcDriverInterface.UfsExecUicCommand = UfsHcDriverInterfaceExecUicCommand;
|
||||||
InitializeListHead (&Private->Queue);
|
InitializeListHead (&Private->Queue);
|
||||||
|
|
||||||
|
//
|
||||||
|
// This has to be done before initializing UfsHcInfo or calling the UfsControllerInit
|
||||||
|
//
|
||||||
|
if (mUfsHcPlatform == NULL) {
|
||||||
|
Status = gBS->LocateProtocol (&gEdkiiUfsHcPlatformProtocolGuid, NULL, (VOID**)&mUfsHcPlatform);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_INFO, "No UfsHcPlatformProtocol present\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Status = GetUfsHcInfo (Private);
|
Status = GetUfsHcInfo (Private);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Failed to initialize UfsHcInfo\n"));
|
DEBUG ((DEBUG_ERROR, "Failed to initialize UfsHcInfo\n"));
|
||||||
|
|
|
@ -63,6 +63,7 @@ typedef struct _UFS_PASS_THRU_PRIVATE_DATA {
|
||||||
EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController;
|
EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController;
|
||||||
UINTN UfsHcBase;
|
UINTN UfsHcBase;
|
||||||
EDKII_UFS_HC_INFO UfsHcInfo;
|
EDKII_UFS_HC_INFO UfsHcInfo;
|
||||||
|
EDKII_UFS_HC_DRIVER_INTERFACE UfsHcDriverInterface;
|
||||||
|
|
||||||
UINT8 TaskTag;
|
UINT8 TaskTag;
|
||||||
|
|
||||||
|
@ -126,6 +127,13 @@ typedef struct {
|
||||||
UFS_PASS_THRU_SIG \
|
UFS_PASS_THRU_SIG \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#define UFS_PASS_THRU_PRIVATE_DATA_FROM_DRIVER_INTF(a) \
|
||||||
|
CR (a, \
|
||||||
|
UFS_PASS_THRU_PRIVATE_DATA, \
|
||||||
|
UfsHcDriverInterface, \
|
||||||
|
UFS_PASS_THRU_SIG \
|
||||||
|
)
|
||||||
|
|
||||||
typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET {
|
typedef struct _UFS_DEVICE_MANAGEMENT_REQUEST_PACKET {
|
||||||
UINT64 Timeout;
|
UINT64 Timeout;
|
||||||
VOID *DataBuffer;
|
VOID *DataBuffer;
|
||||||
|
@ -959,6 +967,23 @@ UfsRwUfsAttribute (
|
||||||
IN OUT UINT32 *AttrSize
|
IN OUT UINT32 *AttrSize
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Execute UIC command.
|
||||||
|
|
||||||
|
@param[in] This Pointer to driver interface produced by the UFS controller.
|
||||||
|
@param[in, out] UicCommand Descriptor of the command that will be executed.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Command executed successfully.
|
||||||
|
@retval EFI_INVALID_PARAMETER This or UicCommand is NULL.
|
||||||
|
@retval Others Command failed to execute.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
UfsHcDriverInterfaceExecUicCommand (
|
||||||
|
IN EDKII_UFS_HC_DRIVER_INTERFACE *This,
|
||||||
|
IN OUT EDKII_UIC_COMMAND *UicCommand
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes UfsHcInfo field in private data.
|
Initializes UfsHcInfo field in private data.
|
||||||
|
|
||||||
|
@ -975,5 +1000,6 @@ GetUfsHcInfo (
|
||||||
extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName;
|
extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName;
|
||||||
extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2;
|
extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2;
|
||||||
extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding;
|
extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding;
|
||||||
|
extern EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatform;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
## @file
|
## @file
|
||||||
# Description file for the Universal Flash Storage (UFS) Pass Thru driver.
|
# Description file for the Universal Flash Storage (UFS) Pass Thru driver.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
#
|
#
|
||||||
|
@ -54,6 +54,7 @@
|
||||||
gEfiExtScsiPassThruProtocolGuid ## BY_START
|
gEfiExtScsiPassThruProtocolGuid ## BY_START
|
||||||
gEfiUfsDeviceConfigProtocolGuid ## BY_START
|
gEfiUfsDeviceConfigProtocolGuid ## BY_START
|
||||||
gEdkiiUfsHostControllerProtocolGuid ## TO_START
|
gEdkiiUfsHostControllerProtocolGuid ## TO_START
|
||||||
|
gEdkiiUfsHcPlatformProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
|
||||||
[UserExtensions.TianoCore."ExtraFiles"]
|
[UserExtensions.TianoCore."ExtraFiles"]
|
||||||
UfsPassThruExtra.uni
|
UfsPassThruExtra.uni
|
||||||
|
|
|
@ -1202,8 +1202,6 @@ UfsSetFlag (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read specified flag from a UFS device.
|
Read specified flag from a UFS device.
|
||||||
|
|
||||||
|
@ -1835,6 +1833,14 @@ UfsEnableHostController (
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINT32 Data;
|
UINT32 Data;
|
||||||
|
|
||||||
|
if (mUfsHcPlatform != NULL && mUfsHcPlatform->Callback != NULL) {
|
||||||
|
Status = mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPreHce, &Private->UfsHcDriverInterface);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHcPreHce, Status = %r\n", Status));
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// UFS 2.0 spec section 7.1.1 - Host Controller Initialization
|
// UFS 2.0 spec section 7.1.1 - Host Controller Initialization
|
||||||
//
|
//
|
||||||
|
@ -1878,6 +1884,14 @@ UfsEnableHostController (
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mUfsHcPlatform != NULL && mUfsHcPlatform->Callback != NULL) {
|
||||||
|
Status = mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPostHce, &Private->UfsHcDriverInterface);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHcPostHce, Status = %r\n", Status));
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1901,6 +1915,14 @@ UfsDeviceDetection (
|
||||||
UINT32 Data;
|
UINT32 Data;
|
||||||
EDKII_UIC_COMMAND LinkStartupCommand;
|
EDKII_UIC_COMMAND LinkStartupCommand;
|
||||||
|
|
||||||
|
if (mUfsHcPlatform != NULL && mUfsHcPlatform->Callback != NULL) {
|
||||||
|
Status = mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPreLinkStartup, &Private->UfsHcDriverInterface);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHcPreLinkStartup, Status = %r\n", Status));
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Start UFS device detection.
|
// Start UFS device detection.
|
||||||
// Try up to 3 times for establishing data link with device.
|
// Try up to 3 times for establishing data link with device.
|
||||||
|
@ -1926,6 +1948,13 @@ UfsDeviceDetection (
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (mUfsHcPlatform != NULL && mUfsHcPlatform->Callback != NULL) {
|
||||||
|
Status = mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPostLinkStartup, &Private->UfsHcDriverInterface);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHcPostLinkStartup, Status = %r\n", Status));
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2350,6 +2379,34 @@ ProcessAsyncTaskList (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Execute UIC command.
|
||||||
|
|
||||||
|
@param[in] This Pointer to driver interface produced by the UFS controller.
|
||||||
|
@param[in, out] UicCommand Descriptor of the command that will be executed.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Command executed successfully.
|
||||||
|
@retval EFI_INVALID_PARAMETER This or UicCommand is NULL.
|
||||||
|
@retval Others Command failed to execute.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
UfsHcDriverInterfaceExecUicCommand (
|
||||||
|
IN EDKII_UFS_HC_DRIVER_INTERFACE *This,
|
||||||
|
IN OUT EDKII_UIC_COMMAND *UicCommand
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UFS_PASS_THRU_PRIVATE_DATA *Private;
|
||||||
|
|
||||||
|
if (This == NULL || UicCommand == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
Private = UFS_PASS_THRU_PRIVATE_DATA_FROM_DRIVER_INTF (This);
|
||||||
|
|
||||||
|
return UfsExecUicCommands (Private, UicCommand);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initializes UfsHcInfo field in private data.
|
Initializes UfsHcInfo field in private data.
|
||||||
|
|
||||||
|
@ -2380,6 +2437,14 @@ GetUfsHcInfo (
|
||||||
|
|
||||||
Private->UfsHcInfo.Capabilities = Data;
|
Private->UfsHcInfo.Capabilities = Data;
|
||||||
|
|
||||||
|
if (mUfsHcPlatform != NULL && mUfsHcPlatform->OverrideHcInfo != NULL) {
|
||||||
|
Status = mUfsHcPlatform->OverrideHcInfo (Private->Handle, &Private->UfsHcInfo);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "Failure from platform on OverrideHcInfo, Status = %r\n", Status));
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue