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.133.124]) by mx.groups.io with SMTP id smtpd.web09.12932.1644335139994891695 for ; Tue, 08 Feb 2022 07:45:40 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PkND4+p/; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: athierry@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644335138; 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=+sksWFv0JTjNqN3UOfne/ASWTJUcf9Hlhr1IULYKDQw=; b=PkND4+p/4GdXjoTg5JywRejL7CiFCIugvTq0DipZOjE/Sun0AEhfb5Fx21KEJem02rPz+N voqPEnLHQOx1KoO4hykQ0uQx6o9G2iLUEvQGqLBGhfKONg4Mrauig+NZjP6g0ANbNxyqeP +04pBoiloGcRbjLPKV6NSlHhlOvXjV4= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-cr3jl57SNruYVKDYwxNeXA-1; Tue, 08 Feb 2022 10:45:37 -0500 X-MC-Unique: cr3jl57SNruYVKDYwxNeXA-1 Received: by mail-qt1-f199.google.com with SMTP id x5-20020ac84d45000000b002cf826b1a18so13853955qtv.2 for ; Tue, 08 Feb 2022 07:45:37 -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=+sksWFv0JTjNqN3UOfne/ASWTJUcf9Hlhr1IULYKDQw=; b=QVSJcjCHYHwwpvmJoslwhm5KrsjBZsDcUJhRfdXzXiLS9pR+OwvhkrO/vkwPeLfHDQ FwaQ5BDFHRonhFYeVyKEedrShRQRUpCVAbylGbSjEtYKYjtFmHA5qP334VwLf0gmWNO6 BMnCjm1+VIZMMT5BUBEBOZYCJtfXhSfVsYoirU0tSqCsi7SiCVbJe1MAcmZsNz16yfYp I3PY7PACAChfoYDiDXhOyJsiHhkVavWt5E4ONkWzDA0eUF5GEopvxJjRS0VuYUsQgm/k 2DmpKchOujGUEKsCPGEyDJ+2f1qkL+uqQ456YjeXckLHPrsF7afNG4Fwrh5ZwytOJz8w kzmA== X-Gm-Message-State: AOAM533jsvzqshw98Jhn8SVyEfRH4Jq8W/CkaR3urbVLayRJ+liRUJjL uaztY+3jyVMBJKkdWV4zogiladLDgZ+lekwuyDR6yhXBahzkEt4Xf1WliQmTGKNmIEe4k2+64GB j6CT2FCN4ZZaBfaRzEiOkXHPsQfwNg65WsaU04VZtI+yGJSu3S+hEWaFM49XnCbJkUw== X-Received: by 2002:a05:6214:2306:: with SMTP id gc6mr3466013qvb.131.1644335137262; Tue, 08 Feb 2022 07:45:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyS95dnrL0scRTgSw52wTrmGsG3tL9DdRPpLz9TEFLDTIfCCiqH/2dQ3S1nINlkR92FdI4MvQ== X-Received: by 2002:a05:6214:2306:: with SMTP id gc6mr3465990qvb.131.1644335136907; Tue, 08 Feb 2022 07:45:36 -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 q8sm7014005qkl.65.2022.02.08.07.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 07:45:36 -0800 (PST) From: "Adrien Thierry" To: devel@edk2.groups.io Cc: Adrien Thierry , Ard Biesheuvel , Leif Lindholm , Pete Batard , Jeremy Linton Subject: [edk2-platforms PATCH v2] Platform/RaspberryPi: Add 'clock-frequency' property for miniuart Date: Tue, 8 Feb 2022 10:45:27 -0500 Message-Id: <20220208154527.36689-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: 8bit 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 [1] 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. [1] https://lore.kernel.org/all/20220207232129.402882-1-athierry@redhat.com/ Signed-off-by: Adrien Thierry --- V1 -> V2: added link to the Linux patch The Linux patch [1] has been merged into Greg Kroah-Hartman's tty tree https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/commit/?h=tty-testing&id=fcc446c8aa6303b247b0d88f460167b731265282 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