From nobody Fri Dec 19 17:37:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+58634+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58634+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1588690249; cv=none; d=zohomail.com; s=zohoarc; b=CFVqtDPkQUv6ttHVHRXJPg/t1g9ZHyFderLc+MsyGcFJqloQ4IT25lQ45mwkFaSW7+cUNkGnHPNbV9tpLHU9VzEv5myL1i1Wn8/KLnq895N/NJoGVrC9sLKkaVdiIBuEGKxVOTCFv04DHNECYqZPM1p2sGcPDEK8lQvrv+Jhdds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588690249; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=Pr6BIeBsZLiOR9SqmQs5xQzsFECc16Bwdkxp2NW6gkA=; b=C4W2zXgj948GGpimSeDVMEBawxfYYeoRMLBVDE4LYG+o26jE6qr8yJnpKHJHzQjWQAiRE77ZDrlsnUlR2wbdI5py0r0/Zh5WZebt5opy/HiTF5/75NpK3jDXJX6HvKyM6prccEFR3aYV+nvt2kqVml1bua9WZzo6GdosLsRSL98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58634+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1588690249522682.5811445254228; Tue, 5 May 2020 07:50:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qE1xYY1788612xM08PAZOISJ; Tue, 05 May 2020 07:50:49 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.9395.1588690248644375747 for ; Tue, 05 May 2020 07:50:48 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5452E31B; Tue, 5 May 2020 07:50:48 -0700 (PDT) X-Received: from e123331-lin.nice.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 054303F68F; Tue, 5 May 2020 07:50:46 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, pete@akeo.ie, andrey.warkentin@gmail.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH edk2-platforms 5/5] Platform/RaspberryPi: create DXE phase SerialPortLib version for RPi3 Date: Tue, 5 May 2020 16:50:29 +0200 Message-Id: <20200505145029.29826-6-ard.biesheuvel@arm.com> In-Reply-To: <20200505145029.29826-1-ard.biesheuvel@arm.com> References: <20200505145029.29826-1-ard.biesheuvel@arm.com> Precedence: Bulk List-Unsubscribe: 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,ard.biesheuvel@arm.com X-Gm-Message-State: HhapiixCrpK27zVMV4eel8F4x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1588690249; bh=jX/YGVvBAfnVTVa9Li4ViMqR0NAysCYQEj5J/0EkPW0=; h=Cc:Date:From:Reply-To:Subject:To; b=BYaoqgXoFaoeWKEdpOxIPvfuz0WyyF3WUHL4mPcp+027RNsdJXe3B6ySpWf82+TDtWg ace8MQVjfUPx5/X+v85i2P++Uc1d2TyzougNUEIND5P2C8mFg9fNDl++oNpI8PZIfAcpt egI9kJiHU0L+eolzMswjtn9kvHXM09p/arA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The Raspberry Pi 3 derives its 16550 baud clock from the variable core clock, and so any reprogramming of the baud rate needs to take the actual core clock value into account. Introduce a DXE phase version of DualSerialPortLib that discovers this value in its constructor, using the RPi firmware protocol, and wire it up for the RPi3 platform. Signed-off-by: Ard Biesheuvel Reviewed-by: Pete Batard Tested-by: Pete Batard --- Platform/RaspberryPi/RPi3/RPi3.dsc = | 2 +- Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortDxeLib.inf = | 67 ++++++++++++++++++++ Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLibConstructo= r.c | 40 ++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index 96b27400eef8..2b8ad1c4bdbd 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -576,7 +576,7 @@ [Components.common] MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf MdeModulePkg/Universal/SerialDxe/SerialDxe.inf { - SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSer= ialPortLib.inf + SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSer= ialPortDxeLib.inf } Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf =20 diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortD= xeLib.inf b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortDx= eLib.inf new file mode 100644 index 000000000000..4c22b39daa7f --- /dev/null +++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortDxeLib.i= nf @@ -0,0 +1,67 @@ +## @file +# +# DXE phase SerialPortLib instance for both PL011 and 16550 UART. +# +# Copyright (c) 2020, Pete Batard +# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D DualSerialPortDxeLib + FILE_GUID =3D d586667e-ec50-4bf6-9701-fb4e29055a60 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D SerialPortLib|DXE_DRIVER + CONSTRUCTOR =3D DualSerialPortDxeLibConstructor + +[Packages] + ArmPlatformPkg/ArmPlatformPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Platform/RaspberryPi/RaspberryPi.dec + Silicon/Broadcom/Bcm283x/Bcm283x.dec + +[LibraryClasses] + IoLib + PcdLib + PL011UartClockLib + PL011UartLib + +[Sources] + DualSerialPortLib.c + DualSerialPortLib.h + DualSerialPortLibCommon.c + DualSerialPortLibConstructor.c + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterAccessWidth ## SOMET= IMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSU= MES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl ## CONSU= MES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialDetectCable ## SOMET= IMES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## CONSU= MES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialLineControl ## CONSU= MES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl ## CONSU= MES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialPciDeviceInfo ## CONSU= MES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize ## CONSU= MES + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## CONSU= MES + +[FixedPcd] + gArmPlatformTokenSpaceGuid.PL011UartClkInHz + gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits + +[Protocols] + gRaspberryPiFirmwareProtocolGuid ## CONSU= MES + +[PatchPcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate ## CONSU= MES + +[Depex] + gRaspberryPiFirmwareProtocolGuid diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL= ibConstructor.c b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerial= PortLibConstructor.c new file mode 100644 index 000000000000..c6d695181ab7 --- /dev/null +++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLibConst= ructor.c @@ -0,0 +1,40 @@ +/** @file + + Copyright (c) 2020, ARM Ltd. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +DualSerialPortDxeLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + RASPBERRY_PI_FIRMWARE_PROTOCOL *Firmware; + UINT32 ClockRate; + EFI_STATUS Status; + + Status =3D SystemTable->BootServices->LocateProtocol ( + &gRaspberryPiFirmwareProtocolGuid, + NULL, (VOID **)&Firmware); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D Firmware->GetClockRate (RPI_MBOX_CLOCK_RATE_CORE, &ClockRate); + if (EFI_ERROR (Status)) { + return Status; + } + + PatchPcdSet32 (PcdSerialClockRate, ClockRate); + return EFI_SUCCESS; +} --=20 2.17.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 (#58634): https://edk2.groups.io/g/devel/message/58634 Mute This Topic: https://groups.io/mt/73999459/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-