From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.groups.io with SMTP id smtpd.web11.426.1584631861172378470 for ; Thu, 19 Mar 2020 08:31:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=p7Z+i/Uv; spf=pass (domain: nuviainc.com, ip: 209.85.221.67, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f67.google.com with SMTP id w10so3576933wrm.4 for ; Thu, 19 Mar 2020 08:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rezuMPb+SNFvIHWAfnTIL1vCF5jmtLd9TvmqaEz9SKE=; b=p7Z+i/Uv6D7EO1PPHzVlMZQ1BRMvmTzaBIARiDI4llPNjEXu4mBgQUvMKT4ruI7kjx FVKDrNq577Ysmvp65x85HYObeI4jvLoM5HniT4Ep9G3poBSv1Vh7BuaGtUmR4nvsFrT0 cwG3u35OrPi3WgqFQwybcEcq5khsZmyl0OFPKHKAuvEelqa1jWDiFmwTFIN+pibhZBGE rC+JhUsAu9JuB+AwxXtN6Q6h6ieB5zpGeV4UlmJ9p1hxnvMYLW4gca3Q9IkrR63i/7j0 y5Q5it8pDrVXyzGxTiF9j1q+Ja6Q80Ctqbk1Ca+C34dzzipdg9nzNbvAMjn0H/Q2UCgF Wv9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rezuMPb+SNFvIHWAfnTIL1vCF5jmtLd9TvmqaEz9SKE=; b=po2rZU1EKa6ixfha8trF8CLNluJ50S9c5cGpPQwazryQF8P/rjULffoX4HkrAvkimJ AGALH97jZTWP3MJp+jDTJ5Ekcd0rznSF7EF+1AnUKvxlOASbOm5Waq1MIgQW7D6d+prH nLuAPqdMl8UPl+8Mh5FSsEPwQo7OueYghgA1EfNqEoN3MzDjABQngXNU6drPRisVmlTw 6gHQZ0K8n+bXdjExAqX0scyz/jeYAsZTzQpk5vxwlalUWcv3Rijt8hu60ipzIa4ZdJiq RYfMT7rrrZXYkurlnNzLiXKvkCG9QOeFUNlrojElM4ivfC3VRvb/SmseXLGA8C63Xplr pBXw== X-Gm-Message-State: ANhLgQ209JQgvVQDlpSVl5pMbDcYwMv1Q2R/a7e6K8yl6Z+MusR62HoE OhEJ5mLMAS+Ex4brPCcguRWmEQ== X-Google-Smtp-Source: ADFU+vugr9wzT2saYuMid/K0tUDwRvhvQcPAwAseG1l8Hrb6/HHktVzXlo/wW2waox9rw2et+mvRxA== X-Received: by 2002:a5d:470f:: with SMTP id y15mr5199304wrq.210.1584631859484; Thu, 19 Mar 2020 08:30:59 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id t5sm3470622wmi.34.2020.03.19.08.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2020 08:30:59 -0700 (PDT) Date: Thu, 19 Mar 2020 15:30:57 +0000 From: "Leif Lindholm" To: "Ni, Ray" Cc: Pankaj Bansal , "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 Message-ID: <20200319153057.GV23627@bivouac.eciton.net> References: <20200219133135.10407-1-pankaj.bansal@oss.nxp.com> <20200219133135.10407-2-pankaj.bansal@oss.nxp.com> <734D49CCEBEEF84792F5B80ED585239D5C4A0C2C@SHSMSX104.ccr.corp.intel.com> MIME-Version: 1.0 In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C4A0C2C@SHSMSX104.ccr.corp.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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/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 > > > > // > > @@ -501,8 +502,8 @@ SerialPortInitialize ( > > // Calculate divisor for baud generator > > // Ref_Clk_Rate / Baud_Rate / 16 > > // > > - Divisor = PcdGet32 (PcdSerialClockRate) / (PcdGet32 (PcdSerialBaudRate) * 16); > > - if ((PcdGet32 (PcdSerialClockRate) % (PcdGet32 (PcdSerialBaudRate) * 16)) >= PcdGet32 (PcdSerialBaudRate) * 8) { > > + Divisor = BaseSerialPortGetClock () / (PcdGet32 (PcdSerialBaudRate) * 16); > > + if ((BaseSerialPortGetClock () % (PcdGet32 (PcdSerialBaudRate) * 16)) >= PcdGet32 (PcdSerialBaudRate) * 8) { > > Divisor++; > > } > > > > @@ -1080,8 +1081,8 @@ SerialPortSetAttributes ( > > // Calculate divisor for baud generator > > // Ref_Clk_Rate / Baud_Rate / 16 > > // > > - Divisor = PcdGet32 (PcdSerialClockRate) / (SerialBaudRate * 16); > > - if ((PcdGet32 (PcdSerialClockRate) % (SerialBaudRate * 16)) >= SerialBaudRate * 8) { > > + Divisor = BaseSerialPortGetClock () / (SerialBaudRate * 16); > > + if ((BaseSerialPortGetClock () % (SerialBaudRate * 16)) >= SerialBaudRate * 8) { > > Divisor++; > > } > > > > diff --git a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.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 > > > > [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/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/BaseSerialUartClockLib.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 = 0x0001001A > > + BASE_NAME = BaseSerialUartClockLib > > + FILE_GUID = fa65495e-d3c8-4ea3-9737-994e9ccbaf11 > > + MODULE_TYPE = BASE > > + VERSION_STRING = 1.0 > > + LIBRARY_CLASS = 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/DxeSecurityManagementLib/DxeSecurityManagementLib.inf > > TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf > > + SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > > SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf > > CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf > > PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf > > @@ -292,6 +293,7 @@ [Components] > > MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf > > MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf > > MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.inf > > + MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > > MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf > > MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf > > MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.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/BaseSynchronizationLib.inf > > LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf > > PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf > > + SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf > > PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf > > TimerLib|UefiCpuPkg/Library/SecPeiDxeTimerLibUefiCpu/SecPeiDxeTimerLibUefiCpu.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.inf > > + SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf > > PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf > > PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.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.inf > > + SerialUartClockLib|MdeModulePkg/Library/BaseSerialUartClockLib/BaseSerialUartClockLib.inf > > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf > > PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf > > PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf > > -- > > 2.17.1 >