From nobody Sun May 5 16:32:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52406+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52406+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576757693; cv=none; d=zohomail.com; s=zohoarc; b=CvhOOOemslNXxuCVhmpRECqhqzKLWb11NuLQjBrzcg6WIPCj7qhlBIIis98Id8FXC2Qc+UsMNtCUFxXOe3JSRXOtsfsj8XUpjk0XtFt2JKS9r3NB2gEP9AH/v6JuZWfuNR+oI4tKqqaxPKAo/R/WLvrqXsrxzYFPs0oyJQISJp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576757693; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4t/wOuzz+QMYuRYU+v19GMACKwr+yTsZImDpjW+8kRs=; b=LbORxrndN91hmVHKoj/0XZg7UFV7bGOaAocf2wl03oMEJ7wXAlZhhf2boENu8bvNrqHZPXWvOlafTiLqwZOoK89JO1LpsdFpVZc6BkgKuO7FcgMTLxr8VifciQPOl6wNmddVRw2DgwPJ76bsNqxpJCcsa8TyWifiHRBZGuyk0Cc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52406+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576757693738509.05124991926914; Thu, 19 Dec 2019 04:14:53 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5TX7YY1788612xu2XlN65EUP; Thu, 19 Dec 2019 04:14:52 -0800 X-Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web12.8819.1576757689810717297 for ; Thu, 19 Dec 2019 04:14:50 -0800 X-Received: by mail-wr1-f65.google.com with SMTP id b6so5788336wrq.0 for ; Thu, 19 Dec 2019 04:14:49 -0800 (PST) X-Gm-Message-State: PWRMS0hTDY53sqmJ0FnAgKsqx1787277AA= X-Google-Smtp-Source: APXvYqzMJE/pFz0jleMASWnPRK8Xt9Nv7Lu2SKaCi+uwDwtvakuPO+KXnjrL9wHR5d1Rb+z54WBvvg== X-Received: by 2002:a05:6000:149:: with SMTP id r9mr784886wrx.147.1576757687989; Thu, 19 Dec 2019 04:14:47 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id u8sm5823147wmm.15.2019.12.19.04.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 04:14:47 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 1/7] Silicon/Bcm283x: Add UART constants for PL011 and miniUART Date: Thu, 19 Dec 2019 12:14:28 +0000 Message-Id: <20191219121434.2856-2-pete@akeo.ie> In-Reply-To: <20191219121434.2856-1-pete@akeo.ie> References: <20191219121434.2856-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576757692; bh=PvJ2/FGm/Kg4iyn0hGl4q84/qtHFJHDU47GM4sl5d/k=; h=Cc:Date:From:Reply-To:Subject:To; b=I5usY5QmVr3Z2RSGs/NwtFaCTmj86ZZwDqnSATVvtX+5+DRy7PFGR/gU1JMEb5jakA9 TDRgctYYJfCAru1e75S72A5DvTa9n8lQHO5qrsNdz+KdPegvaKls5AVvcpGa1b3GZ59Pn jkLA2rfrw3Bamwj+wAHGXgl0GQA4beNp4Uo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This adds offset, base address, interrupt and register-space length for the 2 UARTs that the Bcm283x SoC provides. To be consistent, we simplify the two other existing base address definitions to a more legible equivalent since there is no point in explicit refs to FixedPcdGet64 (PcdBcm283xRegistersAddress). Signed-off-by: Pete Batard Reviewed-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude --- Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h | 17 +++++++++= ++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h b/= Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h index 02107086d439..dd9a698f7218 100644 --- a/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h +++ b/Silicon/Broadcom/Bcm283x/Include/IndustryStandard/Bcm2836.h @@ -24,8 +24,7 @@ =20 /* watchdog constants */ #define BCM2836_WDOG_OFFSET 0x00100000 -#define BCM2836_WDOG_BASE_ADDRESS (FixedPcdGet64= (PcdBcm283xRegistersAddress) \ - + BCM2836_WDOG= _OFFSET) +#define BCM2836_WDOG_BASE_ADDRESS (BCM2836_SOC_R= EGISTERS + BCM2836_WDOG_OFFSET) #define BCM2836_WDOG_PASSWORD 0x5a000000 #define BCM2836_WDOG_RSTC_OFFSET 0x0000001c #define BCM2836_WDOG_WDOG_OFFSET 0x00000024 @@ -34,8 +33,7 @@ =20 /* mailbox interface constants */ #define BCM2836_MBOX_OFFSET 0x0000b880 -#define BCM2836_MBOX_BASE_ADDRESS (FixedPcdGet64= (PcdBcm283xRegistersAddress) \ - + BCM2836_MBOX= _OFFSET) +#define BCM2836_MBOX_BASE_ADDRESS (BCM2836_SOC_R= EGISTERS + BCM2836_MBOX_OFFSET) #define BCM2836_MBOX_READ_OFFSET 0x00000000 #define BCM2836_MBOX_STATUS_OFFSET 0x00000018 #define BCM2836_MBOX_CONFIG_OFFSET 0x0000001c @@ -50,4 +48,15 @@ #define BCM2836_INTC_TIMER_CONTROL_OFFSET 0x00000040 #define BCM2836_INTC_TIMER_PENDING_OFFSET 0x00000060 =20 +/* uart constants */ +#define BCM2836_PL011_UART_OFFSET 0x00201000 +#define BCM2836_PL011_UART_BASE_ADDRESS (BCM2836_SOC_R= EGISTERS + BCM2836_PL011_UART_OFFSET) +#define BCM2836_PL011_UART_LENGTH 0x00001000 +#define BCM2836_PL011_UART_INTERRUPT 0x99 + +#define BCM2836_MINI_UART_OFFSET 0x00215000 +#define BCM2836_MINI_UART_BASE_ADDRESS (BCM2836_SOC_R= EGISTERS + BCM2836_MINI_UART_OFFSET) +#define BCM2836_MINI_UART_LENGTH 0x00000070 +#define BCM2836_MINI_UART_INTERRUPT 0x7D + #endif /*__BCM2836_H__ */ --=20 2.21.0.windows.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 (#52406): https://edk2.groups.io/g/devel/message/52406 Mute This Topic: https://groups.io/mt/68829921/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- From nobody Sun May 5 16:32:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52407+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52407+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576757693; cv=none; d=zohomail.com; s=zohoarc; b=Q/iiSc/NUGNyF+QZcuYx2ytjGahqMJ/OGUVYVrlFd0uhzPCGhv4Y+rL3RHhU+sjbgtf5x8tEiII8rS/UhkyhW47WjGm/1yoKejkwWNdyjrsllvVbYr3OtlRBUS93Xr98s1NZBEwOPDgSE8EqFFl0sRvH73m6agH3Mu2H2v6dd04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576757693; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=raV3bEJW0rWPzFVcR3DGIUzTika69kkLNdjIqAjduHA=; b=JAjnhiDUG4tBrXHuadUxth1F+FtKVHcpltg6Szvk3sGtDE4c2XoJCFd1qgyaVlzrCglav8hpxsCH0Ld8x+0gJkUwmBerCl9ma3kxVESUnh7xgZRD0lcosypStweWfSOaFHseHtRR5OI3VM2dt9dqpq+thW6r6CloF9P9xo6skFg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52407+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157675769337079.93166652582931; Thu, 19 Dec 2019 04:14:53 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6R0wYY1788612xvgzQEDzFV1; Thu, 19 Dec 2019 04:14:52 -0800 X-Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web12.8821.1576757691402261623 for ; Thu, 19 Dec 2019 04:14:52 -0800 X-Received: by mail-wr1-f68.google.com with SMTP id c14so5743592wrn.7 for ; Thu, 19 Dec 2019 04:14:51 -0800 (PST) X-Gm-Message-State: rbCb3TGMGhljdfr8yl9k6nzrx1787277AA= X-Google-Smtp-Source: APXvYqz6AkCCwIyZ7uVVCsiecO+TPE2Tb4lH+A7KKEwV67IygtT9146PslGEJIQdz+qDoK27oor+hA== X-Received: by 2002:adf:a285:: with SMTP id s5mr9045721wra.118.1576757689550; Thu, 19 Dec 2019 04:14:49 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id u8sm5823147wmm.15.2019.12.19.04.14.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 04:14:48 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 2/7] Platform/RPi4: Clean up ACPI definitions Date: Thu, 19 Dec 2019 12:14:29 +0000 Message-Id: <20191219121434.2856-3-pete@akeo.ie> In-Reply-To: <20191219121434.2856-1-pete@akeo.ie> References: <20191219121434.2856-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576757692; bh=OziRyrSBjqf7Kgjs6KmpdQrq4Hm75RkSvs/LaaLPGn8=; h=Cc:Date:From:Reply-To:Subject:To; b=BB9bKBtVJTuc1TSjfSwIv6kDs3FovaIKbI5ng/WucZEeP+BBgEtNIZN+d+I5jhkVvth t254BZUqH4r19qEnKqWyXuv/HSmTyoOtrudCai4USbf3C1UcbBcpNgvmqxS3/Rzlj0bOI sLnw+8l1kICwVDX0NyqIK7wjXbIPff70vGw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" * Use ACPI 5.1 everywhere, since we are constrained to use v5.x for MADT compatibility. * Clean up whitespaces and reorganize header declaration. * Prefix all RPi related constant with RPI_ to make them clearer to differentiate from regular EDK2 ones. * Reference IndustryStandard/Acpi.h always. * Remove explicit references to RPI4 for sources that we may be factorized for both the Pi 3 and Pi 4 platform. Signed-off-by: Pete Batard Reviewed-by: Ard Biesheuvel --- Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h | 12 +++--- Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc | 42 ++++++++++---------- Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc | 30 +++++++------- Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc | 11 ++--- Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl | 4 +- Platform/RaspberryPi/RPi4/AcpiTables/Pep.c | 6 +-- Platform/RaspberryPi/RPi4/AcpiTables/Pep.h | 8 ++-- 7 files changed, 58 insertions(+), 55 deletions(-) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h b/Platform/R= aspberryPi/RPi4/AcpiTables/AcpiTables.h index e61f3fa0bcfa..dcdbac7a0b7b 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h +++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.h @@ -13,7 +13,7 @@ #ifndef __ACPITABLES_H__ #define __ACPITABLES_H__ =20 -#include +#include =20 #define EFI_ACPI_OEM_ID {'M','C','R','S','F','T'} //= OEMID 6 bytes long #define EFI_ACPI_OEM_TABLE_ID SIGNATURE_64 ('R','P','I','4= ','E','D','K','2') // OEM table id 8 bytes long @@ -41,10 +41,10 @@ #define EFI_ACPI_CSRT_DEVICE_ID_DMA 0x00000009 // Fixed id #define EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP 0x0 // Count up from 0 =20 -#define RPI4_DMA_CHANNEL_COUNT 10 // All 10 DMA channels ar= e listed, including the reserved ones -#define RPI4_DMA_USED_CHANNEL_COUNT 5 // Use 5 DMA channels +#define RPI_DMA_CHANNEL_COUNT 10 // All 10 DMA channels ar= e listed, including the reserved ones +#define RPI_DMA_USED_CHANNEL_COUNT 5 // Use 5 DMA channels =20 -#define EFI_ACPI_5_0_CSRT_REVISION 0x00000000 +#define EFI_ACPI_5_1_CSRT_REVISION 0x00000000 =20 typedef enum { @@ -76,7 +76,7 @@ typedef struct UINT16 Revision; // 2 bytes UINT16 Reserved; // 2 bytes UINT32 SharedInfoLength; // 4 bytes -} EFI_ACPI_5_0_CSRT_RESOURCE_GROUP_HEADER; +} EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER; =20 //------------------------------------------------------------------------ // CSRT Resource Descriptor 12 bytes total @@ -87,6 +87,6 @@ typedef struct UINT16 ResourceType; // 2 bytes UINT16 ResourceSubType; // 2 bytes UINT32 UID; // 4 bytes -} EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER; +} EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER; =20 #endif // __ACPITABLES_H__ diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Csrt.aslc index 22a370d04017..f8bf3f26a341 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Csrt.aslc @@ -9,14 +9,16 @@ * **/ =20 +#include + #include "AcpiTables.h" =20 -#define DMA_MAX_REQ_LINES 32 +#define RPI_DMA_MAX_REQ_LINES 32 =20 #pragma pack (push, 1) =20 //------------------------------------------------------------------------ -// DMA Controller Vendor Data for RPi4 +// DMA Controller Vendor Data //------------------------------------------------------------------------ typedef struct { @@ -34,16 +36,16 @@ typedef struct } DMA_CONTROLLER_VENDOR_DATA; =20 //------------------------------------------------------------------------ -// DMA Controller on RPi4 +// DMA Controller //------------------------------------------------------------------------ typedef struct { - EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader; + EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader; DMA_CONTROLLER_VENDOR_DATA ControllerVendorData; } RD_DMA_CONTROLLER; =20 //------------------------------------------------------------------------ -// DMA Channel Vendor Data for RPi4 +// DMA Channel Vendor Data //------------------------------------------------------------------------ typedef struct { @@ -54,27 +56,27 @@ typedef struct } DMA_CHANNEL_VENDOR_DATA; =20 //------------------------------------------------------------------------ -// DMA Channel on RPi4 +// DMA Channel //------------------------------------------------------------------------ typedef struct { - EFI_ACPI_5_0_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaChannelHeader; + EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaChannelHeader; DMA_CHANNEL_VENDOR_DATA ChannelVendorData; } RD_DMA_CHANNEL; =20 //------------------------------------------------------------------------ -// DMA Resource Group on RPi4 +// DMA Resource Group //------------------------------------------------------------------------ =20 typedef struct { - EFI_ACPI_5_0_CSRT_RESOURCE_GROUP_HEADER ResGroupHeader; + EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER ResGroupHeader; RD_DMA_CONTROLLER DmaController; - RD_DMA_CHANNEL DmaChannels[RPI4_DMA_CHANNEL_COUNT]; + RD_DMA_CHANNEL DmaChannels[RPI_DMA_CHANNEL_COUNT]; } RG_DMA; =20 //------------------------------------------------------------------------= ---- -// CSRT table structure for RPi4 platform - current revision only includes= DMA +// CSRT table structure - current revision only includes DMA //------------------------------------------------------------------------= ---- typedef struct { @@ -84,20 +86,20 @@ typedef struct // DMA Resource Group RG_DMA DmaResourceGroup; =20 -} EFI_ACPI_5_0_CSRT_TABLE; +} EFI_ACPI_5_1_CSRT_TABLE; =20 -EFI_ACPI_5_0_CSRT_TABLE Csrt =3D +EFI_ACPI_5_1_CSRT_TABLE Csrt =3D { //----------------------------------------------------------------------= -- // ACPI Table Header //----------------------------------------------------------------------= -- { - EFI_ACPI_5_0_CORE_SYSTEM_RESOURCE_TABLE_SIGNATURE, // Signature = "CSRT" + EFI_ACPI_5_1_CORE_SYSTEM_RESOURCE_TABLE_SIGNATURE, // Signature = "CSRT" sizeof (EFI_ACPI_DESCRIPTION_HEADER) + sizeof (RG_DMA), // Length - EFI_ACPI_5_0_CSRT_REVISION, // Revision + EFI_ACPI_5_1_CSRT_REVISION, // Revision 0x00, // Checksum calculated at runtime. - EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long field "BC28= 36" - EFI_ACPI_OEM_TABLE_ID, // OEM table identification(8 bytes lo= ng) "RPI4EDK2" + EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long field + EFI_ACPI_OEM_TABLE_ID, // OEM table identification (8 bytes l= ong) EFI_ACPI_OEM_REVISION, // OEM revision number. EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID. EFI_ACPI_CREATOR_REVISION // ASL compiler revision number. @@ -136,13 +138,13 @@ EFI_ACPI_5_0_CSRT_TABLE Csrt =3D sizeof (DMA_CONTROLLER_VENDOR_DATA), // Controller vendor data he= re 1, 0xFE007000, // Base address for channels - RPI4_DMA_CHANNEL_COUNT * 0x100, // Base size =3D Number of channel= s x 0x100 size for each channel + RPI_DMA_CHANNEL_COUNT * 0x100, // Base size =3D Number of channels= x 0x100 size for each channel 0xFE007FE0, // Base address for controller 8, // Base size =3D two registers - RPI4_DMA_USED_CHANNEL_COUNT, + RPI_DMA_USED_CHANNEL_COUNT, 0, // cannot use controller interrupt 0, // Minimum Request Line - DMA_MAX_REQ_LINES - 1, // Maximum Request Line + RPI_DMA_MAX_REQ_LINES - 1, // Maximum Request Line FALSE, }, }, diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Gtdt.aslc index 293c6022d258..7c2aa9389456 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Gtdt.aslc @@ -8,41 +8,41 @@ * **/ =20 +#include #include #include -#include =20 #include "AcpiTables.h" =20 -#define SYSTEM_TIMER_BASE_ADDRESS 0xFF80001C -#define GTDT_GLOBAL_FLAGS 0 -#define GTDT_GTIMER_FLAGS EFI_ACPI_6_0_GTDT_TIMER_FLAG_TIMER_INT= ERRUPT_POLARITY +#define RPI_SYSTEM_TIMER_BASE_ADDRESS 0xFF80001C +#define RPI_GTDT_GLOBAL_FLAGS 0 +#define RPI_GTDT_GTIMER_FLAGS EFI_ACPI_5_1_GTDT_TIMER_FLAG_TIMER= _INTERRUPT_POLARITY =20 #pragma pack (1) =20 typedef struct { - EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt; -} EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLES; + EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt; +} EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES; =20 #pragma pack () =20 -EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt =3D { +EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES Gtdt =3D { { ACPI_HEADER( - EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, - EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLES, - EFI_ACPI_6_0_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION + EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLES, + EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION ), - SYSTEM_TIMER_BASE_ADDRESS, // UINT64 PhysicalAddre= ss + RPI_SYSTEM_TIMER_BASE_ADDRESS, // UINT64 PhysicalAddre= ss 0, // UINT32 Reserved FixedPcdGet32 (PcdArmArchTimerSecIntrNum), // UINT32 SecurePL1Time= rGSIV - GTDT_GTIMER_FLAGS, // UINT32 SecurePL1Time= rFlags + RPI_GTDT_GTIMER_FLAGS, // UINT32 SecurePL1Time= rFlags FixedPcdGet32 (PcdArmArchTimerIntrNum), // UINT32 NonSecurePL1T= imerGSIV - GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL1T= imerFlags + RPI_GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL1T= imerFlags FixedPcdGet32 (PcdArmArchTimerVirtIntrNum), // UINT32 VirtualTimerG= SIV - GTDT_GTIMER_FLAGS, // UINT32 VirtualTimerF= lags + RPI_GTDT_GTIMER_FLAGS, // UINT32 VirtualTimerF= lags FixedPcdGet32 (PcdArmArchTimerHypIntrNum), // UINT32 NonSecurePL2T= imerGSIV - GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL2T= imerFlags + RPI_GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL2T= imerFlags 0xFFFFFFFFFFFFFFFF, // UINT64 CntReadBasePh= ysicalAddress 0, // UINT32 PlatformTimer= Count 0 // UINT32 PlatfromTimerO= ffset diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Madt.aslc index 0027cb9fe8bb..f847a9310ff7 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Madt.aslc @@ -8,11 +8,12 @@ * **/ =20 -#include "AcpiTables.h" +#include #include #include #include -#include + +#include "AcpiTables.h" =20 // // Multiple APIC Description Table @@ -45,13 +46,13 @@ PI_MULTIPLE_APIC_DESCRIPTION_TABLE Madt =3D { 0, 0, GET_MPID(0, 0), EFI_ACPI_5_1_GIC_ENABLED, 48, FixedPcdGet64 = (PcdGicInterruptInterfaceBase), 0xFF846000, 0xFF844000, 0x19, 0), EFI_ACPI_5_1_GICC_STRUCTURE_INIT( - 1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 49, FixedPcdGet64= (PcdGicInterruptInterfaceBase), + 1, 1, GET_MPID(0, 1), EFI_ACPI_5_1_GIC_ENABLED, 49, FixedPcdGet64 = (PcdGicInterruptInterfaceBase), 0xFF846000, 0xFF844000, 0x19, 0), EFI_ACPI_5_1_GICC_STRUCTURE_INIT( - 2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 50, FixedPcdGet64= (PcdGicInterruptInterfaceBase), + 2, 2, GET_MPID(0, 2), EFI_ACPI_5_1_GIC_ENABLED, 50, FixedPcdGet64 = (PcdGicInterruptInterfaceBase), 0xFF846000, 0xFF844000, 0x19, 0), EFI_ACPI_5_1_GICC_STRUCTURE_INIT( - 3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 51, FixedPcdGet64= (PcdGicInterruptInterfaceBase), + 3, 3, GET_MPID(0, 3), EFI_ACPI_5_1_GIC_ENABLED, 51, FixedPcdGet64 = (PcdGicInterruptInterfaceBase), 0xFF846000, 0xFF844000, 0x19, 0), }, EFI_ACPI_5_0_GIC_DISTRIBUTOR_INIT(0, FixedPcdGet64 (PcdGicDistributorBas= e), 0) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl b/Platform/Raspbe= rryPi/RPi4/AcpiTables/Pep.asl index 7096109f8819..8a0a44e1c4c9 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.asl @@ -13,9 +13,9 @@ Device(PEPD) { // - // RPI4 PEP virtual device. + // PEP virtual device. // - Name (_HID, "BCM2854") // Note: since pep on rpi4 is virtual device, + Name (_HID, "BCM2854") // Note: Since PEP on RPi is a virtual device, Name (_CID, "BCM2854") // its device id needs to be generated by Microso= ft Name (_UID, 0x0) Name (_CRS, ResourceTemplate () diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c b/Platform/Raspberr= yPi/RPi4/AcpiTables/Pep.c index 1a78392f05a0..f452580c703d 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.c @@ -12,7 +12,7 @@ =20 #include "Pep.h" =20 -PEP_PROCESSOR_TABLE_PLAT RPI4Processors =3D { +PEP_PROCESSOR_TABLE_PLAT RpiProcessors =3D { 1, // Version 1, // NumberProcessors { // ProcessorInfo @@ -30,7 +30,7 @@ PEP_PROCESSOR_TABLE_PLAT RPI4Processors =3D { } }; =20 -PEP_COORDINATED_STATE_TABLE_PLAT RPI4CoordinatedStates =3D { +PEP_COORDINATED_STATE_TABLE_PLAT RpiCoordinatedStates =3D { 1, // Version 1, // CoordinatedStateCount { // CordinatedStates[] @@ -52,7 +52,7 @@ PEP_COORDINATED_STATE_TABLE_PLAT RPI4CoordinatedStates = =3D { } }; =20 -PEP_DEVICE_TABLE_PLAT RPI4Devices =3D { +PEP_DEVICE_TABLE_PLAT RpiDevices =3D { 1, // Version 1, // NumberDevices { // DeviceInfo diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h b/Platform/Raspberr= yPi/RPi4/AcpiTables/Pep.h index 19b801caf783..30f6768f12a5 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Pep.h @@ -14,10 +14,10 @@ * Note: Not everything is here. At least SOC_STATE_TYPE is missing. */ =20 -#ifndef _RPI4PEP_H_INCLUDED_ -#define _RPI4PEP_H_INCLUDED_ +#ifndef _RPI_PEP_H_INCLUDED_ +#define _RPI_PEP_H_INCLUDED_ =20 -#include +#include =20 #define PEP_MAX_DEPENDENCIES_PER_STATE 16 #define MAX_PROCESSOR_PATH_LENGTH 16 @@ -118,4 +118,4 @@ typedef struct _PEP_DEVICE_TABLE_PLAT { PEP_DEVICE_INFO_PLAT DeviceInfo[P_NUMBER_DEVICES]; } PEP_DEVICE_TABLE_PLAT, *PPEP_DEVICE_TABLE_PLAT; =20 -#endif // _RPI4PEP_H_INCLUDED_ +#endif // _RPI_PEP_H_INCLUDED_ --=20 2.21.0.windows.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 (#52407): https://edk2.groups.io/g/devel/message/52407 Mute This Topic: https://groups.io/mt/68829923/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- From nobody Sun May 5 16:32:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52408+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52408+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576757731; cv=none; d=zohomail.com; s=zohoarc; b=CWe/PS9YdvHGXG/VESd8HCFDpWm+kvbit/rjwoc365UrS5V7kymuD0jHv+2aAX7nNyJQVRbyiD5wuabmlqIopWFIY/eGZUGkwZdNc7fmTYPelFivbUc8DPojnYwPIu9W2Nbl2lqhA5v9A0DfeuBqc5l6J1wEBVQqBfQwhhYtZpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576757731; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=jFyX+Fa6nHkRcJEiY8rhQdl3ov2IPHkVqkzOdY6/nbo=; b=e+7hU7jHxmqFyeECWHvHVXol9aRT6tfSqrDL1BSP48ITfU7FpfkEqkgp7x9geAiuNxlSsBEyRva+xCMHo17BgPFHfE7LiJfGAOHg2CyTUCzKYRoh8P+xclAQum0h4TmMHzMQLF9NSUnOztjDcEYmi2u842WoJDawCojJme6kghE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52408+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576757731837834.9808246803435; Thu, 19 Dec 2019 04:15:31 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id I551YY1788612xgiHbXYwgnM; Thu, 19 Dec 2019 04:15:30 -0800 X-Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.groups.io with SMTP id smtpd.web10.8828.1576757692542337503 for ; Thu, 19 Dec 2019 04:14:53 -0800 X-Received: by mail-wr1-f67.google.com with SMTP id b6so5788514wrq.0 for ; Thu, 19 Dec 2019 04:14:52 -0800 (PST) X-Gm-Message-State: RZQnQ6i708GyJ42o3JSuauECx1787277AA= X-Google-Smtp-Source: APXvYqw2RXjVUumUfRSn50Y2AYKTHP1PToifpkvU2u7AFimWefeQwRQKbm97eRHSpZPpXmdV6AO9FQ== X-Received: by 2002:adf:f64b:: with SMTP id x11mr9419176wrp.355.1576757690890; Thu, 19 Dec 2019 04:14:50 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id u8sm5823147wmm.15.2019.12.19.04.14.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 04:14:50 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 3/7] Platform/RPi4: Improve FADT ACPI table generation Date: Thu, 19 Dec 2019 12:14:30 +0000 Message-Id: <20191219121434.2856-4-pete@akeo.ie> In-Reply-To: <20191219121434.2856-1-pete@akeo.ie> References: <20191219121434.2856-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576757730; bh=gfZRW8u6EATLlN/ZhBosfUp+VccbUqEh9wNy5Q3AoNc=; h=Cc:Date:From:Reply-To:Subject:To; b=qydQ6np2KvLC5JcSfvh1d730/sag4ndPNqzI9QkGdX2p3UTDQODoQMHYf9kEwNdCmGM Ol6mdlG8dtQRCZ9gc59Ffh5ZZpOfbduuRRKUiqzTD2o/tqxfpmxl95ukgXLGug1rbhuGL oQVi0eJ14sHoR8IuvkjNnTOklQgyV6jr0pw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Use a proper aslc source to build the table. Note that we use ACPI 5.1 for this table to match the MADT constraints. Signed-off-by: Pete Batard Reviewed-by: Ard Biesheuvel --- Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc | 99 ++++++++++++++------ 1 file changed, 71 insertions(+), 28 deletions(-) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Fadt.aslc index 3ef877fde5f4..ebf58fb7fc3c 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc @@ -2,6 +2,7 @@ * * Fixed ACPI Description Table (FADT) * + * Copyright (c) 2019, Pete Batard * Copyright (c) 2018, Andrey Warkentin * Copyright (c) Microsoft Corporation. All rights reserved. * @@ -9,34 +10,76 @@ * **/ =20 -UINT8 Fadt[268] =3D { - 0x46, 0x41, 0x43, 0x50, 0x0C, 0x01, 0x00, 0x00, 0x05, 0x00, /* 0 */ - 0x42, 0x43, 0x32, 0x38, 0x33, 0x36, 0x45, 0x44, 0x4B, 0x32, /* 10 */ - 0x20, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x00, 0x4D, 0x53, /* 20 */ - 0x46, 0x54, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 30 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, /* 40 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 50 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 60 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 70 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 80 */ - 0x00, 0x04, 0x00, 0x00, 0x00, 0xE3, 0x00, 0x00, 0x00, 0x00, /* 90 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, /* 100 */ - 0x00, 0x00, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, /* 110 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* 120 */ - 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 130 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 140 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 150 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 160 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 170 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 180 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 190 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 200 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 210 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 220 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 230 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 240 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 250 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* 268 */ +#include +#include +#include + +#include "AcpiTables.h" + +/* + * Note: Use ACPI 5.1 since we need to match MADT ACPI requirements + */ +EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE Fadt =3D { + ACPI_HEADER ( + EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE, + EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_REVISION + ), + 0, = // UINT32 FirmwareCtrl + 0, = // UINT32 Dsdt + EFI_ACPI_RESERVED_BYTE, = // UINT8 Reserved0 + EFI_ACPI_5_1_PM_PROFILE_APPLIANCE_PC, = // UINT8 PreferredPmProfile + 0, = // UINT16 SciInt + 0, = // UINT32 SmiCmd + 0, = // UINT8 AcpiEnable + 0, = // UINT8 AcpiDisable + 0, = // UINT8 S4BiosReq + 0, = // UINT8 PstateCnt + 0, = // UINT32 Pm1aEvtBlk + 0, = // UINT32 Pm1bEvtBlk + 0, = // UINT32 Pm1aCntBlk + 0, = // UINT32 Pm1bCntBlk + 0, = // UINT32 Pm2CntBlk + 0, = // UINT32 PmTmrBlk + 0, = // UINT32 Gpe0Blk + 0, = // UINT32 Gpe1Blk + 0, = // UINT8 Pm1EvtLen + 0, = // UINT8 Pm1CntLen + 0, = // UINT8 Pm2CntLen + 0, = // UINT8 PmTmrLen + 0, = // UINT8 Gpe0BlkLen + 0, = // UINT8 Gpe1BlkLen + 0, = // UINT8 Gpe1Base + 0, = // UINT8 CstCnt + 0, = // UINT16 PLvl2Lat + 0, = // UINT16 PLvl3Lat + 0, = // UINT16 FlushSize + 0, = // UINT16 FlushStride + 0, = // UINT8 DutyOffset + 0, = // UINT8 DutyWidth + 0, = // UINT8 DayAlrm + 0, = // UINT8 MonAlrm + 0, = // UINT8 Century + EFI_ACPI_RESERVED_WORD, = // UINT16 IaPcBootArch (Reserved on ARM) + EFI_ACPI_RESERVED_BYTE, = // UINT8 Reserved1 + EFI_ACPI_5_1_WBINVD | EFI_ACPI_5_1_SLP_BUTTON | = // UINT32 Flags + EFI_ACPI_5_1_HW_REDUCED_ACPI, + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE ResetReg + 0, = // UINT8 ResetValue + EFI_ACPI_5_1_ARM_PSCI_COMPLIANT, = // UINT16 ArmBootArchFlags + EFI_ACPI_5_1_FIXED_ACPI_DESCRIPTION_TABLE_MINOR_REVISION, = // UINT8 MinorRevision + 0, = // UINT64 XFirmwareCtrl + 0, = // UINT64 XDsdt + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE XGpe0Blk + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE XGpe1Blk + NULL_GAS, = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE SleepControlReg + NULL_GAS = // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE SleepStatusReg }; =20 // --=20 2.21.0.windows.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 (#52408): https://edk2.groups.io/g/devel/message/52408 Mute This Topic: https://groups.io/mt/68829924/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- From nobody Sun May 5 16:32:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52409+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52409+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576757734; cv=none; d=zohomail.com; s=zohoarc; b=R+6t4Ud3BUlZlgSxANvLq28uGo5PqJDFMs3n0/rJVFkm0zFT3h5lPd7JQOjdVlp9VdVVOmkySLc2IGVOnJYrFtoZKGfphaNFINiyyeJ5NGUWYj8W5NdDNmXZMYkJhpQjuz1Ql3gP9f9BbejIcD9xuKiu3llF33fByA4TGhHWawc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576757734; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=tiKmU4nXgoCO9HTe8SvD5tcE9yaW2xE19MJytKLCVKY=; b=RdtLPQIQOj4argUFwlbDRBiC+0nq04SmCbvokGFb1pFYi9Wkjt5oIDva3UFKglmfV+li4b8pbPpvFFFwCmqgyOT2SIEAOCjnnPvXq7hJjQN69rdJ0F2wvoikeKDBCPKUK7J/WIykOTIbJf56QoJvjgRA6O0D2A1k8lzGGfwRUpE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52409+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576757734619984.6737852750232; Thu, 19 Dec 2019 04:15:34 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SWVdYY1788612x6Br70skitN; Thu, 19 Dec 2019 04:15:34 -0800 X-Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.groups.io with SMTP id smtpd.web10.8829.1576757694330639860 for ; Thu, 19 Dec 2019 04:14:55 -0800 X-Received: by mail-wr1-f67.google.com with SMTP id y17so5773833wrh.5 for ; Thu, 19 Dec 2019 04:14:54 -0800 (PST) X-Gm-Message-State: AJkTpnqbWNROVvZh5xcYDq4jx1787277AA= X-Google-Smtp-Source: APXvYqwX4UTVfiqgkHzIqXvSVuaSfjQdahUa/G78sYxRVJJpvJs4W5/IHrl2p0X8bPWL1idHWvLJvQ== X-Received: by 2002:adf:eb8e:: with SMTP id t14mr9039201wrn.384.1576757692471; Thu, 19 Dec 2019 04:14:52 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id u8sm5823147wmm.15.2019.12.19.04.14.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 04:14:51 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 4/7] Platform/RPi4: Improve SPCR and DBG2 ACPI table generation Date: Thu, 19 Dec 2019 12:14:31 +0000 Message-Id: <20191219121434.2856-5-pete@akeo.ie> In-Reply-To: <20191219121434.2856-1-pete@akeo.ie> References: <20191219121434.2856-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576757734; bh=3AVK2BvWRW192IPhZNGXu+dl0DVxaa+uTi9qeLLLupA=; h=Cc:Date:From:Reply-To:Subject:To; b=dD0Mvkgmo5/KEcunH2JBGTHXoOYJNiE4zwJbGnSlghmi6JSRKgoGQ+IHvmMw8gjpakk NGA8XieIVaA5BNPms/NTvg8jBMRGbRq4KU/7sGED9qHOSwTdY+AY5dPmuJ94GuLftyM9g F8zKEiJjTlIKf2K+zHubASX655xdXbtWZuI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Use code derived from JunoPkg to generate our serial tables and also use PCDs where possible. Signed-off-by: Pete Batard Reviewed-by: Ard Biesheuvel --- Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 5 +- Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc | 98 +++++++++++++++++= --- Platform/RaspberryPi/RPi4/AcpiTables/Spcr.asl | 48 ---------- Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc | 89 ++++++++++++++++++ 4 files changed, 177 insertions(+), 63 deletions(-) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf b/Platform= /RaspberryPi/RPi4/AcpiTables/AcpiTables.inf index 50c9f7694d84..dcbf8d36082c 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf +++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf @@ -31,7 +31,7 @@ [Sources] Gtdt.aslc Dsdt.asl Csrt.aslc - Spcr.asl + Spcr.aslc =20 [Packages] ArmPkg/ArmPkg.dec @@ -39,6 +39,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Silicon/Broadcom/Bcm283x/Bcm283x.dec =20 [FixedPcd] gArmTokenSpaceGuid.PcdArmArchTimerIntrNum @@ -47,4 +48,6 @@ [FixedPcd] gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdGicDistributorBase + gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Dbg2.aslc index 849cf5134793..b71a149c0c0e 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc @@ -2,27 +2,97 @@ * * Debug Port Table (DBG2) * - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) 2019, Pete Batard + * Copyright (c) 2012-2016, ARM Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * **/ =20 -UINT8 Dbg2[92] =3D { - 0x44, 0x42, 0x47, 0x32, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x4D, 0x53, 0x46, 0x54, 0x20, 0x20, 0x45, 0x44, 0x4B, 0x32, - 0x20, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x00, 0x4D, 0x53, - 0x46, 0x54, 0x01, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x01, 0x0A, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x80, 0x10, 0x00, - 0x00, 0x00, 0x16, 0x00, 0x22, 0x00, 0x00, 0x20, 0x00, 0x10, - 0x00, 0x50, 0x21, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00, - 0x00, 0x00, '\\', '_', 'S', 'B', '.', 'U', 'R', 'T', - 'M', 0x00, +#include +#include +#include +#include +#include + +#include "AcpiTables.h" + +#pragma pack(1) + +#define RPI_DBG2_NUM_DEBUG_PORTS 1 +#define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS 1 +#define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE 10 + +#define RPI_UART_INTERFACE_TYPE EFI_ACPI_DBG2_PORT= _SUBTYPE_SERIAL_BCM2835_UART +#define RPI_UART_BASE_ADDRESS BCM2836_MINI_UART_= BASE_ADDRESS +#define RPI_UART_LENGTH BCM2836_MINI_UART_= LENGTH +// +// RPI_UART_STR should match the value used Uart.asl +// +#define RPI_UART_STR { '\\', '_', 'S', = 'B', '.', 'U', 'R', 'T', 'M', 0x00 } + +typedef struct { + EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device; + EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddressRegiste= r; + UINT32 AddressSize; + UINT8 NameSpaceString[RP= I_DBG2_NAMESPACESTRING_FIELD_SIZE]; +} DBG2_DEBUG_DEVICE_INFORMATION; + +typedef struct { + EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE Description; + DBG2_DEBUG_DEVICE_INFORMATION Dbg2DeviceInfo[RPI= _DBG2_NUM_DEBUG_PORTS]; +} DBG2_TABLE; + + +#define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, UartNa= meStr) { \ + { = \ + EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, /* U= INT8 Revision */ \ + sizeof (DBG2_DEBUG_DEVICE_INFORMATION), /* U= INT16 Length */ \ + NumReg, /* U= INT8 NumberofGenericAddressRegisters */ \ + RPI_DBG2_NAMESPACESTRING_FIELD_SIZE, /* U= INT16 NameSpaceStringLength */ \ + OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), /* U= INT16 NameSpaceStringOffset */ \ + 0, /* U= INT16 OemDataLength */ \ + 0, /* U= INT16 OemDataOffset */ \ + EFI_ACPI_DBG2_PORT_TYPE_SERIAL, /* U= INT16 Port Type */ \ + SubType, /* U= INT16 Port Subtype */ \ + {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, /* U= INT8 Reserved[2] */ \ + OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), /* U= INT16 BaseAddressRegister Offset */ \ + OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize) /* U= INT16 AddressSize Offset */ \ + }, = \ + ARM_GAS32 (UartBase), /* EFI_ACPI_5_1_GENER= IC_ADDRESS_STRUCTURE BaseAddressRegister */ \ + UartAddrLen, /* UINT32 AddressSiz= e */ \ + UartNameStr /* UINT8 NameSpaceS= tring[MAX_DBG2_NAME_LEN] */ \ + } + + +STATIC DBG2_TABLE Dbg2 =3D { + { + ACPI_HEADER ( + EFI_ACPI_5_1_DEBUG_PORT_2_TABLE_SIGNATURE, + DBG2_TABLE, + EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION + ), + OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo), + RPI_DBG2_NUM_DEBUG_PORTS /* U= INT32 NumberDbgDeviceInfo */ + }, + { + /* + * Kernel Debug Port + */ + DBG2_DEBUG_PORT_DDI ( + RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS, + RPI_UART_INTERFACE_TYPE, + RPI_UART_BASE_ADDRESS, + RPI_UART_LENGTH, + RPI_UART_STR + ), + } }; =20 +#pragma pack() + // -// Reference the table being generated to prevent the optimizer from remov= ing the -// data structure from the executable +// Reference the table being generated to prevent the optimizer from remov= ing +// the data structure from the executable // VOID* CONST ReferenceAcpiTable =3D &Dbg2; diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.asl b/Platform/Raspb= erryPi/RPi4/AcpiTables/Spcr.asl deleted file mode 100644 index 4632a4f193e7..000000000000 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.asl +++ /dev/null @@ -1,48 +0,0 @@ -/** @file - * - * Serial Port Console Redirection Table (SPCR) - * - * Copyright (c) 2019, ARM Ltd. All rights reserved. - * Copyright (c) 2017-2018, Andrey Warkentin - * - * SPDX-License-Identifier: BSD-2-Clause-Patent - * - **/ - -[000h 0000 4] Signature : "SPCR" [Serial Port Cons= ole Redirection table] -[004h 0004 4] Table Length : 00000050 -[008h 0008 1] Revision : 02 -[009h 0009 1] Checksum : 00 -[00Ah 0010 6] Oem ID : "RPiEFI" -[010h 0016 8] Oem Table ID : "RPi4UEFI" -[018h 0024 4] Oem Revision : 00000001 -[01Ch 0028 4] Asl Compiler ID : "----" -[020h 0032 4] Asl Compiler Revision : 00000000 - -[024h 0036 1] Interface Type : 10 // 0x03 =3D PL011, 0= x10 =3D BCM2835 -[025h 0037 3] Reserved : 000000 - -[028h 0040 12] Serial Port Register : [Generic Address Structure] -[028h 0040 1] Space ID : 00 [SystemMemory] -[029h 0041 1] Bit Width : 20 -[02Ah 0042 1] Bit Offset : 00 -[02Bh 0043 1] Encoded Access Width : 03 [DWord Access:32] -[02Ch 0044 8] Address : FE215000 - -[034h 0052 1] Interrupt Type : 08 // ARMH GIC interrupt -[035h 0053 1] PCAT-compatible IRQ : 00 -[036h 0054 4] Interrupt : 7D -[03Ah 0058 1] Baud Rate : 07 // 115200 -[03Bh 0059 1] Parity : 00 -[03Ch 0060 1] Stop Bits : 01 -[03Dh 0061 1] Flow Control : 00 -[03Eh 0062 1] Terminal Type : 02 // VT-UTF8 -[04Ch 0076 1] Reserved : 00 -[040h 0064 2] PCI Device ID : FFFF -[042h 0066 2] PCI Vendor ID : FFFF -[044h 0068 1] PCI Bus : 00 -[045h 0069 1] PCI Device : 00 -[046h 0070 1] PCI Function : 00 -[047h 0071 4] PCI Flags : 00000000 -[04Bh 0075 1] PCI Segment : 00 -[04Ch 0076 4] Reserved : 00000000 diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Spcr.aslc new file mode 100644 index 000000000000..9931aad8f073 --- /dev/null +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc @@ -0,0 +1,89 @@ +/** @file +* SPCR Table +* +* Copyright (c) 2019 Pete Batard +* Copyright (c) 2014-2016, ARM Limited. All rights reserved. +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include +#include +#include +#include +#include + +#include "AcpiTables.h" + +#define RPI_UART_FLOW_CONTROL_NONE 0 +#define RPI_UART_BASE_ADDRESS BCM2836_MINI_UART_BASE_ADDRESS +#define RPI_UART_INTERRUPT BCM2836_MINI_UART_INTERRUPT + +STATIC EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE Spcr =3D { + ACPI_HEADER ( + EFI_ACPI_5_1_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE, + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION + ), + // UINT8 InterfaceType; + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_BCM2835_UA= RT, + // UINT8 Reserved1[3]; + { + EFI_ACPI_RESERVED_BYTE, + EFI_ACPI_RESERVED_BYTE, + EFI_ACPI_RESERVED_BYTE + }, + // EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddress; + ARM_GAS32 (RPI_UART_BASE_ADDRESS), + // UINT8 InterruptType; + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC, + // UINT8 Irq; + 0, // Not used on ARM + // UINT32 GlobalSystemInterrupt; + RPI_UART_INTERRUPT, + // UINT8 BaudRate; +#if (FixedPcdGet64 (PcdUartDefaultBaudRate) =3D=3D 9600) + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_9600, +#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) =3D=3D 19200) + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_19200, +#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) =3D=3D 57600) + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_57600, +#elif (FixedPcdGet64 (PcdUartDefaultBaudRate) =3D=3D 115200) + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_BAUD_RATE_115200, +#else +#error Unsupported SPCR Baud Rate +#endif + // UINT8 Parity; + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_PARITY_NO_PARITY, + // UINT8 StopBits; + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_STOP_BITS_1, + // UINT8 FlowControl; + RPI_UART_FLOW_CONTROL_NONE, + // UINT8 TerminalType; + EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_TERMINAL_TYPE_VT_UTF8, + // UINT8 Reserved2; + EFI_ACPI_RESERVED_BYTE, + // UINT16 PciDeviceId; + 0xFFFF, + // UINT16 PciVendorId; + 0xFFFF, + // UINT8 PciBusNumber; + 0x00, + // UINT8 PciDeviceNumber; + 0x00, + // UINT8 PciFunctionNumber; + 0x00, + // UINT32 PciFlags; + 0x00000000, + // UINT8 PciSegment; + 0x00, + // UINT32 Reserved3; + EFI_ACPI_RESERVED_DWORD +}; + +// +// Reference the table being generated to prevent the optimizer from remov= ing the +// data structure from the executable +// +VOID* CONST ReferenceAcpiTable =3D &Spcr; --=20 2.21.0.windows.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 (#52409): https://edk2.groups.io/g/devel/message/52409 Mute This Topic: https://groups.io/mt/68829925/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- From nobody Sun May 5 16:32:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52410+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52410+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576757735; cv=none; d=zohomail.com; s=zohoarc; b=WCMLRUXy4tdf0s9XWA35W+Ewvx+jsh0Xcpk55fo6nLtCqlM4CKXLCD3C/v0z2yq9UT3xFZ952x6cHwiOq+d1sFPNcaJiizu7VTcDB9UNIKpMzrYGnXv2CyXixxLsUrOrVlrMlP7uR32P8Icqeqa/gErk6Oz79tzbo9KZtni66Kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576757735; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=OScA38OCcIPazVxmg1BdtCpPGAdZBE/TtXYyVqIQCcU=; b=LPNkAd+4YG5YjasZRyLYk6FfwuXVe108UfkkavJel94VApPehVnrRpncSKP6wyM+lXmF9TOv45cCNqbKRy6uFF3kxRexmY7lRYusu7JENwd+j4H//pKjVowgjvHwfJ1DNfpxWP7Fho/T8U1tXsusEKoMVlaN/FNNHMCfhp6mlpc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52410+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576757735452471.1205267366081; Thu, 19 Dec 2019 04:15:35 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id fhNkYY1788612xJ9mxpfJGBq; Thu, 19 Dec 2019 04:15:34 -0800 X-Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web11.8711.1576757695652306530 for ; Thu, 19 Dec 2019 04:14:56 -0800 X-Received: by mail-wr1-f65.google.com with SMTP id c9so5743166wrw.8 for ; Thu, 19 Dec 2019 04:14:55 -0800 (PST) X-Gm-Message-State: Cn6KSDcqbupKOPtfonM3fRPWx1787277AA= X-Google-Smtp-Source: APXvYqz9KUMT7V2e9/imPaWXmf8Ngr6a7l3OmXZxdtt0VbYE2aAsBqgYGD3X+84idRVpWIz2q3hB1g== X-Received: by 2002:adf:82f3:: with SMTP id 106mr9384945wrc.69.1576757693804; Thu, 19 Dec 2019 04:14:53 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id u8sm5823147wmm.15.2019.12.19.04.14.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 04:14:53 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 5/7] Platform/RPi4: Add switch to select between PL011 and miniUART Date: Thu, 19 Dec 2019 12:14:32 +0000 Message-Id: <20191219121434.2856-6-pete@akeo.ie> In-Reply-To: <20191219121434.2856-1-pete@akeo.ie> References: <20191219121434.2856-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576757734; bh=x0zh4eqS4syCPkznp5KRa+Vj6lQfv2oT/FjkHkkQBaQ=; h=Cc:Date:From:Reply-To:Subject:To; b=ZDyC6TDJApxJoBIy5ne6LJZNh/IrIuYndgy+CCriNSXGXz5u9K7wp7IPGVcnvOhiPyv CaJ443KUxBBqs/ct9h3sfDmPwflIk30bwCE2f/ZP+rBU7nDpYwySPS11+7ABCkWOs64Iv YXwYjWl/+sQt9WS6AArdwFgqbpwuFg6aEO0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The PL011 can be a better choice for the serial console on the RPi4, given that its baud clock is not derived from the CPU clock (which may change under our feet unless we keep it fixed at a low rate), and given the fact that the SBSA/SBBR specs that describe ARM specific architectural requirements for ACPI only permit PL011 based UARTs to begin with. Therefore we add a new PL011_ENABLE build switch to tell the firmware to use PL011 for all console serial I/O, including for TF-A, SPCR and DBG2, as well as toggle the BlueTooth module to use the mini UART. For the time being, the option is disabled by default because it requires an overlay to be enabled in config.txt that pinmuxes the PL011 TX/RX lines to the UART pins on the connector block. Signed-off-by: Pete Batard Reviewed-by: Ard Biesheuvel --- Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc | 7 ++++ Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc | 11 ++++- Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl | 6 ++- Platform/RaspberryPi/RPi4/RPi4.dsc | 23 +++++++++++ Platform/RaspberryPi/RPi4/RPi4.fdf | 4 ++ Platform/RaspberryPi/RPi4/Readme.md | 43 ++++++++++++++++---- 6 files changed, 82 insertions(+), 12 deletions(-) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Dbg2.aslc index b71a149c0c0e..dcad8e205596 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc @@ -23,6 +23,12 @@ #define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS 1 #define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE 10 =20 +#ifdef PL011_ENABLE +#define RPI_UART_INTERFACE_TYPE EFI_ACPI_DBG2_PORT= _SUBTYPE_SERIAL_ARM_PL011_UART +#define RPI_UART_BASE_ADDRESS BCM2836_PL011_UART= _BASE_ADDRESS +#define RPI_UART_LENGTH BCM2836_PL011_UART= _LENGTH +#define RPI_UART_STR { '\\', '_', 'S', = 'B', '.', 'U', 'R', 'T', '0', 0x00 } +#else #define RPI_UART_INTERFACE_TYPE EFI_ACPI_DBG2_PORT= _SUBTYPE_SERIAL_BCM2835_UART #define RPI_UART_BASE_ADDRESS BCM2836_MINI_UART_= BASE_ADDRESS #define RPI_UART_LENGTH BCM2836_MINI_UART_= LENGTH @@ -30,6 +36,7 @@ // RPI_UART_STR should match the value used Uart.asl // #define RPI_UART_STR { '\\', '_', 'S', = 'B', '.', 'U', 'R', 'T', 'M', 0x00 } +#endif =20 typedef struct { EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device; diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Spcr.aslc index 9931aad8f073..cb17fbe0ff2f 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc @@ -17,9 +17,16 @@ #include "AcpiTables.h" =20 #define RPI_UART_FLOW_CONTROL_NONE 0 + +#ifdef PL011_ENABLE +#define RPI_UART_INTERFACE_TYPE EFI_ACPI_SERIAL_PORT_CONSOLE_= REDIRECTION_TABLE_INTERFACE_TYPE_ARM_PL011_UART +#define RPI_UART_BASE_ADDRESS BCM2836_PL011_UART_BASE_ADDRE= SS +#define RPI_UART_INTERRUPT BCM2836_PL011_UART_INTERRUPT +#else +#define RPI_UART_INTERFACE_TYPE EFI_ACPI_SERIAL_PORT_CONSOLE_= REDIRECTION_TABLE_INTERFACE_TYPE_BCM2835_UART #define RPI_UART_BASE_ADDRESS BCM2836_MINI_UART_BASE_ADDRESS #define RPI_UART_INTERRUPT BCM2836_MINI_UART_INTERRUPT - +#endif STATIC EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE Spcr =3D { ACPI_HEADER ( EFI_ACPI_5_1_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, @@ -27,7 +34,7 @@ STATIC EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE Spc= r =3D { EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_REVISION ), // UINT8 InterfaceType; - EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERFACE_TYPE_BCM2835_UA= RT, + RPI_UART_INTERFACE_TYPE, // UINT8 Reserved1[3]; { EFI_ACPI_RESERVED_BYTE, diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl b/Platform/Raspb= erryPi/RPi4/AcpiTables/Uart.asl index 15149892f3b0..5b59f2dd3e16 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Uart.asl @@ -108,7 +108,7 @@ Device(BTH0) { Name (RBUF, ResourceTemplate () { - // BT UART: UART0 (PL011) + // BT UART: URT0 (PL011) or URTM (miniUART) UARTSerialBus( 115200, // InitialBaudRate: in BPS , // BitsPerByte: default to 8 bits @@ -133,7 +133,11 @@ Device(BTH0) // no flow control. 16, // ReceiveBufferSize 16, // TransmitBufferSize +#ifdef PL011_ENABLE + "\\_SB.URTM", // ResourceSource: +#else "\\_SB.URT0", // ResourceSource: +#endif // UART bus controller name , // ResourceSourceIndex: assumed to be 0 , // ResourceUsage: assumed to be diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index 1624ebda27d7..ccf5bd5b9ef3 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -38,6 +38,7 @@ [Defines] DEFINE SECURE_BOOT_ENABLE =3D FALSE DEFINE INCLUDE_TFTP_COMMAND =3D FALSE DEFINE DEBUG_PRINT_ERROR_LEVEL =3D 0x8000004F + DEFINE PL011_ENABLE =3D FALSE =20 ##########################################################################= ###### # @@ -116,10 +117,16 @@ [LibraryClasses.common] ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/Ar= mGenericTimerPhyCounterLib.inf =20 +!if $(PL011_ENABLE) =3D=3D TRUE + PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartCloc= kLib.inf + PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf + SerialPortLib|ArmPlatformPkg/Library/PL011SerialPortLib/PL011SerialPortL= ib.inf +!else PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatfor= mHookLibNull.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort= Lib16550.inf +!endif =20 # Cryptographic libraries IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf @@ -229,6 +236,12 @@ [BuildOptions] GCC:*_*_AARCH64_DLINK_FLAGS =3D -Wl,--fix-cortex-a53-843419 GCC:RELEASE_*_*_CC_FLAGS =3D -DMDEPKG_NDEBUG -DNDEBUG =20 +!if $(PL011_ENABLE) =3D=3D TRUE + GCC:*_*_*_CC_FLAGS =3D -DPL011_ENABLE + GCC:*_*_*_ASLPP_FLAGS =3D -DPL011_ENABLE + GCC:*_*_*_ASLCC_FLAGS =3D -DPL011_ENABLE +!endif + [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] GCC:*_*_AARCH64_DLINK_FLAGS =3D -z common-page-size=3D0x10000 =20 @@ -391,6 +404,13 @@ [PcdsFixedAtBuild.common] gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen|0x3ffffff gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr|0x600000000 =20 +!if $(PL011_ENABLE) =3D=3D TRUE + ## PL011 UART + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0xfe201000 + gArmPlatformTokenSpaceGuid.PL011UartInteger|0 + gArmPlatformTokenSpaceGuid.PL011UartFractional|0 + gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000 +!else ## NS16550 compatible UART gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0xfe215040 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE @@ -398,7 +418,10 @@ [PcdsFixedAtBuild.common] gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8 +!endif + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0 =20 # # ARM General Interrupt Controller diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf b/Platform/RaspberryPi/RPi4= /RPi4.fdf index 7a506bd2813b..50fe554ec9ec 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.fdf +++ b/Platform/RaspberryPi/RPi4/RPi4.fdf @@ -51,7 +51,11 @@ [FD.RPI_EFI] # ATF primary boot image # 0x00000000|0x00020000 +!if $(PL011_ENABLE) =3D=3D TRUE +FILE =3D Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31_pl011.= bin +!else FILE =3D Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31_miniua= rt.bin +!endif =20 # # DTB. diff --git a/Platform/RaspberryPi/RPi4/Readme.md b/Platform/RaspberryPi/RPi= 4/Readme.md index 2e37646e043d..acfbfee185b0 100644 --- a/Platform/RaspberryPi/RPi4/Readme.md +++ b/Platform/RaspberryPi/RPi4/Readme.md @@ -18,13 +18,21 @@ following __major__ limitations: =20 - USB is likely to work only in pre-OS phase at this stage (nonstandard EC= AM, missing ACPI tables). -- Serial I/O from the OS may not work at all due to CPU throttling affecti= ng - the miniUART baudrate. +- Serial I/O from the OS may not work due to CPU throttling affecting the + miniUART baudrate. This can be worked around by using the `PL011_ENABLE` + compilation option. =20 # Building =20 Build instructions from the top level edk2-platforms Readme.md apply. =20 +The following additional build options are also available: +- `-D PL011_ENABLE=3D1`: Selects PL011 for the serial console instead of t= he + miniUART (default). This doesn't change the GPIO pinout for the UART but + can be useful if you find that the miniUART baud rate changes when the + OS throttles the CPU. Note that this requires one of `disable-bt.dtbo` or + `miniuart-bt.dtbo` overlays to have been applied (see below). + # Booting the firmware =20 1. Format a uSD card as FAT16 or FAT32 @@ -33,14 +41,31 @@ Build instructions from the top level edk2-platforms Re= adme.md apply. - `bcm2711-rpi-4-b.dtb` - `fixup4.dat` - `start4.elf` + - `overlays/miniuart-bt.dbto` or `overlays/disable-bt.dtbo` (Optional) 4. Create a `config.txt` with the following content: - ``` - arm_64bit=3D1 - enable_uart=3D1 - core_freq=3D250 - enable_gic=3D1 - armstub=3DRPI_EFI.fd - ``` + - For a firmware **without** the `PL011_ENABLE` build option: + ``` + arm_64bit=3D1 + enable_uart=3D1 + core_freq=3D250 + enable_gic=3D1 + armstub=3DRPI_EFI.fd + disable_commandline_tags=3D1 + ``` + - For a firmware **with** the `PL011_ENABLE` build option: + ``` + arm_64bit=3D1 + enable_gic=3D1 + armstub=3DRPI_EFI.fd + disable_commandline_tags=3D1 + device_tree_address=3D0x20000 + device_tree_end=3D0x30000 + device_tree=3Dbcm2711-rpi-4-b.dtb + dtoverlay=3Dminiuart-bt + ``` + The above also requires `miniuart-bt.dbto` to have been copied into an= `overlays/` + directory on the uSD card. Alternatively, you may use `disable-bt` ins= tead of + `miniuart-bt` if you don't require BlueTooth. 5. Insert the uSD card and power up the Pi. =20 # Notes --=20 2.21.0.windows.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 (#52410): https://edk2.groups.io/g/devel/message/52410 Mute This Topic: https://groups.io/mt/68829927/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- From nobody Sun May 5 16:32:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52411+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52411+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576757736; cv=none; d=zohomail.com; s=zohoarc; b=SS/aVfyDZHy/Z+pRjv2z3bPHDccbN/Or6/RvNl6VAIsvuqHuHtKBOPspnzM1Lg/C7OTMjiUXMq7tyuzqDlYitWoK3/8OPzmXJFdubImy8N0/l6PzOsDwM+utBsumJqUHywPErnuOtW30GTb3DphECmeUoZVtFPMaMCM1rG9Kuw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576757736; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=sPHXQWdbECLj688yPeC1KAiZKKaa/7MHgd+RtRarfV0=; b=Paw2k81ctLtfccbm7XHMZLMGscxSVDQXLwBzuuJxbDNXp6pQ0Qw9/IM+U7oxH4OD9Py7j3bpIaFi7K7CAhmxRCkSUDva2XdOM722OkUl3ZY1Owlwe5Z3qnFtE6pZU8YHqgJRXX/2CeWb8+Kg7tgEKzBP+1Vj2zviEV5zwv9eP3s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52411+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576757736798689.6314655207622; Thu, 19 Dec 2019 04:15:36 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8N4HYY1788612xj97CUnfjON; Thu, 19 Dec 2019 04:15:35 -0800 X-Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.groups.io with SMTP id smtpd.web11.8712.1576757696981169077 for ; Thu, 19 Dec 2019 04:14:58 -0800 X-Received: by mail-wm1-f65.google.com with SMTP id u2so5380073wmc.3 for ; Thu, 19 Dec 2019 04:14:56 -0800 (PST) X-Gm-Message-State: pgrsBHQgXyaQySugsgdW29EEx1787277AA= X-Google-Smtp-Source: APXvYqzFb7esH4KRiCPNWMvAnumF72zyahz1o7VsDTubE0uoOiiUYLL0KNQJM0rhdDGDoxfb/3bh3Q== X-Received: by 2002:a05:600c:2301:: with SMTP id 1mr10160969wmo.147.1576757695294; Thu, 19 Dec 2019 04:14:55 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id u8sm5823147wmm.15.2019.12.19.04.14.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 04:14:54 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 6/7] Platform/RPi4: Add XHCI ACPI table Date: Thu, 19 Dec 2019 12:14:33 +0000 Message-Id: <20191219121434.2856-7-pete@akeo.ie> In-Reply-To: <20191219121434.2856-1-pete@akeo.ie> References: <20191219121434.2856-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576757735; bh=nGW3hMRIblO8cZP3C4qgvX0SdDi/vI+TdHdLEIZJiZQ=; h=Cc:Date:From:Reply-To:Subject:To; b=smzue4qlx3X9NW+0qOfRqlmw+ZNM9S2SDJeiegr3jBdmPnWuD+5q3/ZhhhtZQ9vezWe wL67+poqTdf1b8dlXs/PgwEFiVeE7ZREdxBxE63R+ZvdhZyuVGC0vp5/z2WZQEAULz/al WpTFXPPSgWQjPR+SWDLYevyu5b5oa7kjPqQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Andrei Warkentin Since the RPi4 PCIe host bridge is not ECAM compliant, we can not expose it as a host bridge to the OS via ACPI. However, given the hardwired nature of this platform, we can expose the xHCI controller that is guaranteed to live at the base of the MMIO32 BAR window as a platform device directly. It should be noted that the xHCI table is not finalized at this stage, as Windows xHCI support is still a major question mark. Signed-off-by: Pete Batard Reviewed-by: Ard Biesheuvel --- Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 3 + Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl | 1 + Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl | 137 ++++++++++++++++= ++++ 3 files changed, 141 insertions(+) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf b/Platform= /RaspberryPi/RPi4/AcpiTables/AcpiTables.inf index dcbf8d36082c..5ce4c0b52b32 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf +++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf @@ -39,6 +39,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Silicon/Broadcom/Bcm27xx/Bcm27xx.dec Silicon/Broadcom/Bcm283x/Bcm283x.dec =20 [FixedPcd] @@ -48,6 +49,8 @@ [FixedPcd] gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdGicDistributorBase + gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr + gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl b/Platform/Raspb= erryPi/RPi4/AcpiTables/Dsdt.asl index 42e650a3ef29..b2f1d3439211 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl @@ -22,6 +22,7 @@ DefinitionBlock ("Dsdt.aml", "DSDT", 5, "MSFT", "EDK2", 2) { include ("Sdhc.asl") include ("Pep.asl") + include ("Xhci.asl") =20 Device (CPU0) { diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl b/Platform/Raspb= erryPi/RPi4/AcpiTables/Xhci.asl new file mode 100644 index 000000000000..e1fd501ab895 --- /dev/null +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl @@ -0,0 +1,137 @@ +/** @file + * + * Copyright (c) 2019 Linaro, Limited. All rights reserved. + * Copyright (c) 2019 Andrei Warkentin + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include + +/* + * The following can be used to remove parenthesis from + * defined macros that the compiler complains about. + */ +#define ISOLATE_ARGS(...) __VA_ARGS__ +#define REMOVE_PARENTHESES(x) ISOLATE_ARGS x + +#define SANITIZED_PCIE_CPU_MMIO_WINDOW REMOVE_PARENTHESES(PCIE_CPU_MMIO_W= INDOW) +#define SANITIZED_PCIE_REG_BASE REMOVE_PARENTHESES(PCIE_REG_BASE) + +/* + * According to UEFI boot log for the VLI device on Pi 4. + */ +#define XHCI_REG_LENGTH 0x1000 + +Device (SCB0) { + Name (_HID, "ACPI0004") + Name (_UID, 0x0) + Name (_CCA, 0x0) + + Method (_CRS, 0, Serialized) { // _CRS: Current Resource Settings + /* + * Container devices with _DMA must have _CRS, meaning SCB0 + * to provide all resources that XHC0 consumes (except + * interrupts). + */ + Name (RBUF, ResourceTemplate () { + QWordMemory (ResourceProducer, + , + MinFixed, + MaxFixed, + NonCacheable, + ReadWrite, + 0x0, + SANITIZED_PCIE_CPU_MMIO_WINDOW, // MIN + SANITIZED_PCIE_CPU_MMIO_WINDOW, // MAX + 0x0, + 0x1, // LEN + , + , + MMIO + ) + }) + CreateQwordField (RBUF, MMIO._MAX, MMBE) + CreateQwordField (RBUF, MMIO._LEN, MMLE) + Add (MMBE, XHCI_REG_LENGTH - 1, MMBE) + Add (MMLE, XHCI_REG_LENGTH - 1, MMLE) + Return (RBUF) + } + + Name (_DMA, ResourceTemplate() { + /* + * XHC0 is limited to DMA to first 3GB. Note this + * only applies to PCIe, not GENET or other devices + * next to the A72. + */ + QWordMemory (ResourceConsumer, + , + MinFixed, + MaxFixed, + NonCacheable, + ReadWrite, + 0x0, + 0x0, // MIN + 0xbfffffff, // MAX + 0x0, // TRA + 0xc0000000, // LEN + , + , + ) + }) + + Device (XHC0) + { + Name (_HID, "11063483") // _HID: Hardware ID + Name (_CID, "PNP0D10") // _CID: Hardware ID + Name (_UID, 0x0) // _UID: Unique ID + Name (_CCA, 0x0) // _CCA: Cache Coherency Attribute + + Method (_CRS, 0, Serialized) { // _CRS: Current Resource Settings + Name (RBUF, ResourceTemplate () { + QWordMemory (ResourceConsumer, + , + MinFixed, + MaxFixed, + NonCacheable, + ReadWrite, + 0x0, + SANITIZED_PCIE_CPU_MMIO_WINDOW, // MIN + SANITIZED_PCIE_CPU_MMIO_WINDOW, // MAX + 0x0, + 0x1, // LEN + , + , + MMIO + ) + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive,= ,, ) { + 175 + } + }) + CreateQwordField (RBUF, MMIO._MAX, MMBE) + CreateQwordField (RBUF, MMIO._LEN, MMLE) + Add (MMBE, XHCI_REG_LENGTH - 1, MMBE) + Add (MMLE, XHCI_REG_LENGTH - 1, MMLE) + Return (RBUF) + } + + Method (_INI, 0, Serialized) { + OperationRegion (PCFG, SystemMemory, SANITIZED_PCIE_REG_BASE += PCIE_EXT_CFG_DATA, 0x1000) + Field (PCFG, AnyAcc, NoLock, Preserve) { + Offset (0), + VNID, 16, // Vendor ID + DVID, 16, // Device ID + CMND, 16, // Command register + STAT, 16, // Status register + } + + // Set command register to: + // 1) decode MMIO (set bit 1) + // 2) enable DMA (set bit 2) + // 3) enable interrupts (clear bit 10) + Debug =3D "xHCI enable" + Store (0x6, CMND) + } + } +} --=20 2.21.0.windows.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 (#52411): https://edk2.groups.io/g/devel/message/52411 Mute This Topic: https://groups.io/mt/68829928/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- From nobody Sun May 5 16:32:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52412+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52412+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576757736; cv=none; d=zohomail.com; s=zohoarc; b=GK+sT9lpnn2RJwMl2oWSVWCs9OWSKkeDiliHrkHGZ28jbiei5C4wYiUz1JippeZvjwWfBsSQVT6+pXZzy1Su5D92Pbn8oQ1NtpY8Qy6OXkSt5bzpMQp8GsnjsYgcHuNIikL8DCUUCVrYWxBqhktnQ8r4fc+9TukNlK1Kvto/R9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576757736; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=vSTQjNOafXDUX97FnBx8VKewkpWojttI22FsQRN0gko=; b=lPa9gb5yphGfY3xipty/x/c6RySgI2l1VWunjfxpu957czY0fhuP+SWGGjlh/3+E/b/tz5AP9So3M86s6UjoJmtXn9IgBKnAAPP49pVnZvchlRUoXRJLyLxCsjZXRFdAFPfZcJuG4a415wWk6MBB5mf1XSGtUqW+VIIXXM/H/P4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52412+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576757736326149.9242607875899; Thu, 19 Dec 2019 04:15:36 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id kSk1YY1788612xsMquVqIq7I; Thu, 19 Dec 2019 04:15:35 -0800 X-Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mx.groups.io with SMTP id smtpd.web10.8830.1576757698340192908 for ; Thu, 19 Dec 2019 04:15:00 -0800 X-Received: by mail-wr1-f50.google.com with SMTP id y11so5748802wrt.6 for ; Thu, 19 Dec 2019 04:14:58 -0800 (PST) X-Gm-Message-State: fx4H4zLEgghbx3OmcPtZct7vx1787277AA= X-Google-Smtp-Source: APXvYqzGvjfmVs0t60bamnaL/MH4k8947eirK0xmsSW9f6DQR+HdJ8YzEgZrrO5MFzwHUsErOun/eg== X-Received: by 2002:adf:ec83:: with SMTP id z3mr8951075wrn.133.1576757696639; Thu, 19 Dec 2019 04:14:56 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id u8sm5823147wmm.15.2019.12.19.04.14.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2019 04:14:56 -0800 (PST) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org, philmd@redhat.com Subject: [edk2-devel] [edk2-platforms][PATCH v2 7/7] Platform/RPi4: Add ACPI basic mode build option Date: Thu, 19 Dec 2019 12:14:34 +0000 Message-Id: <20191219121434.2856-8-pete@akeo.ie> In-Reply-To: <20191219121434.2856-1-pete@akeo.ie> References: <20191219121434.2856-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576757735; bh=Zzx7J/bZL24fp9qhEVWOI6/svOifXwhxiuiipdy8IR0=; h=Cc:Date:From:Reply-To:Subject:To; b=ovO1jAtidGgXmOsNqhNZZb518DGZDE5m0H6qHmo/pt2QDPMu8/Gse+k/9DjF4OyzhOp LjWAt2/tPS87DwqJ+oTTrF+CFr+1/fiS0gHi4TBxwexoWly5rPWyKIKj7o2zB6oNkm3qW bwDwbaPJBcknVYv/RWy+Eo9QkSbwiZHzRqg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel Add an ACPI_BASIC_MODE_ENABLE flag to produces builds intended to run in ACPI mode without any additional requirements (memory limits, acpi=3Dforce, etc). This flag is disabled by default. Signed-off-by: Pete Batard Reviewed-by: Leif Lindholm Reviewed-by: Ard Biesheuvel --- Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf | 3 +++ Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c | 8 ++++++++ Platform/RaspberryPi/RPi4/RPi4.dsc | 6 ++++++ Platform/RaspberryPi/RPi4/RPi4.fdf | 3 +++ Platform/RaspberryPi/RPi4/Readme.md | 9 +++++++-- Platform/RaspberryPi/RaspberryPi.dec | 3 +++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf b/Pla= tform/RaspberryPi/Library/PlatformLib/PlatformLib.inf index 77cdbe399a06..9abcc2cc0075 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf +++ b/Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf @@ -59,5 +59,8 @@ [FixedPcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize =20 +[FeaturePcd] + gRaspberryPiTokenSpaceGuid.PcdAcpiBasicMode + [Ppis] gArmMpCoreInfoPpiGuid diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c b/Pl= atform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c index f8223d1b94e8..4b388465cdde 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c +++ b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c @@ -155,6 +155,14 @@ ArmPlatformGetVirtualMemoryMap ( VirtualMemoryInfo[Index].Type =3D RPI_MEM_UNMAPPED_REGION; VirtualMemoryInfo[Index++].Name =3D L"SoC Reserved (283x)"; =20 + if (FeaturePcdGet (PcdAcpiBasicMode)) { + // + // Limit the memory to 3 GB to work around the DMA bugs in the SoC wit= hout + // having to rely on IORT or _DMA descriptions. + // + SystemMemorySize =3D MIN(SystemMemorySize, 3U * SIZE_1GB); + } + // If we have RAM above the 1 GB mark, declare it if (SystemMemorySize - SIZE_1GB > 0) { VirtualMemoryTable[Index].PhysicalBase =3D FixedPcdGet64 (PcdExtended= MemoryBase); diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index ccf5bd5b9ef3..02de104df5bf 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -39,6 +39,7 @@ [Defines] DEFINE INCLUDE_TFTP_COMMAND =3D FALSE DEFINE DEBUG_PRINT_ERROR_LEVEL =3D 0x8000004F DEFINE PL011_ENABLE =3D FALSE + DEFINE ACPI_BASIC_MODE_ENABLE =3D FALSE =20 ##########################################################################= ###### # @@ -263,6 +264,8 @@ [PcdsFeatureFlag.common] gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE =20 + gRaspberryPiTokenSpaceGuid.PcdAcpiBasicMode|$(ACPI_BASIC_MODE_ENABLE) + [PcdsFixedAtBuild.common] gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000 gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000 @@ -558,12 +561,15 @@ [Components.common] MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf MdeModulePkg/Universal/SerialDxe/SerialDxe.inf Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf + EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf =20 MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf =20 ArmPkg/Drivers/ArmGic/ArmGicDxe.inf Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf +!if $(ACPI_BASIC_MODE_ENABLE) =3D=3D FALSE Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf +!endif Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf ArmPkg/Drivers/TimerDxe/TimerDxe.inf MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf b/Platform/RaspberryPi/RPi4= /RPi4.fdf index 50fe554ec9ec..2bcfdb3244f6 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.fdf +++ b/Platform/RaspberryPi/RPi4/RPi4.fdf @@ -208,10 +208,13 @@ [FV.FvMain] INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf INF Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf + INF EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf =20 INF ArmPkg/Drivers/ArmGic/ArmGicDxe.inf INF Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf +!if $(ACPI_BASIC_MODE_ENABLE) =3D=3D FALSE INF Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf +!endif INF Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf diff --git a/Platform/RaspberryPi/RPi4/Readme.md b/Platform/RaspberryPi/RPi= 4/Readme.md index acfbfee185b0..74afc0f89451 100644 --- a/Platform/RaspberryPi/RPi4/Readme.md +++ b/Platform/RaspberryPi/RPi4/Readme.md @@ -16,8 +16,9 @@ Raspberry Pi is a trademark of the [Raspberry Pi Foundati= on](https://www.raspber This firmware is still in development stage, meaning that it comes with the following __major__ limitations: =20 -- USB is likely to work only in pre-OS phase at this stage (nonstandard EC= AM, - missing ACPI tables). +- USB may only work in pre-OS phase at this stage due to nonstandard ECAM, + missing/incomplete ACPI tables as well as other factors. For Linux, using + the `ACPI_BASIC_MODE_ENABLE` build option may help. - Serial I/O from the OS may not work due to CPU throttling affecting the miniUART baudrate. This can be worked around by using the `PL011_ENABLE` compilation option. @@ -27,6 +28,10 @@ following __major__ limitations: Build instructions from the top level edk2-platforms Readme.md apply. =20 The following additional build options are also available: +- `-D ACPI_BASIC_MODE_ENABLE=3D1`: Limits OS visible memory to 3 GB and fo= rces + ACPI (by disabling the Device Tree driver altogether). This may be requi= red + to boot Operating Systems such as Linux on account of the current PCIe/x= HCI + limitations. - `-D PL011_ENABLE=3D1`: Selects PL011 for the serial console instead of t= he miniUART (default). This doesn't change the GPIO pinout for the UART but can be useful if you find that the miniUART baud rate changes when the diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/Ra= spberryPi.dec index c7e17350544a..bc378ffbfb8d 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -57,3 +57,6 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, Pc= dsDynamicEx] gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|0|UINT32|0x00000016 gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes|0|UINT8|0x000000= 17 gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|0|UINT32|0x00000018 + +[PcdsFeatureFlag.common] + gRaspberryPiTokenSpaceGuid.PcdAcpiBasicMode|FALSE|BOOLEAN|0x00000019 --=20 2.21.0.windows.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 (#52412): https://edk2.groups.io/g/devel/message/52412 Mute This Topic: https://groups.io/mt/68829929/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-