From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by mx.groups.io with SMTP id smtpd.web09.7426.1636613875438544328 for ; Wed, 10 Nov 2021 22:57:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EZpHNhs5; spf=pass (domain: gmail.com, ip: 209.85.210.53, mailfrom: lintonrjeremy@gmail.com) Received: by mail-ot1-f53.google.com with SMTP id g91-20020a9d12e4000000b0055ae68cfc3dso7599493otg.9 for ; Wed, 10 Nov 2021 22:57:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ELXP/M6PK56BvFGcA7XDEt/+ZK+y+Foz/YzKagstXXw=; b=EZpHNhs56g553FIaqWWuCAmgfZgYhw/4/0uhIEKVoAxflCh8st9I8kHrLHF9scsKXp PDHfW+SKe7Xj/1u0QZxSdWnp1ubqBko5cofW+dPJXpoAIhfYH5xh0fi0Fg2VmHFCu/dn a24i+XBXyBzqY/guZQzm32rLoBW5AWy9V4zj0TywZio3zTQohXa+gVUC28ivU8B00Tfp r+QFal+f2UCoGSBhDfatdutlf00mDUMm0adEUy5mlf51GHTrUdrZzu14aEVdoRzmwUT+ qYKlNV2G1s99SIWBw92r+Vjg+GOp4Vah4KW+s35kldDXH+ERKYohvFJ10hbVtokKeMi3 X3iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ELXP/M6PK56BvFGcA7XDEt/+ZK+y+Foz/YzKagstXXw=; b=hHuqHaomqaIg3YoTXU2BO+3G5nTf6IapFn/DN3X4XKrbyhVszE9Qiy0t0jF8t4Frl/ CRMVr1Nzny84QnqywtNOjB7UGTry+YDs4M3SwqTt+DyV3lOScsgUTCyoUPMRrdH2jr8R 9LqL1hcSNp3tj3mcoUiEiMH2NqiBfJ/olri8vzg+4b0HKyQ1voZsEGkveI4JsWCPVNlM CfIXM2/Mqv1Yko+SyZCWxmOpTicaSyulnLWDVY9T3JMVevjUkv2Xw/Nt2dP8rBJnD6p1 JBGA+YxDTVpC/INfVcnas5GxGw6Tz4bqlt0EYLpAlCrS70H7xnYMcVXOA/9DR/u0V3m1 0W1g== X-Gm-Message-State: AOAM532AEsBU2eKikx3MIHS7Ffyd3rwFjPAjaNsDkW5+79AIuSzk2ZN4 nCQvG7OLm1O2KpJPhbtHPdHW+EHyL+D9Ow== X-Google-Smtp-Source: ABdhPJwOUO29gbQGW+kMTBHWIGH8aDhdJNsXbwsvLz3/n0+a+rbWpNV7MvxB/9m+86icJneNslcxjw== X-Received: by 2002:a05:6830:1be9:: with SMTP id k9mr4240843otb.123.1636613874348; Wed, 10 Nov 2021 22:57:54 -0800 (PST) Return-Path: Received: from dell-suse.jhome.net (072-191-152-022.res.spectrum.com. [72.191.152.22]) by smtp.gmail.com with ESMTPSA id y12sm649206oiv.49.2021.11.10.22.57.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Nov 2021 22:57:53 -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, Jeremy Linton Subject: [PATCH 1/1] Platform/RaspberryPi: Add menu item to enable/disable GPIO Date: Thu, 11 Nov 2021 00:57:38 -0600 Message-Id: <20211111065742.8923-2-lintonrjeremy@gmail.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20211111065742.8923-1-lintonrjeremy@gmail.com> References: <20211111065742.8923-1-lintonrjeremy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 --- 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