From 2d63d42f5e2f13e879034c6f519cfa6b03fe4445 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Wed, 7 Feb 2024 14:48:39 +0100
Subject: [PATCH] mediatek: convert to new LED color/function format where
 possible

Initial conversion to new LED color/function format
and drop label format where possible. The same label
is composed at runtime.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 .../mediatek/dts/mt7622-totolink-a8000ru.dts      |  4 +++-
 .../dts/mt7622-xiaomi-redmi-router-ax6s.dts       |  7 +++++--
 .../linux/mediatek/dts/mt7629-iptime-a6004mx.dts  |  7 +++++--
 .../mediatek/dts/mt7629-netgear-ex6250-v2.dts     | 10 +++++++---
 .../mediatek/dts/mt7629-tplink_eap225-v5.dts      |  7 +++++--
 .../linux/mediatek/dts/mt7981b-cetron-ct3003.dts  |  7 +++++--
 .../linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts  | 10 +++++++---
 .../linux/mediatek/dts/mt7981b-cudy-wr3000-v1.dts | 11 ++++++++---
 .../mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts   |  7 +++++--
 target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts |  7 +++++--
 target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts |  7 +++++--
 .../mediatek/dts/mt7986a-asus-tuf-ax4200.dts      |  3 ++-
 .../mediatek/dts/mt7986a-asus-tuf-ax6000.dts      |  6 ++++--
 .../dts/mt7986a-tplink-tl-xdr-common.dtsi         |  7 +++++--
 .../dts/mt7986a-zyxel-ex5601-t0-common.dtsi       |  4 +++-
 .../mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts | 13 +++++++++----
 .../linux/mediatek/dts/mt7986b-netgear-wax220.dts | 15 ++++++++++-----
 17 files changed, 93 insertions(+), 39 deletions(-)

diff --git a/target/linux/mediatek/dts/mt7622-totolink-a8000ru.dts b/target/linux/mediatek/dts/mt7622-totolink-a8000ru.dts
index 776d38d1e3..5ec07128ba 100644
--- a/target/linux/mediatek/dts/mt7622-totolink-a8000ru.dts
+++ b/target/linux/mediatek/dts/mt7622-totolink-a8000ru.dts
@@ -2,6 +2,7 @@
 
 /dts-v1/;
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 #include <dt-bindings/gpio/gpio.h>
 
 #include "mt7622.dtsi"
@@ -57,7 +58,8 @@
 		compatible = "gpio-leds";
 
 		led_status: status_red {
-			label = "red:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 81 GPIO_ACTIVE_LOW>;
 			default-state = "on";
 		};
diff --git a/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts b/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts
index dcf851b274..01365a278d 100644
--- a/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts
+++ b/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts
@@ -2,6 +2,7 @@
 /dts-v1/;
 
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 #include <dt-bindings/gpio/gpio.h>
 
 #include "mt7622.dtsi"
@@ -32,12 +33,14 @@
 		compatible = "gpio-leds";
 
 		led_power_blue: power_blue {
-			label = "blue:power";
+			function = LED_FUNCTION_POWER;
+			color = <LED_COLOR_ID_BLUE>;
 			gpios = <&pio 18 GPIO_ACTIVE_LOW>;
 		};
 
 		led_power_amber: power_amber {
-			label = "amber:power";
+			function = LED_FUNCTION_POWER;
+			color = <LED_COLOR_ID_AMBER>;
 			gpios = <&pio 17 GPIO_ACTIVE_LOW>;
 		};
 
diff --git a/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts b/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts
index 5b1b3083a0..78286714ea 100644
--- a/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts
+++ b/target/linux/mediatek/dts/mt7629-iptime-a6004mx.dts
@@ -2,6 +2,7 @@
 
 /dts-v1/;
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 #include "mt7629.dtsi"
 
 / {
@@ -25,7 +26,8 @@
 		compatible = "gpio-leds";
 
 		led_cpu: cpu {
-			label = "orange:cpu";
+			function = LED_FUNCTION_CPU;
+			color = <LED_COLOR_ID_ORANGE>;
 			gpios = <&pio 57 GPIO_ACTIVE_LOW>;
 		};
 
@@ -42,7 +44,8 @@
 		};
 
 		wan {
-			label = "orange:wan";
+			function = LED_FUNCTION_WAN;
+			color = <LED_COLOR_ID_ORANGE>;
 			gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
 		};
 	};
diff --git a/target/linux/mediatek/dts/mt7629-netgear-ex6250-v2.dts b/target/linux/mediatek/dts/mt7629-netgear-ex6250-v2.dts
index 5645ad799e..99d3a7cefb 100644
--- a/target/linux/mediatek/dts/mt7629-netgear-ex6250-v2.dts
+++ b/target/linux/mediatek/dts/mt7629-netgear-ex6250-v2.dts
@@ -2,6 +2,7 @@
 
 /dts-v1/;
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 #include "mt7629.dtsi"
 
 / {
@@ -53,12 +54,14 @@
 		compatible = "gpio-leds";
 
 		led_power_green: power_green {
-			label = "green:power";
+			function = LED_FUNCTION_POWER;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 21 GPIO_ACTIVE_LOW>;
 		};
 
 		led_power_red: power_red {
-			label = "red:power";
+			function = LED_FUNCTION_POWER;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 61 GPIO_ACTIVE_LOW>;
 		};
 
@@ -83,7 +86,8 @@
 		};
 
 		wps_green {
-			label = "green:wps";
+			function = LED_FUNCTION_WPS;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 57 GPIO_ACTIVE_LOW>;
 		};
 
diff --git a/target/linux/mediatek/dts/mt7629-tplink_eap225-v5.dts b/target/linux/mediatek/dts/mt7629-tplink_eap225-v5.dts
index 5eab714fda..bab3ad5737 100644
--- a/target/linux/mediatek/dts/mt7629-tplink_eap225-v5.dts
+++ b/target/linux/mediatek/dts/mt7629-tplink_eap225-v5.dts
@@ -2,6 +2,7 @@
 
 /dts-v1/;
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 #include "mt7629.dtsi"
 
 / {
@@ -35,13 +36,15 @@
 		compatible = "gpio-leds";
 
 		led_status_green: status_green {
-			label = "green:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 55 GPIO_ACTIVE_HIGH>;
 			default-state = "on";
 		};
 
 		led_status_amber: status_amber {
-			label = "amber:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_AMBER>;
 			gpios = <&pio 56 GPIO_ACTIVE_HIGH>;
 		};
 	};
diff --git a/target/linux/mediatek/dts/mt7981b-cetron-ct3003.dts b/target/linux/mediatek/dts/mt7981b-cetron-ct3003.dts
index 281c96e275..919c208918 100644
--- a/target/linux/mediatek/dts/mt7981b-cetron-ct3003.dts
+++ b/target/linux/mediatek/dts/mt7981b-cetron-ct3003.dts
@@ -3,6 +3,7 @@
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 
 #include "mt7981.dtsi"
 
@@ -47,12 +48,14 @@
 		compatible = "gpio-leds";
 
 		led_status_red: led_status_red {
-			label = "red:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 3 GPIO_ACTIVE_LOW>;
 		};
 
 		led_status_green: led_status_green {
-			label = "green:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 7 GPIO_ACTIVE_LOW>;
 		};
 	};
diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts
index 3f330f40fa..c8db5b58f5 100644
--- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts
+++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts
@@ -6,6 +6,7 @@
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 
 #include "mt7981.dtsi"
 
@@ -50,17 +51,20 @@
 		compatible = "gpio-leds";
 
 		green_led: led-0 {
-			label = "green:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
 		};
 
 		led-1 {
-			label = "blue:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_BLUE>;
 			gpios = <&pio 12 GPIO_ACTIVE_LOW>;
 		};
 
 		red_led: led-2 {
-			label = "red:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 35 GPIO_ACTIVE_LOW>;
 		};
 	};
diff --git a/target/linux/mediatek/dts/mt7981b-cudy-wr3000-v1.dts b/target/linux/mediatek/dts/mt7981b-cudy-wr3000-v1.dts
index f4ba629525..10b56a3aa7 100644
--- a/target/linux/mediatek/dts/mt7981b-cudy-wr3000-v1.dts
+++ b/target/linux/mediatek/dts/mt7981b-cudy-wr3000-v1.dts
@@ -2,6 +2,8 @@
 
 /dts-v1/;
 
+#include <dt-bindings/leds/common.h>
+
 #include "mt7981.dtsi"
 
 / {
@@ -42,7 +44,8 @@
 		compatible = "gpio-leds";
 
 		led_status: led@0 {
-			label = "blue:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_BLUE>;
 			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
 		};
 
@@ -52,12 +55,14 @@
 		};
 
 		led@2 {
-			label = "blue:wan";
+			function = LED_FUNCTION_WAN;
+			color = <LED_COLOR_ID_BLUE>;
 			gpios = <&pio 5 GPIO_ACTIVE_LOW>;
 		};
 
 		led@3 {
-			label = "blue:lan";
+			function = LED_FUNCTION_LAN;
+			color = <LED_COLOR_ID_BLUE>;
 			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
 		};
 
diff --git a/target/linux/mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts b/target/linux/mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts
index de702d4a53..030cc25041 100644
--- a/target/linux/mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts
+++ b/target/linux/mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts
@@ -3,6 +3,7 @@
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 
 #include "mt7981.dtsi"
 
@@ -46,12 +47,14 @@
 		compatible = "gpio-leds";
 
 		led_status_green: green {
-			label = "green:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 4 GPIO_ACTIVE_LOW>;
 		};
 
 		led_status_red: red {
-			label = "red:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 5 GPIO_ACTIVE_LOW>;
 		};
 	};
diff --git a/target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts b/target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts
index bb6b474080..c8b9aeba42 100644
--- a/target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts
+++ b/target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts
@@ -3,6 +3,7 @@
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 
 #include "mt7981.dtsi"
 
@@ -41,12 +42,14 @@
 		compatible = "gpio-leds";
 
 		led_status_red: red {
-			label = "red:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 8 GPIO_ACTIVE_HIGH>;
 		};
 
 		led_status_blue: blue {
-			label = "blue:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_BLUE>;
 			gpios = <&pio 13 GPIO_ACTIVE_LOW>;
 		};
 	};
diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts b/target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts
index cd6f6b30c3..3925f80ba3 100644
--- a/target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts
+++ b/target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts
@@ -3,6 +3,7 @@
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 
 #include "mt7981.dtsi"
 
@@ -46,12 +47,14 @@
 		compatible = "gpio-leds";
 
 		led_status_red: red {
-			label = "red:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 3 GPIO_ACTIVE_LOW>;
 		};
 
 		led_status_green: green {
-			label = "green:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 7 GPIO_ACTIVE_LOW>;
 		};
 	};
diff --git a/target/linux/mediatek/dts/mt7986a-asus-tuf-ax4200.dts b/target/linux/mediatek/dts/mt7986a-asus-tuf-ax4200.dts
index 2af18958bc..e9c8edc3dc 100644
--- a/target/linux/mediatek/dts/mt7986a-asus-tuf-ax4200.dts
+++ b/target/linux/mediatek/dts/mt7986a-asus-tuf-ax4200.dts
@@ -65,7 +65,8 @@
 		};
 
 		wan-red {
-			label = "red:wan";
+			function = LED_FUNCTION_WAN;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 12 GPIO_ACTIVE_LOW>;
 		};
 	};
diff --git a/target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts b/target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts
index b05dec93b4..2d7b9c8c5c 100644
--- a/target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts
+++ b/target/linux/mediatek/dts/mt7986a-asus-tuf-ax6000.dts
@@ -48,7 +48,8 @@
 		compatible = "gpio-leds";
 
 		wlan {
-			label = "white:wlan";
+			function = LED_FUNCTION_WLAN;
+			color = <LED_COLOR_ID_WHITE>;
 			gpios = <&pio 2 GPIO_ACTIVE_HIGH>;
 			linux,default-trigger = "phy1tpt";
 		};
@@ -59,7 +60,8 @@
 		};
 
 		wan-red {
-			label = "red:wan";
+			function = LED_FUNCTION_WAN;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 12 GPIO_ACTIVE_LOW>;
 		};
 
diff --git a/target/linux/mediatek/dts/mt7986a-tplink-tl-xdr-common.dtsi b/target/linux/mediatek/dts/mt7986a-tplink-tl-xdr-common.dtsi
index da08bdc723..c851853286 100644
--- a/target/linux/mediatek/dts/mt7986a-tplink-tl-xdr-common.dtsi
+++ b/target/linux/mediatek/dts/mt7986a-tplink-tl-xdr-common.dtsi
@@ -2,6 +2,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 
 #include "mt7986a.dtsi"
 
@@ -67,12 +68,14 @@
 		compatible = "gpio-leds";
 
 		led_status_red: status_red {
-			label = "red:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
 		};
 
 		led_status_green: status_green {
-			label = "green:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 8 GPIO_ACTIVE_HIGH>;
 		};
 
diff --git a/target/linux/mediatek/dts/mt7986a-zyxel-ex5601-t0-common.dtsi b/target/linux/mediatek/dts/mt7986a-zyxel-ex5601-t0-common.dtsi
index 04e86a737d..335ee93989 100644
--- a/target/linux/mediatek/dts/mt7986a-zyxel-ex5601-t0-common.dtsi
+++ b/target/linux/mediatek/dts/mt7986a-zyxel-ex5601-t0-common.dtsi
@@ -7,6 +7,7 @@
 #include "mt7986a.dtsi"
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 
 / {
 	aliases {
@@ -140,7 +141,8 @@
 		};
 
 		led_green_lan {
-			label = "green:lan";
+			function = LED_FUNCTION_LAN;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 20 GPIO_ACTIVE_HIGH>;
 			default-state = "off";
 		};
diff --git a/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts b/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts
index f5bb73c97d..29961e528c 100644
--- a/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts
+++ b/target/linux/mediatek/dts/mt7986a-zyxel-ex5700-telenor.dts
@@ -2,6 +2,7 @@
 
 /dts-v1/;
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
 #include <dt-bindings/gpio/gpio.h>
 
 #include "mt7986a.dtsi"
@@ -88,25 +89,29 @@
 		};
 
 		white2 {
-			label = "white:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_WHITE>;
 			gpios = <&pio 16 GPIO_ACTIVE_HIGH>;
 			default-state = "off";
 		};
 
 		red2 {
-			label = "red:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 17 GPIO_ACTIVE_HIGH>;
 			default-state = "off";
 		};
 
 		led_status_green: green2 {
-			label = "green:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 31 GPIO_ACTIVE_HIGH>;
 			default-state = "off";
 		};
 
 		led_status_amber: amber2 {
-			label = "amber:status";
+			function = LED_FUNCTION_STATUS;
+			color = <LED_COLOR_ID_AMBER>;
 			gpios = <&pio 18 GPIO_ACTIVE_HIGH>;
 			default-state = "off";
 		};
diff --git a/target/linux/mediatek/dts/mt7986b-netgear-wax220.dts b/target/linux/mediatek/dts/mt7986b-netgear-wax220.dts
index 19419f593f..6e51d88470 100644
--- a/target/linux/mediatek/dts/mt7986b-netgear-wax220.dts
+++ b/target/linux/mediatek/dts/mt7986b-netgear-wax220.dts
@@ -43,7 +43,8 @@
 
 		led_power_amber: power_amber {
 			gpios = <&pio 15 GPIO_ACTIVE_LOW>;
-			label = "amber:power";
+			function = LED_FUNCTION_POWER;
+			color = <LED_COLOR_ID_AMBER>;
 		};
 
 		wlan2g_green {
@@ -53,12 +54,14 @@
 
 		led_power_blue: power_blue {
 			gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
-			label = "blue:power";
+			function = LED_FUNCTION_POWER;
+			color = <LED_COLOR_ID_BLUE>;
 		};
 
 		led_power_green: power_green {
 			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
-			label = "green:power";
+			function = LED_FUNCTION_POWER;
+			color = <LED_COLOR_ID_GREEN>;
 		};
 
 		wlan2g_blue {
@@ -68,12 +71,14 @@
 
 		lan_green {
 			gpios = <&pio 22 GPIO_ACTIVE_HIGH>;
-			label = "green:lan";
+			function = LED_FUNCTION_LAN;
+			color = <LED_COLOR_ID_GREEN>;
 		};
 
 		lan_amber {
 			gpios = <&pio 13 GPIO_ACTIVE_LOW>;
-			label = "amber:lan";
+			function = LED_FUNCTION_LAN;
+			color = <LED_COLOR_ID_AMBER>;
 		};
 
 		wlan5g_blue {
-- 
2.30.2