public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jeremy Linton" <jeremy.linton@arm.com>
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 <jeremy.linton@arm.com>,
	Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCH V2 08/10] Platform/RaspberryPi: Allow pin function selection at runtime
Date: Sat,  1 Jan 2022 23:49:22 -0600	[thread overview]
Message-ID: <20220102054924.1195762-9-jeremy.linton@arm.com> (raw)
In-Reply-To: <20220102054924.1195762-1-jeremy.linton@arm.com>

Update GpioLib slightly so that we can change the GPIO pin
muxing at runtime. For the moment only the GpioPinFuncGet/Set()
routines are used at runtime, and only by the Variable service.

Tested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h |  6 ++++++
 Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c | 16 ++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
index 1f7d2204e0..79765be4fb 100644
--- a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
+++ b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
@@ -45,4 +45,10 @@ GpioSetPull (
   IN  UINTN   Pud
 );
 
+VOID
+GpioSetupRuntime (
+  VOID
+);
+
+
 #endif /* __GPIO_LIB__ */
diff --git a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
index eaf53e5369..fc1f928e6b 100644
--- a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
+++ b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
@@ -15,10 +15,22 @@
 #include <Library/DebugLib.h>
 #include <Library/IoLib.h>
 #include <Library/GpioLib.h>
+#include <Library/UefiRuntimeLib.h>
 #include <Library/TimerLib.h>
 #include <IndustryStandard/Bcm2836.h>
 #include <IndustryStandard/Bcm2836Gpio.h>
 
+
+STATIC EFI_PHYSICAL_ADDRESS GpioGfpSel0 = GPIO_GPFSEL0;
+
+VOID
+GpioSetupRuntime (
+  VOID
+  )
+{
+  EfiConvertPointer (0x0, (VOID**)&GpioGfpSel0);
+}
+
 STATIC
 VOID
 GpioFSELModify (
@@ -30,7 +42,7 @@ GpioFSELModify (
   UINT32 Val;
   EFI_PHYSICAL_ADDRESS Reg;
 
-  Reg = RegIndex * sizeof (UINT32) + GPIO_GPFSEL0;
+  Reg = RegIndex * sizeof (UINT32) + GpioGfpSel0;
 
   ASSERT (Reg <= GPIO_GPFSEL5);
   ASSERT ((~ModifyMask & FunctionMask) == 0);
@@ -77,7 +89,7 @@ GpioPinFuncGet (
 
   RegIndex = Pin / 10;
   SelIndex = Pin % 10;
-  Reg = RegIndex * sizeof (UINT32) + GPIO_GPFSEL0;
+  Reg = RegIndex * sizeof (UINT32) + GpioGfpSel0;
 
   Val = MmioRead32 (Reg);
   Val >>= SelIndex * GPIO_FSEL_BITS_PER_PIN;
-- 
2.13.7


  parent reply	other threads:[~2022-01-02  5:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-02  5:49 [PATCH V2 00/10] Platform/RaspberryPi: Utilize SPI flash for EFI variables Jeremy Linton
2022-01-02  5:49 ` [PATCH V2 01/10] Platform/RaspberryPi: Cleanup menu visibility Jeremy Linton
2022-01-02  5:49 ` [PATCH V2 02/10] Platform/RaspberryPi: Give the user control over the XHCI mailbox Jeremy Linton
2022-01-02  5:49 ` [PATCH V2 03/10] Platform/RaspberryPi: Move GPIO/SPI/I2C to SSDT Jeremy Linton
2022-01-02  5:49 ` [PATCH V2 04/10] Platform/RaspberryPi: Add menu item to enable/disable GPIO Jeremy Linton
2022-01-02  5:49 ` [PATCH V2 05/10] Platform/RaspberryPi: Add constants for controlling SPI Jeremy Linton
2022-01-02  5:49 ` [PATCH V2 06/10] Platform/RaspberryPi: Add mailbox cmd to control audio amp Jeremy Linton
2022-01-02  5:49 ` [PATCH V2 07/10] Platform/RaspberryPi: Add SPI/GPIO to memory map Jeremy Linton
2022-01-02  5:49 ` Jeremy Linton [this message]
2022-01-02  5:49 ` [PATCH V2 09/10] Platform/RaspberryPi: Add SPI flash variable store Jeremy Linton
2022-01-02  5:49 ` [PATCH V2 10/10] Platform/RaspberryPi: Update RPi4 Readme Jeremy Linton
2022-02-01 18:03 ` [edk2-devel] [PATCH V2 00/10] Platform/RaspberryPi: Utilize SPI flash for EFI variables 0n0w1c
2022-02-10 16:38 ` Jeff Booher-Kaeding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220102054924.1195762-9-jeremy.linton@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox