From 4a77c8ac8b0e2b479e81fb817bd05fd59b2788e3 Mon Sep 17 00:00:00 2001
From: The-going <48602507+The-going@users.noreply.github.com>
Date: Wed, 2 Feb 2022 20:27:02 +0300
Subject: arm64:dts:overlay: sun50i-a64-pine64-7inch-lcd

Added to orange-pi-5.9 2020-11-30
---
 .../arm64/boot/dts/allwinner/overlay/Makefile |  1 +
 .../overlay/README.sun50i-a64-overlays        |  5 ++
 .../overlay/sun50i-a64-pine64-7inch-lcd.dtso  | 87 +++++++++++++++++++
 3 files changed, 93 insertions(+)
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-a64-pine64-7inch-lcd.dtso

diff --git a/arch/arm64/boot/dts/allwinner/overlay/Makefile b/arch/arm64/boot/dts/allwinner/overlay/Makefile
index ae404a5258a9..8d5ae3e3beb8 100644
--- a/arch/arm64/boot/dts/allwinner/overlay/Makefile
+++ b/arch/arm64/boot/dts/allwinner/overlay/Makefile
@@ -2,6 +2,7 @@
 dtb-$(CONFIG_ARCH_SUNXI) += \
 	sun50i-a64-i2c0.dtbo \
 	sun50i-a64-i2c1.dtbo \
+	sun50i-a64-pine64-7inch-lcd.dtbo \
 	sun50i-a64-pps-gpio.dtbo \
 	sun50i-a64-spi-add-cs1.dtbo \
 	sun50i-a64-spi-jedec-nor.dtbo \
diff --git a/arch/arm64/boot/dts/allwinner/overlay/README.sun50i-a64-overlays b/arch/arm64/boot/dts/allwinner/overlay/README.sun50i-a64-overlays
index cd9dbc686412..b684c2e3abb1 100644
--- a/arch/arm64/boot/dts/allwinner/overlay/README.sun50i-a64-overlays
+++ b/arch/arm64/boot/dts/allwinner/overlay/README.sun50i-a64-overlays
@@ -20,6 +20,7 @@ on supported boards, so this controller is not supported in provided overlays
 
 - i2c0
 - i2c1
+- pine64-7inch-lcd
 - pps-gpio
 - spi-add-cs1
 - spi-jedec-nor
@@ -44,6 +45,10 @@ Activates TWI/I2C bus 1
 
 I2C1 pins (SCL, SDA): PH2, PH3
 
+### pine64-7inch-lcd
+
+Activates the Pine64 7" LCD on pine64/pine64so boards
+
 ### pps-gpio
 
 Activates pulse-per-second GPIO client
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-a64-pine64-7inch-lcd.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-a64-pine64-7inch-lcd.dtso
new file mode 100644
index 000000000000..34708103fe15
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-a64-pine64-7inch-lcd.dtso
@@ -0,0 +1,87 @@
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/pwm/pwm.h>
+
+/ {
+	compatible = "allwinner,sun50i-a64";
+
+	fragment@0 {
+		target = <&reg_ldo_io0>;
+
+		__overlay__ {
+			regulator-min-microvolt = <3300000>;
+			regulator-max-microvolt = <3300000>;
+			regulator-name = "vcc-ctp";
+			status = "okay";
+		};
+	};
+
+	fragment@1 {
+		target = <&i2c0>;
+
+		__overlay__ {
+			status = "okay";
+
+			gt911: touchscreen@5d {
+				compatible = "goodix,gt911";
+				reg = <0x5d>;
+		
+				interrupt-parent = <&pio>;
+				interrupts = <7 4 IRQ_TYPE_EDGE_RISING>; /* PH4 */
+				reset-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
+				AVDD28-supply = <&reg_ldo_io0>;
+			};
+		};
+	};
+
+	fragment@2 {
+		target = <&r_pwm>;
+
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	fragment@3 {
+		target-path = "/";
+
+		__overlay__ {
+			backlight: backlight {
+				compatible = "pwm-backlight";
+				pwms = <&r_pwm 0 50000 PWM_POLARITY_INVERTED>;
+				brightness-levels = <1 2 4 8 16 32 64 128 512>;
+				default-brightness-level = <8>;
+				enable-gpios = <&pio 7 10 GPIO_ACTIVE_HIGH>; /* PH10 */
+			};
+		};
+	};
+
+	fragment@4 {
+		target = <&dsi>;
+
+		__overlay__ {
+			vcc-dsi-supply = <&reg_dldo1>;
+			status = "okay";
+		
+			panel@0 {
+				compatible = "feiyang,fy07024di26a30d";
+				reg = <0>;
+				avdd-supply = <&reg_dc1sw>;
+				dvdd-supply = <&reg_dldo2>;
+				reset-gpios = <&pio 3 24 GPIO_ACTIVE_HIGH>; /* PD24 */
+				backlight = <&backlight>;
+			};
+		};
+	};
+
+	fragment@5 {
+		target = <&dphy>;
+
+		__overlay__ {
+			status = "okay";
+		};
+	};
+};
-- 
2.35.3

