From 0d986679b1a17d80ce2cef42b36b0ee5a5e42aa7 Mon Sep 17 00:00:00 2001
From: Elias Bakken <elias@iagent.no>
Date: Tue, 7 Feb 2023 21:56:20 +0100
Subject: [PATCH] Add support for Recore

---
 arch/arm/dts/Makefile              |   1 +
 arch/arm/dts/sun50i-a64-recore.dts | 271 +++++++++++++++++++++++++++++
 configs/recore_defconfig           |  32 ++++
 3 files changed, 304 insertions(+)
 create mode 100644 arch/arm/dts/sun50i-a64-recore.dts
 create mode 100644 configs/recore_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 43951a7731..1badd2e38e 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -735,6 +735,7 @@ dtb-$(CONFIG_MACH_SUN50I) += \
 	sun50i-a64-pinephone-1.1.dtb \
 	sun50i-a64-pinephone-1.2.dtb \
 	sun50i-a64-pinetab.dtb \
+	sun50i-a64-recore.dtb \
 	sun50i-a64-sopine-baseboard.dtb \
 	sun50i-a64-teres-i.dtb
 dtb-$(CONFIG_MACH_SUN9I) += \
diff --git a/arch/arm/dts/sun50i-a64-recore.dts b/arch/arm/dts/sun50i-a64-recore.dts
new file mode 100644
index 0000000000..d704731873
--- /dev/null
+++ b/arch/arm/dts/sun50i-a64-recore.dts
@@ -0,0 +1,271 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+// Copyright (c) 2016 ARM Ltd.
+
+/dts-v1/;
+
+#include "sun50i-a64.dtsi"
+#include "sun50i-a64-cpu-opp.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	model = "Recore-u-boot";
+	compatible = "recore", "allwinner,sun50i-a64";
+
+	aliases {
+		ethernet0 = &emac;
+		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
+		serial3 = &uart3;
+		serial4 = &uart4;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	hdmi-connector {
+		compatible = "hdmi-connector";
+		type = "a";
+
+		port {
+			hdmi_con_in: endpoint {
+				remote-endpoint = <&hdmi_out_con>;
+			};
+		};
+	};
+
+	reg_usb1_vbus1: usb1-vbus1 {
+		compatible = "regulator-fixed";
+		regulator-name = "usb1-vbus1";
+		gpio = <&pio 7 0 GPIO_ACTIVE_HIGH>; /* PH0 */
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+		regulator-boot-on;
+		enable-active-high;
+	};
+
+	reg_usb1_vbus2: usb1-vbus2 {
+		compatible = "regulator-fixed";
+		regulator-name = "usb1-vbus2";
+		gpio = <&pio 7 1 GPIO_ACTIVE_HIGH>; /* PH1 */
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+		regulator-boot-on;
+		enable-active-high;
+	};
+
+	reg_usb1_vbus3: usb1-vbus3 {
+		compatible = "regulator-fixed";
+		regulator-name = "usb1-vbus3";
+		gpio = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+		regulator-boot-on;
+		enable-active-high;
+	};
+
+	reg_usb1_vbus4: usb1-vbus4 {
+		compatible = "regulator-fixed";
+		regulator-name = "usb1-vbus4";
+		gpio = <&pio 7 3 GPIO_ACTIVE_HIGH>; /* PH3 */
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+		regulator-boot-on;
+		enable-active-high;
+	};
+
+	reg_usb1_vbus5: usb1-vbus5 {
+		compatible = "regulator-fixed";
+		regulator-name = "usb1-vbus5";
+		gpio = <&pio 3 5 GPIO_ACTIVE_HIGH>; /* PD5 */
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+		regulator-boot-on;
+		enable-active-high;
+	};
+
+	reg_usb1_vbus6: usb1-vbus6 {
+		compatible = "regulator-fixed";
+		regulator-name = "usb1-vbus6";
+		gpio = <&pio 3 6 GPIO_ACTIVE_HIGH> ; /* PD6 */
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+		regulator-boot-on;
+		enable-active-high;
+	};
+};
+
+&de {
+	status = "okay";
+};
+
+&hdmi {
+	hvcc-supply = <&reg_dldo1>;
+	status = "okay";
+};
+
+&hdmi_out {
+	hdmi_out_con: endpoint {
+		remote-endpoint = <&hdmi_con_in>;
+	};
+};
+
+&emac {
+	pinctrl-names = "default";
+	pinctrl-0 = <&rgmii_pins>;
+	phy-mode = "rgmii";
+	phy-handle = <&ext_rgmii_phy>;
+	phy-supply = <&reg_dc1sw>;
+	status = "okay";
+};
+
+&mdio {
+	ext_rgmii_phy: ethernet-phy@1 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <7>;
+	};
+};
+
+&mmc2 {
+	pinctrl-names = "default";
+  pinctrl-0 = <&mmc2_pins>, <&mmc2_ds_pin>;
+	vmmc-supply = <&reg_dcdc1>;
+  vqmmc-supply = <&reg_eldo1>;
+  non-removable;
+  cap-mmc-hw-reset;
+	bus-width = <8>;
+	status = "okay";
+  mmc-hs200-1_8v;
+  max-frequency = <100000000>;
+};
+
+&ohci0 {
+	status = "okay";
+};
+
+&ohci1 {
+  status = "okay";
+};
+
+&ehci0 {
+	status = "okay";
+};
+
+&ehci1 {
+	status = "okay";
+};
+
+&r_rsb {
+	status = "okay";
+
+	axp803: pmic@3a3 {
+		compatible = "x-powers,axp803";
+		reg = <0x3a3>;
+		interrupt-parent = <&r_intc>;
+		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+	};
+};
+
+#include "axp803.dtsi"
+
+&reg_aldo3 {
+	regulator-always-on;
+	regulator-min-microvolt = <3000000>;
+	regulator-max-microvolt = <3000000>;
+	regulator-name = "vcc-pll-avcc";
+};
+
+&reg_dc1sw {
+  regulator-always-on;
+	regulator-name = "vcc-phy";
+};
+
+&reg_dcdc1 {
+	regulator-always-on;
+	regulator-min-microvolt = <3300000>;
+	regulator-max-microvolt = <3300000>;
+	regulator-name = "vcc-3v3";
+};
+
+&reg_dcdc2 {
+	regulator-always-on;
+	regulator-min-microvolt = <1040000>;
+	regulator-max-microvolt = <1300000>;
+	regulator-name = "vdd-cpux";
+};
+
+&reg_dcdc5 {
+	regulator-always-on;
+	regulator-min-microvolt = <1360000>;
+	regulator-max-microvolt = <1360000>;
+	regulator-name = "vcc-dram";
+};
+
+&reg_dcdc6 {
+	regulator-always-on;
+	regulator-min-microvolt = <1100000>;
+	regulator-max-microvolt = <1100000>;
+	regulator-name = "vdd-sys";
+};
+
+&reg_dldo1 {
+	regulator-min-microvolt = <3300000>;
+	regulator-max-microvolt = <3300000>;
+	regulator-name = "vcc-hdmi";
+};
+
+&reg_eldo1 {
+  regulator-always-on;
+	regulator-min-microvolt = <1800000>;
+	regulator-max-microvolt = <1800000>;
+	regulator-name = "cpvdd";
+};
+
+&reg_fldo2 {
+	regulator-always-on;
+	regulator-min-microvolt = <1100000>;
+	regulator-max-microvolt = <1100000>;
+	regulator-name = "vdd-cpus";
+};
+
+&reg_rtc_ldo {
+	regulator-name = "vcc-rtc";
+};
+
+&simplefb_hdmi {
+	vcc-hdmi-supply = <&reg_dldo1>;
+};
+
+&spdif {
+	status = "disabled";
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pb_pins>;
+	status = "okay";
+};
+
+&usb_otg {
+  dr_mode = "peripheral";
+  vcc-supply = <&reg_dcdc1>;
+	status = "okay";
+};
+
+&usb_power_supply {
+	status = "okay";
+};
+
+&usbphy {
+	usb0_vbus_power-supply = <&usb_power_supply>;
+  vcc-supply = <&reg_dcdc1>;
+	status = "okay";
+};
diff --git a/configs/recore_defconfig b/configs/recore_defconfig
new file mode 100644
index 0000000000..2a7c40d276
--- /dev/null
+++ b/configs/recore_defconfig
@@ -0,0 +1,32 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_MACH_SUN50I=y
+CONFIG_MMC=y
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-recore"
+CONFIG_OF_LIST="sun50i-a64-recore"
+CONFIG_VIDEO=y
+CONFIG_PHY_REALTEK=y
+CONFIG_SUN8I_EMAC=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_ENV_IS_NOWHERE=y
+#CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_STACK=0x54000
+CONFIG_SYS_PBSIZE=1024
+CONFIG_SYS_BOOTM_LEN=0x2000000
+CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
+CONFIG_VIDEO_LOGO=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
+CONFIG_VIDEO_BMP_RLE8=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_CMD_REGULATOR=y
-- 
2.34.1

