From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Ayotte <martinayotte@yahoo.ca>
Date: Tue, 18 Apr 2017 12:35:50 -0400
Subject: [ARCHEOLOGY] preliminary commit for new OrangepiWin builds

> X-Git-Archeology: - Revision ae0fc2e757b59be3aeeff7869fe356f6e4cefa08: https://github.com/armbian/build/commit/ae0fc2e757b59be3aeeff7869fe356f6e4cefa08
> X-Git-Archeology:   Date: Tue, 18 Apr 2017 12:35:50 -0400
> X-Git-Archeology:   From: Martin Ayotte <martinayotte@yahoo.ca>
> X-Git-Archeology:   Subject: preliminary commit for new OrangepiWin builds
> X-Git-Archeology:
> X-Git-Archeology: - Revision a09111c40722c9d508a01ebe4f44f88af08e8530: https://github.com/armbian/build/commit/a09111c40722c9d508a01ebe4f44f88af08e8530
> X-Git-Archeology:   Date: Wed, 19 Apr 2017 17:34:56 -0400
> X-Git-Archeology:   From: Martin Ayotte <martinayotte@yahoo.ca>
> X-Git-Archeology:   Subject: remove useless wifi in A64 u-boot
> X-Git-Archeology:
> X-Git-Archeology: - Revision 509f2ab04d535a779b3cc444aa3811b65efb31a4: https://github.com/armbian/build/commit/509f2ab04d535a779b3cc444aa3811b65efb31a4
> X-Git-Archeology:   Date: Thu, 20 Apr 2017 10:26:30 -0400
> X-Git-Archeology:   From: Martin Ayotte <martinayotte@yahoo.ca>
> X-Git-Archeology:   Subject: add missing sun50i_a64_opiwin.its to u-boot builds
> X-Git-Archeology:
> X-Git-Archeology: - Revision f8153eda0925e510bea80fdf1d013fff5ba8ae6b: https://github.com/armbian/build/commit/f8153eda0925e510bea80fdf1d013fff5ba8ae6b
> X-Git-Archeology:   Date: Fri, 21 Apr 2017 21:20:46 -0400
> X-Git-Archeology:   From: Martin Ayotte <martinayotte@yahoo.ca>
> X-Git-Archeology:   Subject: initial patches for orangepiprime
> X-Git-Archeology:
> X-Git-Archeology: - Revision 2e2887f64b3c3693c6861e555c646f0a27155fc5: https://github.com/armbian/build/commit/2e2887f64b3c3693c6861e555c646f0a27155fc5
> X-Git-Archeology:   Date: Sun, 23 Apr 2017 10:35:16 -0400
> X-Git-Archeology:   From: Martin Ayotte <martinayotte@yahoo.ca>
> X-Git-Archeology:   Subject: OpiPrime has 2GB RAM
> X-Git-Archeology:
> X-Git-Archeology: - Revision 5ad09a5c06d75f9c252037de564d94f38ef322c6: https://github.com/armbian/build/commit/5ad09a5c06d75f9c252037de564d94f38ef322c6
> X-Git-Archeology:   Date: Tue, 25 Apr 2017 12:14:39 -0400
> X-Git-Archeology:   From: Martin Ayotte <martinayotte@yahoo.ca>
> X-Git-Archeology:   Subject: add new OPiZeroPlus patches + tweak OPiPrime/OPiWin patches
> X-Git-Archeology:
> X-Git-Archeology: - Revision 147545fabb9ab0e84a15b327ea7ddc2a012d371b: https://github.com/armbian/build/commit/147545fabb9ab0e84a15b327ea7ddc2a012d371b
> X-Git-Archeology:   Date: Tue, 25 Apr 2017 20:06:08 +0200
> X-Git-Archeology:   From: Igor Pecovnik <igor.pecovnik@gmail.com>
> X-Git-Archeology:   Subject: Added Nanopi M1 plus2 kernel DT and uboot config, not done yet
> X-Git-Archeology:
> X-Git-Archeology: - Revision 41c2c3051e66ab964c46efd04e8d16fc1aebb7c8: https://github.com/armbian/build/commit/41c2c3051e66ab964c46efd04e8d16fc1aebb7c8
> X-Git-Archeology:   Date: Tue, 25 Apr 2017 22:12:30 +0200
> X-Git-Archeology:   From: Igor Pecovnik <igor.pecovnik@gmail.com>
> X-Git-Archeology:   Subject: Update u-boot patch for Nano M1+2
> X-Git-Archeology:
> X-Git-Archeology: - Revision f6875b14152f1106356a435f4ce7b60bfb9e49be: https://github.com/armbian/build/commit/f6875b14152f1106356a435f4ce7b60bfb9e49be
> X-Git-Archeology:   Date: Wed, 26 Apr 2017 00:46:19 -0700
> X-Git-Archeology:   From: ThomasKaiser <github@kaiser-edv.de>
> X-Git-Archeology:   Subject: Lower DRAM clockspeed for H5 boards
> X-Git-Archeology:
> X-Git-Archeology: - Revision fe6969b057d36a91f06c96b0026cde0031e49e42: https://github.com/armbian/build/commit/fe6969b057d36a91f06c96b0026cde0031e49e42
> X-Git-Archeology:   Date: Fri, 14 Jul 2017 12:06:54 +0300
> X-Git-Archeology:   From: zador-blood-stained <zador-blood-stained@users.noreply.github.com>
> X-Git-Archeology:   Subject: Add proper u-boot config for Zero Plus 2 H3
> X-Git-Archeology:
> X-Git-Archeology: - Revision 1bdcdba9ff1443060bd78cb06a6e64143ab6472c: https://github.com/armbian/build/commit/1bdcdba9ff1443060bd78cb06a6e64143ab6472c
> X-Git-Archeology:   Date: Tue, 24 Oct 2017 13:15:27 +0200
> X-Git-Archeology:   From: Igor Pecovnik <igor.pecovnik@gmail.com>
> X-Git-Archeology:   Subject: Adding Orangepi Zero Plus2 u-boot and kernel bits and removing unsupported ZeroPlus which is another beast we don't have yet: http://www.orangepi.org/OrangePiZeroPlus/ fancy ethernet and FTV8189. HDMI, WifI and eMMC on Zero2+ H3 works, while I had no luck with Bluetooth
> X-Git-Archeology:
> X-Git-Archeology: - Revision 89ea5f0ca0062d185b4d1fde9b9e2cbb4b96fee6: https://github.com/armbian/build/commit/89ea5f0ca0062d185b4d1fde9b9e2cbb4b96fee6
> X-Git-Archeology:   Date: Sun, 10 Dec 2017 23:05:33 +0300
> X-Git-Archeology:   From: Karabek <r.github1@raschid.org>
> X-Git-Archeology:   Subject: Mainline support for Sunvell R69 (#843)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 137797d1e397ced3d1e3e4c36de15217ca674e3c: https://github.com/armbian/build/commit/137797d1e397ced3d1e3e4c36de15217ca674e3c
> X-Git-Archeology:   Date: Sun, 17 Dec 2017 10:49:56 +0100
> X-Git-Archeology:   From: karabek <st.gothian@gmail.com>
> X-Git-Archeology:   Subject: HDMI support for (community supported) mainlen kernel for Sunvell R69
> X-Git-Archeology:
> X-Git-Archeology: - Revision e99b45b3260b6ad2f28d142d4791ca8bc3c55462: https://github.com/armbian/build/commit/e99b45b3260b6ad2f28d142d4791ca8bc3c55462
> X-Git-Archeology:   Date: Wed, 07 Feb 2018 12:43:56 +0300
> X-Git-Archeology:   From: Karabek <r.github1@raschid.org>
> X-Git-Archeology:   Subject: Improve boot stability (#886)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 1a12994e79b6ef173dc58efe4df8919cb6cc7781: https://github.com/armbian/build/commit/1a12994e79b6ef173dc58efe4df8919cb6cc7781
> X-Git-Archeology:   Date: Tue, 17 Jul 2018 15:53:30 +0200
> X-Git-Archeology:   From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology:   Subject: Moving sunxi-next to 4.17.y (#1049)
> X-Git-Archeology:
> X-Git-Archeology: - Revision 9363e3ec4d3a3234c5bdab6b7a1e3fd606b68102: https://github.com/armbian/build/commit/9363e3ec4d3a3234c5bdab6b7a1e3fd606b68102
> X-Git-Archeology:   Date: Mon, 14 Jan 2019 16:52:22 -0500
> X-Git-Archeology:   From: Martin Ayotte <martinayotte@yahoo.ca>
> X-Git-Archeology:   Subject: u-boot v2018.11 migration + tons of patches touchups
> X-Git-Archeology:
> X-Git-Archeology: - Revision 158e0f48491f4c0008294f0d6c7306c38fd66873: https://github.com/armbian/build/commit/158e0f48491f4c0008294f0d6c7306c38fd66873
> X-Git-Archeology:   Date: Wed, 27 Nov 2019 22:50:46 +0100
> X-Git-Archeology:   From: Karabek <github@karabek.net>
> X-Git-Archeology:   Subject: Sunvell R69: cpu voltage regulator (re-)added - dram clock reduced. (#1643)
> X-Git-Archeology:
> X-Git-Archeology: - Revision d513a4376846d4cb6fc5112657a0b495f75308d6: https://github.com/armbian/build/commit/d513a4376846d4cb6fc5112657a0b495f75308d6
> X-Git-Archeology:   Date: Mon, 02 Dec 2019 15:32:46 +0100
> X-Git-Archeology:   From: Karabek <github@karabek.net>
> X-Git-Archeology:   Subject: Sunvell R69: enable eMMC boot
> X-Git-Archeology:
> X-Git-Archeology: - Revision 5e8cbd8e6aaa87ee03d08c761d5e765e81c4c686: https://github.com/armbian/build/commit/5e8cbd8e6aaa87ee03d08c761d5e765e81c4c686
> X-Git-Archeology:   Date: Fri, 17 Apr 2020 23:44:35 +0200
> X-Git-Archeology:   From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology:   Subject: Switch sunxi and sunxi64 to u-boot v2020.04 (#1894)
> X-Git-Archeology:
> X-Git-Archeology: - Revision f6a09def35e647a5442e0f92f399485be29f19a9: https://github.com/armbian/build/commit/f6a09def35e647a5442e0f92f399485be29f19a9
> X-Git-Archeology:   Date: Thu, 10 Nov 2022 21:49:36 +0100
> X-Git-Archeology:   From: Igor Pecovnik <igorpecovnik@users.noreply.github.com>
> X-Git-Archeology:   Subject: Moving patches to per board and removing obsolete (#4409)
---
 arch/arm/dts/Makefile                      |   1 +
 arch/arm/dts/sun8i-h2-plus-sunvell-r69.dts | 220 ++++++++++
 configs/sunvell_r69_defconfig              |  20 +
 3 files changed, 241 insertions(+)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index a7e0d9f6c0..d51f7d74fd 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -646,6 +646,7 @@ dtb-$(CONFIG_MACH_SUN8I_H3) += \
 	sun8i-h2-plus-libretech-all-h3-cc.dtb \
 	sun8i-h2-plus-orangepi-r1.dtb \
 	sun8i-h2-plus-orangepi-zero.dtb \
+	sun8i-h2-plus-sunvell-r69.dtb \
 	sun8i-h3-bananapi-m2-plus.dtb \
 	sun8i-h3-bananapi-m2-plus-v1.2.dtb \
 	sun8i-h3-beelink-x2.dtb \
diff --git a/arch/arm/dts/sun8i-h2-plus-sunvell-r69.dts b/arch/arm/dts/sun8i-h2-plus-sunvell-r69.dts
new file mode 100644
index 0000000000..830990cec1
--- /dev/null
+++ b/arch/arm/dts/sun8i-h2-plus-sunvell-r69.dts
@@ -0,0 +1,220 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Based original Sunvell R69 FEX file (2019 karabek)
+ */
+
+/dts-v1/;
+#include "sun8i-h3.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/pinctrl/sun4i-a10.h>
+
+/ {
+	model = "Sunvell R69";
+	compatible = "sunvell,sunvell-r69", "allwinner,sun8i-h2-plus";
+
+	aliases {
+		ethernet0 = &emac;
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	connector {
+		compatible = "hdmi-connector";
+		type = "a";
+
+		port {
+			hdmi_con_in: endpoint {
+				remote-endpoint = <&hdmi_out_con>;
+			};
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+		pinctrl-0 = <&leds_opc>, <&leds_r_opc>;
+
+		pwr_led {
+			label = "sunvell-r69:red:pwr";
+			gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>;
+			default-state = "on";
+		};
+
+		status_led {
+			label = "sunvell-r69:blue:status";
+			gpios = <&pio 0 15 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
+	reg_vdd_cpux: vdd-cpux-regulator {
+		compatible = "regulator-gpio";
+		regulator-name = "vdd-cpux";
+		regulator-type = "voltage";
+		regulator-boot-on;
+		regulator-always-on;
+		regulator-min-microvolt = <1100000>;
+		regulator-max-microvolt = <1300000>;
+		regulator-ramp-delay = <50>; /* 4ms */
+
+		gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
+		enable-active-high;
+		gpios-states = <0x1>;
+		states = <1100000 0x0
+			  1300000 0x1>;
+	};
+
+	reg_vcc_wifi: reg_vcc_wifi {
+		compatible = "regulator-fixed";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-name = "vcc-wifi";
+		gpio = <&r_pio 0 7 GPIO_ACTIVE_HIGH>;
+	        startup-delay-us = <70000>;
+		enable-active-high;
+	};
+
+	wifi_pwrseq: wifi_pwrseq {
+		compatible = "mmc-pwrseq-simple";
+		reset-gpios = <&r_pio 0 0 GPIO_ACTIVE_LOW>;
+		post-power-on-delay-ms = <200>;
+	};
+};
+
+&cpu0 {
+	cpu-supply = <&reg_vdd_cpux>;
+};
+
+&de {
+	status = "okay";
+};
+
+&ehci0 {
+	status = "okay";
+};
+
+&ehci1 {
+	status = "okay";
+};
+
+&emac {
+	phy-handle = <&int_mii_phy>;
+	phy-mode = "mii";
+	allwinner,leds-active-low;
+	status = "okay";
+};
+
+&hdmi {
+	status = "okay";
+};
+
+&hdmi_out {
+	hdmi_out_con: endpoint {
+		remote-endpoint = <&hdmi_con_in>;
+	};
+};
+
+&mmc0 {
+	vmmc-supply = <&reg_vcc3v3>;
+	bus-width = <4>;
+	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
+	status = "okay";
+};
+
+&mmc1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mmc1_pins>;
+	vmmc-supply = <&reg_vcc_wifi>;
+	mmc-pwrseq = <&wifi_pwrseq>;
+	bus-width = <4>;
+	non-removable;
+	status = "okay";
+
+	/*
+	 * Explicitly define the sdio device, so that we can add an ethernet
+	 * alias for it (which e.g. makes u-boot set a mac-address).
+	 */
+	xr819: sdio_wifi@1 {
+		reg = <1>;
+	};
+};
+
+&mmc2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mmc2_8bit_pins>;
+	vmmc-supply = <&reg_vcc3v3>;
+	bus-width = <8>;
+	non-removable;
+	cap-mmc-hw-reset;
+	status = "okay";
+};
+
+&mmc2_8bit_pins {
+	/* Increase current from 30mA to 40mA for DDR eMMC */
+	allwinner,drive = <SUN4I_PINCTRL_40_MA>;
+};
+
+&ohci0 {
+	status = "okay";
+};
+
+&ohci1 {
+	status = "okay";
+};
+
+&pio {
+	leds_opc: led_pins {
+		pins = "PA15";
+		function = "gpio_out";
+	};
+};
+
+&r_pio {
+	leds_r_opc: led_pins {
+		pins = "PL10";
+		function = "gpio_out";
+	};
+};
+
+&reg_usb0_vbus {
+	gpio = <&r_pio 0 2 GPIO_ACTIVE_HIGH>; /* PL2 */
+	status = "okay";
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pa_pins>;
+	status = "okay";
+};
+
+&uart1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart1_pins>;
+	status = "disabled";
+};
+
+&uart2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart2_pins>;
+	status = "disabled";
+};
+
+&uart3 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart3_pins>;
+	status = "disabled";
+};
+
+&usb_otg {
+	dr_mode = "otg";
+	status = "okay";
+};
+
+&usbphy {
+	status = "okay";
+};
diff --git a/configs/sunvell_r69_defconfig b/configs/sunvell_r69_defconfig
new file mode 100644
index 0000000000..d03dcec8d0
--- /dev/null
+++ b/configs/sunvell_r69_defconfig
@@ -0,0 +1,22 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_SPL_STACK=0x8000
+CONFIG_SYS_PBSIZE=1024
+CONFIG_MACH_SUN8I_H3=y
+CONFIG_DRAM_CLK=408
+CONFIG_DRAM_ZQ=3881979
+CONFIG_DRAM_ODT_EN=y
+CONFIG_NR_DRAM_BANKS=1
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_DEFAULT_DEVICE_TREE="sun8i-h2-plus-sunvell-r69"
+CONFIG_SUN8I_EMAC=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_SYS_CLK_FREQ=480000000
+
-- 
Armbian

