From c7140e73b84431eb1e8cb31bdfce4c9d8a908de0 Mon Sep 17 00:00:00 2001
From: Paolo Sabatino <paolo.sabatino@gmail.com>
Date: Sat, 17 Apr 2021 16:26:46 +0000
Subject: [PATCH 2/4] rk3318-box: add led configuration for YX_RK3328 boards
 and clones

---
 arch/arm64/boot/dts/rockchip/overlay/Makefile |  3 +-
 .../rockchip/overlay/README.rockchip-overlays |  4 +-
 .../overlay/rockchip-rk3318-box-led-conf1.dts | 54 +++++++++++++++++++
 3 files changed, 58 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm64/boot/dts/rockchip/overlay/rockchip-rk3318-box-led-conf1.dts

diff --git a/arch/arm64/boot/dts/rockchip/overlay/Makefile b/arch/arm64/boot/dts/rockchip/overlay/Makefile
index 9c07d64a1..8e9ff2ef1 100644
--- a/arch/arm64/boot/dts/rockchip/overlay/Makefile
+++ b/arch/arm64/boot/dts/rockchip/overlay/Makefile
@@ -10,7 +10,8 @@ dtbo-$(CONFIG_ARCH_ROCKCHIP) += \
 	rockchip-spi-spidev.dtbo \
 	rockchip-uart4.dtbo \
 	rockchip-dwc3-0-host.dtbo \
-	rockchip-w1-gpio.dtbo
+	rockchip-w1-gpio.dtbo \
+	rockchip-rk3318-box-led-conf1.dtbo

 scr-$(CONFIG_ARCH_ROCKCHIP) += \
        rockchip-fixup.scr
diff --git a/arch/arm64/boot/dts/rockchip/overlay/rockchip-rk3318-box-led-conf1.dts b/arch/arm64/boot/dts/rockchip/overlay/rockchip-rk3318-box-led-conf1.dts
new file mode 100644
index 000000000000..26bfd7c634c0
--- /dev/null
+++ b/arch/arm64/boot/dts/rockchip/overlay/rockchip-rk3318-box-led-conf1.dts
@@ -0,0 +1,49 @@
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/pinctrl/rockchip.h>
+
+/**
+ * Generic rk3318 board with base common configuration.
+ * Some boards with this configuration have signature: YX_RK3318 (circular board), RK3318_V1.x
+ */
+
+&gpio_led {
+
+	working {
+		gpios = <&gpio2 RK_PC7 GPIO_ACTIVE_HIGH>;
+		linux,default-trigger = "mmc2";
+	};
+
+	/*
+		* no auxiliary led on YX_RK3328 boards
+		*
+	auxiliary {
+		gpios = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
+		label = "auxiliary";
+		linux,default-trigger = "mmc2";
+		default-state = "off";
+		pinctrl-names = "default";
+		pinctrl-0 = <&gpio_led_aux>;
+	};
+	*/
+
+};
+
+/*
+ * TODO: needs to find the GPIO for this
+ *
+&gpio_keys {
+
+	reset {
+		gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_LOW>;
+		label = "reset";
+		linux,code = <KEY_RESTART>;
+		debounce-interval = <200>;
+		wakeup-source;
+	};
+
+};
+*/

diff --git a/arch/arm64/boot/dts/rockchip/overlay/README.rockchip-overlays b/arch/arm64/boot/dts/rockchip/overlay/README.rockchip-overlays
index d6979437a..1de0a95e8 100644
--- a/arch/arm64/boot/dts/rockchip/overlay/README.rockchip-overlays
+++ b/arch/arm64/boot/dts/rockchip/overlay/README.rockchip-overlays
@@ -119,3 +119,7 @@ Activates 1-Wire GPIO master
 Requires an external pull-up resistor on the data pin
 or enabling the internal pull-up

+### rk3318-box-led-conf1
+
+Activates led/gpio configuration for rk3318 tv box boards with signature
+YX_RK3328 and clones
--
2.25.1
