From: "Andrei Warkentin" <andrey.warkentin@gmail.com>
To: devel@edk2.groups.io
Cc: ard.biesheuvel@arm.com, leif@nuviainc.com, pete@akeo.ie,
philmd@redhat.com
Subject: [edk2-platforms][PATCH 1/1] RPi: add Gpio output set/clear functions to GpioLib
Date: Sun, 10 May 2020 14:36:50 -0700 [thread overview]
Message-ID: <20200510213650.12829-1-andrey.warkentin@gmail.com> (raw)
GpioSet and GpioClear. Using hw of course (not mailbox).
Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
---
Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h | 10 +++++
Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c | 42 +++++++++++++++++++-
2 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
index 014c6b07..10c9cdfb 100644
--- a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
+++ b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
@@ -24,4 +24,14 @@ GpioPinFuncGet (
IN UINTN Pin
);
+VOID
+GpioSet (
+ IN UINTN Pin
+ );
+
+VOID
+GpioClear (
+ IN UINTN Pin
+ );
+
#endif /* __GPIO_LIB__ */
diff --git a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
index 542b6e8f..716b05be 100644
--- a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
+++ b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
@@ -18,7 +18,7 @@
STATIC
VOID
-GpioFSELModify (
+GpioFSelModify (
IN UINTN RegIndex,
IN UINT32 ModifyMask,
IN UINT32 FunctionMask
@@ -38,6 +38,44 @@ GpioFSELModify (
MmioWrite32 (Reg, Val);
}
+VOID
+GpioSet (
+ IN UINTN Pin
+ )
+{
+ UINT32 Val;
+ EFI_PHYSICAL_ADDRESS Reg;
+ UINT8 RegIndex = Pin / 32;
+ UINT8 SelIndex = Pin % 32;
+
+ Reg = RegIndex * sizeof (UINT32) + GPIO_GPSET0;
+
+ ASSERT (Reg <= GPIO_GPSET1);
+
+ Val = MmioRead32 (Reg);
+ Val |= 1 << SelIndex;
+ MmioWrite32 (Reg, Val);
+}
+
+VOID
+GpioClear (
+ IN UINTN Pin
+ )
+{
+ UINT32 Val;
+ EFI_PHYSICAL_ADDRESS Reg;
+ UINT8 RegIndex = Pin / 32;
+ UINT8 SelIndex = Pin % 32;
+
+ Reg = RegIndex * sizeof (UINT32) + GPIO_GPCLR0;
+
+ ASSERT (Reg <= GPIO_GPCLR1);
+
+ Val = MmioRead32 (Reg);
+ Val |= 1 << SelIndex;
+ MmioWrite32 (Reg, Val);
+}
+
VOID
GpioPinFuncSet (
IN UINTN Pin,
@@ -57,7 +95,7 @@ GpioPinFuncSet (
ModifyMask = GPIO_FSEL_MASK << (SelIndex * GPIO_FSEL_BITS_PER_PIN);
FunctionMask = Function << (SelIndex * GPIO_FSEL_BITS_PER_PIN);
- GpioFSELModify (RegIndex, ModifyMask, FunctionMask);
+ GpioFSelModify (RegIndex, ModifyMask, FunctionMask);
}
UINTN
--
2.17.1
next reply other threads:[~2020-05-10 21:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-10 21:36 Andrei Warkentin [this message]
2020-05-10 21:38 ` [edk2-platforms][PATCH 1/1] RPi: add Gpio output set/clear functions to GpioLib Ard Biesheuvel
2020-05-11 17:02 ` [edk2-devel] " Andrei Warkentin
2020-05-12 8:12 ` Ard Biesheuvel
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=20200510213650.12829-1-andrey.warkentin@gmail.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