diff mbox series

[Linaro-uefi,v4,3/5] Platforms/Hisilicon/HiKey: support all GPIO controller

Message ID 1487170499-22374-4-git-send-email-haojian.zhuang@linaro.org
State New
Headers show
Series add drivers for Android Fastboot App on HiKey | expand

Commit Message

Haojian Zhuang Feb. 15, 2017, 2:54 p.m. UTC
Enable all PL061 GPIO controllers on HiKey platform. Without this,
only one PL061 GPIO controller could be supported on HiKey platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c    | 96 ++++++++++++++++++++++
 .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  | 38 +++++++++
 2 files changed, 134 insertions(+)
 create mode 100644 Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
 create mode 100644 Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf

Comments

Leif Lindholm March 1, 2017, 2:36 p.m. UTC | #1
On Wed, Feb 15, 2017 at 10:54:57PM +0800, Haojian Zhuang wrote:
> Enable all PL061 GPIO controllers on HiKey platform. Without this,
> only one PL061 GPIO controller could be supported on HiKey platform.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

> ---
>  .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c    | 96 ++++++++++++++++++++++
>  .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  | 38 +++++++++
>  2 files changed, 134 insertions(+)
>  create mode 100644 Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
>  create mode 100644 Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
> 
> diff --git a/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
> new file mode 100644
> index 0000000..4a2943c
> --- /dev/null
> +++ b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
> @@ -0,0 +1,96 @@
> +/** @file
> +*
> +*  Copyright (c) 2015-2017, Linaro. All rights reserved.
> +*
> +*  This program and the accompanying materials
> +*  are licensed and made available under the terms and conditions of the BSD License
> +*  which accompanies this distribution.  The full text of the license may be found at
> +*  http://opensource.org/licenses/bsd-license.php
> +*
> +*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +*
> +**/
> +
> +#include <Drivers/PL061Gpio.h>
> +
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +#include <Protocol/EmbeddedGpio.h>
> +
> +#include <Hi6220.h>
> +
> +#define GPIO0_CTRL_PIN_BASE                (0 * PL061_GPIO_PINS)
> +#define GPIO1_CTRL_PIN_BASE                (1 * PL061_GPIO_PINS)
> +#define GPIO2_CTRL_PIN_BASE                (2 * PL061_GPIO_PINS)
> +#define GPIO3_CTRL_PIN_BASE                (3 * PL061_GPIO_PINS)
> +#define GPIO4_CTRL_PIN_BASE                (4 * PL061_GPIO_PINS)
> +#define GPIO5_CTRL_PIN_BASE                (5 * PL061_GPIO_PINS)
> +#define GPIO6_CTRL_PIN_BASE                (6 * PL061_GPIO_PINS)
> +#define GPIO7_CTRL_PIN_BASE                (7 * PL061_GPIO_PINS)
> +#define GPIO8_CTRL_PIN_BASE                (8 * PL061_GPIO_PINS)
> +#define GPIO9_CTRL_PIN_BASE                (9 * PL061_GPIO_PINS)
> +#define GPIO10_CTRL_PIN_BASE               (10 * PL061_GPIO_PINS)
> +#define GPIO11_CTRL_PIN_BASE               (11 * PL061_GPIO_PINS)
> +#define GPIO12_CTRL_PIN_BASE               (12 * PL061_GPIO_PINS)
> +#define GPIO13_CTRL_PIN_BASE               (13 * PL061_GPIO_PINS)
> +#define GPIO14_CTRL_PIN_BASE               (14 * PL061_GPIO_PINS)
> +#define GPIO15_CTRL_PIN_BASE               (15 * PL061_GPIO_PINS)
> +#define GPIO16_CTRL_PIN_BASE               (16 * PL061_GPIO_PINS)
> +#define GPIO17_CTRL_PIN_BASE               (17 * PL061_GPIO_PINS)
> +#define GPIO18_CTRL_PIN_BASE               (18 * PL061_GPIO_PINS)
> +#define GPIO19_CTRL_PIN_BASE               (19 * PL061_GPIO_PINS)
> +
> +#define GPIO_CTRL_NUMS                     20
> +#define GPIO_PIN_NUMS                      (GPIO_CTRL_NUMS * PL061_GPIO_PINS)
> +
> +GPIO_CONTROLLER gGpioDevice[]= {
> +  { GPIO0_CTRL_BASE,  GPIO0_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO1_CTRL_BASE,  GPIO1_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO2_CTRL_BASE,  GPIO2_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO3_CTRL_BASE,  GPIO3_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO4_CTRL_BASE,  GPIO4_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO5_CTRL_BASE,  GPIO5_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO6_CTRL_BASE,  GPIO6_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO7_CTRL_BASE,  GPIO7_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO8_CTRL_BASE,  GPIO8_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO9_CTRL_BASE,  GPIO9_CTRL_PIN_BASE,  PL061_GPIO_PINS },
> +  { GPIO10_CTRL_BASE, GPIO10_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO11_CTRL_BASE, GPIO11_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO12_CTRL_BASE, GPIO12_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO13_CTRL_BASE, GPIO13_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO14_CTRL_BASE, GPIO14_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO15_CTRL_BASE, GPIO15_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO16_CTRL_BASE, GPIO16_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO17_CTRL_BASE, GPIO17_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO18_CTRL_BASE, GPIO18_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +  { GPIO19_CTRL_BASE, GPIO19_CTRL_PIN_BASE, PL061_GPIO_PINS },
> +};
> +
> +PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
> +  GPIO_PIN_NUMS, GPIO_CTRL_NUMS, gGpioDevice
> +};
> +
> +EFI_STATUS
> +EFIAPI
> +HiKeyGpioEntryPoint (
> +  IN EFI_HANDLE         ImageHandle,
> +  IN EFI_SYSTEM_TABLE   *SystemTable
> +  )
> +{
> +  EFI_STATUS  Status;
> +  EFI_HANDLE  Handle;
> +
> +  // Install the Embedded Platform GPIO Protocol onto a new handle
> +  Handle = NULL;
> +  Status = gBS->InstallMultipleProtocolInterfaces (
> +                  &Handle,
> +                  &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
> +                  NULL
> +                 );
> +  if (EFI_ERROR (Status)) {
> +    Status = EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  return Status;
> +}
> diff --git a/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
> new file mode 100644
> index 0000000..d69c6f4
> --- /dev/null
> +++ b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
> @@ -0,0 +1,38 @@
> +#
> +#  Copyright (c) 2015-2017, Linaro. All rights reserved.
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD License
> +#  which accompanies this distribution.  The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010019
> +  BASE_NAME                      = HiKeyGpio
> +  FILE_GUID                      = b51a851c-7bf7-463f-b261-cfb158b7f699
> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = HiKeyGpioEntryPoint
> +
> +[Sources.common]
> +  HiKeyGpioDxe.c
> +
> +[Packages]
> +  ArmPlatformPkg/ArmPlatformPkg.dec
> +  EmbeddedPkg/EmbeddedPkg.dec
> +  MdePkg/MdePkg.dec
> +  OpenPlatformPkg/Platforms/Hisilicon/HiKey/HiKey.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  UefiDriverEntryPoint
> +
> +[Protocols]
> +  gPlatformGpioProtocolGuid
> +
> +[Depex]
> +  TRUE
> -- 
> 2.7.4
>
diff mbox series

Patch

diff --git a/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
new file mode 100644
index 0000000..4a2943c
--- /dev/null
+++ b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
@@ -0,0 +1,96 @@ 
+/** @file
+*
+*  Copyright (c) 2015-2017, Linaro. All rights reserved.
+*
+*  This program and the accompanying materials
+*  are licensed and made available under the terms and conditions of the BSD License
+*  which accompanies this distribution.  The full text of the license may be found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include <Drivers/PL061Gpio.h>
+
+#include <Library/UefiBootServicesTableLib.h>
+
+#include <Protocol/EmbeddedGpio.h>
+
+#include <Hi6220.h>
+
+#define GPIO0_CTRL_PIN_BASE                (0 * PL061_GPIO_PINS)
+#define GPIO1_CTRL_PIN_BASE                (1 * PL061_GPIO_PINS)
+#define GPIO2_CTRL_PIN_BASE                (2 * PL061_GPIO_PINS)
+#define GPIO3_CTRL_PIN_BASE                (3 * PL061_GPIO_PINS)
+#define GPIO4_CTRL_PIN_BASE                (4 * PL061_GPIO_PINS)
+#define GPIO5_CTRL_PIN_BASE                (5 * PL061_GPIO_PINS)
+#define GPIO6_CTRL_PIN_BASE                (6 * PL061_GPIO_PINS)
+#define GPIO7_CTRL_PIN_BASE                (7 * PL061_GPIO_PINS)
+#define GPIO8_CTRL_PIN_BASE                (8 * PL061_GPIO_PINS)
+#define GPIO9_CTRL_PIN_BASE                (9 * PL061_GPIO_PINS)
+#define GPIO10_CTRL_PIN_BASE               (10 * PL061_GPIO_PINS)
+#define GPIO11_CTRL_PIN_BASE               (11 * PL061_GPIO_PINS)
+#define GPIO12_CTRL_PIN_BASE               (12 * PL061_GPIO_PINS)
+#define GPIO13_CTRL_PIN_BASE               (13 * PL061_GPIO_PINS)
+#define GPIO14_CTRL_PIN_BASE               (14 * PL061_GPIO_PINS)
+#define GPIO15_CTRL_PIN_BASE               (15 * PL061_GPIO_PINS)
+#define GPIO16_CTRL_PIN_BASE               (16 * PL061_GPIO_PINS)
+#define GPIO17_CTRL_PIN_BASE               (17 * PL061_GPIO_PINS)
+#define GPIO18_CTRL_PIN_BASE               (18 * PL061_GPIO_PINS)
+#define GPIO19_CTRL_PIN_BASE               (19 * PL061_GPIO_PINS)
+
+#define GPIO_CTRL_NUMS                     20
+#define GPIO_PIN_NUMS                      (GPIO_CTRL_NUMS * PL061_GPIO_PINS)
+
+GPIO_CONTROLLER gGpioDevice[]= {
+  { GPIO0_CTRL_BASE,  GPIO0_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO1_CTRL_BASE,  GPIO1_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO2_CTRL_BASE,  GPIO2_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO3_CTRL_BASE,  GPIO3_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO4_CTRL_BASE,  GPIO4_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO5_CTRL_BASE,  GPIO5_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO6_CTRL_BASE,  GPIO6_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO7_CTRL_BASE,  GPIO7_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO8_CTRL_BASE,  GPIO8_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO9_CTRL_BASE,  GPIO9_CTRL_PIN_BASE,  PL061_GPIO_PINS },
+  { GPIO10_CTRL_BASE, GPIO10_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO11_CTRL_BASE, GPIO11_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO12_CTRL_BASE, GPIO12_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO13_CTRL_BASE, GPIO13_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO14_CTRL_BASE, GPIO14_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO15_CTRL_BASE, GPIO15_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO16_CTRL_BASE, GPIO16_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO17_CTRL_BASE, GPIO17_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO18_CTRL_BASE, GPIO18_CTRL_PIN_BASE, PL061_GPIO_PINS },
+  { GPIO19_CTRL_BASE, GPIO19_CTRL_PIN_BASE, PL061_GPIO_PINS },
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  GPIO_PIN_NUMS, GPIO_CTRL_NUMS, gGpioDevice
+};
+
+EFI_STATUS
+EFIAPI
+HiKeyGpioEntryPoint (
+  IN EFI_HANDLE         ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  Handle;
+
+  // Install the Embedded Platform GPIO Protocol onto a new handle
+  Handle = NULL;
+  Status = gBS->InstallMultipleProtocolInterfaces (
+                  &Handle,
+                  &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
+                  NULL
+                 );
+  if (EFI_ERROR (Status)) {
+    Status = EFI_OUT_OF_RESOURCES;
+  }
+
+  return Status;
+}
diff --git a/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
new file mode 100644
index 0000000..d69c6f4
--- /dev/null
+++ b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
@@ -0,0 +1,38 @@ 
+#
+#  Copyright (c) 2015-2017, Linaro. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution.  The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+[Defines]
+  INF_VERSION                    = 0x00010019
+  BASE_NAME                      = HiKeyGpio
+  FILE_GUID                      = b51a851c-7bf7-463f-b261-cfb158b7f699
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = HiKeyGpioEntryPoint
+
+[Sources.common]
+  HiKeyGpioDxe.c
+
+[Packages]
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  OpenPlatformPkg/Platforms/Hisilicon/HiKey/HiKey.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gPlatformGpioProtocolGuid
+
+[Depex]
+  TRUE