* [PATCH 0/4] Platform/RaspberryPi: new GPIO and DT menu items @ 2021-11-11 6:57 lintonrjeremy 2021-11-11 6:57 ` [PATCH 1/1] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: lintonrjeremy @ 2021-11-11 6:57 UTC (permalink / raw) To: devel Cc: pete, ardb+tianocore, leif, awarkentin, Sunny.Wang, samer.el-haj-mahmoud, Jeremy Linton Its been reported that some kernel versions still need the XHCI reload while others only work if the reload isn't present. Lets give the user the ability to control that for DT systems. Further, there is now an example persistent variable store implementation that uses the on-board SPI flash rather than trying to rewrite the UEFI firmware image on SD/etc late in the boot cycle. The problem is that we now need to control the GPIO pin mux. This isn't a problem for Linux as such, because it only messes with the pin mux under DT, but windows has some drivers which export the GPIO devices using the ACPI definition. Lets add a menu item to enable the GPIO and default it to off on the RPi4 under the assumption that we can't fix a GPIO pin mux war reliably and instead will simply revert to a mode that fails to persist variables written while the OS is active if the GPIO is enabled. This set also cleans up the ACPI/DT visiblity of a couple nearby menu items as well. Jeremy Linton (4): Platform/RaspberryPi: Cleanup menu visibility Platform/RaspberryPi: Give the user control over the XHCI mailbox Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Platform/RaspberryPi: Add menu item to enable/disable GPIO Platform/RaspberryPi/AcpiTables/AcpiTables.inf | 1 + Platform/RaspberryPi/AcpiTables/Dsdt.asl | 7 - Platform/RaspberryPi/AcpiTables/GpuDevs.asl | 125 ---------------- Platform/RaspberryPi/AcpiTables/SsdtGpio.asl | 157 +++++++++++++++++++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 31 ++++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 2 + .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 10 ++ .../RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 36 ++++- Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c | 4 + Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf | 1 + Platform/RaspberryPi/Include/ConfigVars.h | 4 + Platform/RaspberryPi/RPi3/RPi3.dsc | 12 ++ Platform/RaspberryPi/RPi4/RPi4.dsc | 14 ++ Platform/RaspberryPi/RaspberryPi.dec | 2 + 14 files changed, 271 insertions(+), 135 deletions(-) create mode 100644 Platform/RaspberryPi/AcpiTables/SsdtGpio.asl -- 2.13.7 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] Platform/RaspberryPi: Add menu item to enable/disable GPIO 2021-11-11 6:57 [PATCH 0/4] Platform/RaspberryPi: new GPIO and DT menu items lintonrjeremy @ 2021-11-11 6:57 ` Jeremy Linton 2021-11-11 6:57 ` [PATCH 1/4] Platform/RaspberryPi: Cleanup menu visibility Jeremy Linton ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Jeremy Linton @ 2021-11-11 6:57 UTC (permalink / raw) To: devel Cc: pete, ardb+tianocore, leif, awarkentin, Sunny.Wang, samer.el-haj-mahmoud, Jeremy Linton Now that the GPIO devices are in their own SSDT lets add a menu item for the rpi4 to enable/disable it. For the rpi3 the SSDT is always exported. Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com> --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 17 ++++++++++++++++- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 1 + Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 5 +++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 15 +++++++++++++++ Platform/RaspberryPi/Include/ConfigVars.h | 4 ++++ Platform/RaspberryPi/RPi3/RPi3.dsc | 6 ++++++ Platform/RaspberryPi/RPi4/RPi4.dsc | 7 +++++++ Platform/RaspberryPi/RaspberryPi.dec | 1 + 8 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index d22ecb3128..794d056dc6 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -308,12 +308,27 @@ SetupVariables ( } } + + Size = sizeof (UINT32); + Status = gRT->GetVariable (L"EnableGpio", + &gConfigDxeFormSetGuid, + NULL, &Size, &Var32); + if (EFI_ERROR (Status)) { + Status = PcdSet32S (PcdEnableGpio, PcdGet32 (PcdEnableGpio)); + ASSERT_EFI_ERROR (Status); + } + } else { /* * Disable PCIe and XHCI */ Status = PcdSet32S (PcdXhciPci, 0); ASSERT_EFI_ERROR (Status); + /* + * Enable GPIO + */ + Status = PcdSet32S (PcdEnableGpio, 1); + ASSERT_EFI_ERROR (Status); } Size = sizeof (AssetTagVar); @@ -840,7 +855,7 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = { #endif { SIGNATURE_64 ('R', 'P', 'I', '3', 'G', 'P', 'I', 'O'), - 0, + PcdToken(PcdEnableGpio), 0, NULL }, diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index ff182e831d..1cba4a2a22 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -96,6 +96,7 @@ gRaspberryPiTokenSpaceGuid.PcdUartInUse gRaspberryPiTokenSpaceGuid.PcdXhciPci gRaspberryPiTokenSpaceGuid.PcdXhciReload + gRaspberryPiTokenSpaceGuid.PcdEnableGpio [Depex] gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni index 8130638876..8fcb6a3949 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -67,6 +67,11 @@ #string STR_ADVANCED_XHCIRELOAD_DISABLE #language en-US "Disabled" #string STR_ADVANCED_XHCIRELOAD_RELOAD #language en-US "Reload" +#string STR_ADVANCED_ENABLEGPIO_PROMPT #language en-US "Export GPIO devices to OS" +#string STR_ADVANCED_ENABLEGPIO_HELP #language en-US "OS can see the GPIO device and some low level SPI and I2C interfaces" +#string STR_ADVANCED_ENABLEGPIO_DISABLE #language en-US "Disabled" +#string STR_ADVANCED_ENABLEGPIO_ENABLE #language en-US "Enable" + #string STR_ADVANCED_ASSET_TAG_PROMPT #language en-US "Asset Tag" #string STR_ADVANCED_ASSET_TAG_HELP #language en-US "Set the system Asset Tag" diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index f13b70711d..04eb0a15a2 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -66,6 +66,11 @@ formset name = XhciReload, guid = CONFIGDXE_FORM_SET_GUID; + efivarstore ADVANCED_ENABLEGPIO_VARSTORE_DATA, + attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + name = EnableGpio, + guid = CONFIGDXE_FORM_SET_GUID; + efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA, attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, name = SystemTableMode, @@ -244,6 +249,16 @@ formset endoneof; endif; endif; + + grayoutif ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_DT; + oneof varid = EnableGpio.Value, + prompt = STRING_TOKEN(STR_ADVANCED_ENABLEGPIO_PROMPT), + help = STRING_TOKEN(STR_ADVANCED_ENABLEGPIO_HELP), + flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED, + option text = STRING_TOKEN(STR_ADVANCED_ENABLEGPIO_DISABLE), value = 0, flags = DEFAULT; + option text = STRING_TOKEN(STR_ADVANCED_ENABLEGPIO_ENABLE), value = 1, flags = 0; + endoneof; + endif; #endif string varid = AssetTag.AssetTag, prompt = STRING_TOKEN(STR_ADVANCED_ASSET_TAG_PROMPT), diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/RaspberryPi/Include/ConfigVars.h index a5b32b5284..43a39891d4 100644 --- a/Platform/RaspberryPi/Include/ConfigVars.h +++ b/Platform/RaspberryPi/Include/ConfigVars.h @@ -81,6 +81,10 @@ typedef struct { } ADVANCED_XHCIPCI_VARSTORE_DATA; typedef struct { + UINT32 Value; +} ADVANCED_ENABLEGPIO_VARSTORE_DATA; + +typedef struct { #define SYSTEM_TABLE_MODE_ACPI 0 #define SYSTEM_TABLE_MODE_BOTH 1 #define SYSTEM_TABLE_MODE_DT 2 diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc index 72fafb7195..1d59cda4a7 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -532,6 +532,12 @@ # gRaspberryPiTokenSpaceGuid.PcdXhciReload|L"XhciReload"|gConfigDxeFormSetGuid|0x0|0 + # Export GPIO block to OS + # + # 1 - Yes (for legacy reasons) + # + gRaspberryPiTokenSpaceGuid.PcdEnableGpio|L"EnableGpio"|gConfigDxeFormSetGuid|0x0|1 + # # Common UEFI ones. # diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc index 6de4407749..c918af6dab 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -551,6 +551,13 @@ # gRaspberryPiTokenSpaceGuid.PcdXhciReload|L"XhciReload"|gConfigDxeFormSetGuid|0x0|0 + # Export GPIO block to OS + # + # 0 - No + # 1 - Yes + # + gRaspberryPiTokenSpaceGuid.PcdEnableGpio|L"EnableGpio"|gConfigDxeFormSetGuid|0x0|0 + # # Common UEFI ones. # diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec index c50ebdcf77..97709f9b94 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -73,3 +73,4 @@ gRaspberryPiTokenSpaceGuid.PcdUartInUse|1|UINT32|0x00000021 gRaspberryPiTokenSpaceGuid.PcdXhciPci|0|UINT32|0x00000022 gRaspberryPiTokenSpaceGuid.PcdXhciReload|0|UINT32|0x00000023 + gRaspberryPiTokenSpaceGuid.PcdEnableGpio|0|UINT32|0x00000024 -- 2.13.7 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/4] Platform/RaspberryPi: Cleanup menu visibility 2021-11-11 6:57 [PATCH 0/4] Platform/RaspberryPi: new GPIO and DT menu items lintonrjeremy 2021-11-11 6:57 ` [PATCH 1/1] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton @ 2021-11-11 6:57 ` Jeremy Linton 2021-11-11 6:57 ` [PATCH 2/4] Platform/RaspberryPi: Give the user control over the XHCI mailbox Jeremy Linton ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: Jeremy Linton @ 2021-11-11 6:57 UTC (permalink / raw) To: devel Cc: pete, ardb+tianocore, leif, awarkentin, Sunny.Wang, samer.el-haj-mahmoud, Jeremy Linton Lets allow some of these options to change when the system is in ACPI+DT mode. Plus the fan temp should be disabled when ACPI isn't enabled. Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com> --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index e8bf16312d..f668b7a553 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -196,7 +196,7 @@ formset endoneof; #if (RPI_MODEL == 4) - grayoutif NOT ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_ACPI; + grayoutif ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_DT; oneof varid = FanOnGpio.Enabled, prompt = STRING_TOKEN(STR_ADVANCED_FANONGPIO_PROMPT), help = STRING_TOKEN(STR_ADVANCED_FANONGPIO_HELP), @@ -207,7 +207,7 @@ formset endoneof; endif; - grayoutif ideqval FanOnGpio.Enabled == 0; + grayoutif ideqval FanOnGpio.Enabled == 0 OR ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_DT; numeric varid = FanTemp.Value, prompt = STRING_TOKEN(STR_ADVANCED_FANTEMP_PROMPT), help = STRING_TOKEN(STR_ADVANCED_FANTEMP_HELP), @@ -219,7 +219,7 @@ formset endif; suppressif ideqval XhciPci.Value == 2; - grayoutif NOT ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_ACPI; + grayoutif ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_DT; oneof varid = XhciPci.Value, prompt = STRING_TOKEN(STR_ADVANCED_XHCIPCI_PROMPT), help = STRING_TOKEN(STR_ADVANCED_XHCIPCI_HELP), -- 2.13.7 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] Platform/RaspberryPi: Give the user control over the XHCI mailbox 2021-11-11 6:57 [PATCH 0/4] Platform/RaspberryPi: new GPIO and DT menu items lintonrjeremy 2021-11-11 6:57 ` [PATCH 1/1] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton 2021-11-11 6:57 ` [PATCH 1/4] Platform/RaspberryPi: Cleanup menu visibility Jeremy Linton @ 2021-11-11 6:57 ` Jeremy Linton 2021-11-11 6:57 ` [PATCH 3/4] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Jeremy Linton 2021-11-11 6:57 ` [PATCH 4/4] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton 4 siblings, 0 replies; 6+ messages in thread From: Jeremy Linton @ 2021-11-11 6:57 UTC (permalink / raw) To: devel Cc: pete, ardb+tianocore, leif, awarkentin, Sunny.Wang, samer.el-haj-mahmoud, Jeremy Linton Its a complete tossup whether removing the mailbox call after we have set up the XHCI works for a given kernel+distro in DT mode. So lets give users which want to try DT the option of flipping this on/off. Users that don't want to have to deal with DT, can use ACPI. Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com> --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 10 ++++++++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 1 + Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 5 +++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 15 +++++++++++++++ Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c | 4 ++++ Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf | 1 + Platform/RaspberryPi/RPi3/RPi3.dsc | 6 ++++++ Platform/RaspberryPi/RPi4/RPi4.dsc | 7 +++++++ Platform/RaspberryPi/RaspberryPi.dec | 1 + 9 files changed, 50 insertions(+) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index 415d99fadb..bdabdec7a5 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -297,6 +297,16 @@ SetupVariables ( Status = PcdSet32S (PcdXhciPci, 1); ASSERT_EFI_ERROR (Status); } + + Size = sizeof (UINT32); + Status = gRT->GetVariable (L"XhciReload", + &gConfigDxeFormSetGuid, + NULL, &Size, &Var32); + if (EFI_ERROR (Status)) { + Status = PcdSet32S (PcdXhciReload, PcdGet32 (PcdXhciReload)); + ASSERT_EFI_ERROR (Status); + } + } } else { /* diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index e6e22ad82e..ff182e831d 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -95,6 +95,7 @@ gRaspberryPiTokenSpaceGuid.PcdFanTemp gRaspberryPiTokenSpaceGuid.PcdUartInUse gRaspberryPiTokenSpaceGuid.PcdXhciPci + gRaspberryPiTokenSpaceGuid.PcdXhciReload [Depex] gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni index 5ec17072c3..8130638876 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -62,6 +62,11 @@ #string STR_ADVANCED_XHCIPCI_XHCI #language en-US "XHCI" #string STR_ADVANCED_XHCIPCI_PCIE #language en-US "PCIe" +#string STR_ADVANCED_XHCIRELOAD_PROMPT #language en-US "DT Reload XHCI firmware" +#string STR_ADVANCED_XHCIRELOAD_HELP #language en-US "OS should reload XHCI firmware on reset" +#string STR_ADVANCED_XHCIRELOAD_DISABLE #language en-US "Disabled" +#string STR_ADVANCED_XHCIRELOAD_RELOAD #language en-US "Reload" + #string STR_ADVANCED_ASSET_TAG_PROMPT #language en-US "Asset Tag" #string STR_ADVANCED_ASSET_TAG_HELP #language en-US "Set the system Asset Tag" diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index f668b7a553..f13b70711d 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -61,6 +61,11 @@ formset name = XhciPci, guid = CONFIGDXE_FORM_SET_GUID; + efivarstore ADVANCED_XHCIPCI_VARSTORE_DATA, + attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + name = XhciReload, + guid = CONFIGDXE_FORM_SET_GUID; + efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA, attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, name = SystemTableMode, @@ -228,6 +233,16 @@ formset option text = STRING_TOKEN(STR_ADVANCED_XHCIPCI_PCIE), value = 1, flags = 0; endoneof; endif; + + grayoutif ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_ACPI; + oneof varid = XhciReload.Value, + prompt = STRING_TOKEN(STR_ADVANCED_XHCIRELOAD_PROMPT), + help = STRING_TOKEN(STR_ADVANCED_XHCIRELOAD_HELP), + flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED, + option text = STRING_TOKEN(STR_ADVANCED_XHCIRELOAD_DISABLE), value = 0, flags = DEFAULT; + option text = STRING_TOKEN(STR_ADVANCED_XHCIRELOAD_RELOAD), value = 1, flags = 0; + endoneof; + endif; endif; #endif string varid = AssetTag.AssetTag, diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c index e72d132b18..7eb1b26b68 100644 --- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c +++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c @@ -375,6 +375,10 @@ SyncPcie ( return EFI_NOT_FOUND; } + if (PcdGet32 (PcdXhciReload) != 1) { + return EFI_SUCCESS; + } + /* * Now that we are always running without DMA translation, and with a 3G * limit, there shouldn't be a need to reset/reload the XHCI. The diff --git a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf index 26f84e5940..d9fb6ee480 100644 --- a/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf +++ b/Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf @@ -47,3 +47,4 @@ [Pcd] gRaspberryPiTokenSpaceGuid.PcdSystemTableMode + gRaspberryPiTokenSpaceGuid.PcdXhciReload diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc index 6ab5d1ae6d..72fafb7195 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -526,6 +526,12 @@ # gRaspberryPiTokenSpaceGuid.PcdXhciPci|L"XhciPci"|gConfigDxeFormSetGuid|0x0|0 + # DT contains XHCI quirk node (not valid on rpi3) + # + # 0 - DISABLED + # + gRaspberryPiTokenSpaceGuid.PcdXhciReload|L"XhciReload"|gConfigDxeFormSetGuid|0x0|0 + # # Common UEFI ones. # diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc index 44ed60ab2f..6de4407749 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -544,6 +544,13 @@ # gRaspberryPiTokenSpaceGuid.PcdXhciPci|L"XhciPci"|gConfigDxeFormSetGuid|0x0|0 + # DT contains XHCI quirk node + # + # 0 - No reload + # 1 - Yes, DT has Reload + # + gRaspberryPiTokenSpaceGuid.PcdXhciReload|L"XhciReload"|gConfigDxeFormSetGuid|0x0|0 + # # Common UEFI ones. # diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec index 797be59274..c50ebdcf77 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -72,3 +72,4 @@ gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x0000001F gRaspberryPiTokenSpaceGuid.PcdUartInUse|1|UINT32|0x00000021 gRaspberryPiTokenSpaceGuid.PcdXhciPci|0|UINT32|0x00000022 + gRaspberryPiTokenSpaceGuid.PcdXhciReload|0|UINT32|0x00000023 -- 2.13.7 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT 2021-11-11 6:57 [PATCH 0/4] Platform/RaspberryPi: new GPIO and DT menu items lintonrjeremy ` (2 preceding siblings ...) 2021-11-11 6:57 ` [PATCH 2/4] Platform/RaspberryPi: Give the user control over the XHCI mailbox Jeremy Linton @ 2021-11-11 6:57 ` Jeremy Linton 2021-11-11 6:57 ` [PATCH 4/4] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton 4 siblings, 0 replies; 6+ messages in thread From: Jeremy Linton @ 2021-11-11 6:57 UTC (permalink / raw) To: devel Cc: pete, ardb+tianocore, leif, awarkentin, Sunny.Wang, samer.el-haj-mahmoud, Jeremy Linton 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. Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com> --- Platform/RaspberryPi/AcpiTables/AcpiTables.inf | 1 + Platform/RaspberryPi/AcpiTables/Dsdt.asl | 7 - Platform/RaspberryPi/AcpiTables/GpuDevs.asl | 125 ---------------- Platform/RaspberryPi/AcpiTables/SsdtGpio.asl | 157 +++++++++++++++++++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 6 + 5 files changed, 164 insertions(+), 132 deletions(-) create mode 100644 Platform/RaspberryPi/AcpiTables/SsdtGpio.asl diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.inf b/Platform/RaspberryPi/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 [Packages] ArmPkg/ArmPkg.dec diff --git a/Platform/RaspberryPi/AcpiTables/Dsdt.asl b/Platform/RaspberryPi/AcpiTables/Dsdt.asl index b594d50bdf..08acc81d57 100644 --- a/Platform/RaspberryPi/AcpiTables/Dsdt.asl +++ b/Platform/RaspberryPi/AcpiTables/Dsdt.asl @@ -21,13 +21,6 @@ #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 - // // 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/RaspberryPi/AcpiTables/GpuDevs.asl index 9750dc25c0..b1fd5a1387 100644 --- a/Platform/RaspberryPi/AcpiTables/GpuDevs.asl +++ b/Platform/RaspberryPi/AcpiTables/GpuDevs.asl @@ -203,56 +203,6 @@ Device (VCSM) } } -// 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_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) - } -} // I2C2 is the HDMI DDC connection Device (I2C2) @@ -278,81 +228,6 @@ Device (I2C2) } } -// 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_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,) { BCM2836_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,) { BCM2836_SPI2_INTERRUPT } -// }) -// Return (RBUF) -// } -// } // PWM Driver Device (PWM0) diff --git a/Platform/RaspberryPi/AcpiTables/SsdtGpio.asl b/Platform/RaspberryPi/AcpiTables/SsdtGpio.asl new file mode 100644 index 0000000000..0c8e1455d3 --- /dev/null +++ b/Platform/RaspberryPi/AcpiTables/SsdtGpio.asl @@ -0,0 +1,157 @@ +/** @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 <IndustryStandard/Acpi.h> +#include <IndustryStandard/Bcm2711.h> +#include <IndustryStandard/Bcm2836.h> +#include <IndustryStandard/Bcm2836Gpio.h> + +#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) + { + // 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) { BCM2836_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,) { BCM2836_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,) { BCM2836_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) { BCM2836_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/Platform/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[] = { 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, -- 2.13.7 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] Platform/RaspberryPi: Add menu item to enable/disable GPIO 2021-11-11 6:57 [PATCH 0/4] Platform/RaspberryPi: new GPIO and DT menu items lintonrjeremy ` (3 preceding siblings ...) 2021-11-11 6:57 ` [PATCH 3/4] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Jeremy Linton @ 2021-11-11 6:57 ` Jeremy Linton 4 siblings, 0 replies; 6+ messages in thread From: Jeremy Linton @ 2021-11-11 6:57 UTC (permalink / raw) To: devel Cc: pete, ardb+tianocore, leif, awarkentin, Sunny.Wang, samer.el-haj-mahmoud, Jeremy Linton Now that the GPIO devices are in their own SSDT lets add a menu item for the rpi4 to enable/disable it. For the rpi3 the SSDT is always exported. Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com> --- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c | 17 ++++++++++++++++- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf | 1 + Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni | 5 +++++ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 15 +++++++++++++++ Platform/RaspberryPi/Include/ConfigVars.h | 4 ++++ Platform/RaspberryPi/RPi3/RPi3.dsc | 6 ++++++ Platform/RaspberryPi/RPi4/RPi4.dsc | 7 +++++++ Platform/RaspberryPi/RaspberryPi.dec | 1 + 8 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c index d22ecb3128..794d056dc6 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c @@ -308,12 +308,27 @@ SetupVariables ( } } + + Size = sizeof (UINT32); + Status = gRT->GetVariable (L"EnableGpio", + &gConfigDxeFormSetGuid, + NULL, &Size, &Var32); + if (EFI_ERROR (Status)) { + Status = PcdSet32S (PcdEnableGpio, PcdGet32 (PcdEnableGpio)); + ASSERT_EFI_ERROR (Status); + } + } else { /* * Disable PCIe and XHCI */ Status = PcdSet32S (PcdXhciPci, 0); ASSERT_EFI_ERROR (Status); + /* + * Enable GPIO + */ + Status = PcdSet32S (PcdEnableGpio, 1); + ASSERT_EFI_ERROR (Status); } Size = sizeof (AssetTagVar); @@ -840,7 +855,7 @@ STATIC CONST NAMESPACE_TABLES SdtTables[] = { #endif { SIGNATURE_64 ('R', 'P', 'I', '3', 'G', 'P', 'I', 'O'), - 0, + PcdToken(PcdEnableGpio), 0, NULL }, diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf index ff182e831d..1cba4a2a22 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf @@ -96,6 +96,7 @@ gRaspberryPiTokenSpaceGuid.PcdUartInUse gRaspberryPiTokenSpaceGuid.PcdXhciPci gRaspberryPiTokenSpaceGuid.PcdXhciReload + gRaspberryPiTokenSpaceGuid.PcdEnableGpio [Depex] gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni index 8130638876..8fcb6a3949 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni @@ -67,6 +67,11 @@ #string STR_ADVANCED_XHCIRELOAD_DISABLE #language en-US "Disabled" #string STR_ADVANCED_XHCIRELOAD_RELOAD #language en-US "Reload" +#string STR_ADVANCED_ENABLEGPIO_PROMPT #language en-US "Export GPIO devices to OS" +#string STR_ADVANCED_ENABLEGPIO_HELP #language en-US "OS can see the GPIO device and some low level SPI and I2C interfaces" +#string STR_ADVANCED_ENABLEGPIO_DISABLE #language en-US "Disabled" +#string STR_ADVANCED_ENABLEGPIO_ENABLE #language en-US "Enable" + #string STR_ADVANCED_ASSET_TAG_PROMPT #language en-US "Asset Tag" #string STR_ADVANCED_ASSET_TAG_HELP #language en-US "Set the system Asset Tag" diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr index f13b70711d..04eb0a15a2 100644 --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr @@ -66,6 +66,11 @@ formset name = XhciReload, guid = CONFIGDXE_FORM_SET_GUID; + efivarstore ADVANCED_ENABLEGPIO_VARSTORE_DATA, + attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + name = EnableGpio, + guid = CONFIGDXE_FORM_SET_GUID; + efivarstore SYSTEM_TABLE_MODE_VARSTORE_DATA, attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, name = SystemTableMode, @@ -244,6 +249,16 @@ formset endoneof; endif; endif; + + grayoutif ideqval SystemTableMode.Mode == SYSTEM_TABLE_MODE_DT; + oneof varid = EnableGpio.Value, + prompt = STRING_TOKEN(STR_ADVANCED_ENABLEGPIO_PROMPT), + help = STRING_TOKEN(STR_ADVANCED_ENABLEGPIO_HELP), + flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED, + option text = STRING_TOKEN(STR_ADVANCED_ENABLEGPIO_DISABLE), value = 0, flags = DEFAULT; + option text = STRING_TOKEN(STR_ADVANCED_ENABLEGPIO_ENABLE), value = 1, flags = 0; + endoneof; + endif; #endif string varid = AssetTag.AssetTag, prompt = STRING_TOKEN(STR_ADVANCED_ASSET_TAG_PROMPT), diff --git a/Platform/RaspberryPi/Include/ConfigVars.h b/Platform/RaspberryPi/Include/ConfigVars.h index a5b32b5284..43a39891d4 100644 --- a/Platform/RaspberryPi/Include/ConfigVars.h +++ b/Platform/RaspberryPi/Include/ConfigVars.h @@ -81,6 +81,10 @@ typedef struct { } ADVANCED_XHCIPCI_VARSTORE_DATA; typedef struct { + UINT32 Value; +} ADVANCED_ENABLEGPIO_VARSTORE_DATA; + +typedef struct { #define SYSTEM_TABLE_MODE_ACPI 0 #define SYSTEM_TABLE_MODE_BOTH 1 #define SYSTEM_TABLE_MODE_DT 2 diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc index 72fafb7195..1d59cda4a7 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -532,6 +532,12 @@ # gRaspberryPiTokenSpaceGuid.PcdXhciReload|L"XhciReload"|gConfigDxeFormSetGuid|0x0|0 + # Export GPIO block to OS + # + # 1 - Yes (for legacy reasons) + # + gRaspberryPiTokenSpaceGuid.PcdEnableGpio|L"EnableGpio"|gConfigDxeFormSetGuid|0x0|1 + # # Common UEFI ones. # diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc index 6de4407749..c918af6dab 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -551,6 +551,13 @@ # gRaspberryPiTokenSpaceGuid.PcdXhciReload|L"XhciReload"|gConfigDxeFormSetGuid|0x0|0 + # Export GPIO block to OS + # + # 0 - No + # 1 - Yes + # + gRaspberryPiTokenSpaceGuid.PcdEnableGpio|L"EnableGpio"|gConfigDxeFormSetGuid|0x0|0 + # # Common UEFI ones. # diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/RaspberryPi.dec index c50ebdcf77..97709f9b94 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -73,3 +73,4 @@ gRaspberryPiTokenSpaceGuid.PcdUartInUse|1|UINT32|0x00000021 gRaspberryPiTokenSpaceGuid.PcdXhciPci|0|UINT32|0x00000022 gRaspberryPiTokenSpaceGuid.PcdXhciReload|0|UINT32|0x00000023 + gRaspberryPiTokenSpaceGuid.PcdEnableGpio|0|UINT32|0x00000024 -- 2.13.7 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-11 6:58 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-11-11 6:57 [PATCH 0/4] Platform/RaspberryPi: new GPIO and DT menu items lintonrjeremy 2021-11-11 6:57 ` [PATCH 1/1] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton 2021-11-11 6:57 ` [PATCH 1/4] Platform/RaspberryPi: Cleanup menu visibility Jeremy Linton 2021-11-11 6:57 ` [PATCH 2/4] Platform/RaspberryPi: Give the user control over the XHCI mailbox Jeremy Linton 2021-11-11 6:57 ` [PATCH 3/4] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Jeremy Linton 2021-11-11 6:57 ` [PATCH 4/4] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox