From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.175.1584630572455837051 for ; Thu, 19 Mar 2020 08:09:32 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: ray.ni@intel.com) IronPort-SDR: y675S35FHkogVu9XVW/1qyngzyrRRs67PjsKJp/vFmZSDYeOhq7iAMejfUsRp/TLWn/32Gut2v 8ySIoxgOKo7A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2020 08:09:31 -0700 IronPort-SDR: tD6V/+AAgVgqzYvP03+woJ94AuZzic2hzOnq+oetlmwiqXNgpByglaLkjn6F8SjwmbIX9n8URR MHfsCZyn3MzA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,572,1574150400"; d="scan'208";a="446256160" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 19 Mar 2020 08:09:31 -0700 Received: from fmsmsx162.amr.corp.intel.com (10.18.125.71) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 19 Mar 2020 08:09:23 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx162.amr.corp.intel.com (10.18.125.71) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 19 Mar 2020 08:09:23 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.206]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.235]) with mapi id 14.03.0439.000; Thu, 19 Mar 2020 23:09:19 +0800 From: "Ni, Ray" To: Pankaj Bansal , "Wang, Jian J" , "Wu, Hao A" , "Ma, Maurice" , "Dong, Guo" , "You, Benjamin" , Leif Lindholm , "Meenakshi Aggarwal" , Varun Sethi CC: "devel@edk2.groups.io" , Pankaj Bansal Subject: Re: [PATCH 1/1] MdeModulePkg: UART Dynamic clock freq Support Thread-Topic: [PATCH 1/1] MdeModulePkg: UART Dynamic clock freq Support Thread-Index: AQHV5vxVx5e5cJiHTUaCl0MH5dIVsKhQMn8A Date: Thu, 19 Mar 2020 15:09:19 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5C4A0C2C@SHSMSX104.ccr.corp.intel.com> References: <20200219133135.10407-1-pankaj.bansal@oss.nxp.com> <20200219133135.10407-2-pankaj.bansal@oss.nxp.com> In-Reply-To: <20200219133135.10407-2-pankaj.bansal@oss.nxp.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: ray.ni@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable It seems this change requires all platforms DSC to include the new library = class/instance. Is there a way that can avoid the platform impact? Thanks, Ray > -----Original Message----- > From: Pankaj Bansal > Sent: Wednesday, February 19, 2020 9:32 PM > To: Wang, Jian J ; Wu, Hao A ;= Ni, Ray ; Ma, Maurice > ; Dong, Guo ; You, Benjamin ; Leif Lindholm > ; Meenakshi Aggarwal ; Var= un Sethi > Cc: devel@edk2.groups.io; Pankaj Bansal > Subject: [PATCH 1/1] MdeModulePkg: UART Dynamic clock freq Support >=20 > From: Pankaj Bansal >=20 > Some platform support dynamic clocking, which is controlled by some > jumper setting or hardware registers. Result of that is that PCD > PcdSerialClockRate would need to be updated for frequency change. >=20 > This patch implements support for dynamic frequency for Uart. >=20 > This patch implements default lib, which is using Pcd. Platform which > needs dynamic clocking needs implement SerialUartClockLib >=20 > This patch is based on ArmPlatformPkg/Library/PL011UartClockLib >=20 > Signed-off-by: Pankaj Bansal > --- > .../Include/Library/SerialUartClockLib.h | 21 +++++++++++++++ > .../BaseSerialPortLib16550.c | 9 ++++--- > .../BaseSerialPortLib16550.inf | 2 +- > .../BaseSerialUartClockLib.c | 24 +++++++++++++++++ > .../BaseSerialUartClockLib.inf | 27 +++++++++++++++++++ > MdeModulePkg/MdeModulePkg.dsc | 2 ++ > SourceLevelDebugPkg/SourceLevelDebugPkg.dsc | 1 + > UefiPayloadPkg/UefiPayloadPkgIa32.dsc | 1 + > UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc | 1 + > 9 files changed, 83 insertions(+), 5 deletions(-) > create mode 100644 MdeModulePkg/Include/Library/SerialUartClockLib.h > create mode 100644 MdeModulePkg/Library/BaseSerialUartClockLib/BaseSeria= lUartClockLib.c > create mode 100644 MdeModulePkg/Library/BaseSerialUartClockLib/BaseSeria= lUartClockLib.inf >=20 > diff --git a/MdeModulePkg/Include/Library/SerialUartClockLib.h b/MdeModul= ePkg/Include/Library/SerialUartClockLib.h > new file mode 100644 > index 000000000000..b6b16f71d4cf > --- /dev/null > +++ b/MdeModulePkg/Include/Library/SerialUartClockLib.h > @@ -0,0 +1,21 @@ > +/** @file > +* > +* Copyright 2020 NXP > +* > +* SPDX-License-Identifier: BSD-2-Clause-Patent > +* > +**/ > + > +#ifndef SERIAL_UART_CLOCK_LIB_H__ > +#define SERIAL_UART_CLOCK_LIB_H__ > + > +/** > + Return clock in for Uart IP > +**/ > +UINT32 > +EFIAPI > +BaseSerialPortGetClock ( > + VOID > + ); > + > +#endif > diff --git a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLi= b16550.c > b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c > index 9cb50dd80d56..2e0c05d5789e 100644 > --- a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.= c > +++ b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.= c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include >=20 > // > @@ -501,8 +502,8 @@ SerialPortInitialize ( > // Calculate divisor for baud generator > // Ref_Clk_Rate / Baud_Rate / 16 > // > - Divisor =3D PcdGet32 (PcdSerialClockRate) / (PcdGet32 (PcdSerialBaudRa= te) * 16); > - if ((PcdGet32 (PcdSerialClockRate) % (PcdGet32 (PcdSerialBaudRate) * 1= 6)) >=3D PcdGet32 (PcdSerialBaudRate) * 8) { > + Divisor =3D BaseSerialPortGetClock () / (PcdGet32 (PcdSerialBaudRate) = * 16); > + if ((BaseSerialPortGetClock () % (PcdGet32 (PcdSerialBaudRate) * 16)) = >=3D PcdGet32 (PcdSerialBaudRate) * 8) { > Divisor++; > } >=20 > @@ -1080,8 +1081,8 @@ SerialPortSetAttributes ( > // Calculate divisor for baud generator > // Ref_Clk_Rate / Baud_Rate / 16 > // > - Divisor =3D PcdGet32 (PcdSerialClockRate) / (SerialBaudRate * 16); > - if ((PcdGet32 (PcdSerialClockRate) % (SerialBaudRate * 16)) >=3D Seria= lBaudRate * 8) { > + Divisor =3D BaseSerialPortGetClock () / (SerialBaudRate * 16); > + if ((BaseSerialPortGetClock () % (SerialBaudRate * 16)) >=3D SerialBau= dRate * 8) { > Divisor++; > } >=20 > diff --git a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLi= b16550.inf > b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf > index 8b4ae3f1d4ee..b4c16504f211 100644 > --- a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.= inf > +++ b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.= inf > @@ -24,6 +24,7 @@ [LibraryClasses] > IoLib > PlatformHookLib > PciLib > + SerialUartClockLib >=20 > [Sources] > BaseSerialPortLib16550.c > @@ -37,7 +38,6 @@ [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## CON= SUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialLineControl ## CON= SUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl ## CON= SUMES > - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate ## CON= SUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialPciDeviceInfo ## CON= SUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize ## CON= SUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## CON= SUMES > diff --git a/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartCl= ockLib.c > b/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.c > new file mode 100644 > index 000000000000..7a0d0427cc4e > --- /dev/null > +++ b/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.= c > @@ -0,0 +1,24 @@ > +/** @file > +* > +* Copyright 2020 NXP > +* > +* SPDX-License-Identifier: BSD-2-Clause-Patent > +* > +**/ > + > +#include > +#include > + > +/** > + Return clock in for Uart IP > + > + @return Pcd PcdSerialClockRate > +**/ > +UINT32 > +EFIAPI > +BaseSerialPortGetClock ( > + VOID > + ) > +{ > + return PcdGet32 (PcdSerialClockRate); > +} > diff --git a/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartCl= ockLib.inf > b/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > new file mode 100644 > index 000000000000..91ba69436ed6 > --- /dev/null > +++ b/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.= inf > @@ -0,0 +1,27 @@ > +#/* @file > +# Copyright 2020 NXP > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +#*/ > + > +[Defines] > + INF_VERSION =3D 0x0001001A > + BASE_NAME =3D BaseSerialUartClockLib > + FILE_GUID =3D fa65495e-d3c8-4ea3-9737-994e9ccbaf1= 1 > + MODULE_TYPE =3D BASE > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D SerialUartClockLib > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + > +[Sources.common] > + BaseSerialUartClockLib.c > + > +[LibraryClasses] > + PcdLib > + > +[Pcd] > + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate ## CON= SUMES > diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.ds= c > index f7dbb27ce25d..d581ca797b3b 100644 > --- a/MdeModulePkg/MdeModulePkg.dsc > +++ b/MdeModulePkg/MdeModulePkg.dsc > @@ -65,6 +65,7 @@ [LibraryClasses] > UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf > SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/Dx= eSecurityManagementLib.inf > TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTempl= ate.inf > + SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSer= ialUartClockLib.inf > SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNu= ll.inf > CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.in= f > PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf > @@ -292,6 +293,7 @@ [Components] > MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf > MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportSta= tusCodeLib.inf > MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.inf > + MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf > MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.i= nf > MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLeve= lLib.inf > diff --git a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc b/SourceLevelDeb= ugPkg/SourceLevelDebugPkg.dsc > index a1a1b81d03cb..c0ad88f26341 100644 > --- a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc > +++ b/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc > @@ -33,6 +33,7 @@ [LibraryClasses.common] > SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroni= zationLib.inf > LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf > PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BaseP= eCoffGetEntryPointLib.inf > + SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSer= ialUartClockLib.inf > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo= rtLib16550.inf > PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibD= ebug/PeCoffExtraActionLibDebug.inf > TimerLib|UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLib= UefiCpu.inf > diff --git a/UefiPayloadPkg/UefiPayloadPkgIa32.dsc b/UefiPayloadPkg/UefiP= ayloadPkgIa32.dsc > index d52945442e0e..a556a32b272c 100644 > --- a/UefiPayloadPkg/UefiPayloadPkgIa32.dsc > +++ b/UefiPayloadPkg/UefiPayloadPkgIa32.dsc > @@ -174,6 +174,7 @@ [LibraryClasses] > # > TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf > ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.in= f > + SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSer= ialUartClockLib.inf > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo= rtLib16550.inf > PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib= .inf > PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/P= latformBootManagerLib.inf > diff --git a/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc b/UefiPayloadPkg/Ue= fiPayloadPkgIa32X64.dsc > index 0736cd995476..7e86375fe57d 100644 > --- a/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc > +++ b/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc > @@ -175,6 +175,7 @@ [LibraryClasses] > # > TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf > ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.in= f > + SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSer= ialUartClockLib.inf > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo= rtLib16550.inf > PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib= .inf > PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/P= latformBootManagerLib.inf > -- > 2.17.1