From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mx.groups.io with SMTP id smtpd.web10.31726.1643632500660727277 for ; Mon, 31 Jan 2022 04:35:01 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20210112.gappssmtp.com header.s=20210112 header.b=UHcI6Mbj; spf=pass (domain: nuviainc.com, ip: 209.85.128.48, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f48.google.com with SMTP id f22-20020a1c1f16000000b003525bf08b1eso4895557wmf.0 for ; Mon, 31 Jan 2022 04:35:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9b1r9jlpC8c4t5udpLtlFCCroTEB1HxHVLPhV52FsVE=; b=UHcI6MbjqrXZDWonrAh/xAFemeSKjWl+TqHSuFgi4HCWblo3DgXvN5fBVq1qwor5bV 2+e+g4ukL1ci4QEHmvaXNCOnOH66yJazABpjvrKeVeHvIU3ptpym/tEsQR1I/QwQViYe bqbgR+UJLwgDIkiFrxte7SJOdehAWYTFLqGcul9b4OTw6x5sh7Ih2eBmadBRm8UtuF74 Qg6sj/4kXmFadzCcBRPidhTE4JLngFXn5dX1CHCilgM3JXDJf1W4B0tyND3r+ND+jf2/ 8OSbEuIVFmPubKgpbUCUVPPBf26ZzmR9xZydWrGJ0GWJR+7MXlGJqIVzTjWTyCcpJWeT /Cig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9b1r9jlpC8c4t5udpLtlFCCroTEB1HxHVLPhV52FsVE=; b=0Xf1xcnUXf3lHyvTggtnM7hWSoau1xwWgsai5WeorpCvjIdrpQ0bkcDdOmNOqKzfa6 MnQ8a7sQvcEjWcLgXuDsDSIBen+vBnW07RYl0au2qUbBEvnQzg4yjhJIKYENiVHUG719 yZEnAHpFVDmhhm0v8pUPWfCyDVco+peb9Rpn/x+XoW0zBj3HJ7XrTqqDLNRW9f+Jw/eW eS1HlJsrPZAioXma9+NQfo1nccVsTYyAqvTIcFyyxLigd9g+nHhmZEhIxMaexyaYTe9P yZS6g7DVYAhrr9PaZHJ19OdUkEVVvQagEbKhifDi4jvwQQSdpaOc3MHOD8c4klVYHLJF OAew== X-Gm-Message-State: AOAM530reokxs0bKm3z9ZyhZV9tE3xh7CAWAtd4g5LyxNcapXfMcTOOA nIPkQRqdbZqs9sNEszXPjyckuw== X-Google-Smtp-Source: ABdhPJzbGOJN50160qkRiFyWTrIR/qij28RMebgHtPxW10oOswjzf8msxUzyQdZDbex7WBYZ4/AZWg== X-Received: by 2002:a05:600c:4f87:: with SMTP id n7mr27242226wmq.133.1643632499165; Mon, 31 Jan 2022 04:34:59 -0800 (PST) Return-Path: Received: from leviathan (cpc92314-cmbg19-2-0-cust559.5-4.cable.virginm.net. [82.11.186.48]) by smtp.gmail.com with ESMTPSA id f2sm12243974wri.49.2022.01.31.04.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 04:34:58 -0800 (PST) Date: Mon, 31 Jan 2022 12:34:56 +0000 From: "Leif Lindholm" To: Adrien Thierry Cc: devel@edk2.groups.io, Ard Biesheuvel , Pete Batard , Jeremy Linton Subject: Re: [edk2-platforms PATCH] Platform/RaspberryPi: Add 'clock-frequency' property for miniuart Message-ID: References: <20220128153818.29890-1-athierry@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220128153818.29890-1-athierry@redhat.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline +Jeremy On Fri, Jan 28, 2022 at 10:38:18 -0500, Adrien Thierry wrote: > Describe the miniuart clock frequency in a _DSD property, so that it can > be read from the Linux driver. > > The miniuart clock frequency is the core clock frequency on the > Raspberry Pi. It can be modified by the user using the 'core_freq' > property in the config.txt file. So, we fetch it from the underlying > Raspberry Pi firmware. > > Signed-off-by: Adrien Thierry > --- > Platform/RaspberryPi/AcpiTables/Uart.asl | 14 ++++++++++++++ > Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 9 +++++++++ > .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 1 + > Platform/RaspberryPi/RPi3/RPi3.dsc | 5 +++++ > Platform/RaspberryPi/RPi4/RPi4.dsc | 5 +++++ > Platform/RaspberryPi/RaspberryPi.dec | 1 + > 6 files changed, 35 insertions(+) > > diff --git a/Platform/RaspberryPi/AcpiTables/Uart.asl b/Platform/RaspberryPi/AcpiTables/Uart.asl > index 974f06d3bc..ef5165be98 100644 > --- a/Platform/RaspberryPi/AcpiTables/Uart.asl > +++ b/Platform/RaspberryPi/AcpiTables/Uart.asl > @@ -77,6 +77,20 @@ Device (URTM) > MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_MINI_UART_OFFSET) > Return (^RBUF) > } > + > + // > + // Mini Uart Clock Rate will be dynamically updated during boot > + // 0x4D 0x55 0x43 0x52 0xC 0x1000000 (Value must be > 16777215) > + // > + Name (MUCR, 0x1000000) > + > + Name (_DSD, Package () > + { > + ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package () > + { > + Package (2) { "clock-frequency", MUCR }, > + } > + }) > } > > // > diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c > index 415d99fadb..3dcf2bac0d 100644 > --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c > +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c > @@ -44,6 +44,7 @@ STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol; > STATIC UINT32 mModelFamily = 0; > STATIC UINT32 mModelInstalledMB = 0; > STATIC UINT32 mModelRevision = 0; > +STATIC UINT32 mCoreClockRate = 0; > > STATIC EFI_MAC_ADDRESS mMacAddress; > > @@ -798,6 +799,7 @@ STATIC CONST AML_NAME_OP_REPLACE SsdtEmmcNameOpReplace[] = { > > STATIC CONST AML_NAME_OP_REPLACE DsdtNameOpReplace[] = { > { "URIU", PcdToken (PcdUartInUse) }, > + { "MUCR", PcdToken (PcdMiniUartClockRate) }, > { } > }; > > @@ -944,6 +946,13 @@ ConfigInitialize ( > DEBUG ((DEBUG_INFO, "Current Raspberry Pi revision %x\n", mModelRevision)); > } > > + Status = mFwProtocol->GetClockRate (RPI_MBOX_CLOCK_RATE_CORE, &mCoreClockRate); > + if (Status != EFI_SUCCESS) { > + DEBUG ((DEBUG_ERROR, "Couldn't get the Raspberry Pi core clock rate: %r\n", Status)); > + } else { > + PcdSet32S (PcdMiniUartClockRate, mCoreClockRate); > + } > + > Status = SetupVariables (); > if (Status != EFI_SUCCESS) { > DEBUG ((DEBUG_ERROR, "Couldn't not setup NV vars: %r\n", Status)); > diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > index e6e22ad82e..6f6e8f42ac 100644 > --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf > @@ -95,6 +95,7 @@ > gRaspberryPiTokenSpaceGuid.PcdFanTemp > gRaspberryPiTokenSpaceGuid.PcdUartInUse > gRaspberryPiTokenSpaceGuid.PcdXhciPci > + gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate > > [Depex] > gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid > diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc > index 6ab5d1ae6d..6dc48dc233 100644 > --- a/Platform/RaspberryPi/RPi3/RPi3.dsc > +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc > @@ -561,6 +561,11 @@ > # > gRaspberryPiTokenSpaceGuid.PcdUartInUse|1 > > + # > + # Mini-UART clock rate > + # > + gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate|250000000 > + > ################################################################################ > # > # Components Section - list of all EDK II Modules needed by this Platform > diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc > index 44ed60ab2f..a9c0c36bb1 100644 > --- a/Platform/RaspberryPi/RPi4/RPi4.dsc > +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc > @@ -580,6 +580,11 @@ > # > gRaspberryPiTokenSpaceGuid.PcdUartInUse|0 > > + # > + # Mini-UART clock rate > + # > + gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate|500000000 > + > ################################################################################ > # > # Components Section - list of all EDK II Modules needed by this Platform > diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec > index 797be59274..17b6061a05 100644 > --- a/Platform/RaspberryPi/RaspberryPi.dec > +++ b/Platform/RaspberryPi/RaspberryPi.dec > @@ -72,3 +72,4 @@ > gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F > gRaspberryPiTokenSpaceGuid.PcdUartInUse|1|UINT32|0x00000021 > gRaspberryPiTokenSpaceGuid.PcdXhciPci|0|UINT32|0x00000022 > + gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate|0|UINT32|0x00000023 > -- > 2.17.1 >