From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.9280.1641102582273272137 for ; Sat, 01 Jan 2022 21:49:42 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: jeremy.linton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DF749113E; Sat, 1 Jan 2022 21:49:41 -0800 (PST) Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E3403F5A1; Sat, 1 Jan 2022 21:49:41 -0800 (PST) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com, awarkentin@vmware.com, Sunny.Wang@arm.com, samer.el-haj-mahmoud@arm.com, mariobalanica02@gmail.com, Jeremy Linton , Ard Biesheuvel Subject: [PATCH V2 03/10] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Date: Sat, 1 Jan 2022 23:49:17 -0600 Message-Id: <20220102054924.1195762-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220102054924.1195762-1-jeremy.linton@arm.com> References: <20220102054924.1195762-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The UEFI firmware uses the GPIO port for the fan and real soon now the runtime SPI variable store. As such we need to be able to either isolate those devices from the OS or we risk clashing with OS's that reconfigure the GPIO pins. Ideally we would just rip this out and use _DSM() or just individual device power on/off methods to adjust the GPIO pins when needed. For now, lets leave it since windows at least knows about it. In the future we will decide whether the firmware is controlling something (SPI!) based on whether the user has enabled the GPIO block. Tested-by: Ard Biesheuvel Signed-off-by: Jeremy Linton --- Platform/RaspberryPi/AcpiTables/AcpiTables.inf | 1 + Platform/RaspberryPi/AcpiTables/Dsdt.asl | 7 - Platform/RaspberryPi/AcpiTables/GpuDevs.asl | 126 ---------------= - Platform/RaspberryPi/AcpiTables/SsdtGpio.asl | 159 +++++++++++++++= ++++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 6 + 5 files changed, 166 insertions(+), 133 deletions(-) create mode 100644 Platform/RaspberryPi/AcpiTables/SsdtGpio.asl diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/Ra= spberryPi/AcpiTables/AcpiTables.inf index da2a6db85f..3894d00565 100644 --- a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf +++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.inf @@ -40,6 +40,7 @@ SsdtThermal.asl Xhci.asl Pci.asl + SsdtGpio.asl =20 [Packages] ArmPkg/ArmPkg.dec diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl b/Platform/Raspberr= yPi/AcpiTables/Dsdt.asl index b594d50bdf..08acc81d57 100644 --- a/Platform/RaspberryPi/AcpiTables/Dsdt.asl +++ b/Platform/RaspberryPi/AcpiTables/Dsdt.asl @@ -21,13 +21,6 @@ =20 #include "AcpiTables.h" =20 -#define BCM_ALT0 0x4 -#define BCM_ALT1 0x5 -#define BCM_ALT2 0x6 -#define BCM_ALT3 0x7 -#define BCM_ALT4 0x3 -#define BCM_ALT5 0x2 - // // The ASL compiler does not support argument arithmetic in functions // like QWordMemory (). So we need to instantiate dummy qword regions diff --git a/Platform/RaspberryPi/AcpiTables/GpuDevs.asl b/Platform/Raspb= erryPi/AcpiTables/GpuDevs.asl index 9750dc25c0..3399f0fc9a 100644 --- a/Platform/RaspberryPi/AcpiTables/GpuDevs.asl +++ b/Platform/RaspberryPi/AcpiTables/GpuDevs.asl @@ -203,56 +203,6 @@ Device (VCSM) } } =20 -// Description: GPIO -Device (GPI0) -{ - Name (_HID, "BCM2845") - Name (_CID, "BCM2845") - Name (_UID, 0x0) - Name (_CCA, 0x0) - Method (_STA) - { - Return(0xf) - } - Name (RBUF, ResourceTemplate () - { - MEMORY32FIXED (ReadWrite, 0, GPIO_LENGTH, RMEM) - Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) - { - BCM2386_GPIO_INTERRUPT0, BCM2386_GPIO_INTERRUPT1, - BCM2386_GPIO_INTERRUPT2, BCM2386_GPIO_INTERRUPT3 - } - }) - Method (_CRS, 0x0, Serialized) - { - MEMORY32SETBASE (RBUF, RMEM, RBAS, GPIO_OFFSET) - Return (^RBUF) - } -} - -// Description: I2C -Device (I2C1) -{ - Name (_HID, "BCM2841") - Name (_CID, "BCM2841") - Name (_UID, 0x1) - Name (_CCA, 0x0) - Method (_STA) - { - Return(0xf) - } - Name (RBUF, ResourceTemplate () - { - MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C1_LENGTH, RMEM) - Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_I2= C1_INTERRUPT } - PinFunction (Exclusive, PullUp, BCM_ALT0, "\\_SB.GDV0.GPI0", 0, Reso= urceConsumer, , ) { 2, 3 } - }) - Method (_CRS, 0x0, Serialized) - { - MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_I2C1_OFFSET) - Return (^RBUF) - } -} =20 // I2C2 is the HDMI DDC connection Device (I2C2) @@ -278,81 +228,6 @@ Device (I2C2) } } =20 -// SPI -Device (SPI0) -{ - Name (_HID, "BCM2838") - Name (_CID, "BCM2838") - Name (_UID, 0x0) - Name (_CCA, 0x0) - Method (_STA) - { - Return (0xf) - } - Name (RBUF, ResourceTemplate () - { - MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI0_LENGTH, RMEM) - Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_SP= I0_INTERRUPT } - PinFunction (Exclusive, PullDown, BCM_ALT0, "\\_SB.GDV0.GPI0", 0, Re= sourceConsumer, , ) { 9, 10, 11 } // MISO, MOSI, SCLK - PinFunction (Exclusive, PullUp, BCM_ALT0, "\\_SB.GDV0.GPI0", 0, Reso= urceConsumer, , ) { 8 } // CE0 - PinFunction (Exclusive, PullUp, BCM_ALT0, "\\_SB.GDV0.GPI0", 0, Reso= urceConsumer, , ) { 7 } // CE1 - }) - - Method (_CRS, 0x0, Serialized) - { - MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI0_OFFSET) - Return (^RBUF) - } -} - -Device (SPI1) -{ - Name (_HID, "BCM2839") - Name (_CID, "BCM2839") - Name (_UID, 0x1) - Name (_CCA, 0x0) - Name (_DEP, Package() { \_SB.GDV0.RPIQ }) - Method (_STA) - { - Return (0xf) - } - Name (RBUF, ResourceTemplate () - { - MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI1_LENGTH, RMEM) - Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM2836_S= PI1_INTERRUPT } - PinFunction (Exclusive, PullDown, BCM_ALT4, "\\_SB.GDV0.GPI0", 0, Re= sourceConsumer, , ) { 19, 20, 21 } // MISO, MOSI, SCLK - PinFunction (Exclusive, PullDown, BCM_ALT4, "\\_SB.GDV0.GPI0", 0, Re= sourceConsumer, , ) { 16 } // CE2 - }) - - Method (_CRS, 0x0, Serialized) - { - MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI1_OFFSET) - Return (^RBUF) - } -} - -// SPI2 has no pins on GPIO header -// Device (SPI2) -// { -// Name (_HID, "BCM2839") -// Name (_CID, "BCM2839") -// Name (_UID, 0x2) -// Name (_CCA, 0x0) -// Name (_DEP, Package() { \_SB.GDV0.RPIQ }) -// Method (_STA) -// { -// Return (0xf) // Disabled -// } -// Method (_CRS, 0x0, Serialized) -// { -// Name (RBUF, ResourceTemplate () -// { -// MEMORY32FIXED (ReadWrite, BCM2836_SPI2_BASE_ADDRESS, BCM2836_SP= I2_LENGTH, RMEM) -// Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM2= 836_SPI2_INTERRUPT } -// }) -// Return (RBUF) -// } -// } =20 // PWM Driver Device (PWM0) @@ -393,5 +268,4 @@ Device (PWM0) } =20 include ("Uart.asl") -include ("Rhpx.asl") include ("Sdhc.asl") diff --git a/Platform/RaspberryPi/AcpiTables/SsdtGpio.asl b/Platform/Rasp= berryPi/AcpiTables/SsdtGpio.asl new file mode 100644 index 0000000000..38e8a54a8f --- /dev/null +++ b/Platform/RaspberryPi/AcpiTables/SsdtGpio.asl @@ -0,0 +1,159 @@ +/** @file + * + * Secondary System Description Table (SSDT) for the GPIO port + * + * Copyright (c) 2021, Arm Ltd. All rights reserved. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + * + **/ + +#include +#include +#include +#include + +#include "AcpiTables.h" + +#define BCM_ALT0 0x4 +#define BCM_ALT1 0x5 +#define BCM_ALT2 0x6 +#define BCM_ALT3 0x7 +#define BCM_ALT4 0x3 +#define BCM_ALT5 0x2 + +DefinitionBlock (__FILE__, "SSDT", 5, "RPIFDN", "RPI3GPIO", 2) +{ + External (\_SB_.GDV0, DeviceObj) + External (\_SB_.GDV0.RPIQ, DeviceObj) + Scope (\_SB_.GDV0) + { + include ("Rhpx.asl") + + // Description: GPIO + Device (GPI0) + { + Name (_HID, "BCM2845") + Name (_CID, "BCM2845") + Name (_UID, 0x0) + Name (_CCA, 0x0) + Method (_STA) + { + Return(0xf) + } + Name (RBUF, ResourceTemplate () + { + MEMORY32FIXED (ReadWrite, 0, GPIO_LENGTH, RMEM) + Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) + { + BCM2386_GPIO_INTERRUPT0, BCM2386_GPIO_INTERRUPT1, + BCM2386_GPIO_INTERRUPT2, BCM2386_GPIO_INTERRUPT3 + } + }) + Method (_CRS, 0x0, Serialized) + { + MEMORY32SETBASE (RBUF, RMEM, RBAS, GPIO_OFFSET) + Return (^RBUF) + } + } + + // SPI + Device (SPI0) + { + Name (_HID, "BCM2838") + Name (_CID, "BCM2838") + Name (_UID, 0x0) + Name (_CCA, 0x0) + Method (_STA) + { + Return (0xf) + } + Name (RBUF, ResourceTemplate () + { + MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI0_LENGTH, RMEM) + Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM283= 6_SPI0_INTERRUPT } + PinFunction (Exclusive, PullDown, BCM_ALT0, "\\_SB.GDV0.GPI0", 0= , ResourceConsumer, , ) { 9, 10, 11 } // MISO, MOSI, SCLK + PinFunction (Exclusive, PullUp, BCM_ALT0, "\\_SB.GDV0.GPI0", 0, = ResourceConsumer, , ) { 8 } // CE0 + PinFunction (Exclusive, PullUp, BCM_ALT0, "\\_SB.GDV0.GPI0", 0, = ResourceConsumer, , ) { 7 } // CE1 + }) + + Method (_CRS, 0x0, Serialized) + { + MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI0_OFFSET) + Return (^RBUF) + } + } + + Device (SPI1) + { + Name (_HID, "BCM2839") + Name (_CID, "BCM2839") + Name (_UID, 0x1) + Name (_CCA, 0x0) + Name (_DEP, Package() { \_SB.GDV0.RPIQ }) + Method (_STA) + { + Return (0xf) + } + Name (RBUF, ResourceTemplate () + { + MEMORY32FIXED (ReadWrite, 0, BCM2836_SPI1_LENGTH, RMEM) + Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BCM28= 36_SPI1_INTERRUPT } + PinFunction (Exclusive, PullDown, BCM_ALT4, "\\_SB_.GDV0.GPI0", = 0, ResourceConsumer, , ) { 19, 20, 21 } // MISO, MOSI, SCLK + PinFunction (Exclusive, PullDown, BCM_ALT4, "\\_SB_.GDV0.GPI0", = 0, ResourceConsumer, , ) { 16 } // CE2 + }) + + Method (_CRS, 0x0, Serialized) + { + MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_SPI1_OFFSET) + Return (^RBUF) + } + } + + // SPI2 has no pins on GPIO header + // Device (SPI2) + // { + // Name (_HID, "BCM2839") + // Name (_CID, "BCM2839") + // Name (_UID, 0x2) + // Name (_CCA, 0x0) + // Name (_DEP, Package() { \_SB.GDV0.RPIQ }) + // Method (_STA) + // { + // Return (0xf) // Disabled + // } + // Method (_CRS, 0x0, Serialized) + // { + // Name (RBUF, ResourceTemplate () + // { + // MEMORY32FIXED (ReadWrite, BCM2836_SPI2_BASE_ADDRESS, BCM2836_= SPI2_LENGTH, RMEM) + // Interrupt (ResourceConsumer, Level, ActiveHigh, Shared,) { BC= M2836_SPI2_INTERRUPT } + // }) + // Return (RBUF) + // } + // } + + Device (I2C1) + { + Name (_HID, "BCM2841") + Name (_CID, "BCM2841") + Name (_UID, 0x1) + Name (_CCA, 0x0) + Method (_STA) + { + Return(0xf) + } + Name (RBUF, ResourceTemplate () + { + MEMORY32FIXED (ReadWrite, 0, BCM2836_I2C1_LENGTH, RMEM) + Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { BCM283= 6_I2C1_INTERRUPT } + PinFunction (Exclusive, PullUp, BCM_ALT0, "\\_SB_.GDV0.GPI0", 0,= ResourceConsumer, , ) { 2, 3 } + }) + Method (_CRS, 0x0, Serialized) + { + MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_I2C1_OFFSET) + Return (^RBUF) + } + } + } +} diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platfor= m/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index bdabdec7a5..d22ecb3128 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -838,6 +838,12 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] =3D { NULL }, #endif + { + SIGNATURE_64 ('R', 'P', 'I', '3', 'G', 'P', 'I', 'O'), + 0, + 0, + NULL + }, { // DSDT SIGNATURE_64 ('R', 'P', 'I', 0, 0, 0, 0, 0), 0, --=20 2.13.7