[edk2-devel] [PATCH v4 2/3] Silicon/Broadcom/Bcm283x: Clean up GpioPinSet function

Sunny Wang Sunny.Wang at arm.com
Mon Jun 7 07:53:38 UTC 2021


Make the changes below for making it clearer.
    - Rename GpioPinSet() to GpioPinConfigure()
    - Rename parameter Val to Config and change its type to BOOLEAN

Cc: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud at arm.com>
Cc: Sami Mujawar <sami.mujawar at arm.com>
Cc: Jeremy Linton <jeremy.linton at arm.com>
Cc: Pete Batard <pete at akeo.ie>
Cc: Ard Biesheuvel <ardb+tianocore at kernel.org>
Cc: Mario Bălănică <mariobalanica02 at gmail.com>
Signed-off-by: Sunny Wang <sunny.wang at arm.com>
---
 Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h | 10 +++++++---
 Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c |  9 +++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
index 75c2c8be51..1f7d2204e0 100644
--- a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
+++ b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
@@ -3,6 +3,7 @@
  *  GPIO manipulation.
  *
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin at gmail.com>
+ *  Copyright (c) 2021, ARM Limited. All rights reserved.
  *
  *  SPDX-License-Identifier: BSD-2-Clause-Patent
  *
@@ -13,6 +14,9 @@
 
 #include <IndustryStandard/Bcm2836Gpio.h>
 
+#define CLEAR_GPIO    0
+#define SET_GPIO      1
+
 VOID
 GpioPinFuncSet (
   IN  UINTN Pin,
@@ -25,9 +29,9 @@ GpioPinFuncGet (
   );
 
 VOID
-GpioPinSet (
-  IN  UINTN Pin,
-  IN  UINTN Val
+GpioPinConfigure (
+  IN  UINTN   Pin,
+  IN  BOOLEAN Config
   );
 
 UINTN
diff --git a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
index a4b4af59eb..eaf53e5369 100644
--- a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
+++ b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
@@ -4,6 +4,7 @@
  *
  *  Copyright (c) 2020, Pete Batard <pete at akeo.ie>
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin at gmail.com>
+ *  Copyright (c) 2021, ARM Limited. All rights reserved.
  *
  *  SPDX-License-Identifier: BSD-2-Clause-Patent
  *
@@ -85,9 +86,9 @@ GpioPinFuncGet (
 }
 
 VOID
-GpioPinSet (
-  IN  UINTN Pin,
-  IN  UINTN Val
+GpioPinConfigure (
+  IN  UINTN   Pin,
+  IN  BOOLEAN Config
   )
 {
   EFI_PHYSICAL_ADDRESS Reg;
@@ -102,7 +103,7 @@ GpioPinSet (
   //
   // Different base addresses are used for clear and set
   //
-  Reg = (Val == 0) ? GPIO_GPCLR0 : GPIO_GPSET0;
+  Reg = (Config == CLEAR_GPIO) ? GPIO_GPCLR0 : GPIO_GPSET0;
   Reg += RegIndex * sizeof (UINT32);
   MmioWrite32 (Reg, 1 << SelIndex);
 }
-- 
2.31.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76117): https://edk2.groups.io/g/devel/message/76117
Mute This Topic: https://groups.io/mt/83365132/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list