Skip to contentSkip to conversation

Add support for hi6220 SoC and HiKey 96boards CE board.

PATCH Superseded Peter Griffin 5 participants 23 messages Jul 8, 2015 – Jul 29, 2015

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for hi6220 SoC and HiKey 96boards CE board.

Hi Folks,

This series adds support for the first 96boards consumer edition HiKey board.

More information can be found about this board at the following link
https://www.96boards.org/products/hikey/.

This initial port adds support for: -
1) Serial
2) eMMC and sd card
3) USB
4) GPIO

It has been tested with Arm Trusted Firmware running u-boot as the BL33 executable.

Some instructions on exactly how to compile everything (l-loader,
with Arm Trusted Firmware, which then loads u-boot) is documented in the README found in the board/hisilicon/hikey directory.

A basic SoC datasheet can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf

Board schematic can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
96Boards-Hikey-Rev-A1.pdf

A rather pleasant side effect of rebasing to v2015.07-rc2 is that the two main bugs with the v1 series (that I new about at least) are resolved. DHCP now works correctly, and USB mass storage devices are also enumerated).

I had a quick look at migrating the gpio driver over to DT like Simon suggested. Currently there is a bug in fdtdec_get_addr() for 64bit platforms which I ran into. See patch from Thierry here http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/215346

Also I'm not sure on the protocol here, but the DT nodes for the gpio controller aren't yet present in upstream Linux kernel, so I think it would be better to wait until they are, so that u-boot and kernel DT don't diverge. Migrating over to DT at that point should then be fairly trivial.

Changes since v1:
- Rename vendor to hisilicon not 96boards (Rob)
- Get rid of aemv8a vexpress leftover (Rob)
- Remove __weak on misc_init_r (Rob)
- Remove unnecessary LINUX_BOOT_PARAM_ADDR (Rob)
- COUNTER_FREQUENCY in decimal to avoid comment (Rob)
- Remove leftover V2M* from vexpress (Rob)
- Migrate configs/hikey.h over to use config_distro_defaults.h (Rob)
- Remove custom u-boot prompt (Rob)
- Enable icache
- Remove custom delay function, as mdelay/udelay work fine (Rob)
- Update CONFIG_SYS_LOAD_ADDR to 0x80000 (Rob)

- Use suggested macro for declaring gpio addresses (Marek)
- Zap dead Macros (Marek)
- Use calloc instead of malloc (Marek)

- Reduce PHYS_RAM by 16Mb to accomodate OPTEE in latest ATF code (Peter)
- Rebase on v2015.07-rc2 (Peter)
- Add CONFIG_NET=y so that env callbacks work (Peter)

- Add a README on how to build / flash u-boot (Simon)

kind regards,

Peter.

Peter Griffin (6):
dm: gpio: hi6220: Add a hi6220 GPIO driver model driver.
ARM: hi6220: Add register and bitfield definition header files.
hi6553: Add register definition and bitfield header for 6553 pmic
mmc: hi6220_dw_mmc: Add hi6220 glue code for dw_mmc controller.
ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey
board.
ARM64: hikey: Add a README for this board.

 arch/arm/Kconfig                                   |   8 +
 arch/arm/include/asm/arch-hi6220/dwmmc.h           |   8 +
 arch/arm/include/asm/arch-hi6220/gpio.h            |  29 ++
 arch/arm/include/asm/arch-hi6220/hi6220.h          | 324 ++++++++++++++++
 .../include/asm/arch-hi6220/hi6220_regs_alwayson.h | 349 +++++++++++++++++
 arch/arm/include/asm/arch-hi6220/hi6553.h          |  75 ++++
 board/hisilicon/hikey/Kconfig                      |  15 +
 board/hisilicon/hikey/Makefile                     |   8 +
 board/hisilicon/hikey/README                       | 160 ++++++++
 board/hisilicon/hikey/hikey.c                      | 415 +++++++++++++++++++++
 configs/hikey_defconfig                            |   5 +
 drivers/gpio/Makefile                              |   2 +
 drivers/gpio/hi6220_gpio.c                         |  95 +++++
 drivers/mmc/Makefile                               |   1 +
 drivers/mmc/hi6220_dw_mmc.c                        |  56 +++
 include/configs/hikey.h                            | 168 +++++++++
 16 files changed, 1718 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/dwmmc.h
 create mode 100644 arch/arm/include/asm/arch-hi6220/gpio.h
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6220.h
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6220_regs_alwayson.h
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6553.h
 create mode 100644 board/hisilicon/hikey/Kconfig
 create mode 100644 board/hisilicon/hikey/Makefile
 create mode 100644 board/hisilicon/hikey/README
 create mode 100644 board/hisilicon/hikey/hikey.c
 create mode 100644 configs/hikey_defconfig
 create mode 100644 drivers/gpio/hi6220_gpio.c
 create mode 100644 drivers/mmc/hi6220_dw_mmc.c
 create mode 100644 include/configs/hikey.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/6 dm: gpio: hi6220: Add a hi6220 GPIO driver model driver.

This patch adds support for the GPIO perif found on hi6220 SoC.

---
 arch/arm/include/asm/arch-hi6220/gpio.h | 29 ++++++++++
 drivers/gpio/Makefile                   |  2 +
 drivers/gpio/hi6220_gpio.c              | 95 +++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/gpio.h
 create mode 100644 drivers/gpio/hi6220_gpio.c
arch/arm/include/asm/arch-hi6220/gpio.h new file +29 -0
new file mode 100644
index 0000000..98122a2
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _HI6220_GPIO_H_
+#define _HI6220_GPIO_H_
+
+#define HI6220_GPIO_BASE(bank)	(((bank < 4) ? 0xf8011000 : \
+				0xf7020000 - 0x4000) + (0x1000 * bank))
+
+#define BIT(x)			(1 << (x))
+
+#define HI6220_GPIO_PER_BANK	8
+#define HI6220_GPIO_DIR		0x400
+
+struct gpio_bank {
+	u8 *base;	/* address of registers in physical memory */
+};
+
+/* Information about a GPIO bank */
+struct hikey_gpio_platdata {
+	int bank_index;
+	unsigned int base;     /* address of registers in physical memory */
+};
+
+#endif /* _HI6220_GPIO_H_ */
drivers/gpio/Makefile +2 -0
index 5864850..b470bab 100644
@@ -46,3 +46,5 @@ obj-$(CONFIG_LPC32XX_GPIO)	+= lpc32xx_gpio.o
 obj-$(CONFIG_STM32_GPIO)	+= stm32_gpio.o
 obj-$(CONFIG_ZYNQ_GPIO)		+= zynq_gpio.o
 obj-$(CONFIG_VYBRID_GPIO)	+= vybrid_gpio.o
+obj-$(CONFIG_HIKEY_GPIO)	+= hi6220_gpio.o
+
drivers/gpio/hi6220_gpio.c new file +95 -0

95 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/6 dm: gpio: hi6220: Add a hi6220 GPIO driver model driver.

Hi Peter,

Quoted 22 lines · Peter Griffin

This patch adds support for the GPIO perif found on hi6220 SoC.

---
 arch/arm/include/asm/arch-hi6220/gpio.h | 29 ++++++++++
 drivers/gpio/Makefile                   |  2 +
 drivers/gpio/hi6220_gpio.c              | 95 +++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/gpio.h
 create mode 100644 drivers/gpio/hi6220_gpio.c
arch/arm/include/asm/arch-hi6220/gpio.h new file +4 -0
new file mode 100644
index 0000000..98122a2
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *

arch/arm/include/asm/arch-hi6220/gpio.h line 14

Quoted 10 lines
arch/arm/include/asm/arch-hi6220/gpio.h new file +10 -0
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _HI6220_GPIO_H_
+#define _HI6220_GPIO_H_
+
+#define HI6220_GPIO_BASE(bank) (((bank < 4) ? 0xf8011000 : \
+                               0xf7020000 - 0x4000) + (0x1000 * bank))
+
+#define BIT(x)                 (1 << (x))

I thought we had this in U-Boot now but cannot find it.

arch/arm/include/asm/arch-hi6220/gpio.h line 21

Quoted 7 lines
arch/arm/include/asm/arch-hi6220/gpio.h new file +7 -0
+
+#define HI6220_GPIO_PER_BANK   8
+#define HI6220_GPIO_DIR                0x400
+
+struct gpio_bank {
+       u8 *base;       /* address of registers in physical memory */
+};

We should use a C struct to access registers. See here:

http://www.denx.de/wiki/U-Boot/CodingStyle

Quoted 35 lines
arch/arm/include/asm/arch-hi6220/gpio.h new file +8 -0
+
+/* Information about a GPIO bank */
+struct hikey_gpio_platdata {
+       int bank_index;
+       unsigned int base;     /* address of registers in physical memory */
+};
+
+#endif /* _HI6220_GPIO_H_ */
drivers/gpio/Makefile +2 -0
index 5864850..b470bab 100644
@@ -46,3 +46,5 @@ obj-$(CONFIG_LPC32XX_GPIO)    += lpc32xx_gpio.o
 obj-$(CONFIG_STM32_GPIO)       += stm32_gpio.o
 obj-$(CONFIG_ZYNQ_GPIO)                += zynq_gpio.o
 obj-$(CONFIG_VYBRID_GPIO)      += vybrid_gpio.o
+obj-$(CONFIG_HIKEY_GPIO)       += hi6220_gpio.o
+
drivers/gpio/hi6220_gpio.c new file +11 -0
new file mode 100644
index 0000000..3f41bff
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <asm/gpio.h>
+#include <asm/io.h>

drivers/gpio/hi6220_gpio.c line 21

Quoted 10 lines
drivers/gpio/hi6220_gpio.c new file +10 -0
+#include <errno.h>
+
+static int hi6220_gpio_direction_input(struct udevice *dev, unsigned int gpio)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+       u8 data;
+
+       data = readb(bank->base + HI6220_GPIO_DIR);
+       data &= ~(1 << gpio);
+       writeb(data, bank->base + HI6220_GPIO_DIR);

Something like this:

clrbits_8(&regs->gpio_dir, 1 << gpio)

drivers/gpio/hi6220_gpio.c line 31

Quoted 10 lines
drivers/gpio/hi6220_gpio.c new file +10 -0
+
+       return 0;
+}
+
+static int hi6220_gpio_set_value(struct udevice *dev, unsigned gpio,
+                                 int value)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+
+       writeb(!!value << gpio, bank->base + (BIT(gpio + 2)));

Ick, use struct access.

Quoted 32 lines
drivers/gpio/hi6220_gpio.c new file +32 -0
+       return 0;
+}
+
+static int hi6220_gpio_direction_output(struct udevice *dev, unsigned gpio,
+                                       int value)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+       u8 data;
+
+       data = readb(bank->base + HI6220_GPIO_DIR);
+       data |= 1 << gpio;
+       writeb(data, bank->base + HI6220_GPIO_DIR);
+
+       hi6220_gpio_set_value(dev, gpio, value);
+
+       return 0;
+}
+
+static int hi6220_gpio_get_value(struct udevice *dev, unsigned gpio)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+
+       return !!readb(bank->base + (BIT(gpio + 2)));
+}
+
+
+
+static const struct dm_gpio_ops gpio_hi6220_ops = {
+       .direction_input        = hi6220_gpio_direction_input,
+       .direction_output       = hi6220_gpio_direction_output,
+       .get_value              = hi6220_gpio_get_value,
+       .set_value              = hi6220_gpio_set_value,

drivers/gpio/hi6220_gpio.c line 73

Quoted 10 lines
drivers/gpio/hi6220_gpio.c new file +10 -0
+};
+
+static int hi6220_gpio_probe(struct udevice *dev)
+{
+       struct gpio_bank *bank = dev_get_priv(dev);
+       struct hikey_gpio_platdata *plat = dev_get_platdata(dev);
+       struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+       char name[18], *str;
+
+       sprintf(name, "GPIO%d_", plat->bank_index);

Could use just use 'GP' or 'P'? This seems quite long as a name. Also I don't think you want the %d.

Quoted 23 lines
drivers/gpio/hi6220_gpio.c new file +22 -1
+
+       str = strdup(name);
+       if (!str)
+               return -ENOMEM;
+
+       uc_priv->bank_name = str;
+       uc_priv->gpio_count = HI6220_GPIO_PER_BANK;
+
+       bank->base = (u8 *)plat->base;
+
+       return 0;
+}
+
+U_BOOT_DRIVER(gpio_hi6220) = {
+       .name   = "gpio_hi6220",
+       .id     = UCLASS_GPIO,
+       .ops    = &gpio_hi6220_ops,
+       .probe  = hi6220_gpio_probe,
+       .priv_auto_alloc_size = sizeof(struct gpio_bank),
+};
+
+
--
Quoted 2 lines

1.9.1

Regards,
Simon

#3 lore raw

PATCH v2 2/6 ARM: hi6220: Add register and bitfield definition header files.

In reply to Peter Griffin

This patch adds the header files which will be used in the subsquent board / drivers to enable support for hi6220 hikey board.

---
 arch/arm/include/asm/arch-hi6220/hi6220.h          | 324 +++++++++++++++++++
 .../include/asm/arch-hi6220/hi6220_regs_alwayson.h | 349 +++++++++++++++++++++
 2 files changed, 673 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6220.h
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6220_regs_alwayson.h
arch/arm/include/asm/arch-hi6220/hi6220.h new file +324 -0
new file mode 100644
index 0000000..3ddec91
@@ -0,0 +1,324 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __HI6220_H__
+#define __HI6220_H__
+
+#include "hi6220_regs_alwayson.h"
+
+#define HI6220_MMC0_BASE			0xF723D000
+#define HI6220_MMC1_BASE			0xF723E000
+
+#define HI6220_PMUSSI_BASE			0xF8000000
+
+#define HI6220_PERI_BASE			0xF7030000
+
+#define PERI_SC_PERIPH_CTRL1			(HI6220_PERI_BASE + 0x000)
+
+#define PERI_CTRL1_ETR_AXI_CSYSREQ_N			(1 << 0)
+#define PERI_CTRL1_HIFI_INT_MASK			(1 << 1)
+#define PERI_CTRL1_HIFI_ALL_INT_MASK			(1 << 2)
+#define PERI_CTRL1_ETR_AXI_CSYSREQ_N_MSK		(1 << 16)
+#define PERI_CTRL1_HIFI_INT_MASK_MSK			(1 << 17)
+#define PERI_CTRL1_HIFI_ALL_INT_MASK_MSK		(1 << 18)
+
+
+#define PERI_SC_PERIPH_CTRL2			(HI6220_PERI_BASE + 0x004)
+
+#define PERI_CTRL2_MMC_CLK_PHASE_BYPASS_EN_MMC0		(1 << 0)
+#define PERI_CTRL2_MMC_CLK_PHASE_BYPASS_EN_MMC1		(1 << 2)
+#define PERI_CTRL2_NAND_SYS_MEM_SEL			(1 << 6)
+#define PERI_CTRL2_G3D_DDRT_AXI_SEL			(1 << 7)
+#define PERI_CTRL2_GU_MDM_BBP_TESTPIN_SEL		(1 << 8)
+#define PERI_CTRL2_CODEC_SSI_MASTER_CHECK		(1 << 9)
+#define PERI_CTRL2_FUNC_TEST_SOFT			(1 << 12)
+#define PERI_CTRL2_CSSYS_TS_ENABLE			(1 << 15)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_EMA			(1 << 16)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_EMAW			(1 << 20)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_EMAS			(1 << 22)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_RET1N			(1 << 26)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_RET2N			(1 << 27)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_PGEN			(1 << 28)
+
+#define PERI_SC_PERIPH_CTRL3			(HI6220_PERI_BASE + 0x008)
+
+#define PERI_CTRL3_HIFI_DDR_HARQMEM_ADDR		(1 << 0)
+#define PERI_CTRL3_HIFI_HARQMEMRMP_EN			(1 << 12)
+#define PERI_CTRL3_HARQMEM_SYS_MED_SEL			(1 << 13)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP1			(1 << 14)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP2			(1 << 16)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP3			(1 << 18)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP4			(1 << 20)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP5			(1 << 22)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP6			(1 << 24)
+
+#define PERI_SC_PERIPH_CTRL4			(HI6220_PERI_BASE + 0x00c)
+
+#define PERI_CTRL4_PICO_FSELV				(1 << 0)
+#define PERI_CTRL4_FPGA_EXT_PHY_SEL			(1 << 3)
+#define PERI_CTRL4_PICO_REFCLKSEL			(1 << 4)
+#define PERI_CTRL4_PICO_SIDDQ				(1 << 6)
+#define PERI_CTRL4_PICO_SUSPENDM_SLEEPM			(1 << 7)
+#define PERI_CTRL4_PICO_OGDISABLE			(1 << 8)
+#define PERI_CTRL4_PICO_COMMONONN			(1 << 9)
+#define PERI_CTRL4_PICO_VBUSVLDEXT			(1 << 10)
+#define PERI_CTRL4_PICO_VBUSVLDEXTSEL			(1 << 11)
+#define PERI_CTRL4_PICO_VATESTENB			(1 << 12)
+#define PERI_CTRL4_PICO_SUSPENDM			(1 << 14)
+#define PERI_CTRL4_PICO_SLEEPM				(1 << 15)
+#define PERI_CTRL4_BC11_C				(1 << 16)
+#define PERI_CTRL4_BC11_B				(1 << 17)
+#define PERI_CTRL4_BC11_A				(1 << 18)
+#define PERI_CTRL4_BC11_GND				(1 << 19)
+#define PERI_CTRL4_BC11_FLOAT				(1 << 20)
+#define PERI_CTRL4_OTG_PHY_SEL				(1 << 21)
+#define PERI_CTRL4_USB_OTG_SS_SCALEDOWN_MODE		(1 << 22)
+#define PERI_CTRL4_OTG_DM_PULLDOWN			(1 << 24)
+#define PERI_CTRL4_OTG_DP_PULLDOWN			(1 << 25)
+#define PERI_CTRL4_OTG_IDPULLUP				(1 << 26)
+#define PERI_CTRL4_OTG_DRVBUS				(1 << 27)
+#define PERI_CTRL4_OTG_SESSEND				(1 << 28)
+#define PERI_CTRL4_OTG_BVALID				(1 << 29)
+#define PERI_CTRL4_OTG_AVALID				(1 << 30)
+#define PERI_CTRL4_OTG_VBUSVALID			(1 << 31)
+
+#define PERI_SC_PERIPH_CTRL5			(HI6220_PERI_BASE + 0x010)
+
+#define PERI_CTRL5_USBOTG_RES_SEL			(1 << 3)
+#define PERI_CTRL5_PICOPHY_ACAENB			(1 << 4)
+#define PERI_CTRL5_PICOPHY_BC_MODE			(1 << 5)
+#define PERI_CTRL5_PICOPHY_CHRGSEL			(1 << 6)
+#define PERI_CTRL5_PICOPHY_VDATSRCEND			(1 << 7)
+#define PERI_CTRL5_PICOPHY_VDATDETENB			(1 << 8)
+#define PERI_CTRL5_PICOPHY_DCDENB			(1 << 9)
+#define PERI_CTRL5_PICOPHY_IDDIG			(1 << 10)
+#define PERI_CTRL5_DBG_MUX				(1 << 11)
+
+#define PERI_SC_PERIPH_CTRL6			(HI6220_PERI_BASE + 0x014)
+
+#define PERI_CTRL6_CSSYSOFF_RAMCTRL_S_EMA		(1 << 0)
+#define PERI_CTRL6_CSSYSOFF_RAMCTRL_S_EMAW		(1 << 4)
+#define PERI_CTRL6_CSSYSOFF_RAMCTRL_S_EMAS		(1 << 6)
+#define PERI_CTRL6_CSSYSOFF_RAMCTRL_S_RET1N		(1 << 10)
+#define PERI_CTRL6_CSSYSOFF_RAMCTRL_S_RET2N		(1 << 11)
+#define PERI_CTRL6_CSSYSOFF_RAMCTRL_S_PGEN		(1 << 12)
+
+#define PERI_SC_PERIPH_CTRL8			(HI6220_PERI_BASE + 0x018)
+
+#define PERI_CTRL8_PICOPHY_TXRISETUNE0			(1 << 0)
+#define PERI_CTRL8_PICOPHY_TXPREEMPAMPTUNE0		(1 << 2)
+#define PERI_CTRL8_PICOPHY_TXRESTUNE0			(1 << 4)
+#define PERI_CTRL8_PICOPHY_TXHSSVTUNE0			(1 << 6)
+#define PERI_CTRL8_PICOPHY_COMPDISTUNE0			(1 << 8)
+#define PERI_CTRL8_PICOPHY_TXPREEMPPULSETUNE0		(1 << 11)
+#define PERI_CTRL8_PICOPHY_OTGTUNE0			(1 << 12)
+#define PERI_CTRL8_PICOPHY_SQRXTUNE0			(1 << 16)
+#define PERI_CTRL8_PICOPHY_TXVREFTUNE0			(1 << 20)
+#define PERI_CTRL8_PICOPHY_TXFSLSTUNE0			(1 << 28)
+
+#define PERI_SC_PERIPH_CTRL9			(HI6220_PERI_BASE + 0x01c)
+
+#define PERI_CTRL9_PICOPLY_TESTCLKEN			(1 << 0)
+#define PERI_CTRL9_PICOPLY_TESTDATAOUTSEL		(1 << 1)
+#define PERI_CTRL9_PICOPLY_TESTADDR			(1 << 4)
+#define PERI_CTRL9_PICOPLY_TESTDATAIN			(1 << 8)
+
+#define PERI_SC_PERIPH_CTRL10			(HI6220_PERI_BASE + 0x020)
+#define PERI_SC_PERIPH_CTRL12			(HI6220_PERI_BASE + 0x024)
+#define PERI_SC_PERIPH_CTRL13			(HI6220_PERI_BASE + 0x028)
+#define PERI_SC_PERIPH_CTRL14			(HI6220_PERI_BASE + 0x02c)
+
+#define PERI_SC_DDR_CTRL0			(HI6220_PERI_BASE + 0x050)
+#define PERI_SC_PERIPH_STAT1			(HI6220_PERI_BASE + 0x094)
+
+#define PERI_SC_PERIPH_CLK0_EN			(HI6220_PERI_BASE + 0x200)
+#define PERI_SC_PERIPH_CLK0_DIS			(HI6220_PERI_BASE + 0x204)
+#define PERI_SC_PERIPH_CLK0_STAT		(HI6220_PERI_BASE + 0x208)
+
+#define PERI_CLK0_MMC0					(1 << 0)
+#define PERI_CLK0_MMC1					(1 << 1)
+#define PERI_CLK0_MMC2					(1 << 2)
+#define PERI_CLK0_NANDC					(1 << 3)
+#define PERI_CLK0_USBOTG				(1 << 4)
+#define PERI_CLK0_PICOPHY				(1 << 5)
+#define PERI_CLK0_PLL					(1 << 6)
+
+#define PERI_SC_PERIPH_CLK1_EN			(HI6220_PERI_BASE + 0x210)
+#define PERI_SC_PERIPH_CLK1_DIS			(HI6220_PERI_BASE + 0x214)
+#define PERI_SC_PERIPH_CLK1_STAT		(HI6220_PERI_BASE + 0x218)
+
+#define PERI_CLK1_HIFI					(1 << 0)
+#define PERI_CLK1_DIGACODEC				(1 << 5)
+
+
+#define PERI_SC_PERIPH_CLK2_EN			(HI6220_PERI_BASE + 0x220)
+#define PERI_SC_PERIPH_CLK2_DIS			(HI6220_PERI_BASE + 0x224)
+#define PERI_SC_PERIPH_CLK2_STAT		(HI6220_PERI_BASE + 0x228)
+
+#define PERI_CLK2_IPF					(1 << 0)
+#define PERI_CLK2_SOCP					(1 << 1)
+#define PERI_CLK2_DMAC					(1 << 2)
+#define PERI_CLK2_SECENG				(1 << 3)
+#define PERI_CLK2_HPM0					(1 << 5)
+#define PERI_CLK2_HPM1					(1 << 6)
+#define PERI_CLK2_HPM2					(1 << 7)
+#define PERI_CLK2_HPM3					(1 << 8)
+
+
+#define PERI_SC_PERIPH_CLK3_EN			(HI6220_PERI_BASE + 0x230)
+#define PERI_SC_PERIPH_CLK3_DIS			(HI6220_PERI_BASE + 0x234)
+#define PERI_SC_PERIPH_CLK3_STAT		(HI6220_PERI_BASE + 0x238)
+
+
+
+
+#define PERI_SC_PERIPH_CLK8_EN			(HI6220_PERI_BASE + 0x240)
+#define PERI_SC_PERIPH_CLK8_DIS			(HI6220_PERI_BASE + 0x244)
+#define PERI_SC_PERIPH_CLK8_STAT		(HI6220_PERI_BASE + 0x248)
+
+#define PERI_CLK8_RS0					(1 << 0)
+#define PERI_CLK8_RS2					(1 << 1)
+#define PERI_CLK8_RS3					(1 << 2)
+#define PERI_CLK8_MS0					(1 << 3)
+#define PERI_CLK8_MS2					(1 << 5)
+#define PERI_CLK8_XG2RAM0				(1 << 6)
+#define PERI_CLK8_X2SRAM				(1 << 7)
+#define PERI_CLK8_SRAM					(1 << 8)
+#define PERI_CLK8_ROM					(1 << 9)
+#define PERI_CLK8_HARQ					(1 << 10)
+#define PERI_CLK8_MMU					(1 << 11)
+#define PERI_CLK8_DDRC					(1 << 12)
+#define PERI_CLK8_DDRPHY				(1 << 13)
+#define PERI_CLK8_DDRPHY_REF				(1 << 14)
+#define PERI_CLK8_X2X_SYSNOC				(1 << 15)
+#define PERI_CLK8_X2X_CCPU				(1 << 16)
+#define PERI_CLK8_DDRT					(1 << 17)
+#define PERI_CLK8_DDRPACK_RS				(1 << 18)
+
+
+#define PERI_SC_PERIPH_CLK9_EN			(HI6220_PERI_BASE + 0x250)
+#define PERI_SC_PERIPH_CLK9_DIS			(HI6220_PERI_BASE + 0x254)
+#define PERI_SC_PERIPH_CLK9_STAT		(HI6220_PERI_BASE + 0x258)
+
+#define PERI_CLK9_CARM_DAP				(1 << 0)
+#define PERI_CLK9_CARM_ATB				(1 << 1)
+#define PERI_CLK9_CARM_LBUS				(1 << 2)
+#define PERI_CLK9_CARM_KERNEL				(1 << 3)
+
+
+#define PERI_SC_PERIPH_CLK10_EN			(HI6220_PERI_BASE + 0x260)
+#define PERI_SC_PERIPH_CLK10_DIS		(HI6220_PERI_BASE + 0x264)
+#define PERI_SC_PERIPH_CLK10_STAT		(HI6220_PERI_BASE + 0x268)
+
+#define PERI_CLK10_IPF_CCPU				(1 << 0)
+#define PERI_CLK10_SOCP_CCPU				(1 << 1)
+#define PERI_CLK10_SECENG_CCPU				(1 << 2)
+#define PERI_CLK10_HARQ_CCPU				(1 << 3)
+#define PERI_CLK10_IPF_MCU				(1 << 16)
+#define PERI_CLK10_SOCP_MCU				(1 << 17)
+#define PERI_CLK10_SECENG_MCU				(1 << 18)
+#define PERI_CLK10_HARQ_MCU				(1 << 19)
+
+#define PERI_SC_PERIPH_CLK12_EN			(HI6220_PERI_BASE + 0x270)
+#define PERI_SC_PERIPH_CLK12_DIS		(HI6220_PERI_BASE + 0x274)
+#define PERI_SC_PERIPH_CLK12_STAT		(HI6220_PERI_BASE + 0x278)
+
+#define PERI_CLK12_HIFI_SRC				(1 << 0)
+#define PERI_CLK12_MMC0_SRC				(1 << 1)
+#define PERI_CLK12_MMC1_SRC				(1 << 2)
+#define PERI_CLK12_MMC2_SRC				(1 << 3)
+#define PERI_CLK12_SYSPLL_DIV				(1 << 4)
+#define PERI_CLK12_TPIU_SRC				(1 << 5)
+#define PERI_CLK12_MMC0_HF				(1 << 6)
+#define PERI_CLK12_MMC1_HF				(1 << 7)
+#define PERI_CLK12_PLL_TEST_SRC				(1 << 8)
+#define PERI_CLK12_CODEC_SOC				(1 << 9)
+#define PERI_CLK12_MEDIA				(1 << 10)
+
+#define PERI_SC_PERIPH_RST0_EN			(HI6220_PERI_BASE + 0x300)
+#define PERI_SC_PERIPH_RST0_DIS			(HI6220_PERI_BASE + 0x304)
+#define PERI_SC_PERIPH_RST0_STAT		(HI6220_PERI_BASE + 0x308)
+
+#define PERI_RST0_MMC0					(1 << 0)
+#define PERI_RST0_MMC1					(1 << 1)
+#define PERI_RST0_MMC2					(1 << 2)
+#define PERI_RST0_NANDC					(1 << 3)
+#define PERI_RST0_USBOTG_BUS				(1 << 4)
+#define PERI_RST0_POR_PICOPHY				(1 << 5)
+#define PERI_RST0_USBOTG				(1 << 6)
+#define PERI_RST0_USBOTG_32K				(1 << 7)
+
+
+#define PERI_SC_PERIPH_RST1_EN			(HI6220_PERI_BASE + 0x310)
+#define PERI_SC_PERIPH_RST1_DIS			(HI6220_PERI_BASE + 0x314)
+#define PERI_SC_PERIPH_RST1_STAT		(HI6220_PERI_BASE + 0x318)
+
+#define PERI_RST1_HIFI					(1 << 0)
+#define PERI_RST1_DIGACODEC				(1 << 5)
+
+
+#define PERI_SC_PERIPH_RST2_EN			(HI6220_PERI_BASE + 0x320)
+#define PERI_SC_PERIPH_RST2_DIS			(HI6220_PERI_BASE + 0x324)
+#define PERI_SC_PERIPH_RST2_STAT		(HI6220_PERI_BASE + 0x328)
+
+#define PERI_RST2_IPF					(1 << 0)
+#define PERI_RST2_SOCP					(1 << 1)
+#define PERI_RST2_DMAC					(1 << 2)
+#define PERI_RST2_SECENG				(1 << 3)
+#define PERI_RST2_ABB					(1 << 4)
+#define PERI_RST2_HPM0					(1 << 5)
+#define PERI_RST2_HPM1					(1 << 6)
+#define PERI_RST2_HPM2					(1 << 7)
+#define PERI_RST2_HPM3					(1 << 8)
+
+
+#define PERI_SC_PERIPH_RST3_EN			(HI6220_PERI_BASE + 0x330)
+#define PERI_SC_PERIPH_RST3_DIS			(HI6220_PERI_BASE + 0x334)
+#define PERI_SC_PERIPH_RST3_STAT		(HI6220_PERI_BASE + 0x338)
+
+#define PERI_RST3_CSSYS					(1 << 0)
+#define PERI_RST3_I2C0					(1 << 1)
+#define PERI_RST3_I2C1					(1 << 2)
+#define PERI_RST3_I2C2					(1 << 3)
+#define PERI_RST3_I2C3					(1 << 4)
+#define PERI_RST3_UART1					(1 << 5)
+#define PERI_RST3_UART2					(1 << 6)
+#define PERI_RST3_UART3					(1 << 7)
+#define PERI_RST3_UART4					(1 << 8)
+#define PERI_RST3_SSP					(1 << 9)
+#define PERI_RST3_PWM					(1 << 10)
+#define PERI_RST3_BLPWM					(1 << 11)
+#define PERI_RST3_TSENSOR				(1 << 12)
+#define PERI_RST3_DAPB					(1 << 18)
+#define PERI_RST3_HKADC					(1 << 19)
+#define PERI_RST3_CODEC					(1 << 20)
+
+
+#define PERI_SC_PERIPH_RST8_EN			(HI6220_PERI_BASE + 0x340)
+#define PERI_SC_PERIPH_RST8_DIS			(HI6220_PERI_BASE + 0x344)
+#define PERI_SC_PERIPH_RST8_STAT		(HI6220_PERI_BASE + 0x338)
+
+#define PERI_RST8_RS0					(1 << 0)
+#define PERI_RST8_RS2					(1 << 1)
+#define PERI_RST8_RS3					(1 << 2)
+#define PERI_RST8_MS0					(1 << 3)
+#define PERI_RST8_MS2					(1 << 5)
+#define PERI_RST8_XG2RAM0				(1 << 6)
+#define PERI_RST8_X2SRAM_TZMA				(1 << 7)
+#define PERI_RST8_SRAM					(1 << 8)
+#define PERI_RST8_HARQ					(1 << 10)
+#define PERI_RST8_DDRC					(1 << 12)
+#define PERI_RST8_DDRC_APB				(1 << 13)
+#define PERI_RST8_DDRPACK_APB				(1 << 14)
+#define PERI_RST8_DDRT					(1 << 17)
+
+#define PERI_SC_CLK0_SEL			(HI6220_PERI_BASE + 0x400)
+#define PERI_SC_CLKCFG8BIT1			(HI6220_PERI_BASE + 0x494)
+#define PERI_SC_CLKCFG8BIT2			(HI6220_PERI_BASE + 0x498)
+#define PERI_SC_RESERVED8_ADDR			(HI6220_PERI_BASE + 0xd04)
+
+#endif /*__HI62220_H__*/
arch/arm/include/asm/arch-hi6220/hi6220_regs_alwayson.h new file +349 -0

349 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 2/6 ARM: hi6220: Add register and bitfield definition header files.

Hi Peter,

Quoted 28 lines · Peter Griffin

This patch adds the header files which will be used in the subsquent board / drivers to enable support for hi6220 hikey board.

---
 arch/arm/include/asm/arch-hi6220/hi6220.h          | 324 +++++++++++++++++++
 .../include/asm/arch-hi6220/hi6220_regs_alwayson.h | 349 +++++++++++++++++++++
 2 files changed, 673 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6220.h
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6220_regs_alwayson.h
arch/arm/include/asm/arch-hi6220/hi6220.h new file +11 -0
new file mode 100644
index 0000000..3ddec91
@@ -0,0 +1,324 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __HI6220_H__
+#define __HI6220_H__
+
+#include "hi6220_regs_alwayson.h"

arch/arm/include/asm/arch-hi6220/hi6220.h line 21

Quoted 10 lines
arch/arm/include/asm/arch-hi6220/hi6220.h new file +10 -0
+
+#define HI6220_MMC0_BASE                       0xF723D000
+#define HI6220_MMC1_BASE                       0xF723E000
+
+#define HI6220_PMUSSI_BASE                     0xF8000000
+
+#define HI6220_PERI_BASE                       0xF7030000
+
+#define PERI_SC_PERIPH_CTRL1                   (HI6220_PERI_BASE + 0x000)
+

I think you should have:

struct peri_sc_regs {
u32 ctrl1;
u32 ctrl2;
...
};

U-Boot uses structs for I/O access.

Quoted 28 lines
arch/arm/include/asm/arch-hi6220/hi6220.h new file +28 -0
+#define PERI_CTRL1_ETR_AXI_CSYSREQ_N                   (1 << 0)
+#define PERI_CTRL1_HIFI_INT_MASK                       (1 << 1)
+#define PERI_CTRL1_HIFI_ALL_INT_MASK                   (1 << 2)
+#define PERI_CTRL1_ETR_AXI_CSYSREQ_N_MSK               (1 << 16)
+#define PERI_CTRL1_HIFI_INT_MASK_MSK                   (1 << 17)
+#define PERI_CTRL1_HIFI_ALL_INT_MASK_MSK               (1 << 18)
+
+
+#define PERI_SC_PERIPH_CTRL2                   (HI6220_PERI_BASE + 0x004)
+
+#define PERI_CTRL2_MMC_CLK_PHASE_BYPASS_EN_MMC0                (1 << 0)
+#define PERI_CTRL2_MMC_CLK_PHASE_BYPASS_EN_MMC1                (1 << 2)
+#define PERI_CTRL2_NAND_SYS_MEM_SEL                    (1 << 6)
+#define PERI_CTRL2_G3D_DDRT_AXI_SEL                    (1 << 7)
+#define PERI_CTRL2_GU_MDM_BBP_TESTPIN_SEL              (1 << 8)
+#define PERI_CTRL2_CODEC_SSI_MASTER_CHECK              (1 << 9)
+#define PERI_CTRL2_FUNC_TEST_SOFT                      (1 << 12)
+#define PERI_CTRL2_CSSYS_TS_ENABLE                     (1 << 15)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_EMA                  (1 << 16)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_EMAW                 (1 << 20)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_EMAS                 (1 << 22)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_RET1N                        (1 << 26)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_RET2N                        (1 << 27)
+#define PERI_CTRL2_HIFI_RAMCTRL_S_PGEN                 (1 << 28)
+
+#define PERI_SC_PERIPH_CTRL3                   (HI6220_PERI_BASE + 0x008)
+
+#define PERI_CTRL3_HIFI_DDR_HARQMEM_ADDR               (1 << 0)

arch/arm/include/asm/arch-hi6220/hi6220.h line 59

Quoted 10 lines
arch/arm/include/asm/arch-hi6220/hi6220.h new file +10 -0
+#define PERI_CTRL3_HIFI_HARQMEMRMP_EN                  (1 << 12)
+#define PERI_CTRL3_HARQMEM_SYS_MED_SEL                 (1 << 13)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP1                  (1 << 14)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP2                  (1 << 16)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP3                  (1 << 18)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP4                  (1 << 20)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP5                  (1 << 22)
+#define PERI_CTRL3_SOC_AP_OCCUPY_GRP6                  (1 << 24)
+
+#define PERI_SC_PERIPH_CTRL4                   (HI6220_PERI_BASE + 0x00c)

[snip]

Regards,
Simon

#5 lore raw

PATCH v2 2/6 ARM: hi6220: Add register and bitfield definition header files.

Hi Simon,

Quoted 49 lines · Simon Glass

Hi Peter,

Quoted 6 lines · Peter Griffin

This patch adds the header files which will be used in the subsquent board / drivers to enable support for hi6220 hikey board.

---
 arch/arm/include/asm/arch-hi6220/hi6220.h          | 324

+++++++++++++++++++

Quoted 1 line
 .../include/asm/arch-hi6220/hi6220_regs_alwayson.h | 349

+++++++++++++++++++++

Quoted 3 lines
 2 files changed, 673 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6220.h
 create mode 100644

arch/arm/include/asm/arch-hi6220/hi6220_regs_alwayson.h

Review

Quoted 2 lines
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-hi6220/hi6220.h

Quoted 15 lines

new file mode 100644
index 0000000..3ddec91

arch/arm/include/asm/arch-hi6220/hi6220.h new file +10 -0
@@ -0,0 +1,324 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __HI6220_H__
+#define __HI6220_H__
+

arch/arm/include/asm/arch-hi6220/hi6220.h line 20

Quoted 10 lines
arch/arm/include/asm/arch-hi6220/hi6220.h new file +10 -0
+#include "hi6220_regs_alwayson.h"
+
+#define HI6220_MMC0_BASE                       0xF723D000
+#define HI6220_MMC1_BASE                       0xF723E000
+
+#define HI6220_PMUSSI_BASE                     0xF8000000
+
+#define HI6220_PERI_BASE                       0xF7030000
+
+#define PERI_SC_PERIPH_CTRL1                   (HI6220_PERI_BASE +

0x000)

arch/arm/include/asm/arch-hi6220/hi6220.h line 21

Quoted 1 line
arch/arm/include/asm/arch-hi6220/hi6220.h new file +1 -0
+

I think you should have:

Quoted 8 lines
struct peri_sc_regs {
   u32 ctrl1;
   u32 ctrl2;

...
};

U-Boot uses structs for I/O access.

Phew...I've converted it over to structs for register access. It actually took quite a long time to do, but it all works again now :)

So it will be using structs for I/O access in V3.

regards,

Peter.

#6 lore raw

PATCH v2 3/6 hi6553: Add register definition and bitfield header for 6553 pmic

In reply to Peter Griffin

This pmic is used on the 96boards consumer edition HiKey board.

---
 arch/arm/include/asm/arch-hi6220/hi6553.h | 75 +++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6553.h
arch/arm/include/asm/arch-hi6220/hi6553.h new file +75 -0
new file mode 100644
index 0000000..d0770e1
@@ -0,0 +1,75 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __HI6553_PMIC_H__
+#define __HI6553_PMIC_H__
+
+#define HI6553_DISABLE6_XO_CLK			0x036
+
+#define HI6553_DISABLE6_XO_CLK_BB		(1 << 0)
+#define HI6553_DISABLE6_XO_CLK_CONN		(1 << 1)
+#define HI6553_DISABLE6_XO_CLK_NFC		(1 << 2)
+#define HI6553_DISABLE6_XO_CLK_RF1		(1 << 3)
+#define HI6553_DISABLE6_XO_CLK_RF2		(1 << 4)
+
+#define HI6553_VERSION_REG			0x000
+#define HI6553_ENABLE2_LDO1_8			0x029
+#define HI6553_DISABLE2_LDO1_8			0x02a
+#define HI6553_ONOFF_STATUS2_LDO1_8		0x02b
+#define HI6553_ENABLE3_LDO9_16			0x02c
+#define HI6553_DISABLE3_LDO9_16			0x02d
+#define HI6553_ONOFF_STATUS3_LDO9_16		0x02e
+#define HI6553_PERI_EN_MARK			0x040
+#define HI6553_BUCK2_REG1			0x04a
+#define HI6553_BUCK2_REG5			0x04e
+#define HI6553_BUCK2_REG6			0x04f
+#define HI6553_BUCK3_REG3			0x054
+#define HI6553_BUCK3_REG5			0x056
+#define HI6553_BUCK3_REG6			0x057
+#define HI6553_BUCK4_REG2			0x05b
+#define HI6553_BUCK4_REG5			0x05e
+#define HI6553_BUCK4_REG6			0x05f
+#define HI6553_CLK_TOP0				0x063
+#define HI6553_CLK_TOP3				0x066
+#define HI6553_CLK_TOP4				0x067
+#define HI6553_VSET_BUCK2_ADJ			0x06d
+#define HI6553_VSET_BUCK3_ADJ			0x06e
+#define HI6553_LDO7_REG_ADJ			0x078
+#define HI6553_LDO10_REG_ADJ			0x07b
+#define HI6553_LDO19_REG_ADJ			0x084
+#define HI6553_LDO20_REG_ADJ			0x085
+#define HI6553_DR_LED_CTRL			0x098
+#define HI6553_DR_OUT_CTRL			0x099
+#define HI6553_DR3_ISET				0x09a
+#define HI6553_DR3_START_DEL			0x09b
+#define HI6553_DR4_ISET				0x09c
+#define HI6553_DR4_START_DEL			0x09d
+#define HI6553_DR345_TIM_CONF0			0x0a0
+#define HI6553_NP_REG_ADJ1			0x0be
+#define HI6553_NP_REG_CHG			0x0c0
+#define HI6553_BUCK01_CTRL2			0x0d9
+#define HI6553_BUCK0_CTRL1			0x0dd
+#define HI6553_BUCK0_CTRL5			0x0e1
+#define HI6553_BUCK0_CTRL7			0x0e3
+#define HI6553_BUCK1_CTRL1			0x0e8
+#define HI6553_BUCK1_CTRL5			0x0ec
+#define HI6553_BUCK1_CTRL7			0x0ef
+#define HI6553_CLK19M2_600_586_EN		0x0fe
+
+#define HI6553_LED_START_DELAY_TIME		0x00
+#define HI6553_LED_ELEC_VALUE			0x07
+#define HI6553_LED_LIGHT_TIME			0xf0
+#define HI6553_LED_GREEN_ENABLE			(1 << 1)
+#define HI6553_LED_OUT_CTRL			0x00
+
+#define HI6553_PMU_V300				0x30
+#define HI6553_PMU_V310				0x31
+
+unsigned char hi6553_read_8(unsigned int offset);
+void hi6553_write_8(unsigned int offset, unsigned char value);
+
+#endif	/* __HI6553_PMIC_H__ */
Signature · 1 line
1.9.1
#7 lore raw

PATCH v2 3/6 hi6553: Add register definition and bitfield header for 6553 pmic

Hi Peter,

Quoted 7 lines · Peter Griffin

This pmic is used on the 96boards consumer edition HiKey board.

---
 arch/arm/include/asm/arch-hi6220/hi6553.h | 75 +++++++++++++++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6553.h

Should be in drivers/power/pmic I think. Also use struct for reg access. Should probably use the new PMIC uclass (we can convert it later if you don't have a device tree yet).

Quoted 85 lines
arch/arm/include/asm/arch-hi6220/hi6553.h new file +75 -1
new file mode 100644
index 0000000..d0770e1
@@ -0,0 +1,75 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __HI6553_PMIC_H__
+#define __HI6553_PMIC_H__
+
+#define HI6553_DISABLE6_XO_CLK                 0x036
+
+#define HI6553_DISABLE6_XO_CLK_BB              (1 << 0)
+#define HI6553_DISABLE6_XO_CLK_CONN            (1 << 1)
+#define HI6553_DISABLE6_XO_CLK_NFC             (1 << 2)
+#define HI6553_DISABLE6_XO_CLK_RF1             (1 << 3)
+#define HI6553_DISABLE6_XO_CLK_RF2             (1 << 4)
+
+#define HI6553_VERSION_REG                     0x000
+#define HI6553_ENABLE2_LDO1_8                  0x029
+#define HI6553_DISABLE2_LDO1_8                 0x02a
+#define HI6553_ONOFF_STATUS2_LDO1_8            0x02b
+#define HI6553_ENABLE3_LDO9_16                 0x02c
+#define HI6553_DISABLE3_LDO9_16                        0x02d
+#define HI6553_ONOFF_STATUS3_LDO9_16           0x02e
+#define HI6553_PERI_EN_MARK                    0x040
+#define HI6553_BUCK2_REG1                      0x04a
+#define HI6553_BUCK2_REG5                      0x04e
+#define HI6553_BUCK2_REG6                      0x04f
+#define HI6553_BUCK3_REG3                      0x054
+#define HI6553_BUCK3_REG5                      0x056
+#define HI6553_BUCK3_REG6                      0x057
+#define HI6553_BUCK4_REG2                      0x05b
+#define HI6553_BUCK4_REG5                      0x05e
+#define HI6553_BUCK4_REG6                      0x05f
+#define HI6553_CLK_TOP0                                0x063
+#define HI6553_CLK_TOP3                                0x066
+#define HI6553_CLK_TOP4                                0x067
+#define HI6553_VSET_BUCK2_ADJ                  0x06d
+#define HI6553_VSET_BUCK3_ADJ                  0x06e
+#define HI6553_LDO7_REG_ADJ                    0x078
+#define HI6553_LDO10_REG_ADJ                   0x07b
+#define HI6553_LDO19_REG_ADJ                   0x084
+#define HI6553_LDO20_REG_ADJ                   0x085
+#define HI6553_DR_LED_CTRL                     0x098
+#define HI6553_DR_OUT_CTRL                     0x099
+#define HI6553_DR3_ISET                                0x09a
+#define HI6553_DR3_START_DEL                   0x09b
+#define HI6553_DR4_ISET                                0x09c
+#define HI6553_DR4_START_DEL                   0x09d
+#define HI6553_DR345_TIM_CONF0                 0x0a0
+#define HI6553_NP_REG_ADJ1                     0x0be
+#define HI6553_NP_REG_CHG                      0x0c0
+#define HI6553_BUCK01_CTRL2                    0x0d9
+#define HI6553_BUCK0_CTRL1                     0x0dd
+#define HI6553_BUCK0_CTRL5                     0x0e1
+#define HI6553_BUCK0_CTRL7                     0x0e3
+#define HI6553_BUCK1_CTRL1                     0x0e8
+#define HI6553_BUCK1_CTRL5                     0x0ec
+#define HI6553_BUCK1_CTRL7                     0x0ef
+#define HI6553_CLK19M2_600_586_EN              0x0fe
+
+#define HI6553_LED_START_DELAY_TIME            0x00
+#define HI6553_LED_ELEC_VALUE                  0x07
+#define HI6553_LED_LIGHT_TIME                  0xf0
+#define HI6553_LED_GREEN_ENABLE                        (1 << 1)
+#define HI6553_LED_OUT_CTRL                    0x00
+
+#define HI6553_PMU_V300                                0x30
+#define HI6553_PMU_V310                                0x31
+
+unsigned char hi6553_read_8(unsigned int offset);
+void hi6553_write_8(unsigned int offset, unsigned char value);
+
+#endif /* __HI6553_PMIC_H__ */
--

1.9.1

#8 lore raw

PATCH v2 3/6 hi6553: Add register definition and bitfield header for 6553 pmic

Hi Simon,

Quoted 8 lines · Simon Glass

Hi Peter,

Quoted 5 lines · Peter Griffin

This pmic is used on the 96boards consumer edition HiKey board.

---
 arch/arm/include/asm/arch-hi6220/hi6553.h | 75
Quoted 8 lines

+++++++++++++++++++++++++++++++

Quoted 2 lines
 1 file changed, 75 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/hi6553.h

Should be in drivers/power/pmic I think. Also use struct for reg access. Should probably use the new PMIC uclass (we can convert it later if you don't have a device tree yet).

OK I've converted it to a simple pmic driver in v3 patches.

<snip>

regards,

Peter

#9 lore raw

PATCH v2 4/6 mmc: hi6220_dw_mmc: Add hi6220 glue code for dw_mmc controller.

In reply to Peter Griffin

This patch adds the glue code for hi6220 SoC which has 2x synopsis dw_mmc controllers. This will be used by the hikey board support in subsequent patches.

---
 arch/arm/include/asm/arch-hi6220/dwmmc.h |  8 +++++
 drivers/mmc/Makefile                     |  1 +
 drivers/mmc/hi6220_dw_mmc.c              | 56 ++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/dwmmc.h
 create mode 100644 drivers/mmc/hi6220_dw_mmc.c
arch/arm/include/asm/arch-hi6220/dwmmc.h new file +8 -0
new file mode 100644
index 0000000..c747383
@@ -0,0 +1,8 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width);
drivers/mmc/Makefile +1 -0
index ed73687..81a1a8f 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
 obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
 obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
+obj-$(CONFIG_HIKEY_DWMMC) += hi6220_dw_mmc.o
 obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o
 obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o
drivers/mmc/hi6220_dw_mmc.c new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.9.1
#10 lore raw

PATCH v2 4/6 mmc: hi6220_dw_mmc: Add hi6220 glue code for dw_mmc controller.

Quoted 51 lines · Peter Griffin

This patch adds the glue code for hi6220 SoC which has 2x synopsis dw_mmc controllers. This will be used by the hikey board support in subsequent patches.

---
 arch/arm/include/asm/arch-hi6220/dwmmc.h |  8 +++++
 drivers/mmc/Makefile                     |  1 +
 drivers/mmc/hi6220_dw_mmc.c              | 56 ++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/dwmmc.h
 create mode 100644 drivers/mmc/hi6220_dw_mmc.c
arch/arm/include/asm/arch-hi6220/dwmmc.h new file +8 -0
new file mode 100644
index 0000000..c747383
@@ -0,0 +1,8 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width);
drivers/mmc/Makefile +1 -0
index ed73687..81a1a8f 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
 obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
 obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
+obj-$(CONFIG_HIKEY_DWMMC) += hi6220_dw_mmc.o
 obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o
 obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o
drivers/mmc/hi6220_dw_mmc.c new file +6 -0
new file mode 100644
index 0000000..106f673
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * peter.griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */

drivers/mmc/hi6220_dw_mmc.c line 16

Quoted 10 lines
drivers/mmc/hi6220_dw_mmc.c new file +10 -0
+
+#include <common.h>
+#include <dwmmc.h>
+#include <malloc.h>
+#include <asm-generic/errno.h>
+
+#define	DWMMC_MAX_CH_NUM		4
+
+#define	DWMMC_MAX_FREQ			50000000
+#define	DWMMC_MIN_FREQ			378000

Is there any reason for using 378000 instead of 400K?

drivers/mmc/hi6220_dw_mmc.c line 19

Quoted 3 lines
drivers/mmc/hi6220_dw_mmc.c new file +3 -0
+
+/* Source clock is configured to 100Mhz by ATF bl1*/
+#define MMC0_DEFAULT_FREQ		100000000

Always configured to 100Mhz? Is there no method to get clock value?

Quoted 18 lines
drivers/mmc/hi6220_dw_mmc.c new file +18 -0
+
+static int hi6220_dwmci_core_init(struct dwmci_host *host, int index)
+{
+	host->name = "HiKey DWMMC";
+
+	host->dev_index = index;
+
+	/* Add the mmc channel to be registered with mmc core */
+	if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) {
+		printf("DWMMC%d registration failed\n", index);
+		return -1;
+	}
+	return 0;
+}
+
+/*
+ * This function adds the mmc channel to be registered with mmc core.
+ * index -	mmc channel number.

drivers/mmc/hi6220_dw_mmc.c line 47

Quoted 10 lines
drivers/mmc/hi6220_dw_mmc.c new file +10 -0
+ * regbase -	register base address of mmc channel specified in 'index'.
+ * bus_width -	operating bus width of mmc channel specified in 'index'.
+ */
+int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width)
+{
+	struct dwmci_host *host = NULL;
+
+	host = calloc(1, sizeof(struct dwmci_host));
+	if (!host) {
+		error("dwmci_host malloc fail!\n");

malloc -> calloc?

Best Regards,
Jaehoon Chung

Quoted 10 lines
drivers/mmc/hi6220_dw_mmc.c new file +9 -0
+		return -ENOMEM;
+	}
+
+	host->ioaddr = (void *)regbase;
+	host->buswidth = bus_width;
+	host->bus_hz = MMC0_DEFAULT_FREQ;
+
+	return hi6220_dwmci_core_init(host, index);
+}
#11 lore raw

PATCH v2 4/6 mmc: hi6220_dw_mmc: Add hi6220 glue code for dw_mmc controller.

In reply to Peter Griffin

Hi Peter,

Quoted 6 lines · Peter Griffin

This patch adds the glue code for hi6220 SoC which has 2x synopsis dw_mmc controllers. This will be used by the hikey board support in subsequent patches.

---

(see nit below - this could be moved to device tree once you have it)

Quoted 47 lines
 arch/arm/include/asm/arch-hi6220/dwmmc.h |  8 +++++
 drivers/mmc/Makefile                     |  1 +
 drivers/mmc/hi6220_dw_mmc.c              | 56 ++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/dwmmc.h
 create mode 100644 drivers/mmc/hi6220_dw_mmc.c
arch/arm/include/asm/arch-hi6220/dwmmc.h new file +8 -0
new file mode 100644
index 0000000..c747383
@@ -0,0 +1,8 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width);
drivers/mmc/Makefile +1 -0
index ed73687..81a1a8f 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
 obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
 obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
+obj-$(CONFIG_HIKEY_DWMMC) += hi6220_dw_mmc.o
 obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o
 obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o
drivers/mmc/hi6220_dw_mmc.c new file +8 -0
new file mode 100644
index 0000000..106f673
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * peter.griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>

drivers/mmc/hi6220_dw_mmc.c line 18

Quoted 10 lines
drivers/mmc/hi6220_dw_mmc.c new file +10 -0
+#include <dwmmc.h>
+#include <malloc.h>
+#include <asm-generic/errno.h>
+
+#define        DWMMC_MAX_CH_NUM                4
+
+#define        DWMMC_MAX_FREQ                  50000000
+#define        DWMMC_MIN_FREQ                  378000
+
+/* Source clock is configured to 100Mhz by ATF bl1*/

nit: MHz

Quoted 39 lines
drivers/mmc/hi6220_dw_mmc.c new file +38 -1
+#define MMC0_DEFAULT_FREQ              100000000
+
+static int hi6220_dwmci_core_init(struct dwmci_host *host, int index)
+{
+       host->name = "HiKey DWMMC";
+
+       host->dev_index = index;
+
+       /* Add the mmc channel to be registered with mmc core */
+       if (add_dwmci(host, DWMMC_MAX_FREQ, DWMMC_MIN_FREQ)) {
+               printf("DWMMC%d registration failed\n", index);
+               return -1;
+       }
+       return 0;
+}
+
+/*
+ * This function adds the mmc channel to be registered with mmc core.
+ * index -     mmc channel number.
+ * regbase -   register base address of mmc channel specified in 'index'.
+ * bus_width - operating bus width of mmc channel specified in 'index'.
+ */
+int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width)
+{
+       struct dwmci_host *host = NULL;
+
+       host = calloc(1, sizeof(struct dwmci_host));
+       if (!host) {
+               error("dwmci_host malloc fail!\n");
+               return -ENOMEM;
+       }
+
+       host->ioaddr = (void *)regbase;
+       host->buswidth = bus_width;
+       host->bus_hz = MMC0_DEFAULT_FREQ;
+
+       return hi6220_dwmci_core_init(host, index);
+}
--
Quoted 2 lines

1.9.1

Regards,
Simon

#12 lore raw

PATCH v2 4/6 mmc: hi6220_dw_mmc: Add hi6220 glue code for dw_mmc controller.

Hi Simon,

Quoted 11 lines · Peter Griffin
Quoted 6 lines

This patch adds the glue code for hi6220 SoC which has 2x synopsis dw_mmc controllers. This will be used by the hikey board support in subsequent patches.

---

(see nit below - this could be moved to device tree once you have it)

Thanks for reviewing :)

My plan regarding DT was to wait for it to land in the kernel, and then convert
over to using it in u-boot.

I saw some of your patches converting Raspberry Pi to DM and DT which should make migrating HiKey board fairly straight forward, as it shares the same Synopsis IP for MMC and USB :)

Quoted 53 lines
Quoted 3 lines
 arch/arm/include/asm/arch-hi6220/dwmmc.h |  8 +++++
 drivers/mmc/Makefile                     |  1 +
 drivers/mmc/hi6220_dw_mmc.c              | 56

++++++++++++++++++++++++++++++++

Review

Quoted 5 lines
 3 files changed, 65 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-hi6220/dwmmc.h
 create mode 100644 drivers/mmc/hi6220_dw_mmc.c
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-hi6220/dwmmc.h

Quoted 43 lines

new file mode 100644
index 0000000..c747383

arch/arm/include/asm/arch-hi6220/dwmmc.h new file +8 -0
@@ -0,0 +1,8 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+int hi6220_dwmci_add_port(int index, u32 regbase, int bus_width);
drivers/mmc/Makefile +1 -0
index ed73687..81a1a8f 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
 obj-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
 obj-$(CONFIG_DWMMC) += dw_mmc.o
 obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o
+obj-$(CONFIG_HIKEY_DWMMC) += hi6220_dw_mmc.o
 obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o
 obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o
drivers/mmc/hi6220_dw_mmc.c new file +12 -0
new file mode 100644
index 0000000..106f673
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * peter.griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dwmmc.h>
+#include <malloc.h>
+#include <asm-generic/errno.h>
+
Quoted 9 lines

drivers/mmc/hi6220_dw_mmc.c line 18

Quoted 6 lines
drivers/mmc/hi6220_dw_mmc.c new file +6 -0
+#define        DWMMC_MAX_CH_NUM                4
+
+#define        DWMMC_MAX_FREQ                  50000000
+#define        DWMMC_MIN_FREQ                  378000
+
+/* Source clock is configured to 100Mhz by ATF bl1*/

nit: MHz

Fixed in v3.

regards,

Peter.

#13 lore raw

PATCH v2 4/6 mmc: hi6220_dw_mmc: Add hi6220 glue code for dw_mmc controller.

Hi Peter,

Quoted 18 lines · Peter Griffin

Hi Simon,

Quoted 11 lines · Peter Griffin
Quoted 6 lines

This patch adds the glue code for hi6220 SoC which has 2x synopsis dw_mmc controllers. This will be used by the hikey board support in subsequent patches.

---

(see nit below - this could be moved to device tree once you have it)

Thanks for reviewing :)

Quoted 7 lines

My plan regarding DT was to wait for it to land in the kernel, and then convert
over to using it in u-boot.

I saw some of your patches converting Raspberry Pi to DM and DT which should make migrating HiKey board fairly straight forward, as it shares the same Synopsis IP for MMC and USB :)

OK good. For MMC I sent something with the Rockchip series but have not applied it yet. But yes it will be easier.

I'm looking forward to trying out your series, soon.

[snip]

Regards,
Simon

#14 lore raw

PATCH v2 5/6 ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey board.

In reply to Peter Griffin

HiKey is the first 96boards consumer edition compliant board. It features a hi6220 SoC which has eight ARM A53 cpu's.

This initial port adds support for: -
1) Serial
2) eMMC / sd card
3) USB
4) GPIO

It has been tested with Arm Trusted Firmware running u-boot as the BL33 executable.

Notes:

eMMC has been tested with basic reading of eMMC partition intto DDR. I have not tested writing / erasing. Due to lack of clock control it won't be running in the most performant high speed mode.

SD card slot has been tested for reading and booting kernels into DDR. It is also currently used for saving the u-boot enviroment.

USB has been tested with ASIX networking adapter to tftpboot kernels into DDR. On v2015.07-rc2 dhcp now works, and also usb mass storage is enumerated correctly.

GPIO has been tested using gpio toggle GPIO4_1-3 to flash LEDs.

Basic SoC datasheet can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf

Board schematic can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
96Boards-Hikey-Rev-A1.pdf

---
 arch/arm/Kconfig               |   8 +
 board/hisilicon/hikey/Kconfig  |  15 ++
 board/hisilicon/hikey/Makefile |   8 +
 board/hisilicon/hikey/hikey.c  | 415 +++++++++++++++++++++++++++++++++++++++++
 configs/hikey_defconfig        |   5 +
 include/configs/hikey.h        | 168 +++++++++++++++++
 6 files changed, 619 insertions(+)
 create mode 100644 board/hisilicon/hikey/Kconfig
 create mode 100644 board/hisilicon/hikey/Makefile
 create mode 100644 board/hisilicon/hikey/hikey.c
 create mode 100644 configs/hikey_defconfig
 create mode 100644 include/configs/hikey.h
arch/arm/Kconfig +8 -0
index 2985e6e..d0b7939 100644
@@ -721,6 +721,13 @@ config TARGET_LS2085ARDB
 	  development platform that supports the QorIQ LS2085A
 	  Layerscape Architecture processor.
 
+config TARGET_HIKEY
+	bool "Support HiKey 96boards Consumer Edition Platform"
+	select ARM64
+	  help
+	  Support for HiKey 96boards platform. It features a HI6220
+	  SoC, with 8xA53 CPU, mali450 gpu, and 1GB RAM.
+
 config TARGET_LS1021AQDS
 	bool "Support ls1021aqds"
 	select CPU_V7
@@ -865,6 +872,7 @@ source "board/Marvell/gplugd/Kconfig"
 source "board/armadeus/apf27/Kconfig"
 source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
+source "board/hisilicon/hikey/Kconfig"
 source "board/bachmann/ot1200/Kconfig"
 source "board/balloon3/Kconfig"
 source "board/barco/platinum/Kconfig"
board/hisilicon/hikey/Kconfig new file +15 -0
new file mode 100644
index 0000000..f7f1055
@@ -0,0 +1,15 @@
+if TARGET_HIKEY
+
+config SYS_BOARD
+	default "hikey"
+
+config SYS_VENDOR
+	default "hisilicon"
+
+config SYS_SOC
+	default "hi6220"
+
+config SYS_CONFIG_NAME
+	default "hikey"
+
+endif
board/hisilicon/hikey/Makefile new file +8 -0
new file mode 100644
index 0000000..d4ec8c7
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2000-2004
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	:= hikey.o
board/hisilicon/hikey/hikey.c new file +415 -0

415 lines not on this page · raw message

configs/hikey_defconfig new file +5 -0
new file mode 100644
index 0000000..50baf22
@@ -0,0 +1,5 @@
+# 96boards HiKey
+CONFIG_ARM=y
+CONFIG_TARGET_HIKEY=y
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_NET=y
include/configs/hikey.h new file +168 -0

168 lines not on this page · raw message

Signature · 1 line
1.9.1
#15 lore raw

PATCH v2 5/6 ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey board.

Quoted 6 lines · Peter Griffin

HiKey is the first 96boards consumer edition compliant board. It features a hi6220 SoC which has eight ARM A53 cpu's.

This initial port adds support for: -
1) Serial
2) eMMC / sd card

s/sd/SD/

Quoted 8 lines

3) USB
4) GPIO

It has been tested with Arm Trusted Firmware running u-boot as the BL33 executable.

Notes:

eMMC has been tested with basic reading of eMMC partition intto DDR. I have not

s/intto/into/

Quoted 5 lines

tested writing / erasing. Due to lack of clock control it won't be running in the most performant high speed mode.

SD card slot has been tested for reading and booting kernels into DDR. It is also currently used for saving the u-boot enviroment.

s/enviroment/environment/

Quoted 2 lines

USB has been tested with ASIX networking adapter to tftpboot kernels into DDR. On v2015.07-rc2 dhcp now works, and also usb mass storage

s/usb/USB/

Quoted 26 lines

is enumerated correctly.

GPIO has been tested using gpio toggle GPIO4_1-3 to flash LEDs.

Basic SoC datasheet can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf

Board schematic can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
96Boards-Hikey-Rev-A1.pdf

---
 arch/arm/Kconfig               |   8 +
 board/hisilicon/hikey/Kconfig  |  15 ++
 board/hisilicon/hikey/Makefile |   8 +
 board/hisilicon/hikey/hikey.c  | 415 +++++++++++++++++++++++++++++++++++++++++
 configs/hikey_defconfig        |   5 +
 include/configs/hikey.h        | 168 +++++++++++++++++
 6 files changed, 619 insertions(+)
 create mode 100644 board/hisilicon/hikey/Kconfig
 create mode 100644 board/hisilicon/hikey/Makefile
 create mode 100644 board/hisilicon/hikey/hikey.c
 create mode 100644 configs/hikey_defconfig
 create mode 100644 include/configs/hikey.h

[...]

board/hisilicon/hikey/hikey.c line 338

Quoted 4 lines
board/hisilicon/hikey/hikey.c new file +4 -0
+
+int misc_init_r(void)
+{
+       init_usb_and_picophy();

Can board_usb_init or usb_lowlevel_init be used here?

board/hisilicon/hikey/hikey.c line 347

Quoted 9 lines
board/hisilicon/hikey/hikey.c new file +9 -0
+
+       return 0;
+}
+
+int board_init(void)
+{
+       gd->flags = 0;
+
+       icache_enable();

The enable_caches call in board_r.c should do this for you.

Quoted 88 lines
board/hisilicon/hikey/hikey.c new file +68 -0
+
+       return 0;
+}
+
+#ifdef CONFIG_GENERIC_MMC
+
+static int init_dwmmc(void)
+{
+       int ret;
+
+#ifdef CONFIG_DWMMC
+       /* mmc0 pinmux and clocks are already configured by ATF */
+       ret = hi6220_dwmci_add_port(0, HI6220_MMC0_BASE, 8);
+
+       if (ret)
+               printf("%s: Error adding eMMC port\n", __func__);
+
+       /* take mmc1 (sd slot) out of reset, configure clocks and pinmuxing */
+
+       mmc1_init_pll();
+       mmc1_reset_clk();
+       mmc1_setup_pinmux();
+
+       ret |= hi6220_dwmci_add_port(1, HI6220_MMC1_BASE, 4);
+
+       if (ret)
+               printf("%s: Error adding SD port\n", __func__);
+#endif
+       return ret;
+}
+
+int board_mmc_init(bd_t *bis)
+{
+       int ret;
+
+       /* init the pmussi ip */
+       hi6220_pmussi_init();
+
+       /* init the hi6553 pmic */
+       hikey_hi6553_init();
+
+       /* add the eMMC and sd ports */
+       ret = init_dwmmc();
+
+       if (ret)
+               debug("init_dwmmc failed\n");
+
+       return ret;
+}
+#endif
+
+int dram_init(void)
+{
+       gd->ram_size = PHYS_SDRAM_1_SIZE;
+       return 0;
+}
+
+void dram_init_banksize(void)
+{
+       gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+       gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+}
+
+/* Use the Watchdog to cause reset */
+void reset_cpu(ulong addr)
+{
+       /* TODO program the watchdog */
+}
configs/hikey_defconfig new file +5 -0
new file mode 100644
index 0000000..50baf22
@@ -0,0 +1,5 @@
+# 96boards HiKey
+CONFIG_ARM=y
+CONFIG_TARGET_HIKEY=y
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_NET=y
include/configs/hikey.h new file +3 -0
new file mode 100644
index 0000000..303b857
@@ -0,0 +1,168 @@
+/*
+ * (C) Copyright 2015 Linaro
+ *

include/configs/hikey.h line 13

Quoted 10 lines
include/configs/hikey.h new file +10 -0
+ * Peter Griffin <[email protected]>
+ *
+ * Configuration for HiKey 96boards CE. Parts were derived from other ARM
+ * configurations.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __HIKEY_AEMV8A_H
+#define __HIKEY_AEMV8A_H

Drop the AEMV8A.

Quoted 43 lines
include/configs/hikey.h new file +43 -0
+
+/* We use generic board for hikey */
+#define CONFIG_SYS_GENERIC_BOARD
+
+#define CONFIG_REMAKE_ELF
+
+#define CONFIG_SUPPORT_RAW_INITRD
+
+/* Cache Definitions */
+#define CONFIG_SYS_DCACHE_OFF
+
+#define CONFIG_IDENT_STRING            "hikey"
+
+/* Flat Device Tree Definitions */
+#define CONFIG_OF_LIBFDT
+
+/* Physical Memory Map */
+
+/* CONFIG_SYS_TEXT_BASE needs to align with where ATF loads bl33.bin */
+#define CONFIG_SYS_TEXT_BASE           0x35000000
+
+#define CONFIG_NR_DRAM_BANKS           1
+#define PHYS_SDRAM_1                   0x00000000
+
+/* 1008 MB (the last 16Mb are secured for TrustZone by ATF*/
+#define PHYS_SDRAM_1_SIZE              0x3f000000
+#define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM_1
+
+#define CONFIG_SYS_INIT_RAM_SIZE       0x1000
+
+#define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
+
+#define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x80000)
+
+/* Generic Timer Definitions */
+#define COUNTER_FREQUENCY              (19000000)
+
+/* Generic Interrupt Controller Definitions */
+#define GICD_BASE                      (0xf6801000)
+#define GICC_BASE                      (0xf6802000)
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN          (CONFIG_ENV_SIZE + (8 << 20))

include/configs/hikey.h line 66

Quoted 10 lines
include/configs/hikey.h new file +10 -0
+
+/* PL011 Serial Configuration */
+#define CONFIG_PL011_SERIAL
+
+#define CONFIG_PL011_CLOCK             19200000
+#define CONFIG_PL01x_PORTS             {(void *)CONFIG_SYS_SERIAL0}
+#define CONFIG_CONS_INDEX              0
+
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_SERIAL0             0xF8015000

Just do:

#define CONFIG_PL01x_PORTS {(void *)0xf8015000}

You are probably going to want to setup multiple serial consoles (debug + LS header). That can come later, but I've figured out how to enable that if you are interested.

Quoted 20 lines
include/configs/hikey.h new file +20 -0
+
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_DWC2
+#define CONFIG_USB_DWC2_REG_ADDR 0xF72C0000
+/*#define CONFIG_DWC2_DFLT_SPEED_FULL*/
+#define CONFIG_DWC2_ENABLE_DYNAMIC_FIFO
+
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MISC_INIT_R
+#endif
+
+#define CONFIG_HIKEY_GPIO
+#define CONFIG_DM_GPIO
+#define CONFIG_CMD_GPIO
+#define CONFIG_DM
+

include/configs/hikey.h line 96

Quoted 10 lines
include/configs/hikey.h new file +10 -0
+/* SD/MMC configuration */
+#define CONFIG_GENERIC_MMC
+#define CONFIG_MMC
+#define CONFIG_DWMMC
+#define CONFIG_HIKEY_DWMMC
+#define CONFIG_BOUNCE_BUFFER
+#define CONFIG_CMD_MMC
+
+#define CONFIG_FS_EXT4
+#define CONFIG_FS_FAT

distro config should set this.

include/configs/hikey.h line 103

Quoted 7 lines
include/configs/hikey.h new file +7 -0
+
+/* Command line configuration */
+#define CONFIG_MENU
+#define CONFIG_CMD_CACHE
+#define CONFIG_CMD_BDI
+#define CONFIG_CMD_UNZIP
+#define CONFIG_CMD_PXE

and this.

include/configs/hikey.h line 114

Quoted 11 lines
include/configs/hikey.h new file +11 -0
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_IMI
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_ECHO
+#define CONFIG_CMD_SOURCE
+
+#define CONFIG_MAC_PARTITION

Supporting Mac partitions, really?

include/configs/hikey.h line 115

Quoted 1 line
include/configs/hikey.h new file +1 -0
+#define CONFIG_MTD_PARTITIONS

On what MTD device?

Quoted 7 lines
include/configs/hikey.h new file +7 -0
+
+/* BOOTP options */
+#define CONFIG_BOOTP_BOOTFILESIZE
+
+#define CONFIG_CMD_NET
+
+#include <config_distro_defaults.h>

include/configs/hikey.h line 132

Quoted 10 lines
include/configs/hikey.h new file +10 -0
+
+/* Initial environment variables */
+
+/*
+ * Defines where the kernel and FDT exist in NOR flash and where it will
+ * be copied into DRAM
+ */
+#define CONFIG_EXTRA_ENV_SETTINGS      \
+                               "kernel_name=Image\0"   \
+                               "kernel_addr=0x0000000\0" \

Shouldn't this be 0x80000 to avoid copying from 0x0 to 0x80000.

include/configs/hikey.h line 135

Quoted 3 lines
include/configs/hikey.h new file +3 -0
+                               "fdt_name=hi6220-hikey.dtb\0" \
+                               "fdt_addr=0x0300000\0" \
+                               "max_fdt=0x100000\0" \

I don't think this is needed.

include/configs/hikey.h line 140

Quoted 5 lines
include/configs/hikey.h new file +5 -0
+                               "fdt_high=0xffffffffffffffff\0" \
+                               "initrd_high=0xffffffffffffffff\0" \
+
+/* Assume we boot with root on the first partition of a USB stick */
+#define CONFIG_BOOTARGS                "console=ttyAMA0,115200n8 /dev/mmcblk0p7 rw "

/dev/mmcblk0p7 doesn't look right. You mean "root=/dev/..."?

include/configs/hikey.h line 143

Quoted 3 lines
include/configs/hikey.h new file +3 -0
+
+/* Copy the kernel and FDT to DRAM memory and boot */
+#define CONFIG_BOOTCOMMAND     "booti $kernel_addr_r - $fdt_addr_r"

Don't you need to set these variables?

Also, don't you need to load the kernel and dtb first?

include/configs/hikey.h line 150

Quoted 7 lines
include/configs/hikey.h new file +7 -0
+
+#define CONFIG_BOOTDELAY               2
+
+/* Preserve enviroment onto sd card */
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV         1
+#define CONFIG_SYS_MMC_ENV_PART                0

Don't you have these reversed? The first MMC device is 0 and I think partition numbering starts at 1.

include/configs/hikey.h line 154

Quoted 4 lines
include/configs/hikey.h new file +4 -0
+#define CONFIG_ENV_OFFSET               0x0
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT

Is redundant env necessary? It seems like this was more for raw NAND and shouldn't really be needed for MMC.

Rob

#16 lore raw

PATCH v2 5/6 ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey board.

Hi Rob,

Quoted 9 lines · Rob Herring
Quoted 6 lines · Peter Griffin

HiKey is the first 96boards consumer edition compliant board. It features a hi6220 SoC which has eight ARM A53 cpu's.

This initial port adds support for: -
1) Serial
2) eMMC / sd card

s/sd/SD/

Will fix in v3

Quoted 11 lines
Quoted 9 lines

3) USB
4) GPIO

It has been tested with Arm Trusted Firmware running u-boot as the BL33 executable.

Notes:

eMMC has been tested with basic reading of eMMC partition intto DDR. I have not

s/intto/into/

Will fix in v3

Quoted 8 lines
Quoted 6 lines

tested writing / erasing. Due to lack of clock control it won't be running in the most performant high speed mode.

SD card slot has been tested for reading and booting kernels into DDR. It is also currently used for saving the u-boot enviroment.

s/enviroment/environment/

Will fix in v3.

Quoted 5 lines
Quoted 3 lines

USB has been tested with ASIX networking adapter to tftpboot kernels into DDR. On v2015.07-rc2 dhcp now works, and also usb mass storage

s/usb/USB/

Will fix in v3

Quoted 28 lines
Quoted 14 lines

is enumerated correctly.

GPIO has been tested using gpio toggle GPIO4_1-3 to flash LEDs.

Basic SoC datasheet can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf

Board schematic can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
96Boards-Hikey-Rev-A1.pdf

Quoted 13 lines
---
 arch/arm/Kconfig               |   8 +
 board/hisilicon/hikey/Kconfig  |  15 ++
 board/hisilicon/hikey/Makefile |   8 +
 board/hisilicon/hikey/hikey.c  | 415 +++++++++++++++++++++++++++++++++++++++++
 configs/hikey_defconfig        |   5 +
 include/configs/hikey.h        | 168 +++++++++++++++++
 6 files changed, 619 insertions(+)
 create mode 100644 board/hisilicon/hikey/Kconfig
 create mode 100644 board/hisilicon/hikey/Makefile
 create mode 100644 board/hisilicon/hikey/hikey.c
 create mode 100644 configs/hikey_defconfig
 create mode 100644 include/configs/hikey.h
Quoted 8 lines

[...]

board/hisilicon/hikey/hikey.c line 338

Quoted 4 lines
board/hisilicon/hikey/hikey.c new file +4 -0
+
+int misc_init_r(void)
+{
+       init_usb_and_picophy();

Can board_usb_init or usb_lowlevel_init be used here?

Umm I wasn't aware of those functions. It looks like usb_lowlevel_init() is used by the host controller driver. Other host controllers like ohci / ehci and xhci call board_usb_init() from their usb_lowlevel_init function, but not dwc2.

So I can make use of board_usb_init() if I update dwc2.c generic code to call it from usb_lowlevel_init(). I'll do this in V3 and hopefully nobody has any objections.

Quoted 12 lines

board/hisilicon/hikey/hikey.c line 347

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +9 -0
+
+       return 0;
+}
+
+int board_init(void)
+{
+       gd->flags = 0;
+
+       icache_enable();

The enable_caches call in board_r.c should do this for you.

Ok, will remove in v3.

Quoted 93 lines
Quoted 93 lines
board/hisilicon/hikey/hikey.c new file +68 -0
+
+       return 0;
+}
+
+#ifdef CONFIG_GENERIC_MMC
+
+static int init_dwmmc(void)
+{
+       int ret;
+
+#ifdef CONFIG_DWMMC
+       /* mmc0 pinmux and clocks are already configured by ATF */
+       ret = hi6220_dwmci_add_port(0, HI6220_MMC0_BASE, 8);
+
+       if (ret)
+               printf("%s: Error adding eMMC port\n", __func__);
+
+       /* take mmc1 (sd slot) out of reset, configure clocks and pinmuxing */
+
+       mmc1_init_pll();
+       mmc1_reset_clk();
+       mmc1_setup_pinmux();
+
+       ret |= hi6220_dwmci_add_port(1, HI6220_MMC1_BASE, 4);
+
+       if (ret)
+               printf("%s: Error adding SD port\n", __func__);
+#endif
+       return ret;
+}
+
+int board_mmc_init(bd_t *bis)
+{
+       int ret;
+
+       /* init the pmussi ip */
+       hi6220_pmussi_init();
+
+       /* init the hi6553 pmic */
+       hikey_hi6553_init();
+
+       /* add the eMMC and sd ports */
+       ret = init_dwmmc();
+
+       if (ret)
+               debug("init_dwmmc failed\n");
+
+       return ret;
+}
+#endif
+
+int dram_init(void)
+{
+       gd->ram_size = PHYS_SDRAM_1_SIZE;
+       return 0;
+}
+
+void dram_init_banksize(void)
+{
+       gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+       gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+}
+
+/* Use the Watchdog to cause reset */
+void reset_cpu(ulong addr)
+{
+       /* TODO program the watchdog */
+}
configs/hikey_defconfig new file +5 -0
new file mode 100644
index 0000000..50baf22
@@ -0,0 +1,5 @@
+# 96boards HiKey
+CONFIG_ARM=y
+CONFIG_TARGET_HIKEY=y
+CONFIG_SHOW_BOOT_PROGRESS=y
+CONFIG_NET=y
include/configs/hikey.h new file +7 -0
new file mode 100644
index 0000000..303b857
@@ -0,0 +1,168 @@
+/*
+ * (C) Copyright 2015 Linaro
+ *
+ * Peter Griffin <[email protected]>
+ *
+ * Configuration for HiKey 96boards CE. Parts were derived from other ARM
+ * configurations.
Quoted 8 lines

include/configs/hikey.h line 13

Quoted 6 lines
include/configs/hikey.h new file +6 -0
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __HIKEY_AEMV8A_H
+#define __HIKEY_AEMV8A_H

Drop the AEMV8A.

Ah, I thought I'd got rid of all that, but cleary missed this one. Will remove in V3

Quoted 57 lines
Quoted 44 lines
include/configs/hikey.h new file +43 -0
+
+/* We use generic board for hikey */
+#define CONFIG_SYS_GENERIC_BOARD
+
+#define CONFIG_REMAKE_ELF
+
+#define CONFIG_SUPPORT_RAW_INITRD
+
+/* Cache Definitions */
+#define CONFIG_SYS_DCACHE_OFF
+
+#define CONFIG_IDENT_STRING            "hikey"
+
+/* Flat Device Tree Definitions */
+#define CONFIG_OF_LIBFDT
+
+/* Physical Memory Map */
+
+/* CONFIG_SYS_TEXT_BASE needs to align with where ATF loads bl33.bin */
+#define CONFIG_SYS_TEXT_BASE           0x35000000
+
+#define CONFIG_NR_DRAM_BANKS           1
+#define PHYS_SDRAM_1                   0x00000000
+
+/* 1008 MB (the last 16Mb are secured for TrustZone by ATF*/
+#define PHYS_SDRAM_1_SIZE              0x3f000000
+#define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM_1
+
+#define CONFIG_SYS_INIT_RAM_SIZE       0x1000
+
+#define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
+
+#define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x80000)
+
+/* Generic Timer Definitions */
+#define COUNTER_FREQUENCY              (19000000)
+
+/* Generic Interrupt Controller Definitions */
+#define GICD_BASE                      (0xf6801000)
+#define GICC_BASE                      (0xf6802000)
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN          (CONFIG_ENV_SIZE + (8 << 20))

include/configs/hikey.h line 66

Quoted 10 lines
include/configs/hikey.h new file +10 -0
+
+/* PL011 Serial Configuration */
+#define CONFIG_PL011_SERIAL
+
+#define CONFIG_PL011_CLOCK             19200000
+#define CONFIG_PL01x_PORTS             {(void *)CONFIG_SYS_SERIAL0}
+#define CONFIG_CONS_INDEX              0
+
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_SERIAL0             0xF8015000

Just do:

Quoted 1 line

#define CONFIG_PL01x_PORTS {(void *)0xf8015000}

Ok, fixed in V3

Quoted 4 lines

You are probably going to want to setup multiple serial consoles (debug + LS header). That can come later, but I've figured out how to enable that if you are interested.

Yes I'm interested, please do let me know :)

Quoted 25 lines
Quoted 25 lines
include/configs/hikey.h new file +24 -0
+
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_DWC2
+#define CONFIG_USB_DWC2_REG_ADDR 0xF72C0000
+/*#define CONFIG_DWC2_DFLT_SPEED_FULL*/
+#define CONFIG_DWC2_ENABLE_DYNAMIC_FIFO
+
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MISC_INIT_R
+#endif
+
+#define CONFIG_HIKEY_GPIO
+#define CONFIG_DM_GPIO
+#define CONFIG_CMD_GPIO
+#define CONFIG_DM
+
+/* SD/MMC configuration */
+#define CONFIG_GENERIC_MMC
+#define CONFIG_MMC
+#define CONFIG_DWMMC
Quoted 8 lines

include/configs/hikey.h line 96

Quoted 6 lines
include/configs/hikey.h new file +6 -0
+#define CONFIG_HIKEY_DWMMC
+#define CONFIG_BOUNCE_BUFFER
+#define CONFIG_CMD_MMC
+
+#define CONFIG_FS_EXT4
+#define CONFIG_FS_FAT

distro config should set this.

Ah ok, indirectly yes, as distro_config sets CONFIG_CMD_FAT, and if that is set config_fallbacks.h will enable CONFIG_FS_FAT.

I've removed both CONFIG_FS_FAT and CONFIG_FS_EXT4 in v3

Quoted 10 lines

include/configs/hikey.h line 103

Quoted 8 lines
include/configs/hikey.h new file +7 -0
+
+/* Command line configuration */
+#define CONFIG_MENU
+#define CONFIG_CMD_CACHE
+#define CONFIG_CMD_BDI
+#define CONFIG_CMD_UNZIP
+#define CONFIG_CMD_PXE

and this.

Whoops, missed this one. I've removed in V3

Quoted 14 lines

include/configs/hikey.h line 114

Quoted 12 lines
include/configs/hikey.h new file +11 -0
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_IMI
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_ECHO
+#define CONFIG_CMD_SOURCE
+
+#define CONFIG_MAC_PARTITION

Supporting Mac partitions, really?

Will remove in V3. It doesn't look like I can blame that on vexpress either, so I must have thought it was a good idea ;)

Quoted 3 lines

include/configs/hikey.h line 115

Quoted 1 line
include/configs/hikey.h new file +1 -0
+#define CONFIG_MTD_PARTITIONS

On what MTD device?

Good point, Will remove in v3.

Quoted 12 lines
Quoted 12 lines
include/configs/hikey.h new file +11 -0
+
+/* BOOTP options */
+#define CONFIG_BOOTP_BOOTFILESIZE
+
+#define CONFIG_CMD_NET
+
+#include <config_distro_defaults.h>
+
+/* Initial environment variables */
+
+/*
Quoted 8 lines

include/configs/hikey.h line 132

Quoted 6 lines
include/configs/hikey.h new file +6 -0
+ * Defines where the kernel and FDT exist in NOR flash and where it will
+ * be copied into DRAM
+ */
+#define CONFIG_EXTRA_ENV_SETTINGS      \
+                               "kernel_name=Image\0"   \
+                               "kernel_addr=0x0000000\0" \

Shouldn't this be 0x80000 to avoid copying from 0x0 to 0x80000.

I've updated this. Kernel boot time is much reduced with this and also the icache being enabled.

Quoted 6 lines

include/configs/hikey.h line 135

Quoted 4 lines
include/configs/hikey.h new file +3 -0
+                               "fdt_name=hi6220-hikey.dtb\0" \
+                               "fdt_addr=0x0300000\0" \
+                               "max_fdt=0x100000\0" \

I don't think this is needed.

Removed in V3

Quoted 8 lines

include/configs/hikey.h line 140

Quoted 6 lines
include/configs/hikey.h new file +5 -0
+                               "fdt_high=0xffffffffffffffff\0" \
+                               "initrd_high=0xffffffffffffffff\0" \
+
+/* Assume we boot with root on the first partition of a USB stick */
+#define CONFIG_BOOTARGS                "console=ttyAMA0,115200n8 /dev/mmcblk0p7 rw "

/dev/mmcblk0p7 doesn't look right. You mean "root=/dev/..."?

Good spot, yes your right. Plus now you highlight it the comment above also needs updating.

Will fix in V3.

Quoted 8 lines

include/configs/hikey.h line 143

Quoted 4 lines
include/configs/hikey.h new file +3 -0
+
+/* Copy the kernel and FDT to DRAM memory and boot */
+#define CONFIG_BOOTCOMMAND     "booti $kernel_addr_r - $fdt_addr_r"

Don't you need to set these variables?

Also, don't you need to load the kernel and dtb first?

Yes, but I'm not sure quite what to make the default here. My personal workflow is: -

"usb start; dhcp; tftp $kernel_addr $kernel_name; tftp $fdt_addr $fdt_name;
booti $kernel_addr - $fdt_addr"

So I could use that unless you have a better idea?

Quoted 11 lines

include/configs/hikey.h line 150

Quoted 8 lines
include/configs/hikey.h new file +7 -0
+
+#define CONFIG_BOOTDELAY               2
+
+/* Preserve enviroment onto sd card */
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV         1
+#define CONFIG_SYS_MMC_ENV_PART                0

Don't you have these reversed? The first MMC device is 0 and I think partition numbering starts at 1.

Having CONFIG_SYS_MMC_ENV_DEV 1 was deliberate, as the first device is eMMC, and I don't have a "official" partition to save the u-boot enviroment in. So as not to corrupt anything folks may have flashed into eMMC from the official builds I opted to save the u-boot env to SD card which is device 1.

However that seems to have been working by luck with ENC_PART being 0, and it was actually corrupting the partition table of the SD card. Looking more closely I think what I should of used is

#define CONFIG_ENV_IS_IN_FAT

#define FAT_ENV_INTERFACE               "mmc"
#define FAT_ENV_DEVICE_AND_PART         "1:1"
#define FAT_ENV_FILE                    "uboot.env"

This then saves the enviroment on a fat formatted SD card with the filename u-boot.env. This is what I plan on using for v3.

Maybe I should additionally request some space in the official eMMC parition table and then we could switch over to using that.

Quoted 8 lines

include/configs/hikey.h line 154

Quoted 5 lines
include/configs/hikey.h new file +4 -0
+#define CONFIG_ENV_OFFSET               0x0
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT

Is redundant env necessary? It seems like this was more for raw NAND and shouldn't really be needed for MMC.

README file documents it as being valid for CONFIG_ENV_IS_IN_MMC, and a bunch of boards declare it with their CONFIG_ENV_IS_IN_MMC such as omap5_uevm.h, dra7xx_evm.h, am335x_evm.h. Whilst using managed NAND should be more reliable, I think it is still used in case there is a power failure whilst issuing 'saveenv'.

Anyways with moving to CONFIG_ENV_IS_IN_FAT I won't need it anymore so it will be removed in V3.

Many thanks for your thorough reviews, you've spotted some really good stuff that has meant boot time is now a lot quicker, and I will no longer be crapping over peoples SD card partition table :)

kind regards,

Peter.

#17 lore raw

PATCH v2 5/6 ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey board.

Quoted 8 lines · Peter Griffin

Hi Rob,

Quoted 4 lines · Rob Herring
Quoted 3 lines · Peter Griffin

HiKey is the first 96boards consumer edition compliant board. It features a hi6220 SoC which has eight ARM A53 cpu's.

[...]

Quoted 7 lines
Quoted 6 lines

include/configs/hikey.h line 66

Quoted 2 lines
include/configs/hikey.h new file +2 -0
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_SERIAL0             0xF8015000

Just do:

#define CONFIG_PL01x_PORTS {(void *)0xf8015000}

Quoted 8 lines

Ok, fixed in V3

Quoted 4 lines

You are probably going to want to setup multiple serial consoles (debug + LS header). That can come later, but I've figured out how to enable that if you are interested.

Yes I'm interested, please do let me know :)

See this commit:

https://git.linaro.org/people/rob.herring/u-boot.git/commitdiff/f1d0aef06ae7fe09793d46589bd94fa36c45bbc0

This may be 8250 specific and require more work for pl011 driver. The mixture of 0 and 1 based indexing makes it fun too.

Quoted 8 lines
Quoted 5 lines

include/configs/hikey.h line 132

Quoted 3 lines
include/configs/hikey.h new file +3 -0
+#define CONFIG_EXTRA_ENV_SETTINGS      \
+                               "kernel_name=Image\0"   \
+                               "kernel_addr=0x0000000\0" \

Shouldn't this be 0x80000 to avoid copying from 0x0 to 0x80000.

I've updated this. Kernel boot time is much reduced with this and also the icache being enabled.

Also, this should be kernel_addr_r

Quoted 4 lines
Quoted 4 lines

include/configs/hikey.h line 134

Quoted 4 lines
include/configs/hikey.h new file +2 -0
+                               "fdt_name=hi6220-hikey.dtb\0" \
+                               "fdt_addr=0x0300000\0" \

and fdt_addr_r

Quoted 27 lines
Quoted 3 lines
Quoted 1 line

+ "max_fdt=0x100000\0" \

I don't think this is needed.

Removed in V3

Quoted 8 lines

include/configs/hikey.h line 140

Quoted 6 lines
include/configs/hikey.h new file +5 -0
+                               "fdt_high=0xffffffffffffffff\0" \
+                               "initrd_high=0xffffffffffffffff\0" \
+
+/* Assume we boot with root on the first partition of a USB stick */
+#define CONFIG_BOOTARGS                "console=ttyAMA0,115200n8 /dev/mmcblk0p7 rw "

/dev/mmcblk0p7 doesn't look right. You mean "root=/dev/..."?

Good spot, yes your right. Plus now you highlight it the comment above also needs updating.

Will fix in V3.

Quoted 8 lines

include/configs/hikey.h line 143

Quoted 4 lines
include/configs/hikey.h new file +3 -0
+
+/* Copy the kernel and FDT to DRAM memory and boot */
+#define CONFIG_BOOTCOMMAND     "booti $kernel_addr_r - $fdt_addr_r"

Don't you need to set these variables?

Also, don't you need to load the kernel and dtb first?

Quoted 7 lines

Yes, but I'm not sure quite what to make the default here. My personal workflow is: -

"usb start; dhcp; tftp $kernel_addr $kernel_name; tftp $fdt_addr $fdt_name;
booti $kernel_addr - $fdt_addr"

So I could use that unless you have a better idea?

Not really as everyone has their own preferences. I have some thing like this:

#define CONFIG_BOOTCOMMAND \
"while true; do " \
"mmc read ${fdt_addr_r} 0x10000 0x1000; " \
"fastboot; " \
"mmc read ${fdt_addr_r} 0x10000 0x1000; " \
"mmc read ${kernel_addr_r} 0x8000 0x8000 && " \
"bootm ${kernel_addr_r} ${kernel_addr_r} ${fdt_addr_r};" \
"done"

This relies on fastboot doing USB cable detection and it exits if no USB connection.

USB ethernet is as good a default as any. Otherwise reading Image and dtb from the 1st or bootable partition (the default) would be reasonable.

Quoted 8 lines
Quoted 7 lines

include/configs/hikey.h line 150

Quoted 4 lines
include/configs/hikey.h new file +4 -0
+/* Preserve enviroment onto sd card */
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV         1
+#define CONFIG_SYS_MMC_ENV_PART                0

Don't you have these reversed? The first MMC device is 0 and I think partition numbering starts at 1.

Quoted 4 lines

Having CONFIG_SYS_MMC_ENV_DEV 1 was deliberate, as the first device is eMMC, and I don't have a "official" partition to save the u-boot enviroment in. So as not to corrupt anything folks may have flashed into eMMC from the official builds I opted to save the u-boot env to SD card which is device 1.

Okay, but don't you have spare space in the partition with u-boot? I have a single bootloader partition 1MB in size and the last 8? KB is the env.

Quoted 24 lines

However that seems to have been working by luck with ENC_PART being 0, and it was actually corrupting the partition table of the SD card. Looking more closely I think what I should of used is

#define CONFIG_ENV_IS_IN_FAT

#define FAT_ENV_INTERFACE               "mmc"
#define FAT_ENV_DEVICE_AND_PART         "1:1"
#define FAT_ENV_FILE                    "uboot.env"

This then saves the enviroment on a fat formatted SD card with the filename u-boot.env. This is what I plan on using for v3.

Maybe I should additionally request some space in the official eMMC parition table and then we could switch over to using that.

Quoted 8 lines

include/configs/hikey.h line 154

Quoted 5 lines
include/configs/hikey.h new file +4 -0
+#define CONFIG_ENV_OFFSET               0x0
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT

Is redundant env necessary? It seems like this was more for raw NAND and shouldn't really be needed for MMC.

Quoted 4 lines

README file documents it as being valid for CONFIG_ENV_IS_IN_MMC, and a bunch of boards declare it with their CONFIG_ENV_IS_IN_MMC such as omap5_uevm.h, dra7xx_evm.h, am335x_evm.h. Whilst using managed NAND should be more reliable, I think it is still used in case there is a power failure whilst issuing 'saveenv'.

Perhaps a bunch of cut and paste. I'd guess there are many more platforms that use MMC and don't enable redundant.

Quoted 2 lines

Anyways with moving to CONFIG_ENV_IS_IN_FAT I won't need it anymore so it will be removed in V3.

Storing in FAT probably only increases your chance of failure from power failure. :)

Rob

#18 lore raw

PATCH v2 5/6 ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey board.

Quoted 1 line · Rob Herring

On Wed, Jul 15, 2015 at 7:41 PM, Peter Griffin <[email protected]> wrote:

[snip]

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

include/configs/hikey.h line 154

Quoted 4 lines
include/configs/hikey.h new file +4 -0
+#define CONFIG_ENV_OFFSET               0x0
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT

Is redundant env necessary? It seems like this was more for raw NAND and shouldn't really be needed for MMC.

Quoted 7 lines
Quoted 4 lines

README file documents it as being valid for CONFIG_ENV_IS_IN_MMC, and a bunch of boards declare it with their CONFIG_ENV_IS_IN_MMC such as omap5_uevm.h, dra7xx_evm.h, am335x_evm.h. Whilst using managed NAND should be more reliable, I think it is still used in case there is a power failure whilst issuing 'saveenv'.

Perhaps a bunch of cut and paste. I'd guess there are many more platforms that use MMC and don't enable redundant.

No, we turn it on, on purpose, out of a certain level of paranoia (and for ref boards like those, showing everything one could do, let $company and their experts argue of which failure possibilities are the important ones).

Quoted 5 lines
Quoted 2 lines

Anyways with moving to CONFIG_ENV_IS_IN_FAT I won't need it anymore so it will be removed in V3.

Storing in FAT probably only increases your chance of failure from power failure. :)

True but IMHO env in FAT is the most friendly option for a community board. "Broke your ENV? Stick the SD card in your PC, delete .." "Here, take a look at my env, copy this file ..." and all that.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150716/14efecdc/attachment.sig>
#19 lore raw

PATCH v2 5/6 ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey board.

In reply to Rob Herring

Hi Rob,

Quoted 15 lines · Rob Herring
Quoted 5 lines · Peter Griffin

Hi Rob,

Quoted 1 line · Rob Herring

On Wed, Jul 8, 2015 at 10:57 AM, Peter Griffin <

Quoted 1 line · peter.griffin at linaro.org> wrote:
Quoted 1 line
Quoted 1 line

HiKey is the first 96boards consumer edition compliant board. It

features a hi6220

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

SoC which has eight ARM A53 cpu's.

[...]

<snip>

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

You are probably going to want to setup multiple serial consoles (debug + LS header). That can come later, but I've figured out how to enable that if you are interested.

Yes I'm interested, please do let me know :)

Quoted 8 lines

See this commit:

https://git.linaro.org/people/rob.herring/u-boot.git/commitdiff/f1d0aef06ae7fe09793d46589bd94fa36c45bbc0

This may be 8250 specific and require more work for pl011 driver. The mixture of 0 and 1 based indexing makes it fun too.

OK thanks for the pointer :) I'm waiting for one of Grants expansion boards to be sent to me, so will try it out when it arrives.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
include/configs/hikey.h new file +3 -0
+#define CONFIG_EXTRA_ENV_SETTINGS      \
+                               "kernel_name=Image\0"   \
+                               "kernel_addr=0x0000000\0" \
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Shouldn't this be 0x80000 to avoid copying from 0x0 to 0x80000.

I've updated this. Kernel boot time is much reduced with this and also

the

Quoted 1 line

icache being enabled.

Also, this should be kernel_addr_r

Fixed in v3

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

include/configs/hikey.h line 134

Quoted 5 lines
include/configs/hikey.h new file +2 -0
+                               "fdt_name=hi6220-hikey.dtb\0" \
+                               "fdt_addr=0x0300000\0" \

and fdt_addr_r

Fixed in v3

Quoted 51 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines

+ "max_fdt=0x100000\0" \

I don't think this is needed.

Quoted 7 lines

Removed in V3

Quoted 6 lines

include/configs/hikey.h

Quoted 6 lines
include/configs/hikey.h new file +5 -0
+                               "fdt_high=0xffffffffffffffff\0" \
+                               "initrd_high=0xffffffffffffffff\0" \
+
+/* Assume we boot with root on the first partition of a USB stick */
+#define CONFIG_BOOTARGS                "console=ttyAMA0,115200n8

/dev/mmcblk0p7 rw "

Quoted 4 lines
Quoted 2 lines

/dev/mmcblk0p7 doesn't look right. You mean "root=/dev/..."?

Good spot, yes your right. Plus now you highlight it the comment above

also needs updating.

Quoted 10 lines

Will fix in V3.

Quoted 7 lines

include/configs/hikey.h line 143

Quoted 4 lines
include/configs/hikey.h new file +3 -0
+
+/* Copy the kernel and FDT to DRAM memory and boot */
+#define CONFIG_BOOTCOMMAND     "booti $kernel_addr_r - $fdt_addr_r"

Don't you need to set these variables?

Quoted 6 lines
Quoted 1 line

Also, don't you need to load the kernel and dtb first?

Yes, but I'm not sure quite what to make the default here. My personal workflow is: -

"usb start; dhcp; tftp $kernel_addr $kernel_name; tftp $fdt_addr

$fdt_name;

Quoted 3 lines

booti $kernel_addr - $fdt_addr"

So I could use that unless you have a better idea?

Not really as everyone has their own preferences. I have some thing like this:

#define CONFIG_BOOTCOMMAND \
"while true; do " \
"mmc read ${fdt_addr_r} 0x10000 0x1000; " \
"fastboot; " \
"mmc read ${fdt_addr_r} 0x10000 0x1000; " \
"mmc read ${kernel_addr_r} 0x8000 0x8000 && " \
"bootm ${kernel_addr_r} ${kernel_addr_r} ${fdt_addr_r};" \
"done"

Quoted 7 lines

This relies on fastboot doing USB cable detection and it exits if no USB connection.

USB ethernet is as good a default as any. Otherwise reading Image and dtb from the 1st or bootable partition (the default) would be reasonable.

Thanks for sharing your setup, I've updated the bootcmd to be the USB ethernet by default in the V3 patches.

Quoted 10 lines
Quoted 9 lines
Quoted 7 lines

+/* Preserve enviroment onto sd card */

include/configs/hikey.h line 150

Quoted 3 lines
include/configs/hikey.h new file +3 -0
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV         1
+#define CONFIG_SYS_MMC_ENV_PART                0

Don't you have these reversed? The first MMC device is 0 and I think partition numbering starts at 1.

Having CONFIG_SYS_MMC_ENV_DEV 1 was deliberate, as the first device is

eMMC, and

Quoted 9 lines
Quoted 2 lines

I don't have a "official" partition to save the u-boot enviroment in. So as not to corrupt anything folks may have flashed into eMMC from the

official

Quoted 1 line

builds I opted to save the u-boot env to SD card which is device 1.

Okay, but don't you have spare space in the partition with u-boot? I have a single bootloader partition 1MB in size and the last 8? KB is the env.

Good idea, I'd not thought of that and we could most likely do that if we wanted. However I plan on sticking with u-boot env on the sd card for the moment
as Tom pointed out it can be a bit more user friendly for a community board.

Quoted 32 lines
Quoted 2 lines

However that seems to have been working by luck with ENC_PART being 0,

and it was

Quoted 1 line

actually corrupting the partition table of the SD card. Looking more

closely I think

Quoted 8 lines

what I should of used is

#define CONFIG_ENV_IS_IN_FAT

#define FAT_ENV_INTERFACE               "mmc"
#define FAT_ENV_DEVICE_AND_PART         "1:1"
#define FAT_ENV_FILE                    "uboot.env"

This then saves the enviroment on a fat formatted SD card with the

filename

Quoted 3 lines

u-boot.env. This is what I plan on using for v3.

Maybe I should additionally request some space in the official eMMC

parition

Quoted 6 lines

table and then we could switch over to using that.

Quoted 4 lines

include/configs/hikey.h

Quoted 4 lines
include/configs/hikey.h new file +3 -0
+#define CONFIG_ENV_OFFSET               0x0
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET +

CONFIG_ENV_SIZE)

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT

Is redundant env necessary? It seems like this was more for raw NAND and shouldn't really be needed for MMC.

README file documents it as being valid for CONFIG_ENV_IS_IN_MMC, and a

bunch of boards

Quoted 9 lines
Quoted 1 line

declare it with their CONFIG_ENV_IS_IN_MMC such as omap5_uevm.h,

dra7xx_evm.h,

Quoted 1 line

am335x_evm.h. Whilst using managed NAND should be more reliable, I think

it

Quoted 1 line

is still used in case there is a power failure whilst issuing 'saveenv'.

Perhaps a bunch of cut and paste. I'd guess there are many more platforms that use MMC and don't enable redundant.

Tom answered this one already.

Quoted 9 lines
Quoted 2 lines

Anyways with moving to CONFIG_ENV_IS_IN_FAT I won't need it anymore so

it will be

Quoted 1 line

removed in V3.

Storing in FAT probably only increases your chance of failure from power failure. :)

Ha, yes maybe :)

regards,

Peter.

#20 lore raw

PATCH v2 5/6 ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey board.

In reply to Peter Griffin

Hi Peter,

Quoted 116 lines · Peter Griffin

HiKey is the first 96boards consumer edition compliant board. It features a hi6220 SoC which has eight ARM A53 cpu's.

This initial port adds support for: -
1) Serial
2) eMMC / sd card
3) USB
4) GPIO

It has been tested with Arm Trusted Firmware running u-boot as the BL33 executable.

Notes:

eMMC has been tested with basic reading of eMMC partition intto DDR. I have not tested writing / erasing. Due to lack of clock control it won't be running in the most performant high speed mode.

SD card slot has been tested for reading and booting kernels into DDR. It is also currently used for saving the u-boot enviroment.

USB has been tested with ASIX networking adapter to tftpboot kernels into DDR. On v2015.07-rc2 dhcp now works, and also usb mass storage is enumerated correctly.

GPIO has been tested using gpio toggle GPIO4_1-3 to flash LEDs.

Basic SoC datasheet can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf

Board schematic can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
96Boards-Hikey-Rev-A1.pdf

---
 arch/arm/Kconfig               |   8 +
 board/hisilicon/hikey/Kconfig  |  15 ++
 board/hisilicon/hikey/Makefile |   8 +
 board/hisilicon/hikey/hikey.c  | 415 +++++++++++++++++++++++++++++++++++++++++
 configs/hikey_defconfig        |   5 +
 include/configs/hikey.h        | 168 +++++++++++++++++
 6 files changed, 619 insertions(+)
 create mode 100644 board/hisilicon/hikey/Kconfig
 create mode 100644 board/hisilicon/hikey/Makefile
 create mode 100644 board/hisilicon/hikey/hikey.c
 create mode 100644 configs/hikey_defconfig
 create mode 100644 include/configs/hikey.h
arch/arm/Kconfig +8 -0
index 2985e6e..d0b7939 100644
@@ -721,6 +721,13 @@ config TARGET_LS2085ARDB
          development platform that supports the QorIQ LS2085A
          Layerscape Architecture processor.
 
+config TARGET_HIKEY
+       bool "Support HiKey 96boards Consumer Edition Platform"
+       select ARM64
+         help
+         Support for HiKey 96boards platform. It features a HI6220
+         SoC, with 8xA53 CPU, mali450 gpu, and 1GB RAM.
+
 config TARGET_LS1021AQDS
        bool "Support ls1021aqds"
        select CPU_V7
@@ -865,6 +872,7 @@ source "board/Marvell/gplugd/Kconfig"
 source "board/armadeus/apf27/Kconfig"
 source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
+source "board/hisilicon/hikey/Kconfig"
 source "board/bachmann/ot1200/Kconfig"
 source "board/balloon3/Kconfig"
 source "board/barco/platinum/Kconfig"
board/hisilicon/hikey/Kconfig new file +15 -0
new file mode 100644
index 0000000..f7f1055
@@ -0,0 +1,15 @@
+if TARGET_HIKEY
+
+config SYS_BOARD
+       default "hikey"
+
+config SYS_VENDOR
+       default "hisilicon"
+
+config SYS_SOC
+       default "hi6220"
+
+config SYS_CONFIG_NAME
+       default "hikey"
+
+endif
board/hisilicon/hikey/Makefile new file +8 -0
new file mode 100644
index 0000000..d4ec8c7
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2000-2004
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  := hikey.o
board/hisilicon/hikey/hikey.c new file +0 -0
new file mode 100644
index 0000000..bd5c409

board/hisilicon/hikey/hikey.c line 10

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +10 -0
@@ -0,0 +1,415 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <common.h>
+#include <dm.h>
+#include <malloc.h>
+#include <errno.h>

nit: errno.h should go above malloc.h

board/hisilicon/hikey/hikey.c line 19

Quoted 9 lines
board/hisilicon/hikey/hikey.c new file +9 -0
+#include <netdev.h>
+#include <asm/io.h>
+#include <asm-generic/gpio.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/dwmmc.h>
+#include <asm/arch/hi6220.h>
+#include <asm/arch/hi6553.h>
+
+#ifdef CONFIG_DM_GPIO

Isn't that always defined? Probably don't need this #ifdef. Also can you add a TODO to drop this table in favour of device tree?

Quoted 123 lines
board/hisilicon/hikey/hikey.c new file +123 -0
+static const struct hikey_gpio_platdata hi6220_gpio[] = {
+       { 0, HI6220_GPIO_BASE(0)},
+       { 1, HI6220_GPIO_BASE(1)},
+       { 2, HI6220_GPIO_BASE(2)},
+       { 3, HI6220_GPIO_BASE(3)},
+       { 4, HI6220_GPIO_BASE(4)},
+       { 5, HI6220_GPIO_BASE(5)},
+       { 6, HI6220_GPIO_BASE(6)},
+       { 7, HI6220_GPIO_BASE(7)},
+       { 8, HI6220_GPIO_BASE(8)},
+       { 9, HI6220_GPIO_BASE(9)},
+       { 10, HI6220_GPIO_BASE(10)},
+       { 11, HI6220_GPIO_BASE(11)},
+       { 12, HI6220_GPIO_BASE(12)},
+       { 13, HI6220_GPIO_BASE(13)},
+       { 14, HI6220_GPIO_BASE(14)},
+       { 15, HI6220_GPIO_BASE(15)},
+       { 16, HI6220_GPIO_BASE(16)},
+       { 17, HI6220_GPIO_BASE(17)},
+       { 18, HI6220_GPIO_BASE(18)},
+       { 19, HI6220_GPIO_BASE(19)},
+
+};
+
+U_BOOT_DEVICES(hi6220_gpios) = {
+       { "gpio_hi6220", &hi6220_gpio[0] },
+       { "gpio_hi6220", &hi6220_gpio[1] },
+       { "gpio_hi6220", &hi6220_gpio[2] },
+       { "gpio_hi6220", &hi6220_gpio[3] },
+       { "gpio_hi6220", &hi6220_gpio[4] },
+       { "gpio_hi6220", &hi6220_gpio[5] },
+       { "gpio_hi6220", &hi6220_gpio[6] },
+       { "gpio_hi6220", &hi6220_gpio[7] },
+       { "gpio_hi6220", &hi6220_gpio[8] },
+       { "gpio_hi6220", &hi6220_gpio[9] },
+       { "gpio_hi6220", &hi6220_gpio[10] },
+       { "gpio_hi6220", &hi6220_gpio[11] },
+       { "gpio_hi6220", &hi6220_gpio[12] },
+       { "gpio_hi6220", &hi6220_gpio[13] },
+       { "gpio_hi6220", &hi6220_gpio[14] },
+       { "gpio_hi6220", &hi6220_gpio[15] },
+       { "gpio_hi6220", &hi6220_gpio[16] },
+       { "gpio_hi6220", &hi6220_gpio[17] },
+       { "gpio_hi6220", &hi6220_gpio[18] },
+       { "gpio_hi6220", &hi6220_gpio[19] },
+};
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define EYE_PATTERN    0x70533483
+
+static void init_usb_and_picophy(void)
+{
+       unsigned int data;
+
+       /* enable USB clock */
+       writel(PERI_CLK0_USBOTG, PERI_SC_PERIPH_CLK0_EN);
+       do {
+               data = readl(PERI_SC_PERIPH_CLK0_STAT);
+       } while ((data & PERI_CLK0_USBOTG) == 0);
+
+       /* take usb IPs out of reset */
+       writel(PERI_RST0_USBOTG_BUS | PERI_RST0_POR_PICOPHY |
+               PERI_RST0_USBOTG | PERI_RST0_USBOTG_32K,
+               PERI_SC_PERIPH_RST0_DIS);
+       do {
+               data = readl(PERI_SC_PERIPH_RST0_STAT);
+               data &= PERI_RST0_USBOTG_BUS | PERI_RST0_POR_PICOPHY |
+                       PERI_RST0_USBOTG | PERI_RST0_USBOTG_32K;
+       } while (data);
+
+       /*CTRL 5*/
+       data = readl(PERI_SC_PERIPH_CTRL5);
+       data &= ~PERI_CTRL5_PICOPHY_BC_MODE;
+       data |= PERI_CTRL5_USBOTG_RES_SEL | PERI_CTRL5_PICOPHY_ACAENB;
+       data |= 0x300;
+       writel(data, PERI_SC_PERIPH_CTRL5);
+
+       /*CTRL 4*/
+
+       /* configure USB PHY */
+       data = readl(PERI_SC_PERIPH_CTRL4);
+
+       /* make PHY out of low power mode */
+       data &= ~PERI_CTRL4_PICO_SIDDQ;
+       data &= ~PERI_CTRL4_PICO_OGDISABLE;
+       data |= PERI_CTRL4_PICO_VBUSVLDEXTSEL | PERI_CTRL4_PICO_VBUSVLDEXT;
+       writel(data, PERI_SC_PERIPH_CTRL4);
+
+       writel(EYE_PATTERN, PERI_SC_PERIPH_CTRL8);
+
+       mdelay(5);
+}
+
+static int sd_card_detect(void)
+{
+       int ret;
+
+       /* configure GPIO8 as nopull */
+       writel(0, 0xf8001830);
+
+       gpio_request(8, "SD CD");
+
+       gpio_direction_input(8);
+       ret = gpio_get_value(8);
+
+       if (!ret) {
+               printf("%s: SD card present\n", __func__);
+               return 1;
+       }
+
+       printf("%s: SD card not present\n", __func__);
+       return 0;
+}
+
+static void mmc1_setup_pinmux(void)
+{
+       /* switch pinmux to SD */
+       writel(0, 0xf701000c);
+       writel(0, 0xf7010010);
+       writel(0, 0xf7010014);
+       writel(0, 0xf7010018);

board/hisilicon/hikey/hikey.c line 152

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +10 -0
+       writel(0, 0xf701001c);
+       writel(0, 0xf7010020);
+
+       /* input, 16mA or 12mA */
+       writel(0x64, 0xf701080c);
+       writel(0x54, 0xf7010810);
+       writel(0x54, 0xf7010814);
+       writel(0x54, 0xf7010818);
+       writel(0x54, 0xf701081c);
+       writel(0x54, 0xf7010820);

Should define a struct for this peripheral.

board/hisilicon/hikey/hikey.c line 163

Quoted 11 lines
board/hisilicon/hikey/hikey.c new file +11 -0
+
+       sd_card_detect();
+}
+
+static void mmc1_init_pll(void)
+{
+       uint32_t data;
+
+       /* select SYSPLL as the source of MMC1 */
+       /* select SYSPLL as the source of MUX1 (SC_CLK_SEL0) */
+       writel(1 << 11 | 1 << 27, PERI_SC_CLK0_SEL);

What are 11 and 27? Should they have an enum?

board/hisilicon/hikey/hikey.c line 172

Quoted 9 lines
board/hisilicon/hikey/hikey.c new file +9 -0
+       do {
+               data = readl(PERI_SC_CLK0_SEL);
+       } while (!(data & (1 << 11)));
+
+       /* select MUX1 as the source of MUX2 (SC_CLK_SEL0) */
+       writel(1 << 30, PERI_SC_CLK0_SEL);
+       do {
+               data = readl(PERI_SC_CLK0_SEL);
+       } while (data & (1 << 14));

Repeating code here and below - how about a function to enable a given clock?

Quoted 151 lines
board/hisilicon/hikey/hikey.c new file +151 -0
+
+       writel((1 << 1), PERI_SC_PERIPH_CLK0_EN);
+       do {
+               data = readl(PERI_SC_PERIPH_CLK0_STAT);
+       } while (!(data & (1 << 1)));
+
+       data = readl(PERI_SC_PERIPH_CLK12_EN);
+       data |= 1 << 2;
+       writel(data, PERI_SC_PERIPH_CLK12_EN);
+
+       do {
+               /* 1.2GHz / 50 = 24MHz */
+               writel(0x31 | (1 << 7), PERI_SC_CLKCFG8BIT2);
+               data = readl(PERI_SC_CLKCFG8BIT2);
+       } while ((data & 0x31) != 0x31);
+}
+
+static void mmc1_reset_clk(void)
+{
+       unsigned int data;
+
+       /* disable mmc1 bus clock */
+       writel(PERI_CLK0_MMC1, PERI_SC_PERIPH_CLK0_DIS);
+       do {
+               data = readl(PERI_SC_PERIPH_CLK0_STAT);
+       } while (data & PERI_CLK0_MMC1);
+
+       /* enable mmc1 bus clock */
+       writel(PERI_CLK0_MMC1, PERI_SC_PERIPH_CLK0_EN);
+       do {
+               data = readl(PERI_SC_PERIPH_CLK0_STAT);
+       } while (!(data & PERI_CLK0_MMC1));
+
+       /* reset mmc1 clock domain */
+       writel(PERI_RST0_MMC1, PERI_SC_PERIPH_RST0_EN);
+
+       /* bypass mmc1 clock phase */
+       data = readl(PERI_SC_PERIPH_CTRL2);
+       data |= 3 << 2;
+       writel(data, PERI_SC_PERIPH_CTRL2);
+
+       /* disable low power */
+       data = readl(PERI_SC_PERIPH_CTRL13);
+       data |= 1 << 4;
+       writel(data, PERI_SC_PERIPH_CTRL13);
+       do {
+               data = readl(PERI_SC_PERIPH_RST0_STAT);
+       } while (!(data & PERI_RST0_MMC1));
+
+       /* unreset mmc0 clock domain */
+       writel(PERI_RST0_MMC1, PERI_SC_PERIPH_RST0_DIS);
+       do {
+               data = readl(PERI_SC_PERIPH_RST0_STAT);
+       } while (data & PERI_RST0_MMC1);
+}
+
+/* PMU SSI is the IP that maps the external PMU hi6553 registers as IO */
+static void hi6220_pmussi_init(void)
+{
+       uint32_t data;
+
+       /* Take PMUSSI out of reset */
+       writel(ALWAYSON_SC_PERIPH_RST4_DIS_PRESET_PMUSSI_N,
+              ALWAYSON_SC_PERIPH_RST4_DIS);
+       do {
+               data = readl(ALWAYSON_SC_PERIPH_RST4_STAT);
+       } while (data & ALWAYSON_SC_PERIPH_RST4_DIS_PRESET_PMUSSI_N);
+
+       /* set PMU SSI clock latency for read operation */
+       data = readl(ALWAYSON_SC_MCU_SUBSYS_CTRL3);
+       data &= ~ALWAYSON_SC_MCU_SUBSYS_CTRL3_RCLK_MASK;
+       data |= ALWAYSON_SC_MCU_SUBSYS_CTRL3_RCLK_3;
+       writel(data, ALWAYSON_SC_MCU_SUBSYS_CTRL3);
+
+       /* enable PMUSSI clock */
+       data = ALWAYSON_SC_PERIPH_CLK5_EN_PCLK_PMUSSI_CCPU |
+              ALWAYSON_SC_PERIPH_CLK5_EN_PCLK_PMUSSI_MCU;
+       writel(data, ALWAYSON_SC_PERIPH_CLK5_EN);
+       data = ALWAYSON_SC_PERIPH_CLK4_EN_PCLK_PMUSSI;
+       writel(data, ALWAYSON_SC_PERIPH_CLK4_EN);
+
+       /* Output high to PMIC on PWR_HOLD_GPIO0_0 */
+       gpio_request(0, "PWR_HOLD_GPIO0_0");
+       gpio_direction_output(0, 1);
+}
+
+uint8_t hi6553_readb(unsigned int offset)
+{
+       return readb((u8 *)(unsigned long)HI6220_PMUSSI_BASE + (offset << 2));
+}
+
+void hi6553_writeb(unsigned int offset, uint8_t value)
+{
+       writeb(value, (u8 *)(unsigned long)HI6220_PMUSSI_BASE + (offset << 2));
+}
+
+static void hikey_hi6553_init(void)
+{
+       int data;
+
+       hi6553_writeb(HI6553_PERI_EN_MARK, 0x1e);
+       hi6553_writeb(HI6553_NP_REG_ADJ1, 0);
+       data = HI6553_DISABLE6_XO_CLK_CONN | HI6553_DISABLE6_XO_CLK_NFC |
+               HI6553_DISABLE6_XO_CLK_RF1 | HI6553_DISABLE6_XO_CLK_RF2;
+       hi6553_writeb(HI6553_DISABLE6_XO_CLK, data);
+
+       /* configure BUCK0 & BUCK1 */
+       hi6553_writeb(HI6553_BUCK01_CTRL2, 0x5e);
+       hi6553_writeb(HI6553_BUCK0_CTRL7, 0x10);
+       hi6553_writeb(HI6553_BUCK1_CTRL7, 0x10);
+       hi6553_writeb(HI6553_BUCK0_CTRL5, 0x1e);
+       hi6553_writeb(HI6553_BUCK1_CTRL5, 0x1e);
+       hi6553_writeb(HI6553_BUCK0_CTRL1, 0xfc);
+       hi6553_writeb(HI6553_BUCK1_CTRL1, 0xfc);
+
+       /* configure BUCK2 */
+       hi6553_writeb(HI6553_BUCK2_REG1, 0x4f);
+       hi6553_writeb(HI6553_BUCK2_REG5, 0x99);
+       hi6553_writeb(HI6553_BUCK2_REG6, 0x45);
+       mdelay(1);
+       hi6553_writeb(HI6553_VSET_BUCK2_ADJ, 0x22);
+       mdelay(1);
+
+       /* configure BUCK3 */
+       hi6553_writeb(HI6553_BUCK3_REG3, 0x02);
+       hi6553_writeb(HI6553_BUCK3_REG5, 0x99);
+       hi6553_writeb(HI6553_BUCK3_REG6, 0x41);
+       hi6553_writeb(HI6553_VSET_BUCK3_ADJ, 0x02);
+       mdelay(1);
+
+       /* configure BUCK4 */
+       hi6553_writeb(HI6553_BUCK4_REG2, 0x9a);
+       hi6553_writeb(HI6553_BUCK4_REG5, 0x99);
+       hi6553_writeb(HI6553_BUCK4_REG6, 0x45);
+
+       /* configure LDO20 */
+       hi6553_writeb(HI6553_LDO20_REG_ADJ, 0x50);
+
+       hi6553_writeb(HI6553_NP_REG_CHG, 0x0f);
+       hi6553_writeb(HI6553_CLK_TOP0, 0x06);
+       hi6553_writeb(HI6553_CLK_TOP3, 0xc0);
+       hi6553_writeb(HI6553_CLK_TOP4, 0x00);
+
+       /* configure LDO7 & LDO10 for SD slot */
+       data = hi6553_readb(HI6553_LDO7_REG_ADJ);
+       data = (data & 0xf8) | 0x2;
+       hi6553_writeb(HI6553_LDO7_REG_ADJ, data);
+       mdelay(5);
+       /* enable LDO7 */
+       hi6553_writeb(HI6553_ENABLE2_LDO1_8, 1 << 6);
+       mdelay(5);

board/hisilicon/hikey/hikey.c line 333

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +10 -0
+       data = hi6553_readb(HI6553_LDO10_REG_ADJ);
+       data = (data & 0xf8) | 0x5;
+       hi6553_writeb(HI6553_LDO10_REG_ADJ, data);
+       mdelay(5);
+       /* enable LDO10 */
+       hi6553_writeb(HI6553_ENABLE3_LDO9_16, 1 << 1);
+       mdelay(5);
+
+       /* select 32.764KHz */
+       hi6553_writeb(HI6553_CLK19M2_600_586_EN, 0x01);

This should go in a PMIC driver. Ideally most of this would happen automatically if the voltages are in the device tree, but since you don't have one, I suggest just moving this code into the driver.

board/hisilicon/hikey/hikey.c line 345

Quoted 12 lines
board/hisilicon/hikey/hikey.c new file +12 -0
+}
+
+int misc_init_r(void)
+{
+       init_usb_and_picophy();
+
+       return 0;
+}
+
+int board_init(void)
+{
+       gd->flags = 0;

Drop that.

board/hisilicon/hikey/hikey.c line 347

Quoted 2 lines
board/hisilicon/hikey/hikey.c new file +2 -0
+
+       icache_enable();

Should happen in generic ARM code at start-up?

Quoted 74 lines
board/hisilicon/hikey/hikey.c new file +68 -0
+
+       return 0;
+}
+
+#ifdef CONFIG_GENERIC_MMC
+
+static int init_dwmmc(void)
+{
+       int ret;
+
+#ifdef CONFIG_DWMMC
+       /* mmc0 pinmux and clocks are already configured by ATF */
+       ret = hi6220_dwmci_add_port(0, HI6220_MMC0_BASE, 8);
+
+       if (ret)
+               printf("%s: Error adding eMMC port\n", __func__);
+
+       /* take mmc1 (sd slot) out of reset, configure clocks and pinmuxing */
+
+       mmc1_init_pll();
+       mmc1_reset_clk();
+       mmc1_setup_pinmux();
+
+       ret |= hi6220_dwmci_add_port(1, HI6220_MMC1_BASE, 4);
+
+       if (ret)
+               printf("%s: Error adding SD port\n", __func__);
+#endif
+       return ret;
+}
+
+int board_mmc_init(bd_t *bis)
+{
+       int ret;
+
+       /* init the pmussi ip */
+       hi6220_pmussi_init();
+
+       /* init the hi6553 pmic */
+       hikey_hi6553_init();
+
+       /* add the eMMC and sd ports */
+       ret = init_dwmmc();
+
+       if (ret)
+               debug("init_dwmmc failed\n");
+
+       return ret;
+}
+#endif
+
+int dram_init(void)
+{
+       gd->ram_size = PHYS_SDRAM_1_SIZE;
+       return 0;
+}
+
+void dram_init_banksize(void)
+{
+       gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+       gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+}
+
+/* Use the Watchdog to cause reset */
+void reset_cpu(ulong addr)
+{
+       /* TODO program the watchdog */
+}
configs/hikey_defconfig new file +0 -0
new file mode 100644
index 0000000..50baf22

configs/hikey_defconfig line 4

Quoted 4 lines
configs/hikey_defconfig new file +4 -0
@@ -0,0 +1,5 @@
+# 96boards HiKey
+CONFIG_ARM=y
+CONFIG_TARGET_HIKEY=y
+CONFIG_SHOW_BOOT_PROGRESS=y

I don't think this works yet - there is no Kconfig for it. You can put it in your hikey.h file.

Quoted 49 lines
configs/hikey_defconfig new file +1 -0
+CONFIG_NET=y
include/configs/hikey.h new file +42 -0
new file mode 100644
index 0000000..303b857
@@ -0,0 +1,168 @@
+/*
+ * (C) Copyright 2015 Linaro
+ *
+ * Peter Griffin <[email protected]>
+ *
+ * Configuration for HiKey 96boards CE. Parts were derived from other ARM
+ * configurations.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __HIKEY_AEMV8A_H
+#define __HIKEY_AEMV8A_H
+
+/* We use generic board for hikey */
+#define CONFIG_SYS_GENERIC_BOARD
+
+#define CONFIG_REMAKE_ELF
+
+#define CONFIG_SUPPORT_RAW_INITRD
+
+/* Cache Definitions */
+#define CONFIG_SYS_DCACHE_OFF
+
+#define CONFIG_IDENT_STRING            "hikey"
+
+/* Flat Device Tree Definitions */
+#define CONFIG_OF_LIBFDT
+
+/* Physical Memory Map */
+
+/* CONFIG_SYS_TEXT_BASE needs to align with where ATF loads bl33.bin */
+#define CONFIG_SYS_TEXT_BASE           0x35000000
+
+#define CONFIG_NR_DRAM_BANKS           1
+#define PHYS_SDRAM_1                   0x00000000
+
+/* 1008 MB (the last 16Mb are secured for TrustZone by ATF*/
+#define PHYS_SDRAM_1_SIZE              0x3f000000
+#define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM_1
+
+#define CONFIG_SYS_INIT_RAM_SIZE       0x1000

include/configs/hikey.h line 52

Quoted 10 lines
include/configs/hikey.h new file +10 -0
+
+#define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE + 0x7fff0)
+
+#define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x80000)
+
+/* Generic Timer Definitions */
+#define COUNTER_FREQUENCY              (19000000)
+
+/* Generic Interrupt Controller Definitions */
+#define GICD_BASE                      (0xf6801000)

Don't need () around simple constants

include/configs/hikey.h line 63

Quoted 11 lines
include/configs/hikey.h new file +11 -0
+#define GICC_BASE                      (0xf6802000)
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN          (CONFIG_ENV_SIZE + (8 << 20))
+
+/* PL011 Serial Configuration */
+#define CONFIG_PL011_SERIAL
+
+#define CONFIG_PL011_CLOCK             19200000
+#define CONFIG_PL01x_PORTS             {(void *)CONFIG_SYS_SERIAL0}
+#define CONFIG_CONS_INDEX              0

Again this need to be device tree soon.

Quoted 106 lines
include/configs/hikey.h new file +105 -1
+
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_SERIAL0             0xF8015000
+
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_DWC2
+#define CONFIG_USB_DWC2_REG_ADDR 0xF72C0000
+/*#define CONFIG_DWC2_DFLT_SPEED_FULL*/
+#define CONFIG_DWC2_ENABLE_DYNAMIC_FIFO
+
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MISC_INIT_R
+#endif
+
+#define CONFIG_HIKEY_GPIO
+#define CONFIG_DM_GPIO
+#define CONFIG_CMD_GPIO
+#define CONFIG_DM
+
+/* SD/MMC configuration */
+#define CONFIG_GENERIC_MMC
+#define CONFIG_MMC
+#define CONFIG_DWMMC
+#define CONFIG_HIKEY_DWMMC
+#define CONFIG_BOUNCE_BUFFER
+#define CONFIG_CMD_MMC
+
+#define CONFIG_FS_EXT4
+#define CONFIG_FS_FAT
+
+/* Command line configuration */
+#define CONFIG_MENU
+#define CONFIG_CMD_CACHE
+#define CONFIG_CMD_BDI
+#define CONFIG_CMD_UNZIP
+#define CONFIG_CMD_PXE
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_IMI
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_ECHO
+#define CONFIG_CMD_SOURCE
+
+#define CONFIG_MAC_PARTITION
+#define CONFIG_MTD_PARTITIONS
+
+/* BOOTP options */
+#define CONFIG_BOOTP_BOOTFILESIZE
+
+#define CONFIG_CMD_NET
+
+#include <config_distro_defaults.h>
+
+/* Initial environment variables */
+
+/*
+ * Defines where the kernel and FDT exist in NOR flash and where it will
+ * be copied into DRAM
+ */
+#define CONFIG_EXTRA_ENV_SETTINGS      \
+                               "kernel_name=Image\0"   \
+                               "kernel_addr=0x0000000\0" \
+                               "fdt_name=hi6220-hikey.dtb\0" \
+                               "fdt_addr=0x0300000\0" \
+                               "max_fdt=0x100000\0" \
+                               "fdt_high=0xffffffffffffffff\0" \
+                               "initrd_high=0xffffffffffffffff\0" \
+
+/* Assume we boot with root on the first partition of a USB stick */
+#define CONFIG_BOOTARGS                "console=ttyAMA0,115200n8 /dev/mmcblk0p7 rw "
+
+/* Copy the kernel and FDT to DRAM memory and boot */
+#define CONFIG_BOOTCOMMAND     "booti $kernel_addr_r - $fdt_addr_r"
+
+#define CONFIG_BOOTDELAY               2
+
+/* Preserve enviroment onto sd card */
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV         1
+#define CONFIG_SYS_MMC_ENV_PART                0
+#define CONFIG_ENV_OFFSET               0x0
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
+
+/* Monitor Command Prompt */
+#define CONFIG_SYS_CBSIZE              512     /* Console I/O Buffer Size */
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + \
+                                       sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE
+#define CONFIG_SYS_LONGHELP
+#define CONFIG_CMDLINE_EDITING
+#define CONFIG_SYS_MAXARGS             64      /* max command args */
+
+#define CONFIG_SYS_NO_FLASH
+
+#endif /* __HIKEY_AEMV8A_H */
--
Quoted 2 lines

1.9.1

Regards,
Simon

#21 lore raw

PATCH v2 5/6 ARM64: hikey: hi6220: Add u-boot support for the 96boards CE HiKey board.

Hi Simon,

Thanks for reviewing.

Quoted 130 lines · Simon Glass

Hi Peter,

Quoted 1 line · Peter Griffin

HiKey is the first 96boards consumer edition compliant board. It

features a hi6220

Quoted 9 lines

SoC which has eight ARM A53 cpu's.

This initial port adds support for: -
1) Serial
2) eMMC / sd card
3) USB
4) GPIO

It has been tested with Arm Trusted Firmware running u-boot as the BL33

executable.

Quoted 4 lines

Notes:

eMMC has been tested with basic reading of eMMC partition intto DDR. I

have not

Quoted 20 lines

tested writing / erasing. Due to lack of clock control it won't be running in the most performant high speed mode.

SD card slot has been tested for reading and booting kernels into DDR. It is also currently used for saving the u-boot enviroment.

USB has been tested with ASIX networking adapter to tftpboot kernels into DDR. On v2015.07-rc2 dhcp now works, and also usb mass storage is enumerated correctly.

GPIO has been tested using gpio toggle GPIO4_1-3 to flash LEDs.

Basic SoC datasheet can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf

Board schematic can be found here: -
https://github.com/96boards/documentation/blob/master/hikey/
96Boards-Hikey-Rev-A1.pdf

Quoted 6 lines
---
 arch/arm/Kconfig               |   8 +
 board/hisilicon/hikey/Kconfig  |  15 ++
 board/hisilicon/hikey/Makefile |   8 +
 board/hisilicon/hikey/hikey.c  | 415

+++++++++++++++++++++++++++++++++++++++++

Review

Quoted 36 lines
 configs/hikey_defconfig        |   5 +
 include/configs/hikey.h        | 168 +++++++++++++++++
 6 files changed, 619 insertions(+)
 create mode 100644 board/hisilicon/hikey/Kconfig
 create mode 100644 board/hisilicon/hikey/Makefile
 create mode 100644 board/hisilicon/hikey/hikey.c
 create mode 100644 configs/hikey_defconfig
 create mode 100644 include/configs/hikey.h
arch/arm/Kconfig +8 -0
index 2985e6e..d0b7939 100644
@@ -721,6 +721,13 @@ config TARGET_LS2085ARDB
          development platform that supports the QorIQ LS2085A
          Layerscape Architecture processor.
 
+config TARGET_HIKEY
+       bool "Support HiKey 96boards Consumer Edition Platform"
+       select ARM64
+         help
+         Support for HiKey 96boards platform. It features a HI6220
+         SoC, with 8xA53 CPU, mali450 gpu, and 1GB RAM.
+
 config TARGET_LS1021AQDS
        bool "Support ls1021aqds"
        select CPU_V7
@@ -865,6 +872,7 @@ source "board/Marvell/gplugd/Kconfig"
 source "board/armadeus/apf27/Kconfig"
 source "board/armltd/vexpress/Kconfig"
 source "board/armltd/vexpress64/Kconfig"
+source "board/hisilicon/hikey/Kconfig"
 source "board/bachmann/ot1200/Kconfig"
 source "board/balloon3/Kconfig"
 source "board/barco/platinum/Kconfig"
(quoted diff) +0 -0

b/board/hisilicon/hikey/Kconfig

Review

Quoted 21 lines

new file mode 100644
index 0000000..f7f1055

board/hisilicon/hikey/Kconfig new file +15 -0
@@ -0,0 +1,15 @@
+if TARGET_HIKEY
+
+config SYS_BOARD
+       default "hikey"
+
+config SYS_VENDOR
+       default "hisilicon"
+
+config SYS_SOC
+       default "hi6220"
+
+config SYS_CONFIG_NAME
+       default "hikey"
+
+endif
(quoted diff) +0 -0

b/board/hisilicon/hikey/Makefile

Review

Quoted 14 lines

new file mode 100644
index 0000000..d4ec8c7

board/hisilicon/hikey/Makefile new file +8 -0
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2000-2004
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  := hikey.o
(quoted diff) +0 -0

b/board/hisilicon/hikey/hikey.c

Quoted 9 lines

new file mode 100644
index 0000000..bd5c409

board/hisilicon/hikey/hikey.c new file +4 -0
@@ -0,0 +1,415 @@
+/*
+ * (C) Copyright 2015 Linaro
+ * Peter Griffin <[email protected]>
+ *
Quoted 9 lines

board/hisilicon/hikey/hikey.c line 10

Quoted 6 lines
board/hisilicon/hikey/hikey.c new file +6 -0
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <common.h>
+#include <dm.h>
+#include <malloc.h>
+#include <errno.h>

nit: errno.h should go above malloc.h

Fixed in v3

Quoted 14 lines

board/hisilicon/hikey/hikey.c line 19

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +9 -0
+#include <netdev.h>
+#include <asm/io.h>
+#include <asm-generic/gpio.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/dwmmc.h>
+#include <asm/arch/hi6220.h>
+#include <asm/arch/hi6553.h>
+
+#ifdef CONFIG_DM_GPIO

Isn't that always defined? Probably don't need this #ifdef. Also can you add a TODO to drop this table in favour of device tree?

#ifdef removed and TODO added in v3

Quoted 129 lines
Quoted 79 lines
board/hisilicon/hikey/hikey.c new file +78 -0
+static const struct hikey_gpio_platdata hi6220_gpio[] = {
+       { 0, HI6220_GPIO_BASE(0)},
+       { 1, HI6220_GPIO_BASE(1)},
+       { 2, HI6220_GPIO_BASE(2)},
+       { 3, HI6220_GPIO_BASE(3)},
+       { 4, HI6220_GPIO_BASE(4)},
+       { 5, HI6220_GPIO_BASE(5)},
+       { 6, HI6220_GPIO_BASE(6)},
+       { 7, HI6220_GPIO_BASE(7)},
+       { 8, HI6220_GPIO_BASE(8)},
+       { 9, HI6220_GPIO_BASE(9)},
+       { 10, HI6220_GPIO_BASE(10)},
+       { 11, HI6220_GPIO_BASE(11)},
+       { 12, HI6220_GPIO_BASE(12)},
+       { 13, HI6220_GPIO_BASE(13)},
+       { 14, HI6220_GPIO_BASE(14)},
+       { 15, HI6220_GPIO_BASE(15)},
+       { 16, HI6220_GPIO_BASE(16)},
+       { 17, HI6220_GPIO_BASE(17)},
+       { 18, HI6220_GPIO_BASE(18)},
+       { 19, HI6220_GPIO_BASE(19)},
+
+};
+
+U_BOOT_DEVICES(hi6220_gpios) = {
+       { "gpio_hi6220", &hi6220_gpio[0] },
+       { "gpio_hi6220", &hi6220_gpio[1] },
+       { "gpio_hi6220", &hi6220_gpio[2] },
+       { "gpio_hi6220", &hi6220_gpio[3] },
+       { "gpio_hi6220", &hi6220_gpio[4] },
+       { "gpio_hi6220", &hi6220_gpio[5] },
+       { "gpio_hi6220", &hi6220_gpio[6] },
+       { "gpio_hi6220", &hi6220_gpio[7] },
+       { "gpio_hi6220", &hi6220_gpio[8] },
+       { "gpio_hi6220", &hi6220_gpio[9] },
+       { "gpio_hi6220", &hi6220_gpio[10] },
+       { "gpio_hi6220", &hi6220_gpio[11] },
+       { "gpio_hi6220", &hi6220_gpio[12] },
+       { "gpio_hi6220", &hi6220_gpio[13] },
+       { "gpio_hi6220", &hi6220_gpio[14] },
+       { "gpio_hi6220", &hi6220_gpio[15] },
+       { "gpio_hi6220", &hi6220_gpio[16] },
+       { "gpio_hi6220", &hi6220_gpio[17] },
+       { "gpio_hi6220", &hi6220_gpio[18] },
+       { "gpio_hi6220", &hi6220_gpio[19] },
+};
+#endif
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define EYE_PATTERN    0x70533483
+
+static void init_usb_and_picophy(void)
+{
+       unsigned int data;
+
+       /* enable USB clock */
+       writel(PERI_CLK0_USBOTG, PERI_SC_PERIPH_CLK0_EN);
+       do {
+               data = readl(PERI_SC_PERIPH_CLK0_STAT);
+       } while ((data & PERI_CLK0_USBOTG) == 0);
+
+       /* take usb IPs out of reset */
+       writel(PERI_RST0_USBOTG_BUS | PERI_RST0_POR_PICOPHY |
+               PERI_RST0_USBOTG | PERI_RST0_USBOTG_32K,
+               PERI_SC_PERIPH_RST0_DIS);
+       do {
+               data = readl(PERI_SC_PERIPH_RST0_STAT);
+               data &= PERI_RST0_USBOTG_BUS | PERI_RST0_POR_PICOPHY |
+                       PERI_RST0_USBOTG | PERI_RST0_USBOTG_32K;
+       } while (data);
+
+       /*CTRL 5*/
+       data = readl(PERI_SC_PERIPH_CTRL5);
+       data &= ~PERI_CTRL5_PICOPHY_BC_MODE;
+       data |= PERI_CTRL5_USBOTG_RES_SEL | PERI_CTRL5_PICOPHY_ACAENB;
+       data |= 0x300;
+       writel(data, PERI_SC_PERIPH_CTRL5);

board/hisilicon/hikey/hikey.c

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +10 -0
+
+       /*CTRL 4*/
+
+       /* configure USB PHY */
+       data = readl(PERI_SC_PERIPH_CTRL4);
+
+       /* make PHY out of low power mode */
+       data &= ~PERI_CTRL4_PICO_SIDDQ;
+       data &= ~PERI_CTRL4_PICO_OGDISABLE;
+       data |= PERI_CTRL4_PICO_VBUSVLDEXTSEL |

PERI_CTRL4_PICO_VBUSVLDEXT;

Quoted 39 lines
board/hisilicon/hikey/hikey.c new file +39 -0
+       writel(data, PERI_SC_PERIPH_CTRL4);
+
+       writel(EYE_PATTERN, PERI_SC_PERIPH_CTRL8);
+
+       mdelay(5);
+}
+
+static int sd_card_detect(void)
+{
+       int ret;
+
+       /* configure GPIO8 as nopull */
+       writel(0, 0xf8001830);
+
+       gpio_request(8, "SD CD");
+
+       gpio_direction_input(8);
+       ret = gpio_get_value(8);
+
+       if (!ret) {
+               printf("%s: SD card present\n", __func__);
+               return 1;
+       }
+
+       printf("%s: SD card not present\n", __func__);
+       return 0;
+}
+
+static void mmc1_setup_pinmux(void)
+{
+       /* switch pinmux to SD */
+       writel(0, 0xf701000c);
+       writel(0, 0xf7010010);
+       writel(0, 0xf7010014);
+       writel(0, 0xf7010018);
+       writel(0, 0xf701001c);
+       writel(0, 0xf7010020);
+
+       /* input, 16mA or 12mA */
Quoted 9 lines

board/hisilicon/hikey/hikey.c line 152

Quoted 6 lines
board/hisilicon/hikey/hikey.c new file +6 -0
+       writel(0x64, 0xf701080c);
+       writel(0x54, 0xf7010810);
+       writel(0x54, 0xf7010814);
+       writel(0x54, 0xf7010818);
+       writel(0x54, 0xf701081c);
+       writel(0x54, 0xf7010820);

Should define a struct for this peripheral.

In v3 I've added a minimal pinmux driver which I've reverse engineered by looking at the Linux code.

Sadly the Linux pinctrl settings don't actually work for the sd card slot and
it hangs the board. I've debugged this to not setting BIT(2) on the pull down/up/drive registers.

I don't have any documentation on the register bit fields only the the existing code which makes things difficult :(

Quoted 15 lines

board/hisilicon/hikey/hikey.c line 163

Quoted 12 lines
board/hisilicon/hikey/hikey.c new file +11 -0
+
+       sd_card_detect();
+}
+
+static void mmc1_init_pll(void)
+{
+       uint32_t data;
+
+       /* select SYSPLL as the source of MMC1 */
+       /* select SYSPLL as the source of MUX1 (SC_CLK_SEL0) */
+       writel(1 << 11 | 1 << 27, PERI_SC_CLK0_SEL);

What are 11 and 27? Should they have an enum?

Ideally yes, but unfortunately I don't have any documentation for the register.
All I know for sure is it doesn't work without it!

Quoted 11 lines

board/hisilicon/hikey/hikey.c line 172

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +9 -0
+       do {
+               data = readl(PERI_SC_CLK0_SEL);
+       } while (!(data & (1 << 11)));
+
+       /* select MUX1 as the source of MUX2 (SC_CLK_SEL0) */
+       writel(1 << 30, PERI_SC_CLK0_SEL);
+       do {
+               data = readl(PERI_SC_CLK0_SEL);
+       } while (data & (1 << 14));
Quoted 3 lines

Repeating code here and below - how about a function to enable a given clock?

I've added a clock_enable and clock_disable function in V3 and removed this code
duplication.

Quoted 160 lines
Quoted 47 lines
board/hisilicon/hikey/hikey.c new file +47 -0
+
+       writel((1 << 1), PERI_SC_PERIPH_CLK0_EN);
+       do {
+               data = readl(PERI_SC_PERIPH_CLK0_STAT);
+       } while (!(data & (1 << 1)));
+
+       data = readl(PERI_SC_PERIPH_CLK12_EN);
+       data |= 1 << 2;
+       writel(data, PERI_SC_PERIPH_CLK12_EN);
+
+       do {
+               /* 1.2GHz / 50 = 24MHz */
+               writel(0x31 | (1 << 7), PERI_SC_CLKCFG8BIT2);
+               data = readl(PERI_SC_CLKCFG8BIT2);
+       } while ((data & 0x31) != 0x31);
+}
+
+static void mmc1_reset_clk(void)
+{
+       unsigned int data;
+
+       /* disable mmc1 bus clock */
+       writel(PERI_CLK0_MMC1, PERI_SC_PERIPH_CLK0_DIS);
+       do {
+               data = readl(PERI_SC_PERIPH_CLK0_STAT);
+       } while (data & PERI_CLK0_MMC1);
+
+       /* enable mmc1 bus clock */
+       writel(PERI_CLK0_MMC1, PERI_SC_PERIPH_CLK0_EN);
+       do {
+               data = readl(PERI_SC_PERIPH_CLK0_STAT);
+       } while (!(data & PERI_CLK0_MMC1));
+
+       /* reset mmc1 clock domain */
+       writel(PERI_RST0_MMC1, PERI_SC_PERIPH_RST0_EN);
+
+       /* bypass mmc1 clock phase */
+       data = readl(PERI_SC_PERIPH_CTRL2);
+       data |= 3 << 2;
+       writel(data, PERI_SC_PERIPH_CTRL2);
+
+       /* disable low power */
+       data = readl(PERI_SC_PERIPH_CTRL13);
+       data |= 1 << 4;
+       writel(data, PERI_SC_PERIPH_CTRL13);
+       do {
+               data = readl(PERI_SC_PERIPH_RST0_STAT);

board/hisilicon/hikey/hikey.c

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +10 -0
+       } while (!(data & PERI_RST0_MMC1));
+
+       /* unreset mmc0 clock domain */
+       writel(PERI_RST0_MMC1, PERI_SC_PERIPH_RST0_DIS);
+       do {
+               data = readl(PERI_SC_PERIPH_RST0_STAT);
+       } while (data & PERI_RST0_MMC1);
+}
+
+/* PMU SSI is the IP that maps the external PMU hi6553 registers as IO

*/

Quoted 22 lines
board/hisilicon/hikey/hikey.c new file +22 -0
+static void hi6220_pmussi_init(void)
+{
+       uint32_t data;
+
+       /* Take PMUSSI out of reset */
+       writel(ALWAYSON_SC_PERIPH_RST4_DIS_PRESET_PMUSSI_N,
+              ALWAYSON_SC_PERIPH_RST4_DIS);
+       do {
+               data = readl(ALWAYSON_SC_PERIPH_RST4_STAT);
+       } while (data & ALWAYSON_SC_PERIPH_RST4_DIS_PRESET_PMUSSI_N);
+
+       /* set PMU SSI clock latency for read operation */
+       data = readl(ALWAYSON_SC_MCU_SUBSYS_CTRL3);
+       data &= ~ALWAYSON_SC_MCU_SUBSYS_CTRL3_RCLK_MASK;
+       data |= ALWAYSON_SC_MCU_SUBSYS_CTRL3_RCLK_3;
+       writel(data, ALWAYSON_SC_MCU_SUBSYS_CTRL3);
+
+       /* enable PMUSSI clock */
+       data = ALWAYSON_SC_PERIPH_CLK5_EN_PCLK_PMUSSI_CCPU |
+              ALWAYSON_SC_PERIPH_CLK5_EN_PCLK_PMUSSI_MCU;
+       writel(data, ALWAYSON_SC_PERIPH_CLK5_EN);
+       data = ALWAYSON_SC_PERIPH_CLK4_EN_PCLK_PMUSSI;

board/hisilicon/hikey/hikey.c

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +10 -0
+       writel(data, ALWAYSON_SC_PERIPH_CLK4_EN);
+
+       /* Output high to PMIC on PWR_HOLD_GPIO0_0 */
+       gpio_request(0, "PWR_HOLD_GPIO0_0");
+       gpio_direction_output(0, 1);
+}
+
+uint8_t hi6553_readb(unsigned int offset)
+{
+       return readb((u8 *)(unsigned long)HI6220_PMUSSI_BASE + (offset

<< 2));

board/hisilicon/hikey/hikey.c

Quoted 5 lines
board/hisilicon/hikey/hikey.c new file +5 -0
+}
+
+void hi6553_writeb(unsigned int offset, uint8_t value)
+{
+       writeb(value, (u8 *)(unsigned long)HI6220_PMUSSI_BASE + (offset

<< 2));

Quoted 63 lines
board/hisilicon/hikey/hikey.c new file +63 -0
+}
+
+static void hikey_hi6553_init(void)
+{
+       int data;
+
+       hi6553_writeb(HI6553_PERI_EN_MARK, 0x1e);
+       hi6553_writeb(HI6553_NP_REG_ADJ1, 0);
+       data = HI6553_DISABLE6_XO_CLK_CONN | HI6553_DISABLE6_XO_CLK_NFC |
+               HI6553_DISABLE6_XO_CLK_RF1 | HI6553_DISABLE6_XO_CLK_RF2;
+       hi6553_writeb(HI6553_DISABLE6_XO_CLK, data);
+
+       /* configure BUCK0 & BUCK1 */
+       hi6553_writeb(HI6553_BUCK01_CTRL2, 0x5e);
+       hi6553_writeb(HI6553_BUCK0_CTRL7, 0x10);
+       hi6553_writeb(HI6553_BUCK1_CTRL7, 0x10);
+       hi6553_writeb(HI6553_BUCK0_CTRL5, 0x1e);
+       hi6553_writeb(HI6553_BUCK1_CTRL5, 0x1e);
+       hi6553_writeb(HI6553_BUCK0_CTRL1, 0xfc);
+       hi6553_writeb(HI6553_BUCK1_CTRL1, 0xfc);
+
+       /* configure BUCK2 */
+       hi6553_writeb(HI6553_BUCK2_REG1, 0x4f);
+       hi6553_writeb(HI6553_BUCK2_REG5, 0x99);
+       hi6553_writeb(HI6553_BUCK2_REG6, 0x45);
+       mdelay(1);
+       hi6553_writeb(HI6553_VSET_BUCK2_ADJ, 0x22);
+       mdelay(1);
+
+       /* configure BUCK3 */
+       hi6553_writeb(HI6553_BUCK3_REG3, 0x02);
+       hi6553_writeb(HI6553_BUCK3_REG5, 0x99);
+       hi6553_writeb(HI6553_BUCK3_REG6, 0x41);
+       hi6553_writeb(HI6553_VSET_BUCK3_ADJ, 0x02);
+       mdelay(1);
+
+       /* configure BUCK4 */
+       hi6553_writeb(HI6553_BUCK4_REG2, 0x9a);
+       hi6553_writeb(HI6553_BUCK4_REG5, 0x99);
+       hi6553_writeb(HI6553_BUCK4_REG6, 0x45);
+
+       /* configure LDO20 */
+       hi6553_writeb(HI6553_LDO20_REG_ADJ, 0x50);
+
+       hi6553_writeb(HI6553_NP_REG_CHG, 0x0f);
+       hi6553_writeb(HI6553_CLK_TOP0, 0x06);
+       hi6553_writeb(HI6553_CLK_TOP3, 0xc0);
+       hi6553_writeb(HI6553_CLK_TOP4, 0x00);
+
+       /* configure LDO7 & LDO10 for SD slot */
+       data = hi6553_readb(HI6553_LDO7_REG_ADJ);
+       data = (data & 0xf8) | 0x2;
+       hi6553_writeb(HI6553_LDO7_REG_ADJ, data);
+       mdelay(5);
+       /* enable LDO7 */
+       hi6553_writeb(HI6553_ENABLE2_LDO1_8, 1 << 6);
+       mdelay(5);
+       data = hi6553_readb(HI6553_LDO10_REG_ADJ);
+       data = (data & 0xf8) | 0x5;
+       hi6553_writeb(HI6553_LDO10_REG_ADJ, data);
+       mdelay(5);
+       /* enable LDO10 */
+       hi6553_writeb(HI6553_ENABLE3_LDO9_16, 1 << 1);
Quoted 9 lines

board/hisilicon/hikey/hikey.c line 333

Quoted 4 lines
board/hisilicon/hikey/hikey.c new file +4 -0
+       mdelay(5);
+
+       /* select 32.764KHz */
+       hi6553_writeb(HI6553_CLK19M2_600_586_EN, 0x01);

This should go in a PMIC driver. Ideally most of this would happen automatically if the voltages are in the device tree, but since you don't have one, I suggest just moving this code into the driver.

Ok I've done as you suggested and added a simple simple pmic driver in v3. From a practical PoV this means you can now dump the pmic regs using the pmic * commands, which might be helpful to somebody.

Quoted 6 lines
Quoted 6 lines
board/hisilicon/hikey/hikey.c new file +6 -0
+}
+
+int misc_init_r(void)
+{
+       init_usb_and_picophy();
+
Quoted 9 lines

board/hisilicon/hikey/hikey.c line 345

Quoted 6 lines
board/hisilicon/hikey/hikey.c new file +6 -0
+       return 0;
+}
+
+int board_init(void)
+{
+       gd->flags = 0;

Drop that.

Fixed in v3

Quoted 6 lines

board/hisilicon/hikey/hikey.c line 347

Quoted 3 lines
board/hisilicon/hikey/hikey.c new file +2 -0
+
+       icache_enable();

Should happen in generic ARM code at start-up?

Yes Rob also pointed this out, I've removed it in V3.

Quoted 75 lines
Quoted 9 lines
board/hisilicon/hikey/hikey.c new file +8 -0
+
+       return 0;
+}
+
+#ifdef CONFIG_GENERIC_MMC
+
+static int init_dwmmc(void)
+{

board/hisilicon/hikey/hikey.c

Quoted 10 lines
board/hisilicon/hikey/hikey.c new file +10 -0
+       int ret;
+
+#ifdef CONFIG_DWMMC
+       /* mmc0 pinmux and clocks are already configured by ATF */
+       ret = hi6220_dwmci_add_port(0, HI6220_MMC0_BASE, 8);
+
+       if (ret)
+               printf("%s: Error adding eMMC port\n", __func__);
+
+       /* take mmc1 (sd slot) out of reset, configure clocks and

pinmuxing */

Quoted 55 lines
board/hisilicon/hikey/hikey.c new file +50 -0
+
+       mmc1_init_pll();
+       mmc1_reset_clk();
+       mmc1_setup_pinmux();
+
+       ret |= hi6220_dwmci_add_port(1, HI6220_MMC1_BASE, 4);
+
+       if (ret)
+               printf("%s: Error adding SD port\n", __func__);
+#endif
+       return ret;
+}
+
+int board_mmc_init(bd_t *bis)
+{
+       int ret;
+
+       /* init the pmussi ip */
+       hi6220_pmussi_init();
+
+       /* init the hi6553 pmic */
+       hikey_hi6553_init();
+
+       /* add the eMMC and sd ports */
+       ret = init_dwmmc();
+
+       if (ret)
+               debug("init_dwmmc failed\n");
+
+       return ret;
+}
+#endif
+
+int dram_init(void)
+{
+       gd->ram_size = PHYS_SDRAM_1_SIZE;
+       return 0;
+}
+
+void dram_init_banksize(void)
+{
+       gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+       gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+}
+
+/* Use the Watchdog to cause reset */
+void reset_cpu(ulong addr)
+{
+       /* TODO program the watchdog */
+}
configs/hikey_defconfig new file +0 -0
new file mode 100644
index 0000000..50baf22
Quoted 9 lines

configs/hikey_defconfig line 4

Quoted 5 lines
configs/hikey_defconfig new file +4 -0
@@ -0,0 +1,5 @@
+# 96boards HiKey
+CONFIG_ARM=y
+CONFIG_TARGET_HIKEY=y
+CONFIG_SHOW_BOOT_PROGRESS=y

I don't think this works yet - there is no Kconfig for it. You can put it in your hikey.h file.

Ok, I've removed in V3, as not much use if it doesn't work.

Quoted 54 lines
Quoted 8 lines
configs/hikey_defconfig new file +1 -0
+CONFIG_NET=y
include/configs/hikey.h new file +0 -0
new file mode 100644
index 0000000..303b857

include/configs/hikey.h line 6

Quoted 6 lines
include/configs/hikey.h new file +6 -0
@@ -0,0 +1,168 @@
+/*
+ * (C) Copyright 2015 Linaro
+ *
+ * Peter Griffin <[email protected]>
+ *
+ * Configuration for HiKey 96boards CE. Parts were derived from other

ARM

Quoted 28 lines
include/configs/hikey.h new file +28 -0
+ * configurations.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __HIKEY_AEMV8A_H
+#define __HIKEY_AEMV8A_H
+
+/* We use generic board for hikey */
+#define CONFIG_SYS_GENERIC_BOARD
+
+#define CONFIG_REMAKE_ELF
+
+#define CONFIG_SUPPORT_RAW_INITRD
+
+/* Cache Definitions */
+#define CONFIG_SYS_DCACHE_OFF
+
+#define CONFIG_IDENT_STRING            "hikey"
+
+/* Flat Device Tree Definitions */
+#define CONFIG_OF_LIBFDT
+
+/* Physical Memory Map */
+
+/* CONFIG_SYS_TEXT_BASE needs to align with where ATF loads bl33.bin */
+#define CONFIG_SYS_TEXT_BASE           0x35000000
+

include/configs/hikey.h

Quoted 10 lines
include/configs/hikey.h new file +10 -0
+#define CONFIG_NR_DRAM_BANKS           1
+#define PHYS_SDRAM_1                   0x00000000
+
+/* 1008 MB (the last 16Mb are secured for TrustZone by ATF*/
+#define PHYS_SDRAM_1_SIZE              0x3f000000
+#define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM_1
+
+#define CONFIG_SYS_INIT_RAM_SIZE       0x1000
+
+#define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_SDRAM_BASE +

0x7fff0)

Quoted 11 lines

include/configs/hikey.h line 52

Quoted 8 lines
include/configs/hikey.h new file +8 -0
+
+#define CONFIG_SYS_LOAD_ADDR           (CONFIG_SYS_SDRAM_BASE + 0x80000)
+
+/* Generic Timer Definitions */
+#define COUNTER_FREQUENCY              (19000000)
+
+/* Generic Interrupt Controller Definitions */
+#define GICD_BASE                      (0xf6801000)

Don't need () around simple constants

Fixed in V3

Quoted 15 lines

include/configs/hikey.h line 63

Quoted 12 lines
include/configs/hikey.h new file +11 -0
+#define GICC_BASE                      (0xf6802000)
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN          (CONFIG_ENV_SIZE + (8 << 20))
+
+/* PL011 Serial Configuration */
+#define CONFIG_PL011_SERIAL
+
+#define CONFIG_PL011_CLOCK             19200000
+#define CONFIG_PL01x_PORTS             {(void *)CONFIG_SYS_SERIAL0}
+#define CONFIG_CONS_INDEX              0

Again this need to be device tree soon.

Yes ok. Also we wish to enable additional UARTS on the low speed connector. In v3 in the pinmux driver I've added code for the additional UARTs.

I'm also being sent an expansion board which brings out the UARTs on the lowspeed
connector, so I can test this :)

Quoted 107 lines
Quoted 68 lines
include/configs/hikey.h new file +67 -0
+
+#define CONFIG_BAUDRATE                        115200
+#define CONFIG_SYS_SERIAL0             0xF8015000
+
+#define CONFIG_CMD_USB
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_DWC2
+#define CONFIG_USB_DWC2_REG_ADDR 0xF72C0000
+/*#define CONFIG_DWC2_DFLT_SPEED_FULL*/
+#define CONFIG_DWC2_ENABLE_DYNAMIC_FIFO
+
+#define CONFIG_USB_STORAGE
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_SMSC95XX
+#define CONFIG_USB_ETHER_ASIX
+#define CONFIG_MISC_INIT_R
+#endif
+
+#define CONFIG_HIKEY_GPIO
+#define CONFIG_DM_GPIO
+#define CONFIG_CMD_GPIO
+#define CONFIG_DM
+
+/* SD/MMC configuration */
+#define CONFIG_GENERIC_MMC
+#define CONFIG_MMC
+#define CONFIG_DWMMC
+#define CONFIG_HIKEY_DWMMC
+#define CONFIG_BOUNCE_BUFFER
+#define CONFIG_CMD_MMC
+
+#define CONFIG_FS_EXT4
+#define CONFIG_FS_FAT
+
+/* Command line configuration */
+#define CONFIG_MENU
+#define CONFIG_CMD_CACHE
+#define CONFIG_CMD_BDI
+#define CONFIG_CMD_UNZIP
+#define CONFIG_CMD_PXE
+#define CONFIG_CMD_ENV
+#define CONFIG_CMD_IMI
+#define CONFIG_CMD_LOADB
+#define CONFIG_CMD_MEMORY
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_CMD_RUN
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_ECHO
+#define CONFIG_CMD_SOURCE
+
+#define CONFIG_MAC_PARTITION
+#define CONFIG_MTD_PARTITIONS
+
+/* BOOTP options */
+#define CONFIG_BOOTP_BOOTFILESIZE
+
+#define CONFIG_CMD_NET
+
+#include <config_distro_defaults.h>
+
+/* Initial environment variables */
+
+/*
+ * Defines where the kernel and FDT exist in NOR flash and where it will
+ * be copied into DRAM
+ */
+#define CONFIG_EXTRA_ENV_SETTINGS      \

include/configs/hikey.h

Quoted 10 lines
include/configs/hikey.h new file +10 -0
+                               "kernel_name=Image\0"   \
+                               "kernel_addr=0x0000000\0" \
+                               "fdt_name=hi6220-hikey.dtb\0" \
+                               "fdt_addr=0x0300000\0" \
+                               "max_fdt=0x100000\0" \
+                               "fdt_high=0xffffffffffffffff\0" \
+                               "initrd_high=0xffffffffffffffff\0" \
+
+/* Assume we boot with root on the first partition of a USB stick */
+#define CONFIG_BOOTARGS                "console=ttyAMA0,115200n8

/dev/mmcblk0p7 rw "

include/configs/hikey.h

Quoted 13 lines
include/configs/hikey.h new file +13 -0
+
+/* Copy the kernel and FDT to DRAM memory and boot */
+#define CONFIG_BOOTCOMMAND     "booti $kernel_addr_r - $fdt_addr_r"
+
+#define CONFIG_BOOTDELAY               2
+
+/* Preserve enviroment onto sd card */
+#define CONFIG_ENV_IS_IN_MMC
+#define CONFIG_SYS_MMC_ENV_DEV         1
+#define CONFIG_SYS_MMC_ENV_PART                0
+#define CONFIG_ENV_OFFSET               0x0
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET +

CONFIG_ENV_SIZE)

include/configs/hikey.h

Quoted 4 lines
include/configs/hikey.h new file +4 -0
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
+
+/* Monitor Command Prompt */
+#define CONFIG_SYS_CBSIZE              512     /* Console I/O Buffer

Size */

Quoted 9 lines
include/configs/hikey.h new file +9 -0
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + \
+                                       sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE
+#define CONFIG_SYS_LONGHELP
+#define CONFIG_CMDLINE_EDITING
+#define CONFIG_SYS_MAXARGS             64      /* max command args */
+
+#define CONFIG_SYS_NO_FLASH
Quoted 9 lines
Quoted 5 lines
include/configs/hikey.h new file +2 -1
+
+#endif /* __HIKEY_AEMV8A_H */
--

1.9.1

Regards,
Simon

regards,

Peter.

#22 lore raw

PATCH v2 6/6 ARM64: hikey: Add a README for this board.

In reply to Peter Griffin

To help others with compiling and flashing ATF and u-boot add a README for this board.

---
 board/hisilicon/hikey/README | 160 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 160 insertions(+)
 create mode 100644 board/hisilicon/hikey/README
board/hisilicon/hikey/README new file +160 -0
new file mode 100644
index 0000000..25c8143
@@ -0,0 +1,160 @@
+Introduction
+============
+
+HiKey is the first certified 96Boards Consumer Edition board. The board/SoC has: -
+* HiSilicon Kirin 6220 eight-core ARM Cortex-A53 64-bit SoC running at 1.2GHz.
+* ARM Mali 450-MP4 GPU
+* 1GB 800MHz LPDDR3 DRAM
+* 4GB eMMC Flash Storage
+* microSD
+* 802.11a/b/g/n WiFi, Bluetooth
+
+The HiKey schematic can be found here: -
+https://github.com/96boards/documentation/blob/master/hikey/96Boards-Hikey-Rev-A1.pdf
+
+A SoC datasheet can be found here: -
+https://github.com/96boards/documentation/blob/master/hikey/
+Hi6220V100_Multi-Mode_Application_Processor_Function_Description.pdf
+
+Currently the u-boot port supports: -
+* USB
+* eMMC
+* SD card
+* GPIO
+
+Compile u-boot
+==============
+
+make CROSS_COMPILE=aarch64-linux-gnu- hikey_config
+make CROSS_COMPILE=aarch64-linux-gnu-
+
+ARM Trusted Firmware (ATF) & l-loader
+=====================================
+
+This u-boot port has been tested with l-loader, booting ATF, which then boots
+u-boot as the bl33.bin executable.
+
+1. Get ATF source code
+git clone https://github.com/96boards/arm-trusted-firmware.git
+
+2. Compile ATF I use the makefile here
+http://people.linaro.org/~peter.griffin/hikey/hikey-u-boot-release_r1/build-tf.mak
+
+3. Get l-loader
+git clone https://github.com/96boards/l-loader.git
+
+4. Make sym links to ATF bip / fip binaries
+ln -s /home/griffinp/aarch64/bl1-hikey.bin bl1.bin
+ln -s /home/griffinp/aarch64/fip-hikey.bin fip.bin
+
+arm-linux-gnueabihf-gcc -c -o start.o start.S
+arm-linux-gnueabihf-gcc -c -o debug.o debug.S
+arm-linux-gnueabihf-ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o debug.o -o loader
+arm-linux-gnueabihf-objcopy -O binary loader temp
+
+python gen_loader.py -o l-loader.bin --img_loader=temp --img_bl1=bl1.bin
+sudo bash -x generate_ptable.sh
+python gen_loader.py -o ptable.img --img_prm_ptable=prm_ptable.img --img_sec_ptable=sec_ptable.img
+
+These instructions are adapted from
+https://github.com/96boards/documentation/wiki/HiKeyUEFI
+
+FLASHING
+========
+
+1. Connect jumper J2 to go into recovery mode and flash l-loader.bin with
+   fastboot using the hisi-idt.py utility
+
+> git clone https://github.com/96boards/burn-boot.git
+> sudo python /home/griffinp/Software/hikey/burn-boot/hisi-idt.py -d /dev/ttyUSB0 --img1=/tmp/l-loader.bin
+
+2. Once LED 0 comes on solid, it should be detected as a fastboot device
+   (on some boards I've found this to be unreliable)
+
+sudo fastboot devices
+
+3. Flash the images
+wget https://builds.96boards.org/releases/hikey/nvme.img
+sudo fastboot flash ptable ptable.img
+sudo fastboot flash fastboot fip.bin
+sudo fastboot flash nvme nvme.img
+
+4. Disconnect jumper J2, and reset the board and you will now (hopefully)
+   have ATF, booting u-boot from eMMC. On 'new' boards I've had to do the
+   flashing twice in the past to avoid an ATF error.
+
+See working boot trace below: -
+
+debug EMMC boot: print init OK
+debug EMMC boot: send RST_N .
+debug EMMC boot: start eMMC boot......
+load fastboot1!
+Switch to aarch64 mode. CPU0 executes at 0xf9801000!
+NOTICE:  Booting Trusted Firmware
+NOTICE:  BL1: v1.1(release):a0c0399
+NOTICE:  BL1: Built : 13:23:48, May 22 2015
+NOTICE:  succeed to init lpddr3 rank0 dram phy
+INFO:    lpddr3_freq_init, set ddrc 533mhz
+INFO:    init ddr3 rank0
+INFO:    ddr3 rank1 init pass
+INFO:    lpddr3_freq_init, set ddrc 800mhz
+INFO:    init ddr3 rank0
+INFO:    ddr3 rank1 init pass
+INFO:    Elpida DDR
+NOTICE:  BL1: Booting BL2
+INFO:    [BDID] [fff91c18] midr: 0x410fd033
+INFO:    [BDID] [fff91c1c] board type: 0
+INFO:    [BDID] [fff91c20] board id: 0x2b
+INFO:    init_acpu_dvfs: pmic version 17
+INFO:    init_acpu_dvfs: ACPU_CHIP_MAX_FREQ=0x186a00.
+INFO:    acpu_dvfs_volt_init: success!
+INFO:    acpu_dvfs_set_freq: support freq num is 5
+INFO:    acpu_dvfs_set_freq: start prof is 0x4
+INFO:    acpu_dvfs_set_freq: magic is 0x5a5ac5c5
+INFO:    acpu_dvfs_set_freq: voltage:
+INFO:      - 0: 0x3a
+INFO:      - 1: 0x3a
+INFO:      - 2: 0x4a
+INFO:      - 3: 0x5b
+INFO:      - 4: 0x6b
+NOTICE:  acpu_dvfs_set_freq: set acpu freq success!NOTICE:  BL2: v1.1(debug):a0c0399
+NOTICE:  BL2: Built : 10:19:28, May 27 2015
+INFO:    BL2: Loading BL3-0
+INFO:    Using FIP
+WARNING: Failed to access image 'bl30.bin' (-1)
+ERROR:   Failed to load BL3-0 (-1)
+ERROR:   Please burn mcu image:
+ERROR:     sudo fastboot flash mcuimage mcuimage.bin
+INFO:    BL2: TrustZone: protecting 16777216 bytes of memory at 0x3f000000
+INFO:    BL2: Loading BL3-1
+INFO:    Using FIP
+INFO:    Loading file 'bl31.bin' at address 0xf9858000
+INFO:    File 'bl31.bin' loaded: 0xf9858000 - 0xf9860010
+INFO:    BL2: Loading BL3-2
+INFO:    Using FIP
+WARNING: Failed to access image 'bl32.bin' (-1)
+WARNING: Failed to load BL3-2 (-1)
+INFO:    BL2: Loading BL3-3
+INFO:    Using FIP
+INFO:    Loading file 'bl33.bin' at address 0x35000000
+INFO:    File 'bl33.bin' loaded: 0x35000000 - 0x35042938
+NOTICE:  BL1: Booting BL3-1
+NOTICE:  BL3-1: v1.1(debug):a0c0399
+NOTICE:  BL3-1: Built : 10:19:31, May 27 2015
+INFO:    BL3-1: Initializing runtime services
+INFO:    BL3-1: Preparing for EL3 exit to normal world
+INFO:    BL3-1: Next image address = 0x35000000
+INFO:    BL3-1: Next image spsr = 0x3c9
+
+
+U-Boot 2015.04-00007-g1b3d379-dirty (May 27 2015 - 10:18:16) hikey
+
+DRAM:  1008 MiB
+MMC:   sd_card_detect: SD card present
+HiKey DWMMC: 0, HiKey DWMMC: 1
+In:    serial
+Out:   serial
+Err:   serial
+Net:   Net Initialization Skipped
+No ethernet found.
+Hit any key to stop autoboot:  0
Signature · 1 line
1.9.1