From 5aa0ef9d4a05f8c20032f045307bb97f1b0f7660 Mon Sep 17 00:00:00 2001
From: handsomeyingyan <handsomeyingyan@github.com>
Date: Tue, 20 Jul 2021 11:54:58 +0800
Subject: [PATCH] add support for sinv3s

---
 arch/arm/dts/Makefile                     |   3 +-
 arch/arm/dts/sun8i-v3s-sinlinx-sinv3s.dts | 142 ++++++++++++++++++++++
 configs/Sinlinx_SinV3s_defconfig          |  12 ++
 3 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/sun8i-v3s-sinlinx-sinv3s.dts
 create mode 100644 configs/Sinlinx_SinV3s_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 225fc877..f0cf069c 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -569,7 +569,8 @@ dtb-$(CONFIG_MACH_SUN8I_R40) += \
 	sun8i-v40-bananapi-m2-berry.dtb
 dtb-$(CONFIG_MACH_SUN8I_V3S) += \
 	sun8i-v3s-licheepi-zero.dtb \
-	sun8i-s3-pinecube.dtb
+	sun8i-s3-pinecube.dtb \
+	sun8i-v3s-sinlinx-sinv3s.dtb
 dtb-$(CONFIG_MACH_SUN50I_H5) += \
 	sun50i-h5-bananapi-m2-plus.dtb \
 	sun50i-h5-emlid-neutis-n5-devboard.dtb \
diff --git a/arch/arm/dts/sun8i-v3s-sinlinx-sinv3s.dts b/arch/arm/dts/sun8i-v3s-sinlinx-sinv3s.dts
new file mode 100644
index 00000000..2e1c34bc
--- /dev/null
+++ b/arch/arm/dts/sun8i-v3s-sinlinx-sinv3s.dts
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2021 HandsomeYingyan <HandsomeYingyan@gmail.com>
+ *
+ * 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 file 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 file 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.
+ */
+
+/dts-v1/;
+#include "sun8i-v3s.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+/ {
+	model = "Sinlinx Sinv3s";
+	compatible = "sinlinx,sinv3s", "allwinner,sun8i-v3s";
+
+	aliases {
+		ethernet0 = &emac;
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+	
+	backlight: backlight {
+		compatible = "pwm-backlight";
+		pwms = <&pwm 0 1000000 0>;
+		brightness-levels = <0 30 40 50 60 70 100>;
+		default-brightness-level = <6>;
+	};
+
+	panel: panel {
+		compatible = "netron-dy,e231732", "simple-panel";
+		backlight = <&backlight>;
+
+		port {
+			panel_input: endpoint {
+				remote-endpoint = <&tcon0_out_lcd>;
+			};
+		};
+
+		display-timings {
+			timing0: timing0 {
+				clock-frequency = <51000000>;
+				hactive = <1024>;
+				vactive = <600>;
+
+				hfront-porch = <160>;
+				hsync-len = <1>;
+				hback-porch = <159>;
+
+				vback-porch = <22>;
+				vsync-len = <1>;
+				vfront-porch = <12>;
+			};
+		};
+	};	
+};
+
+&tcon0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&lcd_pins>;
+	status = "okay";
+};
+
+&tcon0_out {
+	tcon0_out_lcd: endpoint@0 {
+		reg = <0>;
+		remote-endpoint = <&panel_input>;
+	};
+};
+
+&mmc0 {
+	pinctrl-0 = <&mmc0_pins_a>;
+	pinctrl-names = "default";
+	broken-cd;
+	bus-width = <4>;
+	vmmc-supply = <&reg_vcc3v3>;
+	status = "okay";
+};
+
+&uart0 {
+	pinctrl-0 = <&uart0_pins_a>;
+	pinctrl-names = "default";
+	status = "okay";
+};
+
+&pwm {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pwm0_pins>;
+	status = "okay";
+};
+
+
+&usb_otg {
+	dr_mode = "otg";
+	status = "okay";
+};
+
+&usbphy {
+	usb0_id_det-gpio = <&pio 1 3 GPIO_ACTIVE_HIGH>; /* PB3 */
+	status = "okay";
+};
+
+&emac {
+	status = "okay";
+};
diff --git a/configs/Sinlinx_SinV3s_defconfig b/configs/Sinlinx_SinV3s_defconfig
new file mode 100644
index 00000000..a68f4dbb
--- /dev/null
+++ b/configs/Sinlinx_SinV3s_defconfig
@@ -0,0 +1,12 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_SPL=y
+CONFIG_MACH_SUN8I_V3S=y
+CONFIG_DRAM_CLK=360
+CONFIG_USB0_ID_DET="PB3"
+CONFIG_VIDEO_LCD_BL_EN="PB2"
+CONFIG_DEFAULT_DEVICE_TREE="sun8i-v3s-sinlinx-sinv3s"
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_PWM=y
+CONFIG_PWM_SUNXI=y
+CONFIG_SUN8I_EMAC=y
-- 
2.32.0

