From nobody Thu May 2 10:52:08 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+52343+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+52343+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576669333; cv=none; d=zohomail.com; s=zohoarc; b=MNfcdxcAyccmAfr/Gwm/Zv57AXi83JJi+rjt5U4eQL5mK5ST24IaUPH/A3oQCxKaiEllXZ5TVmWYUgjbPQfhFE/o8iQqzrUO3kJSen99QBzCte6gpFS1z+CgIfmYzG9OjggX6s/RcobtVzAtrbM4680uV2Coe0b6reUcJePQNzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576669333; 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=iBRLB+HbzEA3zGVkQo0TS7qaDOGGsg3Hxa0X5peshZ4=; b=OoV7B4Z5sA8GkmFbXsXPgcR1tLHcofi4NFgaqoLNd2HJzIOpPGyXrsd8mi+CGU5+uzyHOp3MB+p1iawJn4Yic0osFMh2kQ6XXK2qDHMs5mkfVt7R7azZsW/WXgJL0GWEvnZ0GB2ogesPxRI+G82hMnNI/z+zwcesYvVBS7HJTts= 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+52343+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576669333397118.25709103338215; Wed, 18 Dec 2019 03:42:13 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id i1jvYY1788612xpuCA7hGMvD; Wed, 18 Dec 2019 03:42:12 -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.web11.9462.1576669332063399018 for ; Wed, 18 Dec 2019 03:42:12 -0800 X-Received: by mail-wr1-f68.google.com with SMTP id z7so1888948wrl.13 for ; Wed, 18 Dec 2019 03:42:11 -0800 (PST) X-Gm-Message-State: ZheJNeiga2QuaDENLPE3I9Qjx1787277AA= X-Google-Smtp-Source: APXvYqyq9kpZvoojn1JGdhmiV8O5JWBPihORzQ/dqPSlLMPd2pARso7uZ7VghdGgWytvEjAsGGO6qA== X-Received: by 2002:adf:ef4e:: with SMTP id c14mr2439209wrp.142.1576669330163; Wed, 18 Dec 2019 03:42:10 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id i8sm2298168wro.47.2019.12.18.03.42.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Dec 2019 03:42:09 -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 1/6] Platform/RPi4: Clean up ACPI definitions Date: Wed, 18 Dec 2019 11:41:51 +0000 Message-Id: <20191218114156.9036-2-pete@akeo.ie> In-Reply-To: <20191218114156.9036-1-pete@akeo.ie> References: <20191218114156.9036-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=1576669332; bh=CXybtzPOIx44DI02aSfmZOhIla/LJr9WhJPbFovWS/g=; h=Cc:Date:From:Reply-To:Subject:To; b=ZmkkgomT9JtbO4tZvZ7HfnoU1W/1CKiX5oGNd+nIgP586sRSkGRUcbKqGfUq+gAAMeX hDofjNIiL0BmUYqs7FCzVWqzHsYiQUbYjykRx4K2hSFWtHQnPh1djK1JSzG3X5buP12wx 1x/TXeKGSZAY6Y9uHjpdwHqlS8ixrIe9ItU= 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 --- 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 (#52343): https://edk2.groups.io/g/devel/message/52343 Mute This Topic: https://groups.io/mt/68791810/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 Thu May 2 10:52:08 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+52344+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+52344+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576669334; cv=none; d=zohomail.com; s=zohoarc; b=Ti9rzy/z5Olv1j/B+GLEeKDbIP3WFa5hAX38diHEMsABzHCD8tdr4YElywbo26V4SlBbS/xnYU/lWIh+6H+6xjG11JeRZaoopt74GoZqKc+EndMN2+dJSNwL/FGY3/QLaevm6899sPjCy54Z0YcVSd1GO4t7NP9AExY2D9EtKYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576669334; 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=2UQjBfCCw7b1lE4TaU5bnjYJY1MRQT/gDDLGKlJinVI=; b=D4+itQzrnVTEaYCPeOiiirBTRKveKFEKF8y8X5ZTZXHEyX1P3pFqWzcv05aeSdh1sFEnf1txyI2nGoXhnSDndwhS1LFXm2agaeHHpmFMEFrGKuCsZPJ7+nMa85vas/e7Pl3AFM0pyJsrgKHPnuf0oq+Mtpnk7vFPlivcIELeKjk= 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+52344+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576669334463966.5572762561367; Wed, 18 Dec 2019 03:42:14 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id mpkVYY1788612xccT0xJPdKM; Wed, 18 Dec 2019 03:42:14 -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.web12.9463.1576669333197712511 for ; Wed, 18 Dec 2019 03:42:13 -0800 X-Received: by mail-wm1-f65.google.com with SMTP id p17so1547364wmb.0 for ; Wed, 18 Dec 2019 03:42:12 -0800 (PST) X-Gm-Message-State: ccWp0MzENHosWI1qK4tgFMEtx1787277AA= X-Google-Smtp-Source: APXvYqxtF2JkGL3n1HD+UpwTjy6fAt8TXmtYJT3MU44VniXqNirPyb/DRPPkZUuDS8LUWR82c35CkA== X-Received: by 2002:a1c:2e91:: with SMTP id u139mr2653257wmu.154.1576669331460; Wed, 18 Dec 2019 03:42:11 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id i8sm2298168wro.47.2019.12.18.03.42.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Dec 2019 03:42:10 -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 2/6] Platform/RPi4: Improve FADT ACPI table generation Date: Wed, 18 Dec 2019 11:41:52 +0000 Message-Id: <20191218114156.9036-3-pete@akeo.ie> In-Reply-To: <20191218114156.9036-1-pete@akeo.ie> References: <20191218114156.9036-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=1576669334; bh=sHj6DI/DqJV3kmfoeB0CtswYi+XUbJa95oiZ8r4colc=; h=Cc:Date:From:Reply-To:Subject:To; b=epBXdCo6TCDmVu7UqYw1v4zbXXyBnBlEoWvUOKSSXE9qstzxLQnOV/MLuTn34eqd/i3 wldIEq3aHoBn8VTWc6ybZC1uISUFAbE3jji2DwZQGvaPrtdMeOkTTD7SbRqIfjc4U/pFh 3g5sXuC/U1w/LFtps1IUfS90p6sYUasM7OU= 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 --- Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc | 104 ++++++++++++++------ 1 file changed, 76 insertions(+), 28 deletions(-) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Fadt.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Fadt.aslc index 3ef877fde5f4..2d851794b989 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,81 @@ * **/ =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" + +#define RPI_DSDT_BASE_ADDRESS 0x33CD0000 +#define RPI_PM_TIMER_BLOCK_LEN 0x04 +#define RPI_CST_VALUE 0xE3 + +/* + * 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 + RPI_DSDT_BASE_ADDRESS, = // 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 + RPI_PM_TIMER_BLOCK_LEN, = // UINT8 PmTmrLen + 0, = // UINT8 Gpe0BlkLen + 0, = // UINT8 Gpe1BlkLen + 0, = // UINT8 Gpe1Base + RPI_CST_VALUE, = // 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_5_1_VGA_NOT_PRESENT | EFI_ACPI_5_1_MSI_NOT_SUPPORTED | = // UINT16 IaPcBootArch + EFI_ACPI_5_1_PCIE_ASPM_CONTROLS | EFI_ACPI_5_1_CMOS_RTC_NOT_PRESENT, + 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 + RPI_DSDT_BASE_ADDRESS, = // 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 (#52344): https://edk2.groups.io/g/devel/message/52344 Mute This Topic: https://groups.io/mt/68791811/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 Thu May 2 10:52:08 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+52345+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+52345+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576669336; cv=none; d=zohomail.com; s=zohoarc; b=MdK1qvnQxLt7WrHH1uemn1TuOc0Ib6T0rD2I07Q4XhoN/+jJwWEeR50C/3d84xM1lYq7XwnNeN0sSDJJlf9ReRxbG9VmTzKx454VQFjJnFsv//wcn1zu9MiSI2YfDh4Wc6Pv2Tm1Hscm1ZO9rXJmQVEctyJ0WJd8Xa9sfln1bCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576669336; 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=CICtD5J8zy2JYcfkeyqGnsa2oWsY+B+/QyUQjW5Igso=; b=eIds1hVmJ4bjZZpM5QTcCofZ44S9ILudh6nSXoEMCxVvDzQUBMc428Lwa3skrhThu8GwUwSFBcXxMqAAd1WJr7aZiro2NCKE1/P4etl9QQs+79fEDp9AXhPQycmk0R6XPGwVuFk/g264kjYrho+xlc5Pz1FszkZRV381IITScBY= 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+52345+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576669336922929.8955642344234; Wed, 18 Dec 2019 03:42:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5TuaYY1788612xlrCQC6xA1w; Wed, 18 Dec 2019 03:42:15 -0800 X-Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by mx.groups.io with SMTP id smtpd.web10.9254.1576669334899260061 for ; Wed, 18 Dec 2019 03:42:15 -0800 X-Received: by mail-wm1-f68.google.com with SMTP id f129so1538326wmf.2 for ; Wed, 18 Dec 2019 03:42:14 -0800 (PST) X-Gm-Message-State: McW58V81tiPRkSLC9sKyt0Aex1787277AA= X-Google-Smtp-Source: APXvYqwUp8DSkWJMkp6OJo4LfbNes6WuZqJX1g7I3yetW3EF1jJvY1CK8JqVfSv4QaRB0Anuj780BQ== X-Received: by 2002:a1c:7f94:: with SMTP id a142mr2710529wmd.33.1576669333034; Wed, 18 Dec 2019 03:42:13 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id i8sm2298168wro.47.2019.12.18.03.42.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Dec 2019 03:42:12 -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 3/6] Platform/RPi4: Improve SPCR and DBG2 ACPI table generation Date: Wed, 18 Dec 2019 11:41:53 +0000 Message-Id: <20191218114156.9036-4-pete@akeo.ie> In-Reply-To: <20191218114156.9036-1-pete@akeo.ie> References: <20191218114156.9036-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=1576669335; bh=W/EQssYqIH3TjriUV1a/2CNXIX6ySIemxwM0gxMv/NI=; h=Cc:Date:From:Reply-To:Subject:To; b=HDdOS2bi6LJ01peNhfQMnLRvWwSXwX8G6BY+XXfSRmtt31E4AWBdR6/NUSulwObgj6f kT1WidsH370mKsnalpKJz6LXRomIZxu8gDlwXXrzT1tqA7q7+N8Y7D0b3OAwZlwMfxqKi nK38KQN4udjzc1Bc+y0596PoYnONTiFyL+M= 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 --- Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 4 +- Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc | 100 ++++++++++++++++= +--- Platform/RaspberryPi/RPi4/AcpiTables/Spcr.asl | 48 ---------- Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc | 94 ++++++++++++++++= ++ 4 files changed, 183 insertions(+), 63 deletions(-) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf b/Platform= /RaspberryPi/RPi4/AcpiTables/AcpiTables.inf index 50c9f7694d84..6b1155d66444 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 @@ -47,4 +47,6 @@ [FixedPcd] gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdGicDistributorBase + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Dbg2.aslc index 849cf5134793..589a5c2cbd71 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc @@ -2,27 +2,99 @@ * * 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 "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 + +// +// When using the miniUART, PcdSerialRegisterBase points to the 8250 base = address, +// which is offset by 0x40 from the actual Bcm2835 base address +// +#define RPI_UART_BASE_ADDRESS (FixedPcdGet64 (Pc= dSerialRegisterBase) - 0x40) +#define RPI_UART_LENGTH 0x70 +// +// 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, + EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART, + 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..65f48ceae688 --- /dev/null +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc @@ -0,0 +1,94 @@ +/** @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 "AcpiTables.h" + + +#define RPI_UART_FLOW_CONTROL_NONE 0 + +// +// When using the miniUART, PcdSerialRegisterBase points to the 8250 base = address, +// which is offset by 0x40 from the actual Bcm2835 base address +// +#define RPI_UART_BASE_ADDRESS (FixedPcdGet64 (PcdSerialRegi= sterBase) - 0x40) +#define RPI_UART_INTERRUPT 0x7D + +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 (#52345): https://edk2.groups.io/g/devel/message/52345 Mute This Topic: https://groups.io/mt/68791813/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 Thu May 2 10:52:08 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+52346+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+52346+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576669339; cv=none; d=zohomail.com; s=zohoarc; b=j8ps5/h5IPP6HHrOnvE4mxnKAjpmz0mN0sEsfTiA5aqLg9gbf6N138lYugGQg4t+gPD5auzd7c0PUl1EiArVZqeGM6KNNGIuMHv+V2OwIvaM1i3qPRSHoEniWqqWQ1qlsrisPqtw77opacKsDhJPQ2bkBBBzG3ktH+9zQRAkhIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576669339; 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=LxGOCyUFD3L07fCNe9Y7xAiGNnorW6xsVeLQrlPPnsA=; b=I+VS10T9Wk+rqVGG0j1Fnp6TniZOXvxyA+y0BaVNDKdh/nu6s/QLGOeHj2q+bLtohnqE6ZKEPt3VC0LbbSqMpPNqoYro+0l7BAGE9RDTfa9ZYQmiqknL8pOwndU/NhNJoWTf0w7PAc2GPGE/h/oHeYwbP8ka87gFaCLT9W0ujts= 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+52346+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157666933912328.46576639193745; Wed, 18 Dec 2019 03:42:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id d5NLYY1788612xCVO46p82yD; Wed, 18 Dec 2019 03:42:17 -0800 X-Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web11.9465.1576669337091206192 for ; Wed, 18 Dec 2019 03:42:17 -0800 X-Received: by mail-wm1-f67.google.com with SMTP id t14so1528040wmi.5 for ; Wed, 18 Dec 2019 03:42:16 -0800 (PST) X-Gm-Message-State: ZqDotbCbNuMdg1DRzM3LcWRcx1787277AA= X-Google-Smtp-Source: APXvYqzA8VCi1iLUx+5ZT/nUbRSJP0SZqJye/F7OMTniDuvlqvbDyG8VfyF+MpeiluWoaj0cL8J+jA== X-Received: by 2002:a7b:cb86:: with SMTP id m6mr2718394wmi.51.1576669335159; Wed, 18 Dec 2019 03:42:15 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id i8sm2298168wro.47.2019.12.18.03.42.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Dec 2019 03:42:14 -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 4/6] Platform/RPi4: Add switch to select between PL011 and miniUART Date: Wed, 18 Dec 2019 11:41:54 +0000 Message-Id: <20191218114156.9036-5-pete@akeo.ie> In-Reply-To: <20191218114156.9036-1-pete@akeo.ie> References: <20191218114156.9036-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=1576669337; bh=ENF0FzOkakVupWjVMECI5+qHvYUq23z4W8/rgFB3AMk=; h=Cc:Date:From:Reply-To:Subject:To; b=RwN19fsziyoZ/VI03sIh7a7wIDpk1wAPauf1qoHYrOKREsyWGkbtzUc2VYugGMzBtA6 TT5TurY+9G5NH5FnjbZaKJsznxaY6p8WMJT2m1lIGw7NvgQTs8nCi0kMJbumZtauWDP95 lwivJ8GMg/uBOUO3Fcb8RAI1yXIE3yecLW0= 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 --- Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc | 10 +++++ Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc | 9 +++- 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, 84 insertions(+), 11 deletions(-) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Dbg2.aslc index 589a5c2cbd71..e408eb02d027 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc @@ -22,6 +22,11 @@ #define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS 1 #define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE 10 =20 +#ifdef PL011_ENABLE +#define RPI_UART_BASE_ADDRESS FixedPcdGet64 (Pcd= SerialRegisterBase) +#define RPI_UART_LENGTH 0x1000 +#define RPI_UART_STR { '\\', '_', 'S', = 'B', '.', 'U', 'R', 'T', '0', 0x00 } +#else // // When using the miniUART, PcdSerialRegisterBase points to the 8250 base = address, // which is offset by 0x40 from the actual Bcm2835 base address @@ -32,6 +37,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; @@ -83,7 +89,11 @@ STATIC DBG2_TABLE Dbg2 =3D { */ DBG2_DEBUG_PORT_DDI ( RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS, +#ifdef PL011_ENABLE + EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART, +#else EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART, +#endif RPI_UART_BASE_ADDRESS, RPI_UART_LENGTH, RPI_UART_STR diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Spcr.aslc index 65f48ceae688..e5c10c923626 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc @@ -18,12 +18,19 @@ =20 #define RPI_UART_FLOW_CONTROL_NONE 0 =20 +#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 FixedPcdGet64 (PcdSerialRegis= terBase) +#define RPI_UART_INTERRUPT 0x99 +#else +#define RPI_UART_INTERFACE_TYPE EFI_ACPI_SERIAL_PORT_CONSOLE_= REDIRECTION_TABLE_INTERFACE_TYPE_BCM2835_UART // // When using the miniUART, PcdSerialRegisterBase points to the 8250 base = address, // which is offset by 0x40 from the actual Bcm2835 base address // #define RPI_UART_BASE_ADDRESS (FixedPcdGet64 (PcdSerialRegi= sterBase) - 0x40) #define RPI_UART_INTERRUPT 0x7D +#endif =20 STATIC EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE Spcr =3D { ACPI_HEADER ( @@ -32,7 +39,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..2ef38d1b2062 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 abobe 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 (#52346): https://edk2.groups.io/g/devel/message/52346 Mute This Topic: https://groups.io/mt/68791814/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 Thu May 2 10:52:08 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+52347+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+52347+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576669340; cv=none; d=zohomail.com; s=zohoarc; b=k15WZnNQcpeCmiKNDUvTV2gTsiiPdKG33HPwFOdHZr+a78IIAOUowXc4j6pW0xAK4FvuO5zzaKM+F718xeZ5wxNc2JR0PqAUCnFbBZqmafYjnZElcjdjNGXl0Di9RLJjlRqhl9CJMOAC0mzu+wHmEXm/cSXNeBzKdE0RnTE6d4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576669340; 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=yfHOpdPvd8alyll/RKpSpzDQuZikg02zOoab36pftb0=; b=Cult9hC4M4Qzm/gm78KCTYn5546GMdcYqgTdYmYQkFxeL16u5c+D6lRhE3HkBEts/n4SOhlHRduVDxVYtQzFBYSncOUWGqLLDMc5/vDCirO5pRbkS79PFZrj9S/+US1t1BhAzqVcxQ6H89HjRBCUZUsuSSvhVrK3/7l4S7lz0hs= 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+52347+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576669340871887.3427594154671; Wed, 18 Dec 2019 03:42:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id la56YY1788612x3eDkINYkHm; Wed, 18 Dec 2019 03:42:19 -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.web09.9337.1576669338984004918 for ; Wed, 18 Dec 2019 03:42:19 -0800 X-Received: by mail-wr1-f68.google.com with SMTP id t2so1957302wrr.1 for ; Wed, 18 Dec 2019 03:42:18 -0800 (PST) X-Gm-Message-State: Nk87MGoBi6YGUbIMzYhGonibx1787277AA= X-Google-Smtp-Source: APXvYqyQzOHuslHiUNiEYQifYbstLa0OHjIqxxvdz7OGlmlPbPaVOlc2YRU4WarC9XyPdOHdqkyJGA== X-Received: by 2002:adf:ffc5:: with SMTP id x5mr2418184wrs.92.1576669337098; Wed, 18 Dec 2019 03:42:17 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id i8sm2298168wro.47.2019.12.18.03.42.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Dec 2019 03:42:16 -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 5/6] Platform/RPi4: Add XHCI and MCFG ACPI tables Date: Wed, 18 Dec 2019 11:41:55 +0000 Message-Id: <20191218114156.9036-6-pete@akeo.ie> In-Reply-To: <20191218114156.9036-1-pete@akeo.ie> References: <20191218114156.9036-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=1576669339; bh=yy27Ebmte+wu6Dqx4aAvQ9KcNSgu4Z5uUTPpElzqIwo=; h=Cc:Date:From:Reply-To:Subject:To; b=f8UkUo6lTNW5Qkfq6eVDg6YXiKjqJ1lqRZtjqG1yPmUAcqllXxkVpCl3bB6DEbn+BO/ VNzOh1U72f57R/29xzsKAlvMJLTblDV8uS2Ec8BnAGMHVyd9aNORSx8Wu+sJyOdyhm0By iGM1BspqT9+S9ShRUStS0buN+uwQ4MgQ4jA= 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 cannot expose it as a host bridge to the OS via ACPI, so we add a dummy MCFG table. 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 --- Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf | 5 + Platform/RaspberryPi/RPi4/AcpiTables/Dsdt.asl | 1 + Platform/RaspberryPi/RPi4/AcpiTables/Mcfg.aslc | 81 +++++++++++ Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl | 140 ++++++++++++++++= ++++ 4 files changed, 227 insertions(+) diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf b/Platform= /RaspberryPi/RPi4/AcpiTables/AcpiTables.inf index 6b1155d66444..69cb43a2f982 100644 --- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf +++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf @@ -29,6 +29,7 @@ [Sources] Fadt.aslc Dbg2.aslc Gtdt.aslc + Mcfg.aslc Dsdt.asl Csrt.aslc Spcr.aslc @@ -39,6 +40,8 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + Silicon/Broadcom/Bcm27xx/Bcm27xx.dec + Silicon/Broadcom/Bcm283x/Bcm283x.dec =20 [FixedPcd] gArmTokenSpaceGuid.PcdArmArchTimerIntrNum @@ -47,6 +50,8 @@ [FixedPcd] gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdGicDistributorBase + gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr + gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase 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/Mcfg.aslc b/Platform/Rasp= berryPi/RPi4/AcpiTables/Mcfg.aslc new file mode 100644 index 000000000000..7315e2a88c91 --- /dev/null +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Mcfg.aslc @@ -0,0 +1,81 @@ +/** @file + * + * Memory Mapped Configuration Address Space table (MCFG) + * + * Copyright (c) 2019, Pete Batard + * Copyright (c) 2013-2015 Intel Corporation. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include +#include + +#include "AcpiTables.h" + +// +// Multiple APIC Description Table +// +#pragma pack (1) + +#define RPI_ACPI_OEM_MCFG_REVISION 0x00000001 +// +// The Pi 4 is not ECAM compliant so, ideally, we would just skip populati= ng +// an allocation structure. However, GenFw throws 'MCFG length check faile= d' +// when the number of allocation structures is zero, so we need at least o= ne. +// +#define RPI_ACPI_ALLOCATION_STRUCTURE_COUNT 1 + +typedef struct { + EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRESS_TABLE_HEADER Header; + EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCAT= ION_STRUCTURE AllocationStructure[RPI_ACPI_ALLOCATION_STRUCTURE_COUNT]; +} EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_DESCRIPTION_TABLE; + +STATIC EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_DESCRIPTION_TABLE= Mcfg =3D +{ + { + //--------------------------------------------------------------------= ---- + // ACPI Table Header + //--------------------------------------------------------------------= ---- + { + EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDR= ESS_DESCRIPTION_TABLE_SIGNATURE, + sizeof (EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_DESCRIPTIO= N_TABLE), + EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION, + 0x00, // Checksum calculated at = runtime. + EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long= field "BC2836" + EFI_ACPI_OEM_TABLE_ID, // OEM table identificatio= n(8 bytes long) "RPI4EDK2" + EFI_ACPI_OEM_REVISION, // OEM revision number + EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID + EFI_ACPI_CREATOR_REVISION // ASL compiler revision n= umber + }, + //--------------------------------------------------------------------= ---- + // Reserved + //--------------------------------------------------------------------= ---- + 0x0000000000000000, // Reserved + }, + + //----------------------------------------------------------------------= -- + // MCFG specific fields + //----------------------------------------------------------------------= -- + { + { + // + // Using (-1) as the base address tells the OS to ignore it. + // + 0xFFFFFFFFFFFFFFFFULL, // BaseAddress + 0x0000, // PciSegmentGroupNumber + 0x00, // StartBusNumber + 0x00, // EndBusNumber + 0x00000000 // Reserved + } + } +}; + +#pragma pack() + +// +// Reference the table being generated to prevent the optimizer from remov= ing +// the data structure from the executable +// +VOID* CONST ReferenceAcpiTable =3D &Mcfg; diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl b/Platform/Raspb= erryPi/RPi4/AcpiTables/Xhci.asl new file mode 100644 index 000000000000..1eaeb7ba451b --- /dev/null +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Xhci.asl @@ -0,0 +1,140 @@ +/** @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 _REMOVE_PAREN(...) __VA_ARGS__ +#define REMOVE_PAREN(x) _REMOVE_PAREN x + +/* + * 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, + 0xAAAA, // MIN + 0xBBBA, // MAX + 0x0, + 0x1111, // LEN + , + , + MMIO + ) + }) + CreateQwordField (RBUF, MMIO._MIN, MMBA) + CreateQwordField (RBUF, MMIO._MAX, MMBE) + CreateQwordField (RBUF, MMIO._LEN, MMLE) + Store (REMOVE_PAREN(PCIE_CPU_MMIO_WINDOW), MMBA) + Store (REMOVE_PAREN(PCIE_CPU_MMIO_WINDOW), MMBE) + Store (XHCI_REG_LENGTH, MMLE) + Add (MMBA, MMLE, MMBE) + 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, + 0xAAAA, // MIN + 0xBBBA, // MAX + 0x0, + 0x1111, // LEN + , + , + MMIO + ) + Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive,= ,, ) { + 175 + } + }) + CreateQwordField (RBUF, MMIO._MIN, MMBA) + CreateQwordField (RBUF, MMIO._MAX, MMBE) + CreateQwordField (RBUF, MMIO._LEN, MMLE) + Store (REMOVE_PAREN(PCIE_CPU_MMIO_WINDOW), MMBA) + Store (REMOVE_PAREN(PCIE_CPU_MMIO_WINDOW), MMBE) + Store (XHCI_REG_LENGTH, MMLE) + Add (MMBA, MMLE, MMBE) + Return (RBUF) + } + + Method (_INI, 0, Serialized) { + OperationRegion (PCFG, SystemMemory, REMOVE_PAREN(PCIE_REG_BAS= E) + 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 (#52347): https://edk2.groups.io/g/devel/message/52347 Mute This Topic: https://groups.io/mt/68791816/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 Thu May 2 10:52:08 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+52348+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+52348+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1576669342; cv=none; d=zohomail.com; s=zohoarc; b=np+QxrCdUkN/eiCn++HEj1K1ZPQB4TTz88cLN5NSV7Mo31cwNhh4qoNJIbq+lV3Gojg/Cwy9cG+Ld0PoLM5xFg/OGYkvzkI0tcT7S6xI4idWVP4vXKly2rRiQ0kxcVEQLHP8whm+spEO8PyVgXFY+ym1t0eRb2p+AW3wyZh/M/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576669342; 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=QI/rCWjWMcM4PzUzroj+ZFcocg8mZITg6DU6B0cLb4s=; b=En1nwD5Ib9Gqq9kegNHFLEi6hXMN9mNfQHDJ14OUO2yffIkRcgdlfxajIxt5jevRVAJsNGLwUvGSQPQvhDrj+h1rp1CLD7C1EFiUxWvpUPsQ+TjI3ocebJaqo0Pl7DQd5t1A8pmEcocDqvw3gkaOolyAWjuM72S0YNanzFhi7eE= 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+52348+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1576669342465169.5710149793415; Wed, 18 Dec 2019 03:42:22 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id rOHOYY1788612xdHkKGku81y; Wed, 18 Dec 2019 03:42:22 -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.9257.1576669341282258009 for ; Wed, 18 Dec 2019 03:42:21 -0800 X-Received: by mail-wr1-f50.google.com with SMTP id c9so1926105wrw.8 for ; Wed, 18 Dec 2019 03:42:21 -0800 (PST) X-Gm-Message-State: nqy7duDjte9biooCnzSo0pD7x1787277AA= X-Google-Smtp-Source: APXvYqzT6VFFYnUMtJO11x6bhfhT0CsFvTXufDHqWWL2fDukK0xK3AZmL3/CKxyBpSuenOetdkxutA== X-Received: by 2002:adf:a285:: with SMTP id s5mr2374232wra.118.1576669338656; Wed, 18 Dec 2019 03:42:18 -0800 (PST) X-Received: from localhost.localdomain ([84.203.77.210]) by smtp.gmail.com with ESMTPSA id i8sm2298168wro.47.2019.12.18.03.42.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Dec 2019 03:42:18 -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 6/6] Platform/RPi4: Add ACPI basic mode build option Date: Wed, 18 Dec 2019 11:41:56 +0000 Message-Id: <20191218114156.9036-7-pete@akeo.ie> In-Reply-To: <20191218114156.9036-1-pete@akeo.ie> References: <20191218114156.9036-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=1576669342; bh=1tcWtILj41sQJbjDCrNp8542FGqTexF9cKZYNWXmFcI=; h=Cc:Date:From:Reply-To:Subject:To; b=Odo8sd1e2k69NYq6XpfAVKR7zw0sP50ptdaZfhTNb2b9DE3UkZu9yk42krExgV0SrIK GZH7tQhe4CXtmTneROZp0rGc2cfIuSdSzKSGja4oAxDnqdFjjKM/Tr6ewAcBOUaDlomGD GQfIuv5f7f6kLHIAbnhhdIYW4O/r8Wo8V7I= 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 --- 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 2ef38d1b2062..83e901c57b08 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 (#52348): https://edk2.groups.io/g/devel/message/52348 Mute This Topic: https://groups.io/mt/68791818/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-