[Linaro-uefi,v2,5/9] Platforms/Hisilicon/HiKey: support GPIO controller

Message ID 1486649511-4149-6-git-send-email-haojian.zhuang@linaro.org
State New
Headers show
Series
  • enable Android Fastboot App on Hikey
Related show

Commit Message

Haojian Zhuang Feb. 9, 2017, 2:11 p.m.
Support PL061 GPIO controller on HiKey platform.

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

Comments

Leif Lindholm Feb. 10, 2017, 10:45 a.m. | #1
On Thu, Feb 09, 2017 at 10:11:47PM +0800, Haojian Zhuang wrote:
> Support PL061 GPIO controller on HiKey platform.

I don't feel this accurately describes what this patch does.

> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> ---
>  .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c    | 68 ++++++++++++++++++++++
>  .../Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf  | 37 ++++++++++++
>  2 files changed, 105 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..9e7a895
> --- /dev/null
> +++ b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
> @@ -0,0 +1,68 @@
> +/** @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 <Library/UefiBootServicesTableLib.h>
> +
> +#include <Protocol/EmbeddedGpio.h>
> +
> +GPIO_CONTROLLER gGpioDevice[]= {
> +  { 0xf8011000, 0, 8 },    // GPIO0
> +  { 0xf8012000, 8, 8 },    // GPIO1
> +  { 0xf8013000, 16, 8 },   // GPIO2
> +  { 0xf8014000, 24, 8 },   // GPIO3
> +  { 0xf7020000, 32, 8 },   // GPIO4
> +  { 0xf7021000, 40, 8 },   // GPIO5
> +  { 0xf7022000, 48, 8 },   // GPIO6
> +  { 0xf7023000, 56, 8 },   // GPIO7
> +  { 0xf7024000, 64, 8 },   // GPIO8
> +  { 0xf7025000, 72, 8 },   // GPIO9
> +  { 0xf7026000, 80, 8 },   // GPIO10
> +  { 0xf7027000, 88, 8 },   // GPIO11
> +  { 0xf7028000, 96, 8 },   // GPIO12
> +  { 0xf7029000, 104, 8 },  // GPIO13
> +  { 0xf702a000, 112, 8 },  // GPIO14
> +  { 0xf702b000, 120, 8 },  // GPIO15
> +  { 0xf702c000, 128, 8 },  // GPIO16
> +  { 0xf702d000, 136, 8 },  // GPIO17
> +  { 0xf702e000, 144, 8 },  // GPIO18
> +  { 0xf702f000, 152, 8 }   // GPIO19

No magic values please, add as #defines.

> +};
> +
> +PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
> +  160, 20, gGpioDevice

No magic values please. Add as #defines.

> +};
> +
> +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(

     Status = gBS->InstallMultipleProtocolInterfaces (

> +                  &Handle,
> +                  &gPlatformGpioProtocolGuid, &gPlatformGpioDevice,
> +                  NULL
> +                 );
> +  if (EFI_ERROR(Status)) {

     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..65aa5da
> --- /dev/null
> +++ b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
> @@ -0,0 +1,37 @@
> +#
> +#  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]
> +  EmbeddedPkg/EmbeddedPkg.dec
> +  MdePkg/MdePkg.dec
> +  OpenPlatformPkg/Platforms/Hisilicon/HiKey/HiKey.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  UefiDriverEntryPoint
> +
> +[Protocols]
> +  gPlatformGpioProtocolGuid
> +
> +[Depex]
> +  TRUE
> -- 
> 2.7.4
>

Patch hide | download patch | download mbox

diff --git a/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
new file mode 100644
index 0000000..9e7a895
--- /dev/null
+++ b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.c
@@ -0,0 +1,68 @@ 
+/** @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 <Library/UefiBootServicesTableLib.h>
+
+#include <Protocol/EmbeddedGpio.h>
+
+GPIO_CONTROLLER gGpioDevice[]= {
+  { 0xf8011000, 0, 8 },    // GPIO0
+  { 0xf8012000, 8, 8 },    // GPIO1
+  { 0xf8013000, 16, 8 },   // GPIO2
+  { 0xf8014000, 24, 8 },   // GPIO3
+  { 0xf7020000, 32, 8 },   // GPIO4
+  { 0xf7021000, 40, 8 },   // GPIO5
+  { 0xf7022000, 48, 8 },   // GPIO6
+  { 0xf7023000, 56, 8 },   // GPIO7
+  { 0xf7024000, 64, 8 },   // GPIO8
+  { 0xf7025000, 72, 8 },   // GPIO9
+  { 0xf7026000, 80, 8 },   // GPIO10
+  { 0xf7027000, 88, 8 },   // GPIO11
+  { 0xf7028000, 96, 8 },   // GPIO12
+  { 0xf7029000, 104, 8 },  // GPIO13
+  { 0xf702a000, 112, 8 },  // GPIO14
+  { 0xf702b000, 120, 8 },  // GPIO15
+  { 0xf702c000, 128, 8 },  // GPIO16
+  { 0xf702d000, 136, 8 },  // GPIO17
+  { 0xf702e000, 144, 8 },  // GPIO18
+  { 0xf702f000, 152, 8 }   // GPIO19
+};
+
+PLATFORM_GPIO_CONTROLLER gPlatformGpioDevice = {
+  160, 20, 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..65aa5da
--- /dev/null
+++ b/Platforms/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
@@ -0,0 +1,37 @@ 
+#
+#  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]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  OpenPlatformPkg/Platforms/Hisilicon/HiKey/HiKey.dec
+
+[LibraryClasses]
+  DebugLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gPlatformGpioProtocolGuid
+
+[Depex]
+  TRUE