From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=B3YY+YnB; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: athierry@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643384425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Rt+y9q2XObqONgX5sTbpcUdrswQfZtVtmX/3L2oAFzI=; b=B3YY+YnB0bmHqOaQl9x7l4qA2LhVHOLHZbeULcwxYqewNOyCHs8Jo/XuWeecDZNfnzm+CM qx8BXGhkupOSp1KI93nCeNoiFdWVJRBWVeG0SEMd9624hu5/YG1kH336XvJYMvrcIPM1aG tuBW+8rjVuJZHlQ/HZf10V7ZNLaID68= 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 Received: by mail-qt1-f200.google.com with SMTP id br10-20020a05622a1e0a00b002d37e07e79aso4808861qtb.4 for ; Fri, 28 Jan 2022 07:40:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1ksxzVsP7O4a1hJdEGH6HB1yLsy73khsXqCs2aKQDSU=; b=YNjPhNVQg3kQzU6qSu2IbJT5utIXNrEhE7KELWFpCt1RSWifC+Jfi6Z2RYr1EXW4IG gmsES8Cl+2uZ5BQMGz16GK2REPyinErzqiKISTpsN7ooSucR7eU2DrsCNtL+qRNnOo08 TgGfx7beG9YAtnW0AXwY91WckOAhoQu3J4qy8ouTvsCaArBNJJC5orMoHg7kADK3fI7I yVMauyt6ZmUfUmweehas2ezFoIi/Bk71NPXfmG1Q8rRX76uhP3Z4/LdFWAcCQ05tHGUV eG/ILPprW08iCPf+OnMrt6voVLHM4jktRH+Y1lwH/k6KVV9N7fMu3AfK3Be5UbsnJiF4 ho0w== X-Gm-Message-State: AOAM530l07/sYNYgmcEkzjjBzH7AAlGJTbBWxTbFX+qGEImGph9++8FW ZH4/t0FYXF7sStcN8VSFBRWxvPy9YB/IMYloPFjS7uuRwUuK9/BEb0fr27q+hz/WrFItDcxZkkK KjRqKMhkdwudXGgczyC7Z0RDTGPkQ6untaUct9fOu9zAhtrKRQVtcash3LWnp6FM+Sw== 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) Return-Path: 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-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> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=athierry@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="US-ASCII" 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/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)=0D Return (^RBUF)=0D }=0D +=0D + //=0D + // Mini Uart Clock Rate will be dynamically updated during boot=0D + // 0x4D 0x55 0x43 0x52 0xC 0x1000000 (Value must be > 16777215)=0D + //=0D + Name (MUCR, 0x1000000)=0D +=0D + Name (_DSD, Package ()=0D + {=0D + ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package ()=0D + {=0D + Package (2) { "clock-frequency", MUCR },=0D + }=0D + })=0D }=0D =20=0D //=0D 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;=0D STATIC UINT32 mModelInstalledMB =3D 0;=0D STATIC UINT32 mModelRevision =3D 0;=0D +STATIC UINT32 mCoreClockRate =3D 0;=0D =20=0D STATIC EFI_MAC_ADDRESS mMacAddress;=0D =20=0D @@ -798,6 +799,7 @@ STATIC CONST AML_NAME_OP_REPLACE SsdtEmmcNameOpReplace[= ] =3D { =20=0D STATIC CONST AML_NAME_OP_REPLACE DsdtNameOpReplace[] =3D {=0D { "URIU", PcdToken (PcdUartInUse) },=0D + { "MUCR", PcdToken (PcdMiniUartClockRate) },=0D { }=0D };=0D =20=0D @@ -944,6 +946,13 @@ ConfigInitialize ( DEBUG ((DEBUG_INFO, "Current Raspberry Pi revision %x\n", mModelRevisi= on));=0D }=0D =20=0D + Status =3D mFwProtocol->GetClockRate (RPI_MBOX_CLOCK_RATE_CORE, &mCoreCl= ockRate);=0D + if (Status !=3D EFI_SUCCESS) {=0D + DEBUG ((DEBUG_ERROR, "Couldn't get the Raspberry Pi core clock rate: %= r\n", Status));=0D + } else {=0D + PcdSet32S (PcdMiniUartClockRate, mCoreClockRate);=0D + }=0D +=0D Status =3D SetupVariables ();=0D if (Status !=3D EFI_SUCCESS) {=0D DEBUG ((DEBUG_ERROR, "Couldn't not setup NV vars: %r\n", Status));=0D 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=0D gRaspberryPiTokenSpaceGuid.PcdUartInUse=0D gRaspberryPiTokenSpaceGuid.PcdXhciPci=0D + gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate=0D =20=0D [Depex]=0D gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid=0D 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 @@ #=0D gRaspberryPiTokenSpaceGuid.PcdUartInUse|1=0D =20=0D + #=0D + # Mini-UART clock rate=0D + #=0D + gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate|250000000=0D +=0D ##########################################################################= ######=0D #=0D # Components Section - list of all EDK II Modules needed by this Platform= =0D 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 @@ #=0D gRaspberryPiTokenSpaceGuid.PcdUartInUse|0=0D =20=0D + #=0D + # Mini-UART clock rate=0D + #=0D + gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate|500000000=0D +=0D ##########################################################################= ######=0D #=0D # Components Section - list of all EDK II Modules needed by this Platform= =0D 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=0D gRaspberryPiTokenSpaceGuid.PcdUartInUse|1|UINT32|0x00000021=0D gRaspberryPiTokenSpaceGuid.PcdXhciPci|0|UINT32|0x00000022=0D + gRaspberryPiTokenSpaceGuid.PcdMiniUartClockRate|0|UINT32|0x00000023=0D --=20 2.17.1