From nobody Sat May 11 12:17:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86166+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86166+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643384427; cv=none; d=zohomail.com; s=zohoarc; b=NWHPOwKVHHwL6mCmUVT8P2ZURpuD076+4G6YccIBOxPfkYRKpB+lY441gJQoYpA/g5HHlVBX2IpB2Et+jbtIdGzRISMqZ2a2lI+/8BpR8+1kogxtqzVQShuzNMkV7Wzv/2WTx4CJ0MnUi9x3TVunirzAZ7cnBR66ZnILtzmdCMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643384427; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=KKdKp/byVzbaqE2McZK8IrTaKs81yaAPupHDIc+fSQw=; b=cMttSmBpdDo+jvxTGlg8JCNyQ/Vn+yMAJZbzCFZGj0pC0EwQCO+tRGqq4OGiQthznd6f3I8pVOWfXOB6SgWOznkanJjkmzhu5fUFKCQwaWulqOaCqpJvXG/SNVmRVS2CUeRj+p0UP5P8Q6m4VwLroDX26SRVIR0Mp9+7KeJQE4c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86166+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1643384427433240.57004646785754; Fri, 28 Jan 2022 07:40:27 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id PautYY1788612xfgSjvFYvT5; Fri, 28 Jan 2022 07:40:26 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.8717.1643384425841915345 for ; Fri, 28 Jan 2022 07:40:26 -0800 X-Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-353-MgY0lRa-PwuWHoF_3mL-CA-1; Fri, 28 Jan 2022 10:40:23 -0500 X-MC-Unique: MgY0lRa-PwuWHoF_3mL-CA-1 X-Received: by mail-qt1-f200.google.com with SMTP id br10-20020a05622a1e0a00b002d37e07e79aso4808861qtb.4 for ; Fri, 28 Jan 2022 07:40:23 -0800 (PST) X-Gm-Message-State: qvFBWOyefYvw2twDQ7y9CdKIx1787277AA= X-Received: by 2002:a05:620a:4311:: with SMTP id u17mr5979123qko.63.1643384423180; Fri, 28 Jan 2022 07:40:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzteTNz/3MDFCLErX4Zx1hLReF7ZrBh2lu91SepdPEocNDTuEKZjIjvksDYdXBkwA6ioGU7vw== X-Received: by 2002:a05:620a:4311:: with SMTP id u17mr5979097qko.63.1643384422797; Fri, 28 Jan 2022 07:40:22 -0800 (PST) X-Received: from fedora.redhat.com (modemcable200.11-22-96.mc.videotron.ca. [96.22.11.200]) by smtp.gmail.com with ESMTPSA id x14sm3969187qkp.105.2022.01.28.07.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 07:40:22 -0800 (PST) From: "Adrien Thierry" To: devel@edk2.groups.io Cc: Adrien Thierry , Ard Biesheuvel , Leif Lindholm , Pete Batard Subject: [edk2-devel] [edk2-platforms PATCH] Platform/RaspberryPi: Add 'clock-frequency' property for miniuart Date: Fri, 28 Jan 2022 10:38:18 -0500 Message-Id: <20220128153818.29890-1-athierry@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,athierry@redhat.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643384426; bh=PfebTKG2QnGjG4UqWGLd7ee0SNccvFdiPzRy0NOk1DI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=tY8dTPvDDvgr2+F4ofylxaOVmJhYCYB5M8pTTRU5r/EDqbRnKyvi8t9IyZbhq1ad1I1 hBz0BmRK7//p4k4kGqnzTaOvhpkdW2jG2+EK6Gh/XMI2vxli3on5cZOzWgzpLHNNWFdSx 06G8ZiQgium+yUp5/K9G+qohHtHAWQ029a4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643384428438100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Jeremy Linton --- 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/RaspberryP= i/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 }, + } + }) } =20 // 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 =3D 0; STATIC UINT32 mModelInstalledMB =3D 0; STATIC UINT32 mModelRevision =3D 0; +STATIC UINT32 mCoreClockRate =3D 0; =20 STATIC EFI_MAC_ADDRESS mMacAddress; =20 @@ -798,6 +799,7 @@ STATIC CONST AML_NAME_OP_REPLACE SsdtEmmcNameOpReplace[= ] =3D { =20 STATIC CONST AML_NAME_OP_REPLACE DsdtNameOpReplace[] =3D { { "URIU", PcdToken (PcdUartInUse) }, + { "MUCR", PcdToken (PcdMiniUartClockRate) }, { } }; =20 @@ -944,6 +946,13 @@ ConfigInitialize ( DEBUG ((DEBUG_INFO, "Current Raspberry Pi revision %x\n", mModelRevisi= on)); } =20 + Status =3D mFwProtocol->GetClockRate (RPI_MBOX_CLOCK_RATE_CORE, &mCoreCl= ockRate); + if (Status !=3D EFI_SUCCESS) { + DEBUG ((DEBUG_ERROR, "Couldn't get the Raspberry Pi core clock rate: %= r\n", Status)); + } else { + PcdSet32S (PcdMiniUartClockRate, mCoreClockRate); + } + Status =3D SetupVariables (); if (Status !=3D EFI_SUCCESS) { DEBUG ((DEBUG_ERROR, "Couldn't not setup NV vars: %r\n", Status)); diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platfor= m/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 =20 [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 =20 + # + # 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 =20 + # + # 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/Ra= spberryPi.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 --=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 (#86166): https://edk2.groups.io/g/devel/message/86166 Mute This Topic: https://groups.io/mt/88746955/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-