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.web12.11079.1638463954968942622 for ; Thu, 02 Dec 2021 08:52:35 -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 68BFF142F; Thu, 2 Dec 2021 08:52:35 -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 17E1F3F73B; Thu, 2 Dec 2021 08:52:35 -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 Subject: [PATCH 8/9] Platform/RaspberryPi: Allow pin function selection at runtime Date: Thu, 2 Dec 2021 10:52:05 -0600 Message-Id: <20211202165206.79615-9-jeremy.linton@arm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211202165206.79615-1-jeremy.linton@arm.com> References: <20211202165206.79615-1-jeremy.linton@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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. Signed-off-by: Jeremy Linton --- 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 #include #include +#include #include #include #include + +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