[U-Boot] [PATCH] meson-gxbb: Add NanoPi K2

technical support techsupport at friendlyarm.com
Mon May 15 09:30:30 UTC 2017


Hi,
      Thank you for your support on our board.We will test it very soon.


thank you!






------------------
Forum: http://www.friendlyarm.com/Forum/
Facebook: https://www.facebook.com/FriendlyARM.Community/
NanoPi/Pi 2/Pi 2 Fire/M2 Family's homepage: nanopi.io , nanopi.cc
NanoPi 2 Wiki: http://wiki.friendlyarm.com/wiki/index.php/NanoPi_2
NanoPi 2 Fire Wiki: http://wiki.friendlyarm.com/wiki/index.php/NanoPi_2_Fire
NanoPi M2 Wiki: http://wiki.friendlyarm.com/wiki/index.php/NanoPi_M2


Company Page: www.friendlyarm.com

 

 
 
 
------------------ Original ------------------
From:  "Andreas Färber"<afaerber at suse.de>;
Date:  Mon, May 15, 2017 09:15 AM
To:  "u-boot"<u-boot at lists.denx.de>; 
Cc:  "Andreas Färber"<afaerber at suse.de>; "techsupport"<techsupport at friendlyarm.com>; "Albert Aribaud"<albert.u.boot at aribaud.net>; 
Subject:  [PATCH] meson-gxbb: Add NanoPi K2

 
The FriendlyARM NanoPi K2 is a single-board computer.

The Device Tree is taken from the v1 kernel patchset.

Cc: techsupport at friendlyarm.com
Signed-off-by: Andreas Färber <afaerber at suse.de>
---
 arch/arm/dts/meson-gxbb-nanopi-k2.dts | 152 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-meson/Kconfig           |   8 ++
 board/amlogic/nanopi-k2/Kconfig       |  12 +++
 board/amlogic/nanopi-k2/MAINTAINERS   |   6 ++
 board/amlogic/nanopi-k2/Makefile      |   7 ++
 board/amlogic/nanopi-k2/nanopi-k2.c   |  54 ++++++++++++
 configs/nanopi-k2_defconfig           |  30 +++++++
 include/configs/nanopi-k2.h           |  19 +++++
 8 files changed, 288 insertions(+)
 create mode 100644 arch/arm/dts/meson-gxbb-nanopi-k2.dts
 create mode 100644 board/amlogic/nanopi-k2/Kconfig
 create mode 100644 board/amlogic/nanopi-k2/MAINTAINERS
 create mode 100644 board/amlogic/nanopi-k2/Makefile
 create mode 100644 board/amlogic/nanopi-k2/nanopi-k2.c
 create mode 100644 configs/nanopi-k2_defconfig
 create mode 100644 include/configs/nanopi-k2.h

diff --git a/arch/arm/dts/meson-gxbb-nanopi-k2.dts b/arch/arm/dts/meson-gxbb-nanopi-k2.dts
new file mode 100644
index 0000000000..a42c89fc75
--- /dev/null
+++ b/arch/arm/dts/meson-gxbb-nanopi-k2.dts
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2017 Andreas Färber
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+ */
+
+/dts-v1/;
+
+#include "meson-gxbb.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	compatible = "friendlyarm,nanopi-k2", "amlogic,meson-gxbb";
+
+	aliases {
+		serial0 = &uart_AO;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	memory at 0 {
+		device_type = "memory";
+		reg = <0x0 0x0 0x0 0x80000000>;
+	};
+
+	vddio_ao3v3: regulator-vddio-ao3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "VDDIO_AO3.3V";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+	};
+
+	vddio_tf: gpio-regulator-vddio-tf {
+		compatible = "regulator-gpio";
+
+		regulator-name = "VDDIO_TF";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <3300000>;
+
+		gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_HIGH>;
+		gpios-states = <0>;
+
+		states = <3300000 0>,
+		         <1800000 1>;
+	};
+};
+
+&ethmac {
+	status = "okay";
+	pinctrl-0 = <&eth_rgmii_pins>;
+	pinctrl-names = "default";
+
+	phy-handle = <&eth_phy0>;
+	phy-mode = "rgmii";
+
+	amlogic,tx-delay-ns = <2>;
+
+	snps,reset-gpio = <&gpio GPIOZ_14 0>;
+	snps,reset-delays-us = <0 10000 1000000>;
+	snps,reset-active-low;
+
+	mdio {
+		compatible = "snps,dwmac-mdio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		eth_phy0: ethernet-phy at 0 {
+			/* Realtek RTL8211F (0x001cc916) */
+			reg = <0>;
+		};
+	};
+};
+
+&ir {
+	status = "okay";
+	pinctrl-0 = <&remote_input_ao_pins>;
+	pinctrl-names = "default";
+};
+
+/* SDIO */
+&sd_emmc_a {
+	status = "disabled";
+};
+
+/* SD */
+&sd_emmc_b {
+	status = "okay";
+	pinctrl-0 = <&sdcard_pins>;
+	pinctrl-names = "default";
+
+	bus-width = <4>;
+	cap-sd-highspeed;
+	max-frequency = <100000000>;
+	disable-wp;
+
+	cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>;
+	cd-inverted;
+
+	vmmc-supply = <&vddio_ao3v3>;
+	vqmmc-supply = <&vddio_tf>;
+};
+
+/* eMMC */
+&sd_emmc_c {
+	status = "disabled";
+};
+
+&uart_AO {
+	status = "okay";
+	pinctrl-0 = <&uart_ao_a_pins>;
+	pinctrl-names = "default";
+};
diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
index af3be59097..d7ef715b7c 100644
--- a/arch/arm/mach-meson/Kconfig
+++ b/arch/arm/mach-meson/Kconfig
@@ -18,6 +18,13 @@ config TARGET_ODROID_C2
 	  with 2 GiB of RAM, Gigabit Ethernet, HDMI, 4 USB, micro-SD
 	  slot, eMMC, IR receiver and a 40-pin GPIO header.
 
+config TARGET_NANOPI_K2
+	bool "NanoPi K2"
+	help
+	  NanoPi K2 is a single-board computer based on Meson GXBaby
+	  with 2 GiB of RAM, Gigabit Ethernet, HDMI, 4 USB, micro SD
+	  slot, eMMC, IR receiver and a 40-pin GPIO header.
+
 endif
 
 config SYS_SOC
@@ -26,6 +33,7 @@ config SYS_SOC
 config SYS_MALLOC_F_LEN
 	default 0x1000
 
+source "board/amlogic/nanopi-k2/Kconfig"
 source "board/amlogic/odroid-c2/Kconfig"
 
 endif
diff --git a/board/amlogic/nanopi-k2/Kconfig b/board/amlogic/nanopi-k2/Kconfig
new file mode 100644
index 0000000000..374bda200c
--- /dev/null
+++ b/board/amlogic/nanopi-k2/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_NANOPI_K2
+
+config SYS_BOARD
+	default "nanopi-k2"
+
+config SYS_VENDOR
+	default "amlogic"
+
+config SYS_CONFIG_NAME
+	default "nanopi-k2"
+
+endif
diff --git a/board/amlogic/nanopi-k2/MAINTAINERS b/board/amlogic/nanopi-k2/MAINTAINERS
new file mode 100644
index 0000000000..75a29c3ab1
--- /dev/null
+++ b/board/amlogic/nanopi-k2/MAINTAINERS
@@ -0,0 +1,6 @@
+NANOPI-K2
+M:	Andreas Färber <afaerber at suse.de>
+S:	Maintained
+F:	board/amlogic/nanopi-k2/
+F:	include/configs/nanopi-k2.h
+F:	configs/nanopi-k2_defconfig
diff --git a/board/amlogic/nanopi-k2/Makefile b/board/amlogic/nanopi-k2/Makefile
new file mode 100644
index 0000000000..9594480017
--- /dev/null
+++ b/board/amlogic/nanopi-k2/Makefile
@@ -0,0 +1,7 @@
+#
+# Copyright (c) 2017 Andreas Färber
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y := nanopi-k2.o
diff --git a/board/amlogic/nanopi-k2/nanopi-k2.c b/board/amlogic/nanopi-k2/nanopi-k2.c
new file mode 100644
index 0000000000..b61daaa4a7
--- /dev/null
+++ b/board/amlogic/nanopi-k2/nanopi-k2.c
@@ -0,0 +1,54 @@
+/*
+ * (C) Copyright 2016 Beniamino Galvani <b.galvani at gmail.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/gxbb.h>
+#include <asm/arch/sm.h>
+#include <dm/platdata.h>
+#include <phy.h>
+
+#define EFUSE_SN_OFFSET		20
+#define EFUSE_SN_SIZE		16
+#define EFUSE_MAC_OFFSET	52
+#define EFUSE_MAC_SIZE		6
+
+int board_init(void)
+{
+	return 0;
+}
+
+int misc_init_r(void)
+{
+	u8 mac_addr[EFUSE_MAC_SIZE];
+	ssize_t len;
+
+	/* Set RGMII mode */
+	setbits_le32(GXBB_ETH_REG_0, GXBB_ETH_REG_0_PHY_INTF |
+				     GXBB_ETH_REG_0_TX_PHASE(1) |
+				     GXBB_ETH_REG_0_TX_RATIO(4) |
+				     GXBB_ETH_REG_0_PHY_CLK_EN |
+				     GXBB_ETH_REG_0_CLK_EN);
+
+	/* Enable power and clock gate */
+	setbits_le32(GXBB_GCLK_MPEG_1, GXBB_GCLK_MPEG_1_ETH);
+	clrbits_le32(GXBB_MEM_PD_REG_0, GXBB_MEM_PD_REG_0_ETH_MASK);
+
+	/* Reset PHY on GPIOZ_14 */
+	clrbits_le32(GXBB_GPIO_EN(3), BIT(14));
+	clrbits_le32(GXBB_GPIO_OUT(3), BIT(14));
+	mdelay(10);
+	setbits_le32(GXBB_GPIO_OUT(3), BIT(14));
+
+	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+		len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
+					  mac_addr, EFUSE_MAC_SIZE);
+		if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr))
+			eth_setenv_enetaddr("ethaddr", mac_addr);
+	}
+
+	return 0;
+}
diff --git a/configs/nanopi-k2_defconfig b/configs/nanopi-k2_defconfig
new file mode 100644
index 0000000000..e6420f75d2
--- /dev/null
+++ b/configs/nanopi-k2_defconfig
@@ -0,0 +1,30 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MESON=y
+CONFIG_MESON_GXBB=y
+CONFIG_TARGET_NANOPI_K2=y
+CONFIG_IDENT_STRING=" nanopi-k2"
+CONFIG_DEFAULT_DEVICE_TREE="meson-gxbb-nanopi-k2"
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+# CONFIG_CMD_BDI is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_LOADS is not set
+CONFIG_CMD_MMC=y
+# CONFIG_CMD_FPGA is not set
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_OF_CONTROL=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_MESON_GX=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_MESON_GXBB=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_MESON=y
+CONFIG_DEBUG_UART_BASE=0xc81004c0
+CONFIG_DEBUG_UART_CLOCK=24000000
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_DEBUG_UART_SKIP_INIT=y
+CONFIG_MESON_SERIAL=y
diff --git a/include/configs/nanopi-k2.h b/include/configs/nanopi-k2.h
new file mode 100644
index 0000000000..0cddb163a3
--- /dev/null
+++ b/include/configs/nanopi-k2.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2017 Andreas Färber
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CONFIG_MISC_INIT_R
+
+/* Serial setup */
+#define CONFIG_CONS_INDEX		0
+
+#define MESON_FDTFILE_SETTING "fdtfile=amlogic/meson-gxbb-nanopi-k2.dtb\0"
+
+#include <configs/meson-gxbb-common.h>
+
+#endif /* __CONFIG_H */
-- 
2.12.0


More information about the U-Boot mailing list