From nobody Fri Apr 19 20:37:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45276+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45276+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565361398; cv=none; d=zoho.com; s=zohoarc; b=js1Z7bC0FrwwZdjh5tUwjUk/gvfuB9OY95IcVyhToWIU/dYpTvy69b/si9TcokSm38nSv1TWowmXiOevHIR6dPHReJo+AR6M10FAyvvBukQHDFjtBBkz3c7zLhLdXfRY+AjzcpmMv6b+c8tsVHK4J3wHZ0G40EnXzS9xJ3hpRJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565361398; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZVdt4WZaqFM2oKxouFErARQKrONZ9MbFOVRgAnFFDZw=; b=n1XBDL0HrcxJEVJKjIVcP3OfoRvCcFaNws31lDugGnPn8z5ilmgKOpizwLoAM1+bxdIlToMI+IRZGDMpma9LJV/gbWRoYXhiehIV7dj//BnEU5M7YlUcUhn7l8arH+IvXA5qkr2crhzDUqg5mg0HpNr+HRVUdF97zhKd3bDt5fM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45276+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565361398017156.34256914791126; Fri, 9 Aug 2019 07:36:38 -0700 (PDT) Return-Path: X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by groups.io with SMTP; Fri, 09 Aug 2019 07:36:37 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2019 07:36:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,364,1559545200"; d="scan'208";a="203941920" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga002.fm.intel.com with ESMTP; 09 Aug 2019 07:36:33 -0700 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu Subject: [edk2-devel] [PATCHv3 1/4] MdeModulePkg: Add definition of the EDKII_UFS_HC_PLATFORM_PROTOCOL Date: Fri, 9 Aug 2019 16:36:17 +0200 Message-Id: <20190809143620.4924-2-mateusz.albecki@intel.com> In-Reply-To: <20190809143620.4924-1-mateusz.albecki@intel.com> References: <20190809143620.4924-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565361397; bh=GpsC3yfGwZmy2Qo4E6b9bPndj10V8F6GZhzA5MztP/E=; h=Cc:Date:From:Reply-To:Subject:To; b=l7EBklocf4ZVEnoUETEZNvbtFtyKLLr07d+FyKwqW3MNWjUavfVeNaVu134hjA7203t f4cmvtNFX0UFZ1Q9JaWAiFzNkpgtRNKzLvznUdf7zHwt4XFjgpIV1e9MIzzmrBiTf8D4R o3nirCs30XasN4L6NXVRJ4qerXdL8bbOYV8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D1343 EDKII_UFS_HC_PLATFORM_PROTOCOL will allow the platform to inject platform specific logic into standard UFS flows. Right now we support callbacks pre and post host controller enable and pre and post link startup. Provided callbacks allow the platform driver to inject UIC programming after HCE is set which is a standard initialization step covered by UFS specification as well as cover some additional use cases during other calllbacks. For instance platform driver may switch to fast mode after link startup. We also allow the platform to override host controller capabilities and version which might be usefull to manage silicon bugs or allow testign experimental features from new versions of the specification. Cc: Hao A Wu Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu --- .../Include/Protocol/UfsHostControllerPlatform.h | 124 +++++++++++++++++= ++++ MdeModulePkg/MdeModulePkg.dec | 3 + 2 files changed, 127 insertions(+) create mode 100644 MdeModulePkg/Include/Protocol/UfsHostControllerPlatform= .h diff --git a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h b/Md= eModulePkg/Include/Protocol/UfsHostControllerPlatform.h new file mode 100644 index 0000000000..0f6732a1f8 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h @@ -0,0 +1,124 @@ +/** @file + EDKII_UFS_HC_PLATFORM_PROTOCOL definition. + +Copyright (c) 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __EDKII_UFS_HC_PLATFORM_PROTOCOL_H__ +#define __EDKII_UFS_HC_PLATFORM_PROTOCOL_H__ + +#include + +#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 1 + +extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid; + +typedef struct _EDKII_UFS_HC_PLATFORM_PROTOCOL EDKII_UFS_HC_PLATFORM_PROT= OCOL; + +typedef struct _EDKII_UFS_HC_DRIVER_INTERFACE EDKII_UFS_HC_DRIVER_INTERFA= CE; + +typedef struct { + UINT32 Opcode; + UINT32 Arg1; + UINT32 Arg2; + UINT32 Arg3; +} EDKII_UIC_COMMAND; + +/** + 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 execu= ted. + + @retval EFI_SUCCESS Command executed successfully. + @retval EFI_INVALID_PARAMETER This or UicCommand is NULL. + @retval Others Command failed to execute. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_UFS_EXEC_UIC_COMMAND) ( + IN EDKII_UFS_HC_DRIVER_INTERFACE *This, + IN OUT EDKII_UIC_COMMAND *UicCommand +); + +struct _EDKII_UFS_HC_DRIVER_INTERFACE { + /// + /// Protocol to accesss host controller MMIO and PCI registers. + /// + EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHcProtocol; + /// + /// Function implementing UIC command execution. + /// + EDKII_UFS_EXEC_UIC_COMMAND UfsExecUicCommand; +}; + +typedef struct { + UINT32 Capabilities; + UINT32 Version; +} EDKII_UFS_HC_INFO; + +/** + Allows platform protocol to override host controller information + + @param[in] ControllerHandle Handle of the UFS controller. + @param[in, out] HcInfo Pointer EDKII_UFS_HC_INFO associated w= ith host controller. + + @retval EFI_SUCCESS Function completed successfully. + @retval EFI_INVALID_PARAMETER HcInfo is NULL. + @retval Others Function failed to complete. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_UFS_HC_PLATFORM_OVERRIDE_HC_INFO) ( + IN EFI_HANDLE ControllerHandle, + IN OUT EDKII_UFS_HC_INFO *HcInfo +); + +typedef enum { + EdkiiUfsHcPreHce, + EdkiiUfsHcPostHce, + EdkiiUfsHcPreLinkStartup, + EdkiiUfsHcPostLinkStartup +} EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE; + +/** + Callback function for platform driver. + + @param[in] ControllerHandle Handle of the UFS controller. + @param[in] CallbackPhase Specifies when the platform protocol i= s called + @param[in, out] CallbackData Data specific to the callback phase. + For PreHce and PostHce - EDKII_UFS_HC_= DRIVER_INTERFACE. + For PreLinkStartup and PostLinkStartup= - EDKII_UFS_HC_DRIVER_INTERFACE. + + @retval EFI_SUCCESS Override function completed successfully. + @retval EFI_INVALID_PARAMETER CallbackPhase is invalid or CallbackData = is NULL when phase expects valid data. + @retval Others Function failed to complete. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_UFS_HC_PLATFORM_CALLBACK) ( + IN EFI_HANDLE ControllerHandle, + IN EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE CallbackPhase, + IN OUT VOID *CallbackData +); + +struct _EDKII_UFS_HC_PLATFORM_PROTOCOL { + /// + /// Version of the protocol. + /// + UINT32 Version; + /// + /// Allows platform driver to override host controller information. + /// + EDKII_UFS_HC_PLATFORM_OVERRIDE_HC_INFO OverrideHcInfo; + /// + /// Allows platform driver to implement platform specific flows + /// for host controller. + /// + EDKII_UFS_HC_PLATFORM_CALLBACK Callback; +}; + +#endif + diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index c4139753d3..b663453c8b 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -558,6 +558,9 @@ ## Include/Protocol/UfsHostController.h gEdkiiUfsHostControllerProtocolGuid =3D { 0xebc01af5, 0x7a9, 0x489e, { 0= xb7, 0xce, 0xdc, 0x8, 0x9e, 0x45, 0x9b, 0x2f } } =20 + ## Include/Protocol/UfsHostControllerPlatform.h + gEdkiiUfsHcPlatformProtocolGuid =3D { 0x3d18ba13, 0xd9b1, 0x4dd4, {0xb9,= 0x16, 0xd3, 0x07, 0x96, 0x53, 0x9e, 0xd8}} + ## Include/Protocol/EsrtManagement.h gEsrtManagementProtocolGuid =3D { 0xa340c064, 0x723c, 0x4a9c, { = 0xa4, 0xdd, 0xd5, 0xb4, 0x7a, 0x26, 0xfb, 0xb0 }} =20 --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45276): https://edk2.groups.io/g/devel/message/45276 Mute This Topic: https://groups.io/mt/32811057/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 20:37:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45277+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45277+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565361404; cv=none; d=zoho.com; s=zohoarc; b=ofQFDPeifWiQEuPlHnAG5ku02y5ztz1ySKkc7n1TUrDw+Na5JzdOP3EGdAxp+o578Ovs2y4YAQeIl72VhFMvS4yJDnn2ht9qLC2nwYRMjHCVNVYCvqyREhZvIaU9x3VOLd61QWKH+f81SVatnZBAUH7lB31C5Y6BHmN8LQ/JvjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565361404; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=DiNHSTYQ87ZTMXDKFcF+J1XWoOhWDCjwqmAL6ycRQ2w=; b=Pc7+bSMdDLHwfoIYwRv+wbRPOAO2nJF5x2s9MIs3XocRX+2OgJcbwL59F9dzD+Zb5+tFGCVVDMBqw39IfOsbaWBk+b+OsqA/KruH+uIbiDyRAFLviaZW2S5plMWAf/fJt/7XYpCqYLHfqKRJ2TRXBgObuPeUhTk99MK92SnLy2Y= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45277+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156536140464518.01132986518644; Fri, 9 Aug 2019 07:36:44 -0700 (PDT) Return-Path: X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by groups.io with SMTP; Fri, 09 Aug 2019 07:36:44 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2019 07:36:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,364,1559545200"; d="scan'208";a="203942017" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga002.fm.intel.com with ESMTP; 09 Aug 2019 07:36:41 -0700 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu Subject: [edk2-devel] [PATCHv3 2/4] MdeModulePkg/UfsPassThruDxe: Refactor UfsExecUicCommand function Date: Fri, 9 Aug 2019 16:36:18 +0200 Message-Id: <20190809143620.4924-3-mateusz.albecki@intel.com> In-Reply-To: <20190809143620.4924-1-mateusz.albecki@intel.com> References: <20190809143620.4924-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565361404; bh=iQyW5yKrsl7eIjctxFqGANbp2Nyx4oSz9pHXBd91XfE=; h=Cc:Date:From:Reply-To:Subject:To; b=v5s4rYJaN18OdtE6GD2oaf4Mjg14ouS+BepTxhy3bzUKKuiw8mRTZ9jTOTU1MCMUt9d PWgTnIcOlyCEFv9sI8XIeuhfhA7Hw7/rrKCBGsXm94cOY++5amVbQkbTADIt/ZzVTpbMs +XOipo5QDGCiVnxYlJwVine2KkrDQseJR8g= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D1343 UfsExecUicCommand function has been refactored to allow the caller to check the command results which is important for commands such as UIC read. Cc: Hao A Wu Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 3 +- .../Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 47 ++++++++++++------= ---- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index 9b68db5ffe..b79be77709 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -13,6 +13,7 @@ #include #include #include +#include =20 #include #include diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 912d6f8202..6ea27e473c 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -2,7 +2,7 @@ UfsPassThruDxe driver is used to produce EFI_EXT_SCSI_PASS_THRU protocol= interface for upper layer application to execute UFS-supported SCSI cmds. =20 - Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -1633,11 +1633,8 @@ Exit1: /** Send UIC command. =20 - @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DAT= A data structure. - @param[in] UicOpcode The opcode of the UIC command. - @param[in] Arg1 The value for 1st argument of the UIC comman= d. - @param[in] Arg2 The value for 2nd argument of the UIC comman= d. - @param[in] Arg3 The value for 3rd argument of the UIC comman= d. + @param[in] Private The pointer to the UFS_PASS_THRU_PRIVATE_DAT= A data structure. + @param[in, out] UicCommand UIC command descriptor. On exit contains UIC= command results. =20 @return EFI_SUCCESS Successfully execute this UIC command and detec= t attached UFS device. @return EFI_DEVICE_ERROR Fail to execute this UIC command and detect att= ached UFS device. @@ -1646,10 +1643,7 @@ Exit1: EFI_STATUS UfsExecUicCommands ( IN UFS_PASS_THRU_PRIVATE_DATA *Private, - IN UINT8 UicOpcode, - IN UINT32 Arg1, - IN UINT32 Arg2, - IN UINT32 Arg3 + IN OUT EDKII_UIC_COMMAND *UicCommand ) { EFI_STATUS Status; @@ -1675,17 +1669,17 @@ UfsExecUicCommands ( // only after all the UIC command argument registers (UICCMDARG1, UICCMD= ARG2 and UICCMDARG3) // are set. // - Status =3D UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG1_OFFSET, Arg1); + Status =3D UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG1_OFFSET, UicCommand-= >Arg1); if (EFI_ERROR (Status)) { return Status; } =20 - Status =3D UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG2_OFFSET, Arg2); + Status =3D UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG2_OFFSET, UicCommand-= >Arg2); if (EFI_ERROR (Status)) { return Status; } =20 - Status =3D UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG3_OFFSET, Arg3); + Status =3D UfsMmioWrite32 (Private, UFS_HC_UCMD_ARG3_OFFSET, UicCommand-= >Arg3); if (EFI_ERROR (Status)) { return Status; } @@ -1698,7 +1692,7 @@ UfsExecUicCommands ( return Status; } =20 - Status =3D UfsMmioWrite32 (Private, UFS_HC_UIC_CMD_OFFSET, (UINT32)UicOp= code); + Status =3D UfsMmioWrite32 (Private, UFS_HC_UIC_CMD_OFFSET, UicCommand->O= pcode); if (EFI_ERROR (Status)) { return Status; } @@ -1712,14 +1706,18 @@ UfsExecUicCommands ( return Status; } =20 - if (UicOpcode !=3D UfsUicDmeReset) { - Status =3D UfsMmioRead32 (Private, UFS_HC_UCMD_ARG2_OFFSET, &Data); + if (UicCommand->Opcode !=3D UfsUicDmeReset) { + Status =3D UfsMmioRead32 (Private, UFS_HC_UCMD_ARG2_OFFSET, &UicComman= d->Arg2); if (EFI_ERROR (Status)) { return Status; } - if ((Data & 0xFF) !=3D 0) { + Status =3D UfsMmioRead32 (Private, UFS_HC_UCMD_ARG3_OFFSET, &UicComman= d->Arg3); + if (EFI_ERROR (Status)) { + return Status; + } + if ((UicCommand->Arg2 & 0xFF) !=3D 0) { DEBUG_CODE_BEGIN(); - DumpUicCmdExecResult (UicOpcode, (UINT8)(Data & 0xFF)); + DumpUicCmdExecResult ((UINT8)UicCommand->Opcode, (UINT8)(UicComman= d->Arg2 & 0xFF)); DEBUG_CODE_END(); return EFI_DEVICE_ERROR; } @@ -1898,16 +1896,21 @@ UfsDeviceDetection ( IN UFS_PASS_THRU_PRIVATE_DATA *Private ) { - UINTN Retry; - EFI_STATUS Status; - UINT32 Data; + UINTN Retry; + EFI_STATUS Status; + UINT32 Data; + EDKII_UIC_COMMAND LinkStartupCommand; =20 // // Start UFS device detection. // Try up to 3 times for establishing data link with device. // for (Retry =3D 0; Retry < 3; Retry++) { - Status =3D UfsExecUicCommands (Private, UfsUicDmeLinkStartup, 0, 0, 0); + LinkStartupCommand.Opcode =3D UfsUicDmeLinkStartup; + LinkStartupCommand.Arg1 =3D 0; + LinkStartupCommand.Arg2 =3D 0; + LinkStartupCommand.Arg3 =3D 0; + Status =3D UfsExecUicCommands (Private, &LinkStartupCommand); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45277): https://edk2.groups.io/g/devel/message/45277 Mute This Topic: https://groups.io/mt/32811059/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 20:37:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45278+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45278+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565361407; cv=none; d=zoho.com; s=zohoarc; b=GWz5FkBnGdwsJZ7eCkWLJuProc1pJkKJEQxlLS+pPcv7KLSKe4VvSbV3tiXSMUz7Mx4WlKcmsv5AYxE7UA1aUFAT0ZhkQceF58J9T2yVLUSjm64ZCMN02s5n6dXX//21UeQao+hnJDxFL8uPQSxfhfDXNAL3D4NUQlzEIVwMc7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565361407; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=zxMeWQR3ctwxGdGPMXPaCX8t92n6eJ6F6NmKcX0Aja8=; b=XTw7Ndv2eSbRA9nT34ZGJmQxwzjOzYLcxFfcLt1DIIoVwo5/Gcny/ayxLYNlK985mscexFHr3cWSYiulrUcDNc2XgrAuvGhV+5ppsH0s4Lw4DHM1V7WtESOtxcc8o5VG4gyT+gmWOWgxc0V2yBUJYVBcIdRhofQWu3P6LSj4YrM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45278+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565361407179170.74099104725815; Fri, 9 Aug 2019 07:36:47 -0700 (PDT) Return-Path: X-Received: from mga09.intel.com (mga09.intel.com []) by groups.io with SMTP; Fri, 09 Aug 2019 07:36:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2019 07:36:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,364,1559545200"; d="scan'208";a="203942047" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga002.fm.intel.com with ESMTP; 09 Aug 2019 07:36:45 -0700 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu Subject: [edk2-devel] [PATCHv3 3/4] MdeModulePkg/UfsPassThruDxe: Refactor private data to use EDKII_UFS_HC_INFO Date: Fri, 9 Aug 2019 16:36:19 +0200 Message-Id: <20190809143620.4924-4-mateusz.albecki@intel.com> In-Reply-To: <20190809143620.4924-1-mateusz.albecki@intel.com> References: <20190809143620.4924-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565361406; bh=YIFgccjCjwHxG+szrnAgl9u8kWmKGPkp1GzxuvznB1s=; h=Cc:Date:From:Reply-To:Subject:To; b=Huz98tzzacxXM463TInWHroyvOLVTl0YRQzec3C/f89NhsC7vz9fc8arlt3OaDVqR9v asuJhqHtCOIguCwb3zRj/+6F0L3W0mLG8ZmY6ChFT03GVZJVRX6gPPp1336QLkd0PI8s/ iWE3HX3mwAbw4Lrvc0QMLXWVBdBAVCRnPJ0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D1343 Private data has been refactored to use EDKII_UFS_HC_INFO structure to store host controller capabilities and version information. Getting host controller data has been moved into single place and is done before host controller enable. Cc: Hao A Wu Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 9 +++- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 15 +++++- .../Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 57 ++++++++++++++----= ---- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 1518b251d8..7dce217d49 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -35,7 +35,7 @@ UFS_PASS_THRU_PRIVATE_DATA gUfsPassThruTemplate =3D { }, 0, // UfsHostController 0, // UfsHcBase - 0, // Capabilities + {0, 0}, // UfsHcInfo 0, // TaskTag 0, // UtpTrlBase 0, // Nutrs @@ -865,6 +865,11 @@ UfsPassThruDriverBindingStart ( Private->UfsHostController =3D UfsHc; Private->UfsHcBase =3D UfsHcBase; InitializeListHead (&Private->Queue); + Status =3D GetUfsHcInfo (Private); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to initialize UfsHcInfo\n")); + goto Error; + } =20 // // Initialize UFS Host Controller H/W. diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index b79be77709..c511aa8c7a 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -62,7 +62,7 @@ typedef struct _UFS_PASS_THRU_PRIVATE_DATA { EFI_UFS_DEVICE_CONFIG_PROTOCOL UfsDevConfig; EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController; UINTN UfsHcBase; - UINT32 Capabilities; + EDKII_UFS_HC_INFO UfsHcInfo; =20 UINT8 TaskTag; =20 @@ -959,6 +959,19 @@ UfsRwUfsAttribute ( IN OUT UINT32 *AttrSize ); =20 +/** + Initializes UfsHcInfo field in private data. + + @param[in] Private Pointer to host controller private data. + + @retval EFI_SUCCESS UfsHcInfo initialized successfully. + @retval Others Failed to initalize UfsHcInfo. +**/ +EFI_STATUS +GetUfsHcInfo ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private + ); + extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName; extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2; extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding; diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 6ea27e473c..74be3efc41 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -731,7 +731,7 @@ UfsFindAvailableSlotInTrl ( return Status; } =20 - Nutrs =3D (UINT8)((Private->Capabilities & UFS_HC_CAP_NUTRS) + 1); + Nutrs =3D (UINT8)((Private->UfsHcInfo.Capabilities & UFS_HC_CAP_NUTRS)= + 1); =20 for (Index =3D 0; Index < Nutrs; Index++) { if ((Data & (BIT0 << Index)) =3D=3D 0) { @@ -1754,7 +1754,7 @@ UfsAllocateAlignCommonBuffer ( BOOLEAN Is32BitAddr; EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc; =20 - if ((Private->Capabilities & UFS_HC_CAP_64ADDR) =3D=3D UFS_HC_CAP_64ADDR= ) { + if ((Private->UfsHcInfo.Capabilities & UFS_HC_CAP_64ADDR) =3D=3D UFS_HC_= CAP_64ADDR) { Is32BitAddr =3D FALSE; } else { Is32BitAddr =3D TRUE; @@ -1947,7 +1947,6 @@ UfsInitTaskManagementRequestList ( IN UFS_PASS_THRU_PRIVATE_DATA *Private ) { - UINT32 Data; UINT8 Nutmrs; VOID *CmdDescHost; EFI_PHYSICAL_ADDRESS CmdDescPhyAddr; @@ -1961,17 +1960,10 @@ UfsInitTaskManagementRequestList ( CmdDescMapping =3D NULL; CmdDescPhyAddr =3D 0; =20 - Status =3D UfsMmioRead32 (Private, UFS_HC_CAP_OFFSET, &Data); - if (EFI_ERROR (Status)) { - return Status; - } - - Private->Capabilities =3D Data; - // // Allocate and initialize UTP Task Management Request List. // - Nutmrs =3D (UINT8) (RShiftU64 ((Private->Capabilities & UFS_HC_CAP_NUTMR= S), 16) + 1); + Nutmrs =3D (UINT8) (RShiftU64 ((Private->UfsHcInfo.Capabilities & UFS_HC= _CAP_NUTMRS), 16) + 1); Status =3D UfsAllocateAlignCommonBuffer (Private, Nutmrs * sizeof (UTP_T= MRD), &CmdDescHost, &CmdDescPhyAddr, &CmdDescMapping); if (EFI_ERROR (Status)) { return Status; @@ -2020,7 +2012,6 @@ UfsInitTransferRequestList ( IN UFS_PASS_THRU_PRIVATE_DATA *Private ) { - UINT32 Data; UINT8 Nutrs; VOID *CmdDescHost; EFI_PHYSICAL_ADDRESS CmdDescPhyAddr; @@ -2034,17 +2025,10 @@ UfsInitTransferRequestList ( CmdDescMapping =3D NULL; CmdDescPhyAddr =3D 0; =20 - Status =3D UfsMmioRead32 (Private, UFS_HC_CAP_OFFSET, &Data); - if (EFI_ERROR (Status)) { - return Status; - } - - Private->Capabilities =3D Data; - // // Allocate and initialize UTP Transfer Request List. // - Nutrs =3D (UINT8)((Private->Capabilities & UFS_HC_CAP_NUTRS) + 1); + Nutrs =3D (UINT8)((Private->UfsHcInfo.Capabilities & UFS_HC_CAP_NUTRS) = + 1); Status =3D UfsAllocateAlignCommonBuffer (Private, Nutrs * sizeof (UTP_TR= D), &CmdDescHost, &CmdDescPhyAddr, &CmdDescMapping); if (EFI_ERROR (Status)) { return Status; @@ -2366,3 +2350,36 @@ ProcessAsyncTaskList ( } } =20 +/** + Initializes UfsHcInfo field in private data. + + @param[in] Private Pointer to host controller private data. + + @retval EFI_SUCCESS UfsHcInfo initialized successfully. + @retval Others Failed to initalize UfsHcInfo. +**/ +EFI_STATUS +GetUfsHcInfo ( + IN UFS_PASS_THRU_PRIVATE_DATA *Private + ) +{ + UINT32 Data; + EFI_STATUS Status; + + Status =3D UfsMmioRead32 (Private, UFS_HC_VER_OFFSET, &Data); + if (EFI_ERROR (Status)) { + return Status; + } + + Private->UfsHcInfo.Version =3D Data; + + Status =3D UfsMmioRead32 (Private, UFS_HC_CAP_OFFSET, &Data); + if (EFI_ERROR (Status)) { + return Status; + } + + Private->UfsHcInfo.Capabilities =3D Data; + + return EFI_SUCCESS; +} + --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45278): https://edk2.groups.io/g/devel/message/45278 Mute This Topic: https://groups.io/mt/32811061/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 19 20:37:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45279+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45279+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565361421; cv=none; d=zoho.com; s=zohoarc; b=LY4e08SLXuQvEmV3FrjZgG7LmJjiQhux4lpQGjve3Tp62zmdxtYsEj7EfpFIqbL8nzfS4TAzmdNEfbOvS7W46nchiuOTRn38pWNak6UjA6R3EjKd8GHi3SBPDJV8WoOd+44BvhCAuHPOjF7DXuCFnGgPaShBl5qBrdVUUx2z6Us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565361421; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=kwJljrPwmJRWs4wjLKqgbSKC484fZy53tc6XFOa9qP4=; b=BNEumIaY1pqC3E31Y0KaZ9GupAziOy5RljG3Ak2S4rwYEt6MNz9rePNFqxRQvJem85KFF8Yk7cECLXP9R+EvrOsGaEHvUVwVGnthoLy9EyQtx2yT5CCXMnkRIMrMCgIrBV4LyYdG/arYGHfr+hU26WhnwBfRB3AEtM/79i17K6c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45279+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565361421256408.82602715746225; Fri, 9 Aug 2019 07:37:01 -0700 (PDT) Return-Path: X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Fri, 09 Aug 2019 07:37:00 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Aug 2019 07:36:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,364,1559545200"; d="scan'208";a="203942141" X-Received: from gklab-27-32.ger.corp.intel.com ([10.102.28.45]) by fmsmga002.fm.intel.com with ESMTP; 09 Aug 2019 07:36:58 -0700 From: "Albecki, Mateusz" To: devel@edk2.groups.io Cc: Mateusz Albecki , Hao A Wu Subject: [edk2-devel] [PATCHv3 4/4] MdeModulePkg/UfsPassThruDxe: Implement EDKII_UFS_HC_PLATFORM_PROTOCOL Date: Fri, 9 Aug 2019 16:36:20 +0200 Message-Id: <20190809143620.4924-5-mateusz.albecki@intel.com> In-Reply-To: <20190809143620.4924-1-mateusz.albecki@intel.com> References: <20190809143620.4924-1-mateusz.albecki@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mateusz.albecki@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565361420; bh=3Tnf91ao007g3pzlAaQTcwJCQj3vFm9Nc9rLR0ZDdWY=; h=Cc:Date:From:Reply-To:Subject:To; b=uVvxqsRIqP3+oYcUhA20PgYrXO7aVwVjEl4lNpqOX8xqmLXKo0LPnfO1TpkDtZJ43vC J8A68chqklsCfKI8o6MorOBEljxePAKXxnCynXE4tWOeIdOJK8SJcDAFtLU8xa/9uN6Eg yG57Y/0QxhqLloaV3Kv0XC5kUvUkcC0PygU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D1343 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. Cc: Hao A Wu Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu --- MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 17 ++++++ MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h | 26 ++++++++ .../Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf | 3 +- .../Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 69 ++++++++++++++++++= +++- 4 files changed, 112 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 7dce217d49..b12404aacb 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -36,6 +36,7 @@ UFS_PASS_THRU_PRIVATE_DATA gUfsPassThruTemplate =3D { 0, // UfsHostController 0, // UfsHcBase {0, 0}, // UfsHcInfo + {NULL, NULL}, // UfsHcDriverInterface 0, // TaskTag 0, // UtpTrlBase 0, // Nutrs @@ -92,6 +93,8 @@ UFS_DEVICE_PATH mUfsDevicePathTemplate =3D { =20 UINT8 mUfsTargetId[TARGET_MAX_BYTES]; =20 +GLOBAL_REMOVE_IF_UNREFERENCED EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatf= orm; + /** Sends a SCSI Request Packet to a SCSI device that is attached to the SCS= I channel. This function supports both blocking I/O and nonblocking I/O. The blocking I/O functio= nality is required, and the @@ -864,7 +867,21 @@ UfsPassThruDriverBindingStart ( Private->ExtScsiPassThru.Mode =3D &Private->ExtScsiPassThruMode; Private->UfsHostController =3D UfsHc; Private->UfsHcBase =3D UfsHcBase; + Private->Handle =3D Controller; + Private->UfsHcDriverInterface.UfsHcProtocol =3D UfsHc; + Private->UfsHcDriverInterface.UfsExecUicCommand =3D UfsHcDriverInterface= ExecUicCommand; InitializeListHead (&Private->Queue); + + // + // This has to be done before initializing UfsHcInfo or calling the UfsC= ontrollerInit + // + if (mUfsHcPlatform =3D=3D NULL) { + Status =3D gBS->LocateProtocol (&gEdkiiUfsHcPlatformProtocolGuid, NULL= , (VOID**)&mUfsHcPlatform); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "No UfsHcPlatformProtocol present\n")); + } + } + Status =3D GetUfsHcInfo (Private); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Failed to initialize UfsHcInfo\n")); diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h index c511aa8c7a..cbc0c2126e 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.h @@ -63,6 +63,7 @@ typedef struct _UFS_PASS_THRU_PRIVATE_DATA { EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHostController; UINTN UfsHcBase; EDKII_UFS_HC_INFO UfsHcInfo; + EDKII_UFS_HC_DRIVER_INTERFACE UfsHcDriverInterface; =20 UINT8 TaskTag; =20 @@ -126,6 +127,13 @@ typedef struct { UFS_PASS_THRU_SIG \ ) =20 +#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 { UINT64 Timeout; VOID *DataBuffer; @@ -959,6 +967,23 @@ UfsRwUfsAttribute ( IN OUT UINT32 *AttrSize ); =20 +/** + 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 execu= ted. + + @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. =20 @@ -975,5 +1000,6 @@ GetUfsHcInfo ( extern EFI_COMPONENT_NAME_PROTOCOL gUfsPassThruComponentName; extern EFI_COMPONENT_NAME2_PROTOCOL gUfsPassThruComponentName2; extern EFI_DRIVER_BINDING_PROTOCOL gUfsPassThruDriverBinding; +extern EDKII_UFS_HC_PLATFORM_PROTOCOL *mUfsHcPlatform; =20 #endif diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf b/MdeMo= dulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf index 24f5ea3a8f..92dc25714b 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruDxe.inf @@ -1,7 +1,7 @@ ## @file # Description file for the Universal Flash Storage (UFS) Pass Thru driver. # -# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -54,6 +54,7 @@ gEfiExtScsiPassThruProtocolGuid ## BY_START gEfiUfsDeviceConfigProtocolGuid ## BY_START gEdkiiUfsHostControllerProtocolGuid ## TO_START + gEdkiiUfsHcPlatformProtocolGuid ## SOMETIMES_CONSUMES =20 [UserExtensions.TianoCore."ExtraFiles"] UfsPassThruExtra.uni diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index 74be3efc41..0b95e7dddd 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c @@ -1202,8 +1202,6 @@ UfsSetFlag ( return Status; } =20 - - /** Read specified flag from a UFS device. =20 @@ -1835,6 +1833,14 @@ UfsEnableHostController ( EFI_STATUS Status; UINT32 Data; =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->Callback !=3D NULL) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPreHce= , &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHc= PreHce, Status =3D %r\n", Status)); + return Status; + } + } + // // UFS 2.0 spec section 7.1.1 - Host Controller Initialization // @@ -1878,6 +1884,14 @@ UfsEnableHostController ( return EFI_DEVICE_ERROR; } =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->Callback !=3D NULL) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPostHc= e, &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHc= PostHce, Status =3D %r\n", Status)); + return Status; + } + } + return EFI_SUCCESS; } =20 @@ -1901,6 +1915,14 @@ UfsDeviceDetection ( UINT32 Data; EDKII_UIC_COMMAND LinkStartupCommand; =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->Callback !=3D NULL) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPreLin= kStartup, &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiUfsHc= PreLinkStartup, Status =3D %r\n", Status)); + return Status; + } + } + // // Start UFS device detection. // Try up to 3 times for establishing data link with device. @@ -1926,6 +1948,13 @@ UfsDeviceDetection ( return EFI_DEVICE_ERROR; } } else { + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->Callback !=3D NULL) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPo= stLinkStartup, &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform driver during EdkiiU= fsHcPostLinkStartup, Status =3D %r\n", Status)); + return Status; + } + } return EFI_SUCCESS; } } @@ -2350,6 +2379,34 @@ ProcessAsyncTaskList ( } } =20 +/** + 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 execu= ted. + + @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 =3D=3D NULL || UicCommand =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Private =3D UFS_PASS_THRU_PRIVATE_DATA_FROM_DRIVER_INTF (This); + + return UfsExecUicCommands (Private, UicCommand); +} + /** Initializes UfsHcInfo field in private data. =20 @@ -2380,6 +2437,14 @@ GetUfsHcInfo ( =20 Private->UfsHcInfo.Capabilities =3D Data; =20 + if (mUfsHcPlatform !=3D NULL && mUfsHcPlatform->OverrideHcInfo !=3D NULL= ) { + Status =3D mUfsHcPlatform->OverrideHcInfo (Private->Handle, &Private->= UfsHcInfo); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failure from platform on OverrideHcInfo, Statu= s =3D %r\n", Status)); + return Status; + } + } + return EFI_SUCCESS; } =20 --=20 2.14.1.windows.1 -------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydz= ial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-31= 6 | Kapital zakladowy 200.000 PLN. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata= i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wi= adomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiek= olwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the s= ole use of the intended recipient(s). If you are not the intended recipient= , please contact the sender and delete all copies; any review or distributi= on by others is strictly prohibited. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45279): https://edk2.groups.io/g/devel/message/45279 Mute This Topic: https://groups.io/mt/32811067/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-