]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UfsPassThruDxe: Refactor UfsExecUicCommand function
authorAlbecki, Mateusz <mateusz.albecki@intel.com>
Fri, 9 Aug 2019 14:36:18 +0000 (22:36 +0800)
committerHao A Wu <hao.a.wu@intel.com>
Tue, 13 Aug 2019 02:54:35 +0000 (10:54 +0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=1343

UfsExecUicCommand function has been refactored to allow
the caller to check the command results which is important
for commands such as UIC read.

Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h
MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c

index 9b68db5ffea22412f31bed6c9b3891800d67e200..b79be77709b8279d133b2938000cfaded75b1b9a 100644 (file)
@@ -1,6 +1,6 @@
 /** @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
@@ -13,6 +13,7 @@
 #include <Protocol/ScsiPassThruExt.h>\r
 #include <Protocol/UfsDeviceConfig.h>\r
 #include <Protocol/UfsHostController.h>\r
+#include <Protocol/UfsHostControllerPlatform.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
index 912d6f82022ac6b2a21b60552ae915e511a3a372..6ea27e473cc72386c23fbeb971bade177ff93b62 100644 (file)
@@ -2,7 +2,7 @@
   UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol interface\r
   for upper layer application to execute UFS-supported SCSI cmds.\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
@@ -1633,11 +1633,8 @@ Exit1:
 /**\r
   Send UIC command.\r
 \r
-  @param[in] Private          The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r
-  @param[in] UicOpcode        The opcode of the UIC command.\r
-  @param[in] Arg1             The value for 1st argument of the UIC command.\r
-  @param[in] Arg2             The value for 2nd argument of the UIC command.\r
-  @param[in] Arg3             The value for 3rd argument of the UIC command.\r
+  @param[in]      Private     The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.\r
+  @param[in, out] UicCommand  UIC command descriptor. On exit contains UIC command results.\r
 \r
   @return EFI_SUCCESS      Successfully execute this UIC command and detect attached UFS device.\r
   @return EFI_DEVICE_ERROR Fail to execute this UIC command and detect attached UFS device.\r
@@ -1646,10 +1643,7 @@ Exit1:
 EFI_STATUS\r
 UfsExecUicCommands (\r
   IN  UFS_PASS_THRU_PRIVATE_DATA    *Private,\r
-  IN  UINT8                         UicOpcode,\r
-  IN  UINT32                        Arg1,\r
-  IN  UINT32                        Arg2,\r
-  IN  UINT32                        Arg3\r
+  IN OUT EDKII_UIC_COMMAND          *UicCommand\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -1675,17 +1669,17 @@ UfsExecUicCommands (
   // only after all the UIC command argument registers (UICCMDARG1, UICCMDARG2 and UICCMDARG3)\r
   // are set.\r
   //\r
-  Status = UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG1_OFFSET, Arg1);\r
+  Status = UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG1_OFFSET, UicCommand->Arg1);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  Status = UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG2_OFFSET, Arg2);\r
+  Status = UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG2_OFFSET, UicCommand->Arg2);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  Status = UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG3_OFFSET, Arg3);\r
+  Status = UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG3_OFFSET, UicCommand->Arg3);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -1698,7 +1692,7 @@ UfsExecUicCommands (
     return Status;\r
   }\r
 \r
-  Status = UfsMmioWrite32 (Private, UFS_HC_UIC_CMD_OFFSET, (UINT32)UicOpcode);\r
+  Status = UfsMmioWrite32 (Private, UFS_HC_UIC_CMD_OFFSET, UicCommand->Opcode);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -1712,14 +1706,18 @@ UfsExecUicCommands (
     return Status;\r
   }\r
 \r
-  if (UicOpcode != UfsUicDmeReset) {\r
-    Status = UfsMmioRead32 (Private, UFS_HC_UCMD_ARG2_OFFSET, &Data);\r
+  if (UicCommand->Opcode != UfsUicDmeReset) {\r
+    Status = UfsMmioRead32 (Private, UFS_HC_UCMD_ARG2_OFFSET, &UicCommand->Arg2);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
-    if ((Data & 0xFF) != 0) {\r
+    Status = UfsMmioRead32 (Private, UFS_HC_UCMD_ARG3_OFFSET, &UicCommand->Arg3);\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+    if ((UicCommand->Arg2 & 0xFF) != 0) {\r
       DEBUG_CODE_BEGIN();\r
-        DumpUicCmdExecResult (UicOpcode, (UINT8)(Data & 0xFF));\r
+        DumpUicCmdExecResult ((UINT8)UicCommand->Opcode, (UINT8)(UicCommand->Arg2 & 0xFF));\r
       DEBUG_CODE_END();\r
       return EFI_DEVICE_ERROR;\r
     }\r
@@ -1898,16 +1896,21 @@ UfsDeviceDetection (
   IN  UFS_PASS_THRU_PRIVATE_DATA     *Private\r
   )\r
 {\r
-  UINTN       Retry;\r
-  EFI_STATUS  Status;\r
-  UINT32      Data;\r
+  UINTN              Retry;\r
+  EFI_STATUS         Status;\r
+  UINT32             Data;\r
+  EDKII_UIC_COMMAND  LinkStartupCommand;\r
 \r
   //\r
   // Start UFS device detection.\r
   // Try up to 3 times for establishing data link with device.\r
   //\r
   for (Retry = 0; Retry < 3; Retry++) {\r
-    Status = UfsExecUicCommands (Private, UfsUicDmeLinkStartup, 0, 0, 0);\r
+    LinkStartupCommand.Opcode = UfsUicDmeLinkStartup;\r
+    LinkStartupCommand.Arg1 = 0;\r
+    LinkStartupCommand.Arg2 = 0;\r
+    LinkStartupCommand.Arg3 = 0;\r
+    Status = UfsExecUicCommands (Private, &LinkStartupCommand);\r
     if (EFI_ERROR (Status)) {\r
       return EFI_DEVICE_ERROR;\r
     }\r