Re: [edk2] [PATCH v6 edk2-platforms 5/6] Platform/HiKey: do basic initialization on hikey

2018-05-25 Thread Leif Lindholm
On Thu, May 24, 2018 at 08:46:29AM +0800, Haojian Zhuang wrote:
> Do some basic initialization on HiKey platform, such as pin
> setting, regulators and making peripherals out of reset mode.
> 
> Cc: Leif Lindholm 
> Cc: Ard Biesheuvel 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Haojian Zhuang 
> ---
>  Platform/Hisilicon/HiKey/HiKey.dsc|   3 +
>  Platform/Hisilicon/HiKey/HiKey.fdf|   3 +
>  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf|  40 
>  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h  |  31 ++
>  Silicon/Hisilicon/Hi6220/Include/Hi6220.h |   6 ++
>  Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h |  50 ++
>  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c  | 102 
>  7 files changed, 235 insertions(+)
> 
> diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
> b/Platform/Hisilicon/HiKey/HiKey.dsc
> index 5c1604d7f689..5cc4ff27f01b 100644
> --- a/Platform/Hisilicon/HiKey/HiKey.dsc
> +++ b/Platform/Hisilicon/HiKey/HiKey.dsc
> @@ -189,8 +189,11 @@ [Components.common]
>#
># GPIO
>#
> +  Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
>ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
>  
> +  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
> +
>#
># MMC/SD
>#
> diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
> b/Platform/Hisilicon/HiKey/HiKey.fdf
> index 2a5c5a4d6e79..39020d27dbcd 100644
> --- a/Platform/Hisilicon/HiKey/HiKey.fdf
> +++ b/Platform/Hisilicon/HiKey/HiKey.fdf
> @@ -120,8 +120,11 @@ [FV.FvMain]
>#
># GPIO
>#
> +  INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
>INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
>  
> +  INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
> +
>#
># Multimedia Card Interface
>#
> diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf 
> b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
> new file mode 100644
> index ..34734391b45a
> --- /dev/null
> +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
> @@ -0,0 +1,40 @@
> +#
> +#  Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.
> +#  Copyright (c) 2018, Linaro Ltd. 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= 0x0001001a
> +  BASE_NAME  = HiKeyDxe
> +  FILE_GUID  = f567684b-1089-4214-8881-d64b20cbda2f
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  ENTRY_POINT= HiKeyEntryPoint
> +
> +[Sources.common]
> +  HiKeyDxe.c
> +
> +[Packages]
> +  EmbeddedPkg/EmbeddedPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  IoLib
> +  UefiLib
> +  UefiDriverEntryPoint
> +
> +[Guids]
> +  gEfiEndOfDxeEventGroupGuid
> +
> +[Depex]
> +  TRUE
> diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h 
> b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
> new file mode 100644
> index ..07f9ae6a949a
> --- /dev/null
> +++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
> @@ -0,0 +1,31 @@
> +/** @file
> +*
> +*  Copyright (c) 2018, Linaro Ltd. 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.
> +*
> +**/
> +
> +#ifndef __HIKEYDXE_H__
> +#define __HIKEYDXE_H__
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 

Like 2/6 please include only files needed by declarations in the
.h file itself, let the .c file make its own includes.

/
Leif

> +
> +#define DETECT_J15_FASTBOOT  24   // GPIO3_0
> +
> +#define ADB_REBOOT_ADDRESS   0x05F01000
> +#define ADB_REBOOT_BOOTLOADER0x77665500
> +#define ADB_REBOOT_NONE  0x77665501
> +
> +#endif /* __HIKEYDXE_H__ */
> diff --git a/Silicon/Hisilicon/Hi6220/Include/Hi6220.h 
> b/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
> index 203424adfc8b..9b2508955772 100644
> --- a/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
> +++ 

[edk2] [PATCH v6 edk2-platforms 5/6] Platform/HiKey: do basic initialization on hikey

2018-05-23 Thread Haojian Zhuang
Do some basic initialization on HiKey platform, such as pin
setting, regulators and making peripherals out of reset mode.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang 
---
 Platform/Hisilicon/HiKey/HiKey.dsc|   3 +
 Platform/Hisilicon/HiKey/HiKey.fdf|   3 +
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf|  40 
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h  |  31 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220.h |   6 ++
 Silicon/Hisilicon/Hi6220/Include/Hi6220RegsPeri.h |  50 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c  | 102 
 7 files changed, 235 insertions(+)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc 
b/Platform/Hisilicon/HiKey/HiKey.dsc
index 5c1604d7f689..5cc4ff27f01b 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -189,8 +189,11 @@ [Components.common]
   #
   # GPIO
   #
+  Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # MMC/SD
   #
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf 
b/Platform/Hisilicon/HiKey/HiKey.fdf
index 2a5c5a4d6e79..39020d27dbcd 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -120,8 +120,11 @@ [FV.FvMain]
   #
   # GPIO
   #
+  INF Platform/Hisilicon/HiKey/HiKeyGpioDxe/HiKeyGpioDxe.inf
   INF ArmPlatformPkg/Drivers/PL061GpioDxe/PL061GpioDxe.inf
 
+  INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+
   #
   # Multimedia Card Interface
   #
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
new file mode 100644
index ..34734391b45a
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
@@ -0,0 +1,40 @@
+#
+#  Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.
+#  Copyright (c) 2018, Linaro Ltd. 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= 0x0001001a
+  BASE_NAME  = HiKeyDxe
+  FILE_GUID  = f567684b-1089-4214-8881-d64b20cbda2f
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= HiKeyEntryPoint
+
+[Sources.common]
+  HiKeyDxe.c
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  IoLib
+  UefiLib
+  UefiDriverEntryPoint
+
+[Guids]
+  gEfiEndOfDxeEventGroupGuid
+
+[Depex]
+  TRUE
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h 
b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
new file mode 100644
index ..07f9ae6a949a
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.h
@@ -0,0 +1,31 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro Ltd. 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.
+*
+**/
+
+#ifndef __HIKEYDXE_H__
+#define __HIKEYDXE_H__
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define DETECT_J15_FASTBOOT  24   // GPIO3_0
+
+#define ADB_REBOOT_ADDRESS   0x05F01000
+#define ADB_REBOOT_BOOTLOADER0x77665500
+#define ADB_REBOOT_NONE  0x77665501
+
+#endif /* __HIKEYDXE_H__ */
diff --git a/Silicon/Hisilicon/Hi6220/Include/Hi6220.h 
b/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
index 203424adfc8b..9b2508955772 100644
--- a/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
+++ b/Silicon/Hisilicon/Hi6220/Include/Hi6220.h
@@ -23,6 +23,12 @@
 #define HI6220_PERIPH_BASE  0xF400
 #define HI6220_PERIPH_SZ0x0580
 
+#define IOMG_BASE   0xF701
+#define IOMG_080_REG(IOMG_BASE + 0x140)
+
+#define IOCG_BASE   0xF7010800
+#define IOCG_084_REG(IOCG_BASE + 0x150)
+
 #define PERI_CTRL_BASE  0xF703
 #define