/** @file\r
\r
- Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
},\r
0, // UfsHostController\r
0, // UfsHcBase\r
- 0, // Capabilities\r
+ {0, 0}, // UfsHcInfo\r
+ {NULL, NULL}, // UfsHcDriverInterface\r
0, // TaskTag\r
0, // UtpTrlBase\r
0, // Nutrs\r
\r
UINT8 mUfsTargetId[TARGET_MAX_BYTES];\r
\r
+GLOBAL_REMOVE_IF_UNREFERENCED EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatform;\r
+\r
/**\r
Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function\r
supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the\r
UINTN UfsHcBase;\r
UINT32 Index;\r
UFS_UNIT_DESC UnitDescriptor;\r
+ UFS_DEV_DESC DeviceDescriptor;\r
UINT32 UnitDescriptorSize;\r
+ UINT32 DeviceDescriptorSize;\r
\r
Status = EFI_SUCCESS;\r
UfsHc = NULL;\r
Private->ExtScsiPassThru.Mode = &Private->ExtScsiPassThruMode;\r
Private->UfsHostController = UfsHc;\r
Private->UfsHcBase = UfsHcBase;\r
+ Private->Handle = Controller;\r
+ Private->UfsHcDriverInterface.UfsHcProtocol = UfsHc;\r
+ Private->UfsHcDriverInterface.UfsExecUicCommand = UfsHcDriverInterfaceExecUicCommand;\r
InitializeListHead (&Private->Queue);\r
\r
+ //\r
+ // This has to be done before initializing UfsHcInfo or calling the UfsControllerInit\r
+ //\r
+ if (mUfsHcPlatform == NULL) {\r
+ Status = gBS->LocateProtocol (&gEdkiiUfsHcPlatformProtocolGuid, NULL, (VOID**)&mUfsHcPlatform);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((DEBUG_INFO, "No UfsHcPlatformProtocol present\n"));\r
+ }\r
+ }\r
+\r
+ Status = GetUfsHcInfo (Private);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((DEBUG_ERROR, "Failed to initialize UfsHcInfo\n"));\r
+ goto Error;\r
+ }\r
+\r
//\r
// Initialize UFS Host Controller H/W.\r
//\r
\r
//\r
// Check if 8 common luns are active and set corresponding bit mask.\r
- // TODO: Parse device descriptor to decide if exposing RPMB LUN to upper layer for authentication access.\r
//\r
UnitDescriptorSize = sizeof (UFS_UNIT_DESC);\r
for (Index = 0; Index < 8; Index++) {\r
}\r
}\r
\r
+ //\r
+ // Check if RPMB WLUN is supported and set corresponding bit mask.\r
+ //\r
+ DeviceDescriptorSize = sizeof (UFS_DEV_DESC);\r
+ Status = UfsRwDeviceDesc (Private, TRUE, UfsDeviceDesc, 0, 0, &DeviceDescriptor, &DeviceDescriptorSize);\r
+ if (EFI_ERROR (Status)) {\r
+ DEBUG ((DEBUG_ERROR, "Failed to read device descriptor, status = %r\n", Status));\r
+ } else {\r
+ if (DeviceDescriptor.SecurityLun == 0x1) {\r
+ DEBUG ((DEBUG_INFO, "UFS WLUN RPMB is supported\n"));\r
+ Private->Luns.BitMask |= BIT11;\r
+ }\r
+ }\r
+\r
//\r
// Start the asynchronous interrupt monitor\r
//\r