From 17c23b36efb63cd249c5cfc8ce4a6b790f1dfeda Mon Sep 17 00:00:00 2001
From: afaulkner420 <afaulkner420@gmail.com>
Date: Fri, 25 Mar 2022 19:23:56 +0000
Subject: Move sun50i-h6-pwm settings to its own overlay

---
 .../allwinner/overlay/sun50i-h6-fixup.scr-cmd | 14 -----------
 .../dts/allwinner/overlay/sun50i-h6-pwm.dtso  | 25 +++++++++++++++++++
 2 files changed, 25 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-pwm.dtso

diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-fixup.scr-cmd b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-fixup.scr-cmd
index d8e79ba4531b..f757db7aa4ad 100644
--- a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-fixup.scr-cmd
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-fixup.scr-cmd
@@ -54,20 +54,6 @@ if test "${param_pps_falling_edge}" = "1"; then
 	fdt set /pps@0 assert-falling-edge
 fi
 
-for f in ${overlays}; do
-	if test "${f}" = "pwm"; then
-		setenv bootargs_new ""
-		for arg in ${bootargs}; do
-			if test "${arg}" = "console=ttyS0,115200"; then
-				echo "Warning: Disabling ttyS0 console due to enabled PWM overlay"
-			else
-				setenv bootargs_new "${bootargs_new} ${arg}"
-			fi
-		done
-		setenv bootargs "${bootargs_new}"
-	fi
-done
-
 if test -n "${param_w1_pin}"; then
 	setenv tmp_bank "${param_w1_pin}"
 	setenv tmp_pin "${param_w1_pin}"
diff --git a/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-pwm.dtso b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-pwm.dtso
new file mode 100644
index 000000000000..a8aa74ed1988
--- /dev/null
+++ b/arch/arm64/boot/dts/allwinner/overlay/sun50i-h6-pwm.dtso
@@ -0,0 +1,25 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	compatible = "allwinner,sun50i-h6-pwm";
+
+	fragment@0 {
+		target = <&pio>;
+		__overlay__ {
+			pwm_pin: pwm-pin {
+				pins = "PD22";
+				function = "pwm";
+			};
+		};
+	};
+
+	fragment@1 {
+		target = <&pwm>;
+		__overlay__ {
+			pinctrl-names = "default";
+			pinctrl-0 = <&pwm_pin>;
+			status = "okay";
+		};
+	};
+};
-- 
2.35.3

