From 515404a81b49cc086e1d18d1910a09ba3f1b0272 Mon Sep 17 00:00:00 2001
From: Pascal Ernster <git@hardfalcon.net>
Date: Sat, 18 Jun 2022 13:28:30 +0200
Subject: realtek: add support for power LED on Netgear GS108Tv3

The Netgear GS108Tv3 is already supported by OpenWrt, but is missing LED
support. After OpenWrt installation, all LEDs are off which makes the
installation quite confusing.
This enables support for the green/amber power LED to give feedback
about the current status.

This is basically just a verbatim copy of commit c4927747d25a ("realtek:
add support for power LED on Netgear GS308Tv1").

Please note that both LEDs are wired up in an anti-parallel fashion,
which means that only one of both LEDs/colors can be switched on at the
same time. If both LEDs/colors are switched on simultanously, the LED
goes dark.

Tested-by: Pascal Ernster <git@hardfalcon.net>
Signed-off-by: Pascal Ernster <git@hardfalcon.net>
[add title to commit reference]
Signed-off-by: Sander Vanheule <sander@svanheule.net>
(cherry picked from commit adbdfc9366fed2d28dbd36883ddbdb566a313f71)
---
 .../realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)

(limited to 'target/linux/realtek')

diff --git a/target/linux/realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts b/target/linux/realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts
index b701e88d1a..e149834d44 100644
--- a/target/linux/realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts
+++ b/target/linux/realtek/dts-5.10/rtl8380_netgear_gs108t-v3.dts
@@ -2,7 +2,34 @@
 
 #include "rtl8380_netgear_gigabit_1xx.dtsi"
 
+#include <dt-bindings/leds/common.h>
+
 / {
 	compatible = "netgear,gs108t-v3", "realtek,rtl838x-soc";
 	model = "Netgear GS108T v3";
+
+	aliases {
+		led-boot = &led_power_green;
+		led-failsafe = &led_power_amber;
+		led-running = &led_power_green;
+		led-upgrade = &led_power_amber;
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led_power_amber: led-0 {
+			label = "amber:power";
+			color = <LED_COLOR_ID_AMBER>;
+			function = LED_FUNCTION_POWER;
+			gpios = <&gpio1 32 GPIO_ACTIVE_LOW>;
+		};
+
+		led_power_green: led-1 {
+			label = "green:power";
+			color = <LED_COLOR_ID_GREEN>;
+			function = LED_FUNCTION_POWER;
+			gpios = <&gpio1 31 GPIO_ACTIVE_LOW>;
+		};
+	};
 };
-- 
cgit v1.2.3