From b96bdf955ab4131023a465dba2035940ee848fb4 Mon Sep 17 00:00:00 2001
From: Zoltan HERPAI <wigyori@uid0.hu>
Date: Thu, 31 Aug 2023 13:35:06 +0200
Subject: [PATCH 18/25] ARM: dts: add support for Rongpin RP-T113 board

Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
---
 arch/arm/boot/dts/allwinner/Makefile                |   1 +
 arch/arm/boot/dts/allwinner/sun8i-t113s-rp-t113.dts | 184 ++++++++++++++++++++++
 2 files changed, 185 insertions(+)
 create mode 100644 arch/arm/boot/dts/allwinner/sun8i-t113s-rp-t113.dts

--- a/arch/arm/boot/dts/allwinner/Makefile
+++ b/arch/arm/boot/dts/allwinner/Makefile
@@ -265,6 +265,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
 	sun8i-t113s-mangopi-mqdual-t113.dtb \
 	sun8i-t113s-myd-yt113x-emmc.dtb \
 	sun8i-t113s-myd-yt113x-spi.dtb \
+	sun8i-t113s-rp-t113.dtb \
 	sun8i-t113s-netcube-nagami-basic-carrier.dtb \
 	sun8i-t113s-netcube-nagami-keypad-carrier.dtb \
 	sun8i-t3-cqa3t-bv3.dtb \
--- /dev/null
+++ b/arch/arm/boot/dts/allwinner/sun8i-t113s-rp-t113.dts
@@ -0,0 +1,213 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+// Copyright (C) 2022 Arm Ltd.
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/gpio/gpio.h>
+
+/dts-v1/;
+
+#include "sun8i-t113s.dtsi"
+
+/ {
+	model = "Rongpin RP-T113";
+	compatible = "rongpin,rp-t113", "allwinner,sun8i-t113s";
+
+	aliases {
+		serial3 = &uart3;
+
+		led-boot = &led_green;
+		led-failsafe = &led_green;
+		led-running = &led_green;
+		led-upgrade = &led_green;
+	};
+
+	chosen {
+		stdout-path = "serial3:115200n8";
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led_green: green {
+			label = "green";
+			gpios = <&pio 3 16 GPIO_ACTIVE_HIGH>; /* PD16 */
+		};
+	};
+
+
+	/* board wide 5V supply directly from the USB-C socket */
+	reg_vcc5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc-5v";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		regulator-always-on;
+	};
+
+	/* SY8008 DC/DC regulator on the board */
+	reg_3v3: regulator-3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc-3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		vin-supply = <&reg_vcc5v>;
+	};
+
+	/* SY8008 DC/DC regulator on the board, also supplying VDD-SYS */
+	reg_vcc_core: regulator-core {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc-core";
+		regulator-min-microvolt = <880000>;
+		regulator-max-microvolt = <880000>;
+		vin-supply = <&reg_vcc5v>;
+	};
+
+	/* XC6206 LDO on the board */
+	reg_avdd2v8: regulator-avdd {
+		compatible = "regulator-fixed";
+		regulator-name = "avdd2v8";
+		regulator-min-microvolt = <2800000>;
+		regulator-max-microvolt = <2800000>;
+		vin-supply = <&reg_3v3>;
+	};
+
+	reg_gmac_3v3: gmac-3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "gmac-3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		startup-delay-us = <100000>;
+		enable-active-high;
+		gpio = <&pio 3 11 GPIO_ACTIVE_HIGH>; /* PG11 */
+	};
+
+	/* We need to pull up some GPIOs to enable the onboard wifi module
+	   and the 4G mPCIe slot, mark these as always-on. */
+	reg_vcc_usbwifi: vcc-usbwifi {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc-usbwifi";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		enable-active-high;
+		gpio = <&pio 3 17 GPIO_ACTIVE_HIGH>; /* PD17 */
+		regulator-always-on;
+	};
+
+	reg_vcc_4g: vcc-4g {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc-4g";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		enable-active-high;
+		gpio = <&pio 4 1 GPIO_ACTIVE_HIGH>; /* PE1 */
+		regulator-always-on;
+	};
+};
+
+&cpu0 {
+	cpu-supply = <&reg_vcc_core>;
+};
+
+&cpu1 {
+	cpu-supply = <&reg_vcc_core>;
+};
+
+&dcxo {
+	clock-frequency = <24000000>;
+};
+
+&pio {
+	vcc-pb-supply = <&reg_3v3>;
+	vcc-pd-supply = <&reg_3v3>;
+	vcc-pe-supply = <&reg_avdd2v8>;
+	vcc-pf-supply = <&reg_3v3>;
+	vcc-pg-supply = <&reg_3v3>;
+
+	/omit-if-no-ref/
+	uart3_pe_pins: uart3-pe-pins {
+		pins = "PE8", "PE9";
+		function = "uart3";
+	};
+
+	/* move this over to riscv common dtsi */
+	/omit-if-no-ref/
+	rmii_pg_pins: rmii-pg-pins {
+		pins = "PG0", "PG1", "PG2", "PG3", "PG4",
+			"PG5", "PG12", "PG13", "PG14", "PG15";
+		function = "emac";
+	};
+
+	emac_25m_pins: emac-25m-pins {
+		pins = "PE10";
+		function = "emac";
+	};
+};
+
+&uart3 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart3_pe_pins>;
+	status = "okay";
+};
+
+&mmc0 {
+	pinctrl-0 = <&mmc0_pins>;
+	pinctrl-names = "default";
+	vmmc-supply = <&reg_3v3>;
+	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;
+	disable-wp;
+	bus-width = <4>;
+	status = "okay";
+};
+
+&mmc2 {
+	pinctrl-0 = <&mmc2_pins>;
+	pinctrl-names = "default";
+	vmmc-supply = <&reg_3v3>;
+	non-removable;
+	bus-width = <4>;
+	status = "okay";
+};
+
+&mdio {
+	clocks = <&ccu CLK_EMAC_25M>;
+	clock-names = "emac_25m";
+
+	ext_rmii_phy: ethernet-phy@1 {
+		reg = <1>;
+		reset-gpios = <&pio 4 11 GPIO_ACTIVE_LOW>;
+	};
+};
+
+&emac {
+	pinctrl-names = "default";
+	pinctrl-0 = <&rmii_pg_pins>, <&emac_25m_pins>;
+
+	phy-supply = <&reg_gmac_3v3>;
+	phy-handle = <&ext_rmii_phy>;
+	phy-mode = "rmii";
+
+	status = "okay";
+};
+
+&usb_otg {
+	dr_mode = "peripheral";
+	status = "okay";
+};
+
+&usbphy {
+	usb1_vbus-supply = <&reg_vcc5v>;
+	status = "okay";
+};
+
+&ehci1 {
+	status = "okay";
+};
+
+&ohci1 {
+	status = "okay";
+};
+
+&wdt {
+	status = "okay";
+};
+
