From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by mx.groups.io with SMTP id smtpd.web10.19973.1617385921895686879 for ; Fri, 02 Apr 2021 10:52:02 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pp1rPe+7; spf=pass (domain: gmail.com, ip: 209.85.208.43, mailfrom: mariobalanica02@gmail.com) Received: by mail-ed1-f43.google.com with SMTP id bf3so6146038edb.6 for ; Fri, 02 Apr 2021 10:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lbvyRWNRKXdO6JZZNKLLDJhK3eytIh29jTv4AjEVCBA=; b=pp1rPe+7bukehm7AZtoVVMpJoJw9G6ZDnnLScRIpgHHN6wCk1gBMZRB5VXEVflRAai wOdKjDYczkJvI+uO7qSo8ypSwTicKvrqZAlwF5H/d0yfVKubl3NojNNj2JhrEqLGtPJG 90lU6lVNEEmwxTjRlAu/5enfNsf7uHYKMHiHHNNsUO8C5jxKbiSlwUiPYeNrKvQ32eTX Q/Bk7G2bVhp5fBxducWYxujXQyZbzFBo2d1DiHuyAnDvDcVdzqSm1j3DoIh9ebG4wVak 9EtOGZZiWyJ/Wz7Ym3qJQaWettfzQL6hD6A3t9mZlux50UB2n90eyPzH6QW+UnlWCFkL 1TXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lbvyRWNRKXdO6JZZNKLLDJhK3eytIh29jTv4AjEVCBA=; b=YGej+ebRZt7IKzA01WFIzZMDphoYTvLT41DkupF0RxkyPR7LdLZ1EzWGq1XhRKKkDH z+PHRBp094tQ6UDXMIAvS8x8CIFQcsuwSgRnIFkteoc5unnacF9Hj1FR3IFg931BVmb5 qNgLSDsubEUlz+uNFbnaPBn7O1iTBXn0eWt8/32GGdQe6y7Qi/YBFDmUwuWlKGzzq6gl a8RFAr8Wbyk+v+rnpdyHd6iM823XA66KsebDDg8BVeJ4Mtf7Hh8oduMejHbBsgrh2L/x j7YahgNwtBQYcy0Q2TeZU7QIf6cmd3UBqlMh79j0hlNo8MJ81ONFfb9r0ygfqsSMmEuV qTyw== X-Gm-Message-State: AOAM531itd7oBJ7mGQ9QOuVuEyms1PoaGZk4/I22vdo8bYJvPYYerya+ e5frs2oTT6CO1XxVXAJ1Op69U5V//ezVbQ== X-Google-Smtp-Source: ABdhPJwjBok8pu3kGoA6nxW5X/AZfWNO2MjcRab8+iGDRZl0m8PSrX/q95meIFLh5UGe9ECZPCdtzw== X-Received: by 2002:a05:6402:35c8:: with SMTP id z8mr16749334edc.341.1617385920295; Fri, 02 Apr 2021 10:52:00 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2a02:2f0e:c50c:8400:45fd:77fa:b87a:47e8]) by smtp.gmail.com with ESMTPSA id q16sm4506939ejd.15.2021.04.02.10.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 10:51:59 -0700 (PDT) From: =?UTF-8?B?TWFyaW8gQsSDbMSDbmljxIM=?= To: devel@edk2.groups.io Cc: ardb+tianocore@kernel.org, leif@nuviainc.com, pete@akeo.ie Subject: [edk2-platforms][PATCH 1/1] Platform/RaspberryPi: Fix mini UART baud divisor calculation Date: Fri, 2 Apr 2021 20:51:48 +0300 Message-Id: <20210402175148.1485-1-mariobalanica02@gmail.com> X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The baud rate divisor calculation for mini UART on BCM2711 is the same as on older models since this commit: https://github.com/raspberrypi/firmware/commit/1e5456a Signed-off-by: Mario B=C4=83l=C4=83nic=C4=83 --- Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c | 15 = +++------------ Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S | 4 = ---- Platform/RaspberryPi/RPi4/RPi4.dsc | 6 = ++++-- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL= ib.c b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c index 5e83bbf022eb..d2f983bf0a9f 100644 --- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c +++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c @@ -34,25 +34,16 @@ SerialPortGetDivisor ( UINT32 SerialBaudRate=0D )=0D {=0D - UINT64 BaseClockRate;=0D + UINT32 BaseClockRate;=0D UINT32 Divisor;=0D =0D - //=0D - // On the Raspberry Pi, the clock to use for the 16650-compatible UART=0D - // is the base clock divided by the 12.12 fixed point VPU clock divisor.= =0D - //=0D - BaseClockRate =3D (UINT64)PcdGet32 (PcdSerialClockRate);=0D -#if (RPI_MODEL =3D=3D 4)=0D - Divisor =3D MmioRead32(BCM2836_CM_BASE + BCM2836_CM_VPU_CLOCK_DIVISOR) &= 0xFFFFFF;=0D - if (Divisor !=3D 0)=0D - BaseClockRate =3D (BaseClockRate << 12) / Divisor;=0D -#endif=0D + BaseClockRate =3D PcdGet32 (PcdSerialClockRate);=0D =0D //=0D // As per the BCM2xxx datasheets:=0D // baudrate =3D system_clock_freq / (8 * (divisor + 1)).=0D //=0D - Divisor =3D (UINT32)BaseClockRate / (SerialBaudRate * 8);=0D + Divisor =3D BaseClockRate / (SerialBaudRate * 8);=0D if (Divisor !=3D 0) {=0D Divisor--;=0D }=0D diff --git a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHe= lper.S b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper= .S index 58351e4fb8cc..7008aaf8aa4c 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S +++ b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S @@ -85,13 +85,11 @@ ASM_FUNC (ArmPlatformPeiBootAction) adr x2, mBoardRevision=0D str w0, [x2]=0D =0D -#if (RPI_MODEL =3D=3D 3)=0D run .Lclkinfo_buffer=0D =0D ldr w0, .Lfrequency=0D adr x2, _gPcd_BinaryPatch_PcdSerialClockRate=0D str w0, [x2]=0D -#endif=0D =0D ret=0D =0D @@ -135,7 +133,6 @@ ASM_FUNC (ArmPlatformPeiBootAction) .long 0 // end tag=0D .set .Lrevinfo_size, . - .Lrevinfo_buffer=0D =0D -#if (RPI_MODEL =3D=3D 3)=0D .align 4=0D .Lclkinfo_buffer:=0D .long .Lclkinfo_size=0D @@ -148,7 +145,6 @@ ASM_FUNC (ArmPlatformPeiBootAction) .long 0 // frequency=0D .long 0 // end tag=0D .set .Lclkinfo_size, . - .Lclkinfo_buffer=0D -#endif=0D =0D //UINTN=0D //ArmPlatformGetPrimaryCoreMpId (=0D diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index 2c05c31118d2..ff802d8347ea 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -429,7 +429,6 @@ [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4=0D - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8=0D gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200=0D @@ -465,6 +464,9 @@ [PcdsFixedAtBuild.common] gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE=0D =0D +[PcdsPatchableInModule]=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000=0D +=0D [PcdsDynamicHii.common.DEFAULT]=0D =0D #=0D @@ -621,7 +623,7 @@ [Components.common] MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf=0D MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {=0D =0D - SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSer= ialPortLib.inf=0D + SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSer= ialPortDxeLib.inf=0D }=0D Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf=0D EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf=0D --=20 2.29.2.windows.2