* [PATCH] [PATCH v3] MdeModulePkg: Add bRefClkFreq card attribute programming support @ 2022-03-08 12:19 Bandaru, Purna Chandra Rao 2022-03-09 1:13 ` Wu, Hao A 0 siblings, 1 reply; 3+ messages in thread From: Bandaru, Purna Chandra Rao @ 2022-03-08 12:19 UTC (permalink / raw) To: devel Cc: Purna Chandra Rao Bandaru, Wu Hao A, Albecki Mateusz, Liming Gao, Zhiguang Liu REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3851 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 <hao.a.wu@intel.com> Cc: Albecki Mateusz <mateusz.albecki@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com> Signed-off-by: Purna Chandra Rao Bandaru <purna.chandra.rao.bandaru@intel.com> --- .../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/MdeModulePkg/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 - Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.<BR> Copyright (c) Microsoft Corporation.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -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; Status = EFI_SUCCESS; UfsHc = NULL; @@ -917,6 +919,54 @@ UfsPassThruDriverBindingStart ( goto Error; } + if ((mUfsHcPlatform != NULL) && + ((mUfsHcPlatform->RefClkFreq == EdkiiUfsCardRefClkFreq19p2Mhz) || + (mUfsHcPlatform->RefClkFreq == EdkiiUfsCardRefClkFreq26Mhz) || + (mUfsHcPlatform->RefClkFreq == EdkiiUfsCardRefClkFreq38p4Mhz))) + { + RefClkAttr = UfsAttrRefClkFreq; + Attributes = EdkiiUfsCardRefClkFreqObsolete; + Status = UfsRwAttributes (Private, TRUE, RefClkAttr, 0, 0, (UINT32 *)&Attributes); + if (!EFI_ERROR (Status)) { + if (Attributes != mUfsHcPlatform->RefClkFreq) { + Attributes = 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 = UfsRwAttributes (Private, FALSE, RefClkAttr, 0, 0, (UINT32 *)&Attributes); + if (EFI_ERROR (Status)) { + DEBUG ( + (DEBUG_ERROR, + "Failed to Change Reference Clock Attribute to %d, Status = %r \n", + mUfsHcPlatform->RefClkFreq, + Status) + ); + } + } + } else { + DEBUG ( + (DEBUG_ERROR, + "Failed to Read Reference Clock Attribute, Status = %r \n", + Status) + ); + } + } + + 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; + } + } + // // 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/MdeModulePkg/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. - Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.<BR> Copyright (c) Microsoft Corporation.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -1970,14 +1970,6 @@ UfsDeviceDetection ( return EFI_DEVICE_ERROR; } } 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; } } diff --git a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h b/MdeModulePkg/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. -Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Protocol/UfsHostController.h> -#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 1 +#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 2 extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid; @@ -83,6 +83,13 @@ typedef enum { EdkiiUfsHcPostLinkStartup } EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE; +typedef enum { + EdkiiUfsCardRefClkFreq19p2Mhz, + EdkiiUfsCardRefClkFreq26Mhz, + EdkiiUfsCardRefClkFreq38p4Mhz, + EdkiiUfsCardRefClkFreqObsolete +} EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE; + /** Callback function for platform driver. @@ -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; }; #endif -- 2.31.1.windows.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [PATCH v3] MdeModulePkg: Add bRefClkFreq card attribute programming support 2022-03-08 12:19 [PATCH] [PATCH v3] MdeModulePkg: Add bRefClkFreq card attribute programming support Bandaru, Purna Chandra Rao @ 2022-03-09 1:13 ` Wu, Hao A 2022-03-10 2:15 ` [edk2-devel] " Wu, Hao A 0 siblings, 1 reply; 3+ messages in thread From: Wu, Hao A @ 2022-03-09 1:13 UTC (permalink / raw) To: Bandaru, Purna Chandra Rao, devel@edk2.groups.io Cc: Albecki, Mateusz, Gao, Liming, Liu, Zhiguang Thanks. Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Best Regards, Hao Wu > -----Original Message----- > From: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com> > Sent: Tuesday, March 8, 2022 8:20 PM > To: devel@edk2.groups.io > Cc: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com>; > Wu, Hao A <hao.a.wu@intel.com>; Albecki, Mateusz > <mateusz.albecki@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; > Liu, Zhiguang <zhiguang.liu@intel.com> > Subject: [PATCH] [PATCH v3] MdeModulePkg: Add bRefClkFreq card > attribute programming support > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3851 > > 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 <hao.a.wu@intel.com> > Cc: Albecki Mateusz <mateusz.albecki@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > > Signed-off-by: Purna Chandra Rao Bandaru > <purna.chandra.rao.bandaru@intel.com> > --- > .../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/MdeModulePkg/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 > > - Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR> > + Copyright (c) 2014 - 2022, Intel Corporation. All rights > + reserved.<BR> > Copyright (c) Microsoft Corporation.<BR> > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -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; > > Status = EFI_SUCCESS; > UfsHc = NULL; > @@ -917,6 +919,54 @@ UfsPassThruDriverBindingStart ( > goto Error; > } > > + if ((mUfsHcPlatform != NULL) && > + ((mUfsHcPlatform->RefClkFreq == EdkiiUfsCardRefClkFreq19p2Mhz) || > + (mUfsHcPlatform->RefClkFreq == EdkiiUfsCardRefClkFreq26Mhz) || > + (mUfsHcPlatform->RefClkFreq == EdkiiUfsCardRefClkFreq38p4Mhz))) > + { > + RefClkAttr = UfsAttrRefClkFreq; > + Attributes = EdkiiUfsCardRefClkFreqObsolete; > + Status = UfsRwAttributes (Private, TRUE, RefClkAttr, 0, 0, (UINT32 > *)&Attributes); > + if (!EFI_ERROR (Status)) { > + if (Attributes != mUfsHcPlatform->RefClkFreq) { > + Attributes = 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 = UfsRwAttributes (Private, FALSE, RefClkAttr, 0, 0, (UINT32 > *)&Attributes); > + if (EFI_ERROR (Status)) { > + DEBUG ( > + (DEBUG_ERROR, > + "Failed to Change Reference Clock Attribute to %d, Status = %r \n", > + mUfsHcPlatform->RefClkFreq, > + Status) > + ); > + } > + } > + } else { > + DEBUG ( > + (DEBUG_ERROR, > + "Failed to Read Reference Clock Attribute, Status = %r \n", > + Status) > + ); > + } > + } > + > + 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; > + } > + } > + > // > // 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/MdeModulePkg/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. > > - Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR> > + Copyright (c) 2014 - 2022, Intel Corporation. All rights > + reserved.<BR> > Copyright (c) Microsoft Corporation.<BR> > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -1970,14 +1970,6 @@ UfsDeviceDetection ( > return EFI_DEVICE_ERROR; > } > } 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; > } > } > diff --git a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h > b/MdeModulePkg/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. > > -Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> > +Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR> > SPDX-License-Identifier: BSD-2-Clause-Patent > > **/ > @@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #include <Protocol/UfsHostController.h> > > -#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 1 > +#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 2 > > extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid; > > @@ -83,6 +83,13 @@ typedef enum { > EdkiiUfsHcPostLinkStartup > } EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE; > > +typedef enum { > + EdkiiUfsCardRefClkFreq19p2Mhz, > + EdkiiUfsCardRefClkFreq26Mhz, > + EdkiiUfsCardRefClkFreq38p4Mhz, > + EdkiiUfsCardRefClkFreqObsolete > +} EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE; > + > /** > Callback function for platform driver. > > @@ -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; > }; > > #endif > -- > 2.31.1.windows.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [PATCH] [PATCH v3] MdeModulePkg: Add bRefClkFreq card attribute programming support 2022-03-09 1:13 ` Wu, Hao A @ 2022-03-10 2:15 ` Wu, Hao A 0 siblings, 0 replies; 3+ messages in thread From: Wu, Hao A @ 2022-03-10 2:15 UTC (permalink / raw) To: devel@edk2.groups.io, Wu, Hao A, Bandaru, Purna Chandra Rao Cc: Albecki, Mateusz, Gao, Liming, Liu, Zhiguang Pushed via: PR - https://github.com/tianocore/edk2/pull/2608 Commit - https://github.com/tianocore/edk2/commit/f06941cc46d002f66875b6f2f711fa3df2775da4 Best Regards, Hao Wu > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao > A > Sent: Wednesday, March 9, 2022 9:14 AM > To: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com>; > devel@edk2.groups.io > Cc: Albecki, Mateusz <mateusz.albecki@intel.com>; Gao, Liming > <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com> > Subject: Re: [edk2-devel] [PATCH] [PATCH v3] MdeModulePkg: Add > bRefClkFreq card attribute programming support > > Thanks. > Reviewed-by: Hao A Wu <hao.a.wu@intel.com> > > Best Regards, > Hao Wu > > > -----Original Message----- > > From: Bandaru, Purna Chandra Rao > <purna.chandra.rao.bandaru@intel.com> > > Sent: Tuesday, March 8, 2022 8:20 PM > > To: devel@edk2.groups.io > > Cc: Bandaru, Purna Chandra Rao <purna.chandra.rao.bandaru@intel.com>; > > Wu, Hao A <hao.a.wu@intel.com>; Albecki, Mateusz > > <mateusz.albecki@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; > > Liu, Zhiguang <zhiguang.liu@intel.com> > > Subject: [PATCH] [PATCH v3] MdeModulePkg: Add bRefClkFreq card > > attribute programming support > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3851 > > > > 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 <hao.a.wu@intel.com> > > Cc: Albecki Mateusz <mateusz.albecki@intel.com> > > Cc: Liming Gao <gaoliming@byosoft.com.cn> > > Cc: Zhiguang Liu <zhiguang.liu@intel.com> > > > > Signed-off-by: Purna Chandra Rao Bandaru > > <purna.chandra.rao.bandaru@intel.com> > > --- > > .../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/MdeModulePkg/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 > > > > - Copyright (c) 2014 - 2021, Intel Corporation. All rights > > reserved.<BR> > > + Copyright (c) 2014 - 2022, Intel Corporation. All rights > > + reserved.<BR> > > Copyright (c) Microsoft Corporation.<BR> > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > @@ -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; > > > > Status = EFI_SUCCESS; > > UfsHc = NULL; > > @@ -917,6 +919,54 @@ UfsPassThruDriverBindingStart ( > > goto Error; > > } > > > > + if ((mUfsHcPlatform != NULL) && > > + ((mUfsHcPlatform->RefClkFreq == EdkiiUfsCardRefClkFreq19p2Mhz) > || > > + (mUfsHcPlatform->RefClkFreq == EdkiiUfsCardRefClkFreq26Mhz) || > > + (mUfsHcPlatform->RefClkFreq == > > + EdkiiUfsCardRefClkFreq38p4Mhz))) { > > + RefClkAttr = UfsAttrRefClkFreq; > > + Attributes = EdkiiUfsCardRefClkFreqObsolete; > > + Status = UfsRwAttributes (Private, TRUE, RefClkAttr, 0, 0, (UINT32 > > *)&Attributes); > > + if (!EFI_ERROR (Status)) { > > + if (Attributes != mUfsHcPlatform->RefClkFreq) { > > + Attributes = 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 = UfsRwAttributes (Private, FALSE, RefClkAttr, 0, 0, > > + (UINT32 > > *)&Attributes); > > + if (EFI_ERROR (Status)) { > > + DEBUG ( > > + (DEBUG_ERROR, > > + "Failed to Change Reference Clock Attribute to %d, Status = %r \n", > > + mUfsHcPlatform->RefClkFreq, > > + Status) > > + ); > > + } > > + } > > + } else { > > + DEBUG ( > > + (DEBUG_ERROR, > > + "Failed to Read Reference Clock Attribute, Status = %r \n", > > + Status) > > + ); > > + } > > + } > > + > > + 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; > > + } > > + } > > + > > // > > // 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/MdeModulePkg/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. > > > > - Copyright (c) 2014 - 2019, Intel Corporation. All rights > > reserved.<BR> > > + Copyright (c) 2014 - 2022, Intel Corporation. All rights > > + reserved.<BR> > > Copyright (c) Microsoft Corporation.<BR> > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > @@ -1970,14 +1970,6 @@ UfsDeviceDetection ( > > return EFI_DEVICE_ERROR; > > } > > } 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; > > } > > } > > diff --git a/MdeModulePkg/Include/Protocol/UfsHostControllerPlatform.h > > b/MdeModulePkg/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. > > > > -Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> > > +Copyright (c) 2019 - 2022, Intel Corporation. All rights > > +reserved.<BR> > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > > > #include <Protocol/UfsHostController.h> > > > > -#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 1 > > +#define EDKII_UFS_HC_PLATFORM_PROTOCOL_VERSION 2 > > > > extern EFI_GUID gEdkiiUfsHcPlatformProtocolGuid; > > > > @@ -83,6 +83,13 @@ typedef enum { > > EdkiiUfsHcPostLinkStartup > > } EDKII_UFS_HC_PLATFORM_CALLBACK_PHASE; > > > > +typedef enum { > > + EdkiiUfsCardRefClkFreq19p2Mhz, > > + EdkiiUfsCardRefClkFreq26Mhz, > > + EdkiiUfsCardRefClkFreq38p4Mhz, > > + EdkiiUfsCardRefClkFreqObsolete > > +} EDKII_UFS_CARD_REF_CLK_FREQ_ATTRIBUTE; > > + > > /** > > Callback function for platform driver. > > > > @@ -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; > > }; > > > > #endif > > -- > > 2.31.1.windows.1 > > > > > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-10 2:15 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-03-08 12:19 [PATCH] [PATCH v3] MdeModulePkg: Add bRefClkFreq card attribute programming support Bandaru, Purna Chandra Rao 2022-03-09 1:13 ` Wu, Hao A 2022-03-10 2:15 ` [edk2-devel] " Wu, Hao A
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox