6c5f577
From 97f002d28e975991226ab70599731bd2ccc8c060 Mon Sep 17 00:00:00 2001
6c5f577
From: Peter Robinson <pbrobinson@gmail.com>
6c5f577
Date: Sun, 6 Mar 2016 12:06:41 +0000
6c5f577
Subject: [PATCH] Initial AllWinner A64 and PINE64 support
6c5f577
6c5f577
---
6c5f577
 Documentation/devicetree/bindings/arm/sunxi.txt    |   1 +
6c5f577
 Documentation/devicetree/bindings/clock/sunxi.txt  |   7 +
6c5f577
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
6c5f577
 arch/arm/boot/dts/sun8i-h3.dtsi                    |  18 +-
6c5f577
 arch/arm/mach-sunxi/Kconfig                        |   7 +
6c5f577
 arch/arm64/Kconfig.platforms                       |   6 +
6c5f577
 arch/arm64/boot/dts/Makefile                       |   1 +
6c5f577
 arch/arm64/boot/dts/allwinner/Makefile             |   5 +
6c5f577
 .../dts/allwinner/sun50i-a64-pine64-common.dtsi    |  80 +++
6c5f577
 .../boot/dts/allwinner/sun50i-a64-pine64-plus.dts  |  59 ++
6c5f577
 .../arm64/boot/dts/allwinner/sun50i-a64-pine64.dts |  58 ++
6c5f577
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi      | 624 +++++++++++++++++++++
6c5f577
 drivers/clk/sunxi/Makefile                         |   1 +
6c5f577
 drivers/clk/sunxi/clk-factors.c                    |   3 +-
6c5f577
 drivers/clk/sunxi/clk-factors.h                    |   1 +
6c5f577
 drivers/clk/sunxi/clk-multi-gates.c                | 105 ++++
6c5f577
 drivers/clk/sunxi/clk-sunxi.c                      |   4 +-
6c5f577
 drivers/crypto/Kconfig                             |   2 +-
6c5f577
 23 files changed, 1582 insertions(+), 16 deletions(-)
6c5f577
 create mode 100644 arch/arm64/boot/dts/allwinner/Makefile
6c5f577
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-common.dtsi
6c5f577
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
6c5f577
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
6c5f577
 create mode 100644 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
6c5f577
 create mode 100644 drivers/clk/sunxi/clk-multi-gates.c
6c5f577
 create mode 100644 drivers/pinctrl/sunxi/pinctrl-sun50i-a64.c
6c5f577
6c5f577
diff --git a/Documentation/devicetree/bindings/arm/sunxi.txt b/Documentation/devicetree/bindings/arm/sunxi.txt
6c5f577
index bb9b0faa..8b39d2b 100644
6c5f577
--- a/Documentation/devicetree/bindings/arm/sunxi.txt
6c5f577
+++ b/Documentation/devicetree/bindings/arm/sunxi.txt
6c5f577
@@ -13,3 +13,4 @@ using one of the following compatible strings:
f20b3e7
   allwinner,sun8i-a83t
6c5f577
   allwinner,sun8i-h3
6c5f577
   allwinner,sun9i-a80
6c5f577
+  allwinner,sun50i-a64
6c5f577
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
6c5f577
index e59f57b..8af12b5 100644
6c5f577
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
6c5f577
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
6c5f577
@@ -77,6 +77,8 @@ Required properties:
6c5f577
 	"allwinner,sun9i-a80-usb-mod-clk" - for usb gates + resets on A80
6c5f577
 	"allwinner,sun9i-a80-usb-phy-clk" - for usb phy gates + resets on A80
6c5f577
 	"allwinner,sun4i-a10-ve-clk" - for the Video Engine clock
6c5f577
+	"allwinner,sunxi-multi-bus-gates-clk" - for the multi-parent bus gates
6c5f577
+	"allwinner,sun50i-a64-bus-gates-clk" - for the bus gates on A64
6c5f577
 
6c5f577
 Required properties for all clocks:
6c5f577
 - reg : shall be the control register address for the clock.
6c5f577
@@ -117,6 +119,11 @@ For "allwinner,sun6i-a31-pll6-clk", there are 2 outputs. The first output
6c5f577
 is the normal PLL6 output, or "pll6". The second output is rate doubled
6c5f577
 PLL6, or "pll6x2".
6c5f577
 
6c5f577
+The "allwinner,sunxi-multi-bus-gates-clk" holds the actual clocks in
6c5f577
+child nodes, where each one specifies the parent clock that the particular
6c5f577
+gates are depending from. The child nodes each follow the common clock
6c5f577
+binding as described in this document.
6c5f577
+
6c5f577
 The "allwinner,*-mmc-clk" clocks have three different outputs: the
6c5f577
 main clock, with the ID 0, and the output and sample clocks, with the
6c5f577
 IDs 1 and 2, respectively.
6c5f577
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
6c5f577
index 72e2c5a..0c22fa9 100644
6c5f577
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
6c5f577
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
6c5f577
@@ -175,6 +175,7 @@ parade	Parade Technologies Inc.
6c5f577
 pericom	Pericom Technology Inc.
6c5f577
 phytec	PHYTEC Messtechnik GmbH
6c5f577
 picochip	Picochip Ltd
6c5f577
+pine64	Pine64
6c5f577
 plathome	Plat'Home Co., Ltd.
6c5f577
 plda	PLDA
6c5f577
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
6c5f577
diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi
6c5f577
index 1524130e..7c50fa0 100644
6c5f577
--- a/arch/arm/boot/dts/sun8i-h3.dtsi
6c5f577
+++ b/arch/arm/boot/dts/sun8i-h3.dtsi
6c5f577
@@ -137,12 +137,12 @@
6c5f577
 			clock-output-names = "pll6d2";
6c5f577
 		};
6c5f577
 
6c5f577
-		/* dummy clock until pll6 can be reused */
6c5f577
-		pll8: pll8_clk {
6c5f577
-			#clock-cells = <0>;
6c5f577
-			compatible = "fixed-clock";
6c5f577
-			clock-frequency = <1>;
6c5f577
-			clock-output-names = "pll8";
6c5f577
+		pll8: clk@c01c20044 {
6c5f577
+			#clock-cells = <1>;
6c5f577
+			compatible = "allwinner,sun6i-a31-pll6-clk";
6c5f577
+			reg = <0x01c20044 0x4>;
6c5f577
+			clocks = <&osc24M>;
6c5f577
+			clock-output-names = "pll8", "pll8x2";
6c5f577
 		};
6c5f577
 
6c5f577
 		cpu: cpu_clk@01c20050 {
6c5f577
@@ -243,7 +243,7 @@
6c5f577
 			#clock-cells = <1>;
6c5f577
 			compatible = "allwinner,sun4i-a10-mmc-clk";
6c5f577
 			reg = <0x01c20088 0x4>;
6c5f577
-			clocks = <&osc24M>, <&pll6 0>, <&pll8>;
6c5f577
+			clocks = <&osc24M>, <&pll6 0>, <&pll8 0>;
6c5f577
 			clock-output-names = "mmc0",
6c5f577
 					     "mmc0_output",
6c5f577
 					     "mmc0_sample";
6c5f577
@@ -253,7 +253,7 @@
6c5f577
 			#clock-cells = <1>;
6c5f577
 			compatible = "allwinner,sun4i-a10-mmc-clk";
6c5f577
 			reg = <0x01c2008c 0x4>;
6c5f577
-			clocks = <&osc24M>, <&pll6 0>, <&pll8>;
6c5f577
+			clocks = <&osc24M>, <&pll6 0>, <&pll8 0>;
6c5f577
 			clock-output-names = "mmc1",
6c5f577
 					     "mmc1_output",
6c5f577
 					     "mmc1_sample";
6c5f577
@@ -263,7 +263,7 @@
6c5f577
 			#clock-cells = <1>;
6c5f577
 			compatible = "allwinner,sun4i-a10-mmc-clk";
6c5f577
 			reg = <0x01c20090 0x4>;
6c5f577
-			clocks = <&osc24M>, <&pll6 0>, <&pll8>;
6c5f577
+			clocks = <&osc24M>, <&pll6 0>, <&pll8 0>;
6c5f577
 			clock-output-names = "mmc2",
6c5f577
 					     "mmc2_output",
6c5f577
 					     "mmc2_sample";
6c5f577
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
6c5f577
index c124d65..b305f5b 100644
6c5f577
--- a/arch/arm/mach-sunxi/Kconfig
6c5f577
+++ b/arch/arm/mach-sunxi/Kconfig
6c5f577
@@ -46,4 +46,11 @@ config MACH_SUN9I
6c5f577
 	default ARCH_SUNXI
6c5f577
 	select ARM_GIC
6c5f577
 
6c5f577
+config MACH_SUN50I
6c5f577
+	bool "Allwinner A64 (sun50i) SoCs support"
6c5f577
+	default ARCH_SUNXI
6c5f577
+	select ARM_GIC
6c5f577
+	select HAVE_ARM_ARCH_TIMER
6c5f577
+	select PINCTRL_SUN50I_A64
6c5f577
+
6c5f577
 endif
6c5f577
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
6c5f577
index 21074f6..63a690d 100644
6c5f577
--- a/arch/arm64/Kconfig.platforms
6c5f577
+++ b/arch/arm64/Kconfig.platforms
6c5f577
@@ -72,6 +72,12 @@ config ARCH_SEATTLE
6c5f577
 config ARCH_SHMOBILE
6c5f577
 	bool
6c5f577
 
6c5f577
+config ARCH_SUNXI
6c5f577
+	bool "Allwinner sunxi 64-bit SoC Family"
6c5f577
+	select PINCTRL_SUN50I_A64
6c5f577
+	help
6c5f577
+	  This enables support for Allwinner sunxi based SoCs like the A64.
6c5f577
+
6c5f577
 config ARCH_RENESAS
6c5f577
 	bool "Renesas SoC Platforms"
6c5f577
 	select ARCH_SHMOBILE
6c5f577
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
6c5f577
index f832b8a..3b7428a 100644
6c5f577
--- a/arch/arm64/boot/dts/Makefile
6c5f577
+++ b/arch/arm64/boot/dts/Makefile
f20b3e7
@@ -2,3 +2,4 @@
f20b3e7
 dts-dirs += al
6c5f577
+dts-dirs += allwinner
6c5f577
 dts-dirs += altera
6c5f577
 dts-dirs += amd
6c5f577
diff --git a/arch/arm64/boot/dts/allwinner/Makefile b/arch/arm64/boot/dts/allwinner/Makefile
6c5f577
new file mode 100644
6c5f577
index 0000000..1e29a5a
6c5f577
--- /dev/null
6c5f577
+++ b/arch/arm64/boot/dts/allwinner/Makefile
6c5f577
@@ -0,0 +1,5 @@
6c5f577
+dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pine64-plus.dtb sun50i-a64-pine64.dtb
6c5f577
+
6c5f577
+always		:= $(dtb-y)
6c5f577
+subdir-y	:= $(dts-dirs)
6c5f577
+clean-files	:= *.dtb
6c5f577
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-common.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-common.dtsi
6c5f577
new file mode 100644
6c5f577
index 0000000..d5a7249
6c5f577
--- /dev/null
6c5f577
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-common.dtsi
6c5f577
@@ -0,0 +1,80 @@
6c5f577
+/*
6c5f577
+ * Copyright (c) 2016 ARM Ltd.
6c5f577
+ *
6c5f577
+ * This file is dual-licensed: you can use it either under the terms
6c5f577
+ * of the GPL or the X11 license, at your option. Note that this dual
6c5f577
+ * licensing only applies to this file, and not this project as a
6c5f577
+ * whole.
6c5f577
+ *
6c5f577
+ *  a) This library is free software; you can redistribute it and/or
6c5f577
+ *     modify it under the terms of the GNU General Public License as
6c5f577
+ *     published by the Free Software Foundation; either version 2 of the
6c5f577
+ *     License, or (at your option) any later version.
6c5f577
+ *
6c5f577
+ *     This library is distributed in the hope that it will be useful,
6c5f577
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
6c5f577
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6c5f577
+ *     GNU General Public License for more details.
6c5f577
+ *
6c5f577
+ * Or, alternatively,
6c5f577
+ *
6c5f577
+ *  b) Permission is hereby granted, free of charge, to any person
6c5f577
+ *     obtaining a copy of this software and associated documentation
6c5f577
+ *     files (the "Software"), to deal in the Software without
6c5f577
+ *     restriction, including without limitation the rights to use,
6c5f577
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
6c5f577
+ *     sell copies of the Software, and to permit persons to whom the
6c5f577
+ *     Software is furnished to do so, subject to the following
6c5f577
+ *     conditions:
6c5f577
+ *
6c5f577
+ *     The above copyright notice and this permission notice shall be
6c5f577
+ *     included in all copies or substantial portions of the Software.
6c5f577
+ *
6c5f577
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6c5f577
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6c5f577
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6c5f577
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
6c5f577
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6c5f577
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6c5f577
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6c5f577
+ *     OTHER DEALINGS IN THE SOFTWARE.
6c5f577
+ */
6c5f577
+
6c5f577
+#include "sun50i-a64.dtsi"
6c5f577
+
6c5f577
+/ {
6c5f577
+
6c5f577
+	aliases {
6c5f577
+		serial0 = &uart;;
6c5f577
+	};
6c5f577
+
6c5f577
+	soc {
6c5f577
+		reg_vcc3v3: vcc3v3 {
6c5f577
+			compatible = "regulator-fixed";
6c5f577
+			regulator-name = "vcc3v3";
6c5f577
+			regulator-min-microvolt = <3300000>;
6c5f577
+			regulator-max-microvolt = <3300000>;
6c5f577
+		};
6c5f577
+	};
6c5f577
+};
6c5f577
+
6c5f577
+&mmc0 {
6c5f577
+	pinctrl-names = "default";
6c5f577
+	pinctrl-0 = <&mmc0_pins>, <&mmc0_default_cd_pin>;
6c5f577
+	vmmc-supply = <&reg_vcc3v3>;
6c5f577
+	cd-gpios = <&pio 5 6 0>;
6c5f577
+	cd-inverted;
6c5f577
+	status = "okay";
6c5f577
+};
6c5f577
+
6c5f577
+&uart0 {
6c5f577
+	pinctrl-names = "default";
6c5f577
+	pinctrl-0 = <&uart0_pins_a>;
6c5f577
+	status = "okay";
6c5f577
+};
6c5f577
+
6c5f577
+&i2c1 {
6c5f577
+	pinctrl-names = "default";
6c5f577
+	pinctrl-0 = <&i2c1_pins>;
6c5f577
+	status = "okay";
6c5f577
+};
6c5f577
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
6c5f577
new file mode 100644
6c5f577
index 0000000..549dc15
6c5f577
--- /dev/null
6c5f577
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
6c5f577
@@ -0,0 +1,59 @@
6c5f577
+/*
6c5f577
+ * Copyright (c) 2016 ARM Ltd.
6c5f577
+ *
6c5f577
+ * This file is dual-licensed: you can use it either under the terms
6c5f577
+ * of the GPL or the X11 license, at your option. Note that this dual
6c5f577
+ * licensing only applies to this file, and not this project as a
6c5f577
+ * whole.
6c5f577
+ *
6c5f577
+ *  a) This library is free software; you can redistribute it and/or
6c5f577
+ *     modify it under the terms of the GNU General Public License as
6c5f577
+ *     published by the Free Software Foundation; either version 2 of the
6c5f577
+ *     License, or (at your option) any later version.
6c5f577
+ *
6c5f577
+ *     This library is distributed in the hope that it will be useful,
6c5f577
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
6c5f577
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6c5f577
+ *     GNU General Public License for more details.
6c5f577
+ *
6c5f577
+ * Or, alternatively,
6c5f577
+ *
6c5f577
+ *  b) Permission is hereby granted, free of charge, to any person
6c5f577
+ *     obtaining a copy of this software and associated documentation
6c5f577
+ *     files (the "Software"), to deal in the Software without
6c5f577
+ *     restriction, including without limitation the rights to use,
6c5f577
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
6c5f577
+ *     sell copies of the Software, and to permit persons to whom the
6c5f577
+ *     Software is furnished to do so, subject to the following
6c5f577
+ *     conditions:
6c5f577
+ *
6c5f577
+ *     The above copyright notice and this permission notice shall be
6c5f577
+ *     included in all copies or substantial portions of the Software.
6c5f577
+ *
6c5f577
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6c5f577
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6c5f577
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6c5f577
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
6c5f577
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6c5f577
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6c5f577
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6c5f577
+ *     OTHER DEALINGS IN THE SOFTWARE.
6c5f577
+ */
6c5f577
+
6c5f577
+/dts-v1/;
6c5f577
+
6c5f577
+#include "sun50i-a64-pine64-common.dtsi"
6c5f577
+
6c5f577
+/ {
6c5f577
+	model = "Pine64+";
6c5f577
+	compatible = "pine64,pine64-plus", "allwinner,sun50i-a64";
6c5f577
+
6c5f577
+	chosen {
6c5f577
+		stdout-path = "serial0:115200n8";
6c5f577
+	};
6c5f577
+
6c5f577
+	/* There is a model with 2GB of DRAM, but U-Boot fixes this for us. */
6c5f577
+	memory {
6c5f577
+		reg = <0x40000000 0x40000000>;
6c5f577
+	};
6c5f577
+};
6c5f577
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
6c5f577
new file mode 100644
6c5f577
index 0000000..ebe029e
6c5f577
--- /dev/null
6c5f577
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
6c5f577
@@ -0,0 +1,58 @@
6c5f577
+/*
6c5f577
+ * Copyright (c) 2016 ARM Ltd.
6c5f577
+ *
6c5f577
+ * This file is dual-licensed: you can use it either under the terms
6c5f577
+ * of the GPL or the X11 license, at your option. Note that this dual
6c5f577
+ * licensing only applies to this file, and not this project as a
6c5f577
+ * whole.
6c5f577
+ *
6c5f577
+ *  a) This library is free software; you can redistribute it and/or
6c5f577
+ *     modify it under the terms of the GNU General Public License as
6c5f577
+ *     published by the Free Software Foundation; either version 2 of the
6c5f577
+ *     License, or (at your option) any later version.
6c5f577
+ *
6c5f577
+ *     This library is distributed in the hope that it will be useful,
6c5f577
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
6c5f577
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6c5f577
+ *     GNU General Public License for more details.
6c5f577
+ *
6c5f577
+ * Or, alternatively,
6c5f577
+ *
6c5f577
+ *  b) Permission is hereby granted, free of charge, to any person
6c5f577
+ *     obtaining a copy of this software and associated documentation
6c5f577
+ *     files (the "Software"), to deal in the Software without
6c5f577
+ *     restriction, including without limitation the rights to use,
6c5f577
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
6c5f577
+ *     sell copies of the Software, and to permit persons to whom the
6c5f577
+ *     Software is furnished to do so, subject to the following
6c5f577
+ *     conditions:
6c5f577
+ *
6c5f577
+ *     The above copyright notice and this permission notice shall be
6c5f577
+ *     included in all copies or substantial portions of the Software.
6c5f577
+ *
6c5f577
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6c5f577
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6c5f577
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6c5f577
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
6c5f577
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6c5f577
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6c5f577
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6c5f577
+ *     OTHER DEALINGS IN THE SOFTWARE.
6c5f577
+ */
6c5f577
+
6c5f577
+/dts-v1/;
6c5f577
+
6c5f577
+#include "sun50i-a64-pine64-common.dtsi"
6c5f577
+
6c5f577
+/ {
6c5f577
+	model = "Pine64";
6c5f577
+	compatible = "pine64,pine64", "allwinner,sun50i-a64";
6c5f577
+
6c5f577
+	chosen {
6c5f577
+		stdout-path = "serial0:115200n8";
6c5f577
+	};
6c5f577
+
6c5f577
+	memory {
6c5f577
+		reg = <0x40000000 0x20000000>;
6c5f577
+	};
6c5f577
+};
6c5f577
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
6c5f577
new file mode 100644
6c5f577
index 0000000..1bd436f
6c5f577
--- /dev/null
6c5f577
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi
6c5f577
@@ -0,0 +1,624 @@
6c5f577
+/*
6c5f577
+ * Copyright (C) 2016 ARM Ltd.
6c5f577
+ * based on the Allwinner H3 dtsi:
6c5f577
+ *    Copyright (C) 2015 Jens Kuske <jenskuske@gmail.com>
6c5f577
+ *
6c5f577
+ * This file is dual-licensed: you can use it either under the terms
6c5f577
+ * of the GPL or the X11 license, at your option. Note that this dual
6c5f577
+ * licensing only applies to this file, and not this project as a
6c5f577
+ * whole.
6c5f577
+ *
6c5f577
+ *  a) This file is free software; you can redistribute it and/or
6c5f577
+ *     modify it under the terms of the GNU General Public License as
6c5f577
+ *     published by the Free Software Foundation; either version 2 of the
6c5f577
+ *     License, or (at your option) any later version.
6c5f577
+ *
6c5f577
+ *     This file is distributed in the hope that it will be useful,
6c5f577
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
6c5f577
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6c5f577
+ *     GNU General Public License for more details.
6c5f577
+ *
6c5f577
+ * Or, alternatively,
6c5f577
+ *
6c5f577
+ *  b) Permission is hereby granted, free of charge, to any person
6c5f577
+ *     obtaining a copy of this software and associated documentation
6c5f577
+ *     files (the "Software"), to deal in the Software without
6c5f577
+ *     restriction, including without limitation the rights to use,
6c5f577
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
6c5f577
+ *     sell copies of the Software, and to permit persons to whom the
6c5f577
+ *     Software is furnished to do so, subject to the following
6c5f577
+ *     conditions:
6c5f577
+ *
6c5f577
+ *     The above copyright notice and this permission notice shall be
6c5f577
+ *     included in all copies or substantial portions of the Software.
6c5f577
+ *
6c5f577
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6c5f577
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6c5f577
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6c5f577
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
6c5f577
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6c5f577
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6c5f577
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6c5f577
+ *     OTHER DEALINGS IN THE SOFTWARE.
6c5f577
+ */
6c5f577
+
6c5f577
+#include <dt-bindings/interrupt-controller/arm-gic.h>
6c5f577
+#include <dt-bindings/pinctrl/sun4i-a10.h>
6c5f577
+
6c5f577
+/ {
6c5f577
+	interrupt-parent = <&gic;;
6c5f577
+	#address-cells = <1>;
6c5f577
+	#size-cells = <1>;
6c5f577
+
6c5f577
+	cpus {
6c5f577
+		#address-cells = <1>;
6c5f577
+		#size-cells = <0>;
6c5f577
+
6c5f577
+		cpu@0 {
6c5f577
+			compatible = "arm,cortex-a53", "arm,armv8";
6c5f577
+			device_type = "cpu";
6c5f577
+			reg = <0>;
6c5f577
+			enable-method = "psci";
6c5f577
+		};
6c5f577
+
6c5f577
+		cpu@1 {
6c5f577
+			compatible = "arm,cortex-a53", "arm,armv8";
6c5f577
+			device_type = "cpu";
6c5f577
+			reg = <1>;
6c5f577
+			enable-method = "psci";
6c5f577
+		};
6c5f577
+
6c5f577
+		cpu@2 {
6c5f577
+			compatible = "arm,cortex-a53", "arm,armv8";
6c5f577
+			device_type = "cpu";
6c5f577
+			reg = <2>;
6c5f577
+			enable-method = "psci";
6c5f577
+		};
6c5f577
+
6c5f577
+		cpu@3 {
6c5f577
+			compatible = "arm,cortex-a53", "arm,armv8";
6c5f577
+			device_type = "cpu";
6c5f577
+			reg = <3>;
6c5f577
+			enable-method = "psci";
6c5f577
+		};
6c5f577
+	};
6c5f577
+
6c5f577
+	psci {
6c5f577
+		compatible = "arm,psci-0.2";
6c5f577
+		method = "smc";
6c5f577
+	};
6c5f577
+
6c5f577
+	memory {
6c5f577
+		device_type = "memory";
6c5f577
+		reg = <0x40000000 0>;
6c5f577
+	};
6c5f577
+
6c5f577
+	gic: interrupt-controller@1c81000 {
6c5f577
+		compatible = "arm,gic-400";
6c5f577
+		interrupt-controller;
6c5f577
+		#interrupt-cells = <3>;
6c5f577
+		#address-cells = <0>;
6c5f577
+
6c5f577
+		reg = <0x01c81000 0x1000>,
6c5f577
+		      <0x01c82000 0x2000>,
6c5f577
+		      <0x01c84000 0x2000>,
6c5f577
+		      <0x01c86000 0x2000>;
6c5f577
+		interrupts = 
6c5f577
+		      (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
6c5f577
+	};
6c5f577
+
6c5f577
+	timer {
6c5f577
+		compatible = "arm,armv8-timer";
6c5f577
+		interrupts = 
6c5f577
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
6c5f577
+			     
6c5f577
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
6c5f577
+			     
6c5f577
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
6c5f577
+			     
6c5f577
+			(GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
6c5f577
+	};
6c5f577
+
6c5f577
+	clocks {
6c5f577
+		#address-cells = <1>;
6c5f577
+		#size-cells = <1>;
6c5f577
+		ranges;
6c5f577
+
6c5f577
+		osc24M: osc24M_clk {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "fixed-clock";
6c5f577
+			clock-frequency = <24000000>;
6c5f577
+			clock-output-names = "osc24M";
6c5f577
+		};
6c5f577
+
6c5f577
+		osc32k: osc32k_clk {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "fixed-clock";
6c5f577
+			clock-frequency = <32768>;
6c5f577
+			clock-output-names = "osc32k";
6c5f577
+		};
6c5f577
+
6c5f577
+		pll1: pll1_clk@1c20000 {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun8i-a23-pll1-clk";
6c5f577
+			reg = <0x01c20000 0x4>;
6c5f577
+			clocks = <&osc24M>;
6c5f577
+			clock-output-names = "pll1";
6c5f577
+		};
6c5f577
+
6c5f577
+		pll6: pll6_clk@1c20028 {
6c5f577
+			#clock-cells = <1>;
6c5f577
+			compatible = "allwinner,sun6i-a31-pll6-clk";
6c5f577
+			reg = <0x01c20028 0x4>;
6c5f577
+			clocks = <&osc24M>;
6c5f577
+			clock-output-names = "pll6", "pll6x2";
6c5f577
+		};
6c5f577
+
6c5f577
+		pll6d2: pll6d2_clk {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "fixed-factor-clock";
6c5f577
+			clock-div = <2>;
6c5f577
+			clock-mult = <1>;
6c5f577
+			clocks = <&pll6 0>;
6c5f577
+			clock-output-names = "pll6d2";
6c5f577
+		};
6c5f577
+
6c5f577
+		pll7: pll7_clk@1c2002c {
6c5f577
+			#clock-cells = <1>;
6c5f577
+			compatible = "allwinner,sun6i-a31-pll6-clk";
6c5f577
+			reg = <0x01c2002c 0x4>;
6c5f577
+			clocks = <&osc24M>;
6c5f577
+			clock-output-names = "pll7", "pll7x2";
6c5f577
+		};
6c5f577
+
6c5f577
+		cpu: cpu_clk@1c20050 {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun4i-a10-cpu-clk";
6c5f577
+			reg = <0x01c20050 0x4>;
6c5f577
+			clocks = <&osc32k>, <&osc24M>, <&pll1>, <&pll1>;
6c5f577
+			clock-output-names = "cpu";
6c5f577
+			critical-clocks = <0>;
6c5f577
+		};
6c5f577
+
6c5f577
+		axi: axi_clk@1c20050 {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun4i-a10-axi-clk";
6c5f577
+			reg = <0x01c20050 0x4>;
6c5f577
+			clocks = <&cpu>;
6c5f577
+			clock-output-names = "axi";
6c5f577
+		};
6c5f577
+
6c5f577
+		ahb1: ahb1_clk@1c20054 {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun6i-a31-ahb1-clk";
6c5f577
+			reg = <0x01c20054 0x4>;
6c5f577
+			clocks = <&osc32k>, <&osc24M>, <&axi>, <&pll6 0>;
6c5f577
+			clock-output-names = "ahb1";
6c5f577
+		};
6c5f577
+
6c5f577
+		ahb2: ahb2_clk@1c2005c {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun8i-h3-ahb2-clk";
6c5f577
+			reg = <0x01c2005c 0x4>;
6c5f577
+			clocks = <&ahb1>, <&pll6d2>;
6c5f577
+			clock-output-names = "ahb2";
6c5f577
+		};
6c5f577
+
6c5f577
+		apb1: apb1_clk@1c20054 {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun4i-a10-apb0-clk";
6c5f577
+			reg = <0x01c20054 0x4>;
6c5f577
+			clocks = <&ahb1>;
6c5f577
+			clock-output-names = "apb1";
6c5f577
+		};
6c5f577
+
6c5f577
+		apb2: apb2_clk@1c20058 {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun4i-a10-apb1-clk";
6c5f577
+			reg = <0x01c20058 0x4>;
6c5f577
+			clocks = <&osc32k>, <&osc24M>, <&pll6 1>, <&pll6 1>;
6c5f577
+			clock-output-names = "apb2";
6c5f577
+		};
6c5f577
+
6c5f577
+		bus_gates: bus_gates_clk@1c20060 {
6c5f577
+			#clock-cells = <1>;
6c5f577
+			compatible = "allwinner,sun50i-a64-bus-gates-clk",
6c5f577
+				     "allwinner,sunxi-multi-bus-gates-clk";
6c5f577
+			reg = <0x01c20060 0x14>;
6c5f577
+			ahb1_parent {
6c5f577
+				clocks = <&ahb1>;
6c5f577
+				clock-indices = <1>, <5>,
6c5f577
+						<6>, <8>,
6c5f577
+						<9>, <10>,
6c5f577
+						<13>, <14>,
6c5f577
+						<18>, <19>,
6c5f577
+						<20>, <21>,
6c5f577
+						<23>, <24>,
6c5f577
+						<25>, <28>,
6c5f577
+						<32>, <35>,
6c5f577
+						<36>, <37>,
6c5f577
+						<40>, <43>,
6c5f577
+						<44>, <52>,
6c5f577
+						<53>, <54>,
6c5f577
+						<135>;
6c5f577
+				clock-output-names = "bus_mipidsi", "bus_ce",
6c5f577
+						"bus_dma", "bus_mmc0",
6c5f577
+						"bus_mmc1", "bus_mmc2",
6c5f577
+						"bus_nand", "bus_sdram",
6c5f577
+						"bus_ts", "bus_hstimer",
6c5f577
+						"bus_spi0", "bus_spi1",
6c5f577
+						"bus_otg", "bus_otg_ehci0",
6c5f577
+						"bus_ehci0", "bus_otg_ohci0",
6c5f577
+						"bus_ve", "bus_lcd0",
6c5f577
+						"bus_lcd1", "bus_deint",
6c5f577
+						"bus_csi", "bus_hdmi",
6c5f577
+						"bus_de", "bus_gpu",
6c5f577
+						"bus_msgbox", "bus_spinlock",
6c5f577
+						"bus_dbg";
6c5f577
+			};
6c5f577
+			ahb2_parent {
6c5f577
+				clocks = <&ahb2>;
6c5f577
+				clock-indices = <17>, <29>;
6c5f577
+				clock-output-names = "bus_gmac", "bus_ohci0";
6c5f577
+			};
6c5f577
+			apb1_parent {
6c5f577
+				clocks = <&apb1>;
6c5f577
+				clock-indices = <64>, <65>,
6c5f577
+						<69>, <72>,
6c5f577
+						<76>, <77>,
6c5f577
+						<78>;
6c5f577
+				clock-output-names = "bus_codec", "bus_spdif",
6c5f577
+						"bus_pio", "bus_ths",
6c5f577
+						"bus_i2s0", "bus_i2s1",
6c5f577
+						"bus_i2s2";
6c5f577
+			};
6c5f577
+			abp2_parent {
6c5f577
+				clocks = <&apb2>;
6c5f577
+				clock-indices = <96>, <97>,
6c5f577
+						<98>, <101>,
6c5f577
+						<112>, <113>,
6c5f577
+						<114>, <115>,
6c5f577
+						<116>;
6c5f577
+				clock-output-names = "bus_i2c0", "bus_i2c1",
6c5f577
+						"bus_i2c2", "bus_scr",
6c5f577
+						"bus_uart0", "bus_uart1",
6c5f577
+						"bus_uart2", "bus_uart3",
6c5f577
+						"bus_uart4";
6c5f577
+			};
6c5f577
+		};
6c5f577
+
6c5f577
+		mmc0_clk: mmc0_clk@1c20088 {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun4i-a10-mod0-clk";
6c5f577
+			reg = <0x01c20088 0x4>;
6c5f577
+			clocks = <&osc24M>, <&pll6 1>, <&pll7 1>;
6c5f577
+			clock-output-names = "mmc0";
6c5f577
+                };
6c5f577
+
6c5f577
+		mmc1_clk: mmc1_clk@1c2008c {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun4i-a10-mod0-clk";
6c5f577
+			reg = <0x01c2008c 0x4>;
6c5f577
+			clocks = <&osc24M>, <&pll6 1>, <&pll7 1>;
6c5f577
+			clock-output-names = "mmc1";
6c5f577
+		};
6c5f577
+
6c5f577
+		mmc2_clk: mmc2_clk@1c20090 {
6c5f577
+			#clock-cells = <0>;
6c5f577
+			compatible = "allwinner,sun4i-a10-mod0-clk";
6c5f577
+			reg = <0x01c20090 0x4>;
6c5f577
+			clocks = <&osc24M>, <&pll6 1>, <&pll7 1>;
6c5f577
+			clock-output-names = "mmc2";
6c5f577
+		};
6c5f577
+	};
6c5f577
+
6c5f577
+	soc {
6c5f577
+		compatible = "simple-bus";
6c5f577
+		#address-cells = <1>;
6c5f577
+		#size-cells = <1>;
6c5f577
+		ranges;
6c5f577
+
6c5f577
+		mmc0: mmc@1c0f000 {
6c5f577
+			compatible = "allwinner,sun50i-a64-mmc",
6c5f577
+				     "allwinner,sun5i-a13-mmc";
6c5f577
+			reg = <0x01c0f000 0x1000>;
6c5f577
+			clocks = <&bus_gates 8>, <&mmc0_clk>,
6c5f577
+				 <&mmc0_clk>, <&mmc0_clk>;
6c5f577
+			clock-names = "ahb", "mmc",
6c5f577
+				      "output", "sample";
6c5f577
+			resets = <&ahb_rst 8>;
6c5f577
+			reset-names = "ahb";
6c5f577
+			interrupts = <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			status = "disabled";
6c5f577
+			#address-cells = <1>;
6c5f577
+			#size-cells = <0>;
6c5f577
+		};
6c5f577
+
6c5f577
+		mmc1: mmc@1c10000 {
6c5f577
+			compatible = "allwinner,sun50i-a64-mmc",
6c5f577
+				     "allwinner,sun5i-a13-mmc";
6c5f577
+			reg = <0x01c10000 0x1000>;
6c5f577
+			clocks = <&bus_gates 9>, <&mmc1_clk>,
6c5f577
+				 <&mmc1_clk>, <&mmc1_clk>;
6c5f577
+			clock-names = "ahb", "mmc",
6c5f577
+				      "output", "sample";
6c5f577
+			resets = <&ahb_rst 9>;
6c5f577
+			reset-names = "ahb";
6c5f577
+			interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			status = "disabled";
6c5f577
+			#address-cells = <1>;
6c5f577
+			#size-cells = <0>;
6c5f577
+		};
6c5f577
+
6c5f577
+		mmc2: mmc@1c11000 {
6c5f577
+			compatible = "allwinner,sun50i-a64-mmc",
6c5f577
+				     "allwinner,sun5i-a13-mmc";
6c5f577
+			reg = <0x01c11000 0x1000>;
6c5f577
+			clocks = <&bus_gates 10>, <&mmc2_clk>,
6c5f577
+				 <&mmc2_clk>, <&mmc2_clk>;
6c5f577
+			clock-names = "ahb", "mmc",
6c5f577
+				      "output", "sample";
6c5f577
+			resets = <&ahb_rst 10>;
6c5f577
+			reset-names = "ahb";
6c5f577
+			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			status = "disabled";
6c5f577
+			#address-cells = <1>;
6c5f577
+			#size-cells = <0>;
6c5f577
+		};
6c5f577
+
6c5f577
+		pio: pinctrl@1c20800 {
6c5f577
+			compatible = "allwinner,sun50i-a64-pinctrl";
6c5f577
+			reg = <0x01c20800 0x400>;
6c5f577
+			interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
6c5f577
+				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
6c5f577
+				     <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			clocks = <&bus_gates 69>;
6c5f577
+			gpio-controller;
6c5f577
+			#gpio-cells = <3>;
6c5f577
+			interrupt-controller;
6c5f577
+			#interrupt-cells = <2>;
6c5f577
+
6c5f577
+			uart0_pins_a: uart0@0 {
6c5f577
+				allwinner,pins = "PB8", "PB9";
6c5f577
+				allwinner,function = "uart0";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart0_pins_b: uart0@1 {
6c5f577
+				allwinner,pins = "PF2", "PF3";
6c5f577
+				allwinner,function = "uart0";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart1_2pins: uart1_2@0 {
6c5f577
+				allwinner,pins = "PG6", "PG7";
6c5f577
+				allwinner,function = "uart1";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart1_4pins: uart1_4@0 {
6c5f577
+				allwinner,pins = "PG6", "PG7", "PG8", "PG9";
6c5f577
+				allwinner,function = "uart1";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart2_2pins: uart2_2@0 {
6c5f577
+				allwinner,pins = "PB0", "PB1";
6c5f577
+				allwinner,function = "uart2";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart2_4pins: uart2_4@0 {
6c5f577
+				allwinner,pins = "PB0", "PB1", "PB2", "PB3";
6c5f577
+				allwinner,function = "uart2";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart3_pins_a: uart3@0 {
6c5f577
+				allwinner,pins = "PD0", "PD1";
6c5f577
+				allwinner,function = "uart3";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart3_2pins_b: uart3_2@1 {
6c5f577
+				allwinner,pins = "PH4", "PH5";
6c5f577
+				allwinner,function = "uart3";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart3_4pins_b: uart3_4@1 {
6c5f577
+				allwinner,pins = "PH4", "PH5", "PH6", "PH7";
6c5f577
+				allwinner,function = "uart3";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart4_2pins: uart4_2@0 {
6c5f577
+				allwinner,pins = "PD2", "PD3";
6c5f577
+				allwinner,function = "uart4";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			uart4_4pins: uart4_4@0 {
6c5f577
+				allwinner,pins = "PD2", "PD3", "PD4", "PD5";
6c5f577
+				allwinner,function = "uart4";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			mmc0_pins: mmc0@0 {
6c5f577
+				allwinner,pins = "PF0", "PF1", "PF2", "PF3",
6c5f577
+						 "PF4", "PF5";
6c5f577
+				allwinner,function = "mmc0";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_30_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			mmc0_default_cd_pin: mmc0_cd_pin@0 {
6c5f577
+				allwinner,pins = "PF6";
6c5f577
+				allwinner,function = "gpio_in";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_PULL_UP>;
6c5f577
+			};
6c5f577
+
6c5f577
+			mmc1_pins: mmc1@0 {
6c5f577
+				allwinner,pins = "PG0", "PG1", "PG2", "PG3",
6c5f577
+						 "PG4", "PG5";
6c5f577
+				allwinner,function = "mmc1";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_30_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			mmc2_pins: mmc2@0 {
6c5f577
+				allwinner,pins = "PC1", "PC5", "PC6", "PC8",
6c5f577
+						 "PC9", "PC10";
6c5f577
+				allwinner,function = "mmc2";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_30_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			i2c0_pins: i2c0_pins {
6c5f577
+				allwinner,pins = "PH0", "PH1";
6c5f577
+				allwinner,function = "i2c0";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			i2c1_pins: i2c1_pins {
6c5f577
+				allwinner,pins = "PH2", "PH3";
6c5f577
+				allwinner,function = "i2c1";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+
6c5f577
+			i2c2_pins: i2c2_pins {
6c5f577
+				allwinner,pins = "PE14", "PE15";
6c5f577
+				allwinner,function = "i2c2";
6c5f577
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
6c5f577
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
6c5f577
+			};
6c5f577
+		};
6c5f577
+
6c5f577
+		ahb_rst: reset@1c202c0 {
6c5f577
+			#reset-cells = <1>;
6c5f577
+			compatible = "allwinner,sun6i-a31-clock-reset";
6c5f577
+			reg = <0x01c202c0 0xc>;
6c5f577
+		};
6c5f577
+
6c5f577
+		apb1_rst: reset@1c202d0 {
6c5f577
+			#reset-cells = <1>;
6c5f577
+			compatible = "allwinner,sun6i-a31-clock-reset";
6c5f577
+			reg = <0x01c202d0 0x4>;
6c5f577
+		};
6c5f577
+
6c5f577
+		apb2_rst: reset@1c202d8 {
6c5f577
+			#reset-cells = <1>;
6c5f577
+			compatible = "allwinner,sun6i-a31-clock-reset";
6c5f577
+			reg = <0x01c202d8 0x4>;
6c5f577
+		};
6c5f577
+
6c5f577
+		uart0: serial@1c28000 {
6c5f577
+			compatible = "snps,dw-apb-uart";
6c5f577
+			reg = <0x01c28000 0x400>;
6c5f577
+			interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			reg-shift = <2>;
6c5f577
+			reg-io-width = <4>;
6c5f577
+			clocks = <&bus_gates 112>;
6c5f577
+			resets = <&apb2_rst 16>;
6c5f577
+			status = "disabled";
6c5f577
+		};
6c5f577
+
6c5f577
+		uart1: serial@1c28400 {
6c5f577
+			compatible = "snps,dw-apb-uart";
6c5f577
+			reg = <0x01c28400 0x400>;
6c5f577
+			interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			reg-shift = <2>;
6c5f577
+			reg-io-width = <4>;
6c5f577
+			clocks = <&bus_gates 113>;
6c5f577
+			resets = <&apb2_rst 17>;
6c5f577
+			status = "disabled";
6c5f577
+		};
6c5f577
+
6c5f577
+		uart2: serial@1c28800 {
6c5f577
+			compatible = "snps,dw-apb-uart";
6c5f577
+			reg = <0x01c28800 0x400>;
6c5f577
+			interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			reg-shift = <2>;
6c5f577
+			reg-io-width = <4>;
6c5f577
+			clocks = <&bus_gates 114>;
6c5f577
+			resets = <&apb2_rst 18>;
6c5f577
+			status = "disabled";
6c5f577
+		};
6c5f577
+
6c5f577
+		uart3: serial@1c28c00 {
6c5f577
+			compatible = "snps,dw-apb-uart";
6c5f577
+			reg = <0x01c28c00 0x400>;
6c5f577
+			interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			reg-shift = <2>;
6c5f577
+			reg-io-width = <4>;
6c5f577
+			clocks = <&bus_gates 115>;
6c5f577
+			resets = <&apb2_rst 19>;
6c5f577
+			status = "disabled";
6c5f577
+		};
6c5f577
+
6c5f577
+		uart4: serial@1c29000 {
6c5f577
+			compatible = "snps,dw-apb-uart";
6c5f577
+			reg = <0x01c29000 0x400>;
6c5f577
+			interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			reg-shift = <2>;
6c5f577
+			reg-io-width = <4>;
6c5f577
+			clocks = <&bus_gates 116>;
6c5f577
+			resets = <&apb2_rst 20>;
6c5f577
+			status = "disabled";
6c5f577
+		};
6c5f577
+
6c5f577
+		rtc: rtc@1f00000 {
6c5f577
+			compatible = "allwinner,sun6i-a31-rtc";
6c5f577
+			reg = <0x01f00000 0x54>;
6c5f577
+			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
6c5f577
+				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+		};
6c5f577
+
6c5f577
+		i2c0: i2c@1c2ac00 {
6c5f577
+			compatible = "allwinner,sun6i-a31-i2c";
6c5f577
+			reg = <0x01c2ac00 0x400>;
6c5f577
+			interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			clocks = <&bus_gates 96>;
6c5f577
+			resets = <&apb2_rst 0>;
6c5f577
+			status = "disabled";
6c5f577
+			#address-cells = <1>;
6c5f577
+			#size-cells = <0>;
6c5f577
+		};
6c5f577
+
6c5f577
+		i2c1: i2c@1c2b000 {
6c5f577
+			compatible = "allwinner,sun6i-a31-i2c";
6c5f577
+			reg = <0x01c2b000 0x400>;
6c5f577
+			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			clocks = <&bus_gates 97>;
6c5f577
+			resets = <&apb2_rst 1>;
6c5f577
+			status = "disabled";
6c5f577
+			#address-cells = <1>;
6c5f577
+			#size-cells = <0>;
6c5f577
+		};
6c5f577
+
6c5f577
+		i2c2: i2c@1c2b400 {
6c5f577
+			compatible = "allwinner,sun6i-a31-i2c";
6c5f577
+			reg = <0x01c2b400 0x400>;
6c5f577
+			interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
6c5f577
+			clocks = <&bus_gates 98>;
6c5f577
+			resets = <&apb2_rst 2>;
6c5f577
+			status = "disabled";
6c5f577
+			#address-cells = <1>;
6c5f577
+			#size-cells = <0>;
6c5f577
+		};
6c5f577
+	};
6c5f577
+};
6c5f577
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
6c5f577
index 3fd7901..3a9dc31 100644
6c5f577
--- a/drivers/clk/sunxi/Makefile
6c5f577
+++ b/drivers/clk/sunxi/Makefile
6c5f577
@@ -11,6 +11,7 @@ obj-y += clk-a10-ve.o
6c5f577
 obj-y += clk-a20-gmac.o
6c5f577
 obj-y += clk-mod0.o
6c5f577
 obj-y += clk-simple-gates.o
6c5f577
+obj-y += clk-multi-gates.o
6c5f577
 obj-y += clk-sun8i-bus-gates.o
6c5f577
 obj-y += clk-sun8i-mbus.o
6c5f577
 obj-y += clk-sun9i-core.o
6c5f577
diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
6c5f577
index 59428db..607ba53 100644
6c5f577
--- a/drivers/clk/sunxi/clk-factors.c
6c5f577
+++ b/drivers/clk/sunxi/clk-factors.c
6c5f577
@@ -184,7 +184,8 @@ struct clk *sunxi_factors_register(struct device_node *node,
6c5f577
 	if (data->name)
6c5f577
 		clk_name = data->name;
6c5f577
 	else
6c5f577
-		of_property_read_string(node, "clock-output-names", &clk_name);
6c5f577
+		of_property_read_string_index(node, "clock-output-names",
6c5f577
+					      data->name_idx, &clk_name);
6c5f577
 
6c5f577
 	factors = kzalloc(sizeof(struct clk_factors), GFP_KERNEL);
6c5f577
 	if (!factors)
6c5f577
diff --git a/drivers/clk/sunxi/clk-factors.h b/drivers/clk/sunxi/clk-factors.h
6c5f577
index 171085a..cc89d1f 100644
6c5f577
--- a/drivers/clk/sunxi/clk-factors.h
6c5f577
+++ b/drivers/clk/sunxi/clk-factors.h
6c5f577
@@ -26,6 +26,7 @@ struct factors_data {
62d5948
 	void (*getter)(struct factors_request *req);
62d5948
 	void (*recalc)(struct factors_request *req);
6c5f577
 	const char *name;
6c5f577
+	int name_idx;
6c5f577
 };
6c5f577
 
6c5f577
 struct clk_factors {
6c5f577
diff --git a/drivers/clk/sunxi/clk-multi-gates.c b/drivers/clk/sunxi/clk-multi-gates.c
6c5f577
new file mode 100644
6c5f577
index 0000000..76e715a
6c5f577
--- /dev/null
6c5f577
+++ b/drivers/clk/sunxi/clk-multi-gates.c
6c5f577
@@ -0,0 +1,105 @@
6c5f577
+/*
6c5f577
+ * Copyright (C) 2016 ARM Ltd.
6c5f577
+ *
6c5f577
+ * Based on clk-sun8i-bus-gates.c, which is:
6c5f577
+ *  Copyright (C) 2015 Jens Kuske <jenskuske@gmail.com>
6c5f577
+ * Based on clk-simple-gates.c, which is:
6c5f577
+ *  Copyright 2015 Maxime Ripard <maxime.ripard@free-electrons.com>
6c5f577
+ *
6c5f577
+ * This program is free software; you can redistribute it and/or modify
6c5f577
+ * it under the terms of the GNU General Public License as published by
6c5f577
+ * the Free Software Foundation; either version 2 of the License, or
6c5f577
+ * (at your option) any later version.
6c5f577
+ *
6c5f577
+ * This program is distributed in the hope that it will be useful,
6c5f577
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
6c5f577
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6c5f577
+ * GNU General Public License for more details.
6c5f577
+ */
6c5f577
+
6c5f577
+#include <linux/clk-provider.h>
6c5f577
+#include <linux/of.h>
6c5f577
+#include <linux/of_address.h>
6c5f577
+#include <linux/slab.h>
6c5f577
+#include <linux/spinlock.h>
6c5f577
+
6c5f577
+static DEFINE_SPINLOCK(gates_lock);
6c5f577
+
6c5f577
+static void __init sunxi_parse_parent(struct device_node *node,
6c5f577
+				      struct clk_onecell_data *clk_data,
6c5f577
+				      void __iomem *reg)
6c5f577
+{
6c5f577
+	const char *parent = of_clk_get_parent_name(node, 0);
6c5f577
+	const char *clk_name;
6c5f577
+	struct property *prop;
6c5f577
+	struct clk *clk;
6c5f577
+	const __be32 *p;
6c5f577
+	int index, i = 0;
6c5f577
+
6c5f577
+	of_property_for_each_u32(node, "clock-indices", prop, p, index) {
6c5f577
+		of_property_read_string_index(node, "clock-output-names",
6c5f577
+					      i, &clk_name);
6c5f577
+
6c5f577
+		clk = clk_register_gate(NULL, clk_name, parent, 0,
6c5f577
+					reg + 4 * (index / 32), index % 32,
6c5f577
+					0, &gates_lock);
6c5f577
+		i++;
6c5f577
+		if (IS_ERR(clk)) {
6c5f577
+			pr_warn("could not register gate clock \"%s\"\n",
6c5f577
+				clk_name);
6c5f577
+			continue;
6c5f577
+		}
6c5f577
+		if (clk_data->clks[index])
6c5f577
+			pr_warn("bus-gate clock %s: index #%d already registered as %s\n",
6c5f577
+				clk_name, index, "?");
6c5f577
+		else
6c5f577
+			clk_data->clks[index] = clk;
6c5f577
+	}
6c5f577
+}
6c5f577
+
6c5f577
+static void __init sunxi_multi_bus_gates_init(struct device_node *node)
6c5f577
+{
6c5f577
+	struct clk_onecell_data *clk_data;
6c5f577
+	struct device_node *child;
6c5f577
+	struct property *prop;
6c5f577
+	struct resource res;
6c5f577
+	void __iomem *reg;
6c5f577
+	const __be32 *p;
6c5f577
+	int number = 0;
6c5f577
+	int index;
6c5f577
+
6c5f577
+	reg = of_io_request_and_map(node, 0, of_node_full_name(node));
6c5f577
+	if (IS_ERR(reg))
6c5f577
+		return;
6c5f577
+
6c5f577
+	clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
6c5f577
+	if (!clk_data)
6c5f577
+		goto err_unmap;
6c5f577
+
6c5f577
+	for_each_child_of_node(node, child)
6c5f577
+		of_property_for_each_u32(child, "clock-indices", prop, p, index)
6c5f577
+			number = max(number, index);
6c5f577
+
6c5f577
+	clk_data->clks = kcalloc(number + 1, sizeof(struct clk *), GFP_KERNEL);
6c5f577
+	if (!clk_data->clks)
6c5f577
+		goto err_free_data;
6c5f577
+
6c5f577
+	for_each_child_of_node(node, child)
6c5f577
+		sunxi_parse_parent(child, clk_data, reg);
6c5f577
+
6c5f577
+	clk_data->clk_num = number + 1;
6c5f577
+	if (of_clk_add_provider(node, of_clk_src_onecell_get, clk_data))
6c5f577
+		pr_err("registering bus-gate clock %s failed\n", node->name);
6c5f577
+
6c5f577
+	return;
6c5f577
+
6c5f577
+err_free_data:
6c5f577
+	kfree(clk_data);
6c5f577
+err_unmap:
6c5f577
+	iounmap(reg);
6c5f577
+	of_address_to_resource(node, 0, &res;;
6c5f577
+	release_mem_region(res.start, resource_size(&res));
6c5f577
+}
6c5f577
+
6c5f577
+CLK_OF_DECLARE(sunxi_multi_bus_gates, "allwinner,sunxi-multi-bus-gates-clk",
6c5f577
+	       sunxi_multi_bus_gates_init);
6c5f577
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
6c5f577
index 5ba2188..ca59458 100644
6c5f577
--- a/drivers/clk/sunxi/clk-sunxi.c
6c5f577
+++ b/drivers/clk/sunxi/clk-sunxi.c
6c5f577
@@ -711,14 +711,14 @@ static const struct factors_data sun4i_pll6_data __initconst = {
6c5f577
 	.enable = 31,
6c5f577
 	.table = &sun4i_pll5_config,
6c5f577
 	.getter = sun4i_get_pll5_factors,
6c5f577
-	.name = "pll6",
6c5f577
+	.name_idx = 2,
6c5f577
 };
6c5f577
 
6c5f577
 static const struct factors_data sun6i_a31_pll6_data __initconst = {
6c5f577
 	.enable = 31,
6c5f577
 	.table = &sun6i_a31_pll6_config,
6c5f577
 	.getter = sun6i_a31_get_pll6_factors,
6c5f577
-	.name = "pll6x2",
6c5f577
+	.name_idx = 1,
6c5f577
 };
6c5f577
 
6c5f577
 static const struct factors_data sun5i_a13_ahb_data __initconst = {
6c5f577
-- 
6c5f577
2.5.0
6c5f577