From nobody Sun May 19 13:14:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87349+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87349+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646742002; cv=none; d=zohomail.com; s=zohoarc; b=dAf1EmdhdtILWoZDzFUHmNeuarp9pVOK7C4KpvmCNTtDTXLUat/mo4kvJenrBwZkC6QJPGHjbOJgRtPEb4tfFw/LJrl+XwX0/A/tlTRnO21WrpIJPkL/B4pAlcE9NBEaFgU4YZ+r66j0ywQiAHqGJullrky+dj0s95zt0EifBhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646742002; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=tAWTzR0hxq26Di3vPA8aSxv2PWndHc7ALoyovZMac9s=; b=FJsrZUx3MbPwDFRil1jVKB/ehZbWaoP2ms4EHbBHoSmrFgpHgJ3afe8cbv2fO3dhuV8SMQKILkSDx3g0321KyvdhEEzmZbeJmgWtPoeRVvC41rvxak/rwIFFZnHfIwiF1vdhLCiNdST2z2xmxjNw/4NxLHPqAA/ZWh8Kh+5G2kA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87349+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1646742002521763.8872480333281; Tue, 8 Mar 2022 04:20:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id eRjDYY1788612x5uhqXWRRak; Tue, 08 Mar 2022 04:20:02 -0800 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web08.7192.1646742000568672308 for ; Tue, 08 Mar 2022 04:20:00 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10279"; a="252241332" X-IronPort-AV: E=Sophos;i="5.90,164,1643702400"; d="scan'208";a="252241332" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2022 04:19:46 -0800 X-IronPort-AV: E=Sophos;i="5.90,164,1643702400"; d="scan'208";a="537548399" X-Received: from pbandaru-mobl1.gar.corp.intel.com ([10.213.110.234]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2022 04:19:44 -0800 From: "Bandaru, Purna Chandra Rao" To: devel@edk2.groups.io Cc: Purna Chandra Rao Bandaru , Wu Hao A , Albecki Mateusz , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [PATCH] [PATCH v3] MdeModulePkg: Add bRefClkFreq card attribute programming support Date: Tue, 8 Mar 2022 17:49:35 +0530 Message-Id: <4014f68bb8428892e14f15efe152805f95d9b829.1646741878.git.purna.chandra.rao.bandaru@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,purna.chandra.rao.bandaru@intel.com X-Gm-Message-State: WIU2aWeAVV8NmpnN14sjsllax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646742002; bh=tS+OvhUTYaFF0lseCiX/fFlVl+BC1+RTJNKHeIzFGPE=; h=Cc:Date:From:Reply-To:Subject:To; b=EkBbNlgV8bWqblyo/9sPR0ZrZ2zvC47zTo7vUKg6zI8yDwHws4zAa7MqiERYH/0xw2e RitA9ssC42kWGp71PfNxNZlbCNz7RKJoSr3OYD+t4RXhTyvzwVQdtc1DRuKQUqNBESO7U zvKtjA3NRMsjsUbu9Dz79MvA1h9YVYEjC2U= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646742003507100002 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3851 When the UFS card comes out of Manufacturer, bRefClkFreq attribute is set to 1h on the UFS card as per the Manufacturer Default Value specified by the spec JESD220*. However, depends on the UFS host system environment, it need to be set to the correct value. Reference Clock Frequency value 0h:19.2 MHz 1h: 26 MHz 2h: 38.4 MHz 3h: Obsolete Others: Reserved Cc: Wu Hao A Cc: Albecki Mateusz Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Purna Chandra Rao Bandaru Reviewed-by: Hao A Wu --- .../Bus/Ufs/UfsPassThruDxe/UfsPassThru.c | 70 ++++++++++++++++--- .../Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c | 10 +-- .../Protocol/UfsHostControllerPlatform.h | 15 +++- 3 files changed, 74 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c b/MdeModuleP= kg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c index 4c2d6ae27f..dc78e09678 100644 --- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c +++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThru.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -834,15 +834,17 @@ UfsPassThruDriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { - EFI_STATUS Status; - EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc; - UFS_PASS_THRU_PRIVATE_DATA *Private; - UINTN UfsHcBase; - UINT32 Index; - UFS_UNIT_DESC UnitDescriptor; - UFS_DEV_DESC DeviceDescriptor; - UINT32 UnitDescriptorSize; - UINT32 DeviceDescriptorSize; + EFI_STATUS Status; + EDKII_UFS_HOST_CONTROLLER_PROTOCOL *UfsHc; + UFS_PASS_THRU_PRIVATE_DATA *Private; + UINTN UfsHcBase; + UINT32 Index; + UFS_UNIT_DESC UnitDescriptor; + UFS_DEV_DESC DeviceDescriptor; + UINT32 UnitDescriptorSize; + UINT32 DeviceDescriptorSize; + EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE Attributes; + UINT8 RefClkAttr; =20 Status =3D EFI_SUCCESS; UfsHc =3D NULL; @@ -917,6 +919,54 @@ UfsPassThruDriverBindingStart ( goto Error; } =20 + if ((mUfsHcPlatform !=3D NULL) && + ((mUfsHcPlatform->RefClkFreq =3D=3D EdkiiUfsCardRefClkFreq19p2Mhz) || + (mUfsHcPlatform->RefClkFreq =3D=3D EdkiiUfsCardRefClkFreq26Mhz) || + (mUfsHcPlatform->RefClkFreq =3D=3D EdkiiUfsCardRefClkFreq38p4Mhz))) + { + RefClkAttr =3D UfsAttrRefClkFreq; + Attributes =3D EdkiiUfsCardRefClkFreqObsolete; + Status =3D UfsRwAttributes (Private, TRUE, RefClkAttr, 0, 0, (UINT= 32 *)&Attributes); + if (!EFI_ERROR (Status)) { + if (Attributes !=3D mUfsHcPlatform->RefClkFreq) { + Attributes =3D mUfsHcPlatform->RefClkFreq; + DEBUG ( + (DEBUG_INFO, + "Setting bRefClkFreq attribute(%x) to %x\n 0 -> 19.2 Mhz\n 1 = -> 26 Mhz\n 2 -> 38.4 Mhz\n 3 -> Obsolete\n", + RefClkAttr, + Attributes) + ); + Status =3D UfsRwAttributes (Private, FALSE, RefClkAttr, 0, 0, (UIN= T32 *)&Attributes); + if (EFI_ERROR (Status)) { + DEBUG ( + (DEBUG_ERROR, + "Failed to Change Reference Clock Attribute to %d, Status =3D= %r \n", + mUfsHcPlatform->RefClkFreq, + Status) + ); + } + } + } else { + DEBUG ( + (DEBUG_ERROR, + "Failed to Read Reference Clock Attribute, Status =3D %r \n", + Status) + ); + } + } + + if ((mUfsHcPlatform !=3D NULL) && (mUfsHcPlatform->Callback !=3D NULL)) { + Status =3D mUfsHcPlatform->Callback (Private->Handle, EdkiiUfsHcPostLi= nkStartup, &Private->UfsHcDriverInterface); + if (EFI_ERROR (Status)) { + DEBUG ( + (DEBUG_ERROR, + "Failure from platform driver during EdkiiUfsHcPostLinkStartup, S= tatus =3D %r\n", + Status) + ); + return Status; + } + } + // // UFS 2.0 spec Section 13.1.3.3: // At the end of the UFS Interconnect Layer initialization on both host = and device side, diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModu= lePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c index eba35cc669..4a9fa01e7d 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 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -1970,14 +1970,6 @@ UfsDeviceDetection ( return EFI_DEVICE_ERROR; } } else { - if ((mUfsHcPlatform !=3D NULL) && (mUfsHcPlatform->Callback !=3D NUL= L)) { - 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; } } diff --git a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h b/Md= eModulePkg/Include/Protocol/UfsHostControllerPlatform.h index faa82d0c4e..32e9f6488c 100644 --- a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h +++ b/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h @@ -1,7 +1,7 @@ /** @file EDKII_UFS_HC_PLATFORM_PROTOCOL definition. =20 -Copyright (c) 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include =20 -#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 1 +#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 2 =20 extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid; =20 @@ -83,6 +83,13 @@ typedef enum { EdkiiUfsHcPostLinkStartup } EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE; =20 +typedef enum { + EdkiiUfsCardRefClkFreq19p2Mhz, + EdkiiUfsCardRefClkFreq26Mhz, + EdkiiUfsCardRefClkFreq38p4Mhz, + EdkiiUfsCardRefClkFreqObsolete +} EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE; + /** Callback function for platform driver. =20 @@ -118,6 +125,10 @@ struct _EDKII_UFS_HC_PLATFORM_PROTOCOL { /// for host controller. /// EDKII_UFS_HC_PLATFORM_CALLBACK Callback; + /// + /// Reference Clock Frequency Ufs Card Attribute that need to be set in = this Ufs Host Environment. + /// + EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE RefClkFreq; }; =20 #endif --=20 2.31.1.windows.1 -=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 (#87349): https://edk2.groups.io/g/devel/message/87349 Mute This Topic: https://groups.io/mt/89635283/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-