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.web12.37812.1585232030017844724 for ; Thu, 26 Mar 2020 07:13:50 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: guomin.jiang@intel.com) IronPort-SDR: mZ1HQjpVIHdb4KxGE28bZIYtSD2VMMf1f14n1GJPcdRFGZCGdKY8zeS62Fssfp/IpkDZ3b3cac SEiQJF0L2diQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2020 07:13:49 -0700 IronPort-SDR: BsD5nMiZK/HSVEOzy5ACjZS536gTf1cmBKmjmfTwxeZBG2bFYi98P+N1S4s0htTFs/ZWoy2x+8 eBmoNID2oCIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,308,1580803200"; d="scan'208";a="293638659" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by FMSMGA003.fm.intel.com with ESMTP; 26 Mar 2020 07:13:48 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 26 Mar 2020 07:13:48 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 26 Mar 2020 07:13:48 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.43]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.235]) with mapi id 14.03.0439.000; Thu, 26 Mar 2020 22:13:44 +0800 From: "Guomin Jiang" To: "devel@edk2.groups.io" , "pankaj.bansal@nxp.com" , Leif Lindholm , "Ni, Ray" CC: "Pankaj Bansal (OSS)" , "Wang, Jian J" , "Wu, Hao A" , "Ma, Maurice" , "Dong, Guo" , "You, Benjamin" , Meenakshi Aggarwal , Varun Sethi Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: UART Dynamic clock freq Support Thread-Topic: [edk2-devel] [PATCH 1/1] MdeModulePkg: UART Dynamic clock freq Support Thread-Index: AQHV5vxViexlBZiafUK+UzKtPSiuIahQMn8A//+AMYCABaHTgIAFyubg Date: Thu, 26 Mar 2020 14:13:44 +0000 Message-ID: References: <20200219133135.10407-1-pankaj.bansal@oss.nxp.com> <20200219133135.10407-2-pankaj.bansal@oss.nxp.com> <734D49CCEBEEF84792F5B80ED585239D5C4A0C2C@SHSMSX104.ccr.corp.intel.com> <20200319153057.GV23627@bivouac.eciton.net> In-Reply-To: Accept-Language: en-US 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: guomin.jiang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable It is a good idea, I have a question: 1. When can detect the jumper signal or register? 2. If the jumper use GPIO, SerialUartClockLib will depend on GpioLib? 3. If the register is inside SIO, how to dispose the dependence? If it is too complex to implement the SerialUartClockLib, the project owne= r will choose use BaseSerialUartClockLib rather implement it. and in this = case, it make no sense after import complexity. I have also reviewed the ArmPlatformPkg/Library/PL011UartClockLib code, it= still use the fixed data rather than dynamically detect clock. > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Pankaj > Bansal > Sent: Monday, March 23, 2020 1:31 PM > To: Leif Lindholm ; Ni, Ray > Cc: Pankaj Bansal (OSS) ; Wang, Jian J > ; Wu, Hao A ; Ma, Maurice > ; Dong, Guo ; You, > Benjamin ; Meenakshi Aggarwal > ; Varun Sethi ; > devel@edk2.groups.io > Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: UART Dynamic clock > freq Support >=20 > Hi Ray, >=20 > I had thought of making PcdSerialClockRate as Dynamic PCD I had made > changes for it too. > But it doesn't work. > SerialPortInitalize, which uses PcdSerialClockRate, gets called from Deb= ugLib > constructor. > DebugLib is used by every module to print any info onto console. > For DxeCore and PcdDxe, for which PcdLib instance is NULL, this results = in > Assert : >=20 > https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BasePcdLi > bNull/PcdLib.c#L123 >=20 > The other approach that I thought of was, to copy BaseSerialPortLib16550= for > our platform and simply return EFI_SUCCESS from SerialPortInitalize. > But as Leif pointed out, this results in code duplication. >=20 > Regards, > Pankaj Bansal >=20 > > -----Original Message----- > > From: Leif Lindholm > > Sent: Thursday, March 19, 2020 9:01 PM > > To: Ni, Ray > > Cc: Pankaj Bansal (OSS) ; Wang, Jian J > > ; Wu, Hao A ; Ma, Maurice > > ; Dong, Guo ; You, > Benjamin > > ; Meenakshi Aggarwal > > ; Varun Sethi ; > > devel@edk2.groups.io; Pankaj Bansal > > Subject: Re: [PATCH 1/1] MdeModulePkg: UART Dynamic clock freq > Support > > > > Hi Ray, > > > > I agree it would be nice, but if not - this lets us get rid of > > otherwise needless driver duplication. To me, that makes it worth a > > little trivial churn. > > > > / > > Leif > > > > On Thu, Mar 19, 2020 at 15:09:19 +0000, Ni, Ray wrote: > > > 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 > > ; Varun Sethi > > > > Cc: devel@edk2.groups.io; Pankaj Bansal > > > > Subject: [PATCH 1/1] MdeModulePkg: UART Dynamic clock freq > Support > > > > > > > > From: Pankaj Bansal > > > > > > > > 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. > > > > > > > > This patch implements support for dynamic frequency for Uart. > > > > > > > > This patch implements default lib, which is using Pcd. Platform > > > > which needs dynamic clocking needs implement SerialUartClockLib > > > > > > > > This patch is based on ArmPlatformPkg/Library/PL011UartClockLib > > > > > > > > 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/BaseSerialUartClockLib.c > > > > create mode 100644 > > MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > > > > > > > > diff --git a/MdeModulePkg/Include/Library/SerialUartClockLib.h > > b/MdeModulePkg/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/BaseSerialPortLib16550.c > > > > > b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib165 > > > > 50.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 > > > > > > > > // > > > > @@ -501,8 +502,8 @@ SerialPortInitialize ( > > > > // Calculate divisor for baud generator > > > > // Ref_Clk_Rate / Baud_Rate / 16 > > > > // > > > > - Divisor =3D PcdGet32 (PcdSerialClockRate) / (PcdGet32 > > > > (PcdSerialBaudRate) * > > 16); > > > > - if ((PcdGet32 (PcdSerialClockRate) % (PcdGet32 > > > > (PcdSerialBaudRate) * > > 16)) >=3D PcdGet32 (PcdSerialBaudRate) * 8) { > > > > + Divisor =3D BaseSerialPortGetClock () / (PcdGet32 > > > > + (PcdSerialBaudRate) * 16); if ((BaseSerialPortGetClock () % > > > > + (PcdGet32 (PcdSerialBaudRate) * 16)) >=3D > > PcdGet32 (PcdSerialBaudRate) * 8) { > > > > Divisor++; > > > > } > > > > > > > > @@ -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 > > SerialBaudRate * 8) { > > > > + Divisor =3D BaseSerialPortGetClock () / (SerialBaudRate * 16); > > > > + if ((BaseSerialPortGetClock () % (SerialBaudRate * 16)) >=3D > > > > + SerialBaudRate * > > 8) { > > > > Divisor++; > > > > } > > > > > > > > diff --git > > a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.i > > nf > > > > > > b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.i > > nf > > > > index 8b4ae3f1d4ee..b4c16504f211 100644 > > > > --- > > a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.i > > nf > > > > +++ > > b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.i > > nf > > > > @@ -24,6 +24,7 @@ [LibraryClasses] > > > > IoLib > > > > PlatformHookLib > > > > PciLib > > > > + SerialUartClockLib > > > > > > > > [Sources] > > > > BaseSerialPortLib16550.c > > > > @@ -37,7 +38,6 @@ [Pcd] > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate = ## > > CONSUMES > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialLineControl = ## > > CONSUMES > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl = ## > > CONSUMES > > > > - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate = ## > > CONSUMES > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialPciDeviceInfo = ## > > CONSUMES > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize > ## > > CONSUMES > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride = ## > > CONSUMES > > > > diff --git > > a/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.c > > > > b/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockL > > > > ib.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/BaseSerialUartClockLib.i > > nf > > > > > > b/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.i > > nf > > > > new file mode 100644 > > > > index 000000000000..91ba69436ed6 > > > > --- /dev/null > > > > +++ > > b/MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.i > > nf > > > > @@ -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-994e= 9ccbaf11 > > > > + 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 = ## > > CONSUMES > > > > diff --git a/MdeModulePkg/MdeModulePkg.dsc > > b/MdeModulePkg/MdeModulePkg.dsc > > > > 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/DxeSecurityManagementL > ib/D > > xeSecurityManagementLib.inf > > > > > > > TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTem > pl > > TimerLib|at > > e.inf > > > > + > > > SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSer > > SerialUartClockLib|ialU > > artClockLib.inf > > > > > > SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNu > > SerialPortLib|ll.inf > > > > > > > CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.i > n > > CapsuleLib|f > > > > PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf > > > > @@ -292,6 +293,7 @@ [Components] > > > > > > > MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib. > inf > > > > > > > MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeRep > ortSt > > atusCodeLib.inf > > > > > > > MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.i > nf > > > > + > > MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > > > > > > MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf > > > > > > > MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull > .i > > nf > > > > > > > MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLe > ve > > lLi > > b.inf > > > > diff --git a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc > > b/SourceLevelDebugPkg/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 > > SynchronizationLib|zati > > onLib.inf > > > > LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf > > > > > > > PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base > P > > PeCoffGetEntryPointLib|eC > > offGetEntryPointLib.inf > > > > + > > > SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSer > > SerialUartClockLib|ialU > > artClockLib.inf > > > > > > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo > > SerialPortLib|rtLib > > 16550.inf > > > > > > > PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibD > > PeCoffExtraActionLib|ebu > > g/PeCoffExtraActionLibDebug.inf > > > > > > > TimerLib|UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLi > b > > TimerLib|Ue > > fiCpu.inf > > > > diff --git a/UefiPayloadPkg/UefiPayloadPkgIa32.dsc > > b/UefiPayloadPkg/UefiPayloadPkgIa32.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 > > ResetSystemLib|f > > > > + > > > SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSer > > SerialUartClockLib|ialU > > artClockLib.inf > > > > > > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo > > SerialPortLib|rtLib > > 16550.inf > > > > > > > PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib > > PlatformHookLib|.in > > f > > > > > > > PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/ > P > > PlatformBootManagerLib|l > > atformBootManagerLib.inf > > > > diff --git a/UefiPayloadPkg/UefiPayloadPkgIa32X64.dsc > > b/UefiPayloadPkg/UefiPayloadPkgIa32X64.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 > > ResetSystemLib|f > > > > + > > > SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSer > > SerialUartClockLib|ialU > > artClockLib.inf > > > > > > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo > > SerialPortLib|rtLib > > 16550.inf > > > > > > > PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib > > PlatformHookLib|.in > > f > > > > > > > PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/ > P > > PlatformBootManagerLib|l > > atformBootManagerLib.inf > > > > -- > > > > 2.17.1 > > > >=20 >=20