[PATCH 15/15] arm64: dts: mediatek: mt7981b-openwrt-one: Enable leds

Sjoerd Simons posted 15 patches 3 months, 3 weeks ago
There is a newer version of this series
[PATCH 15/15] arm64: dts: mediatek: mt7981b-openwrt-one: Enable leds
Posted by Sjoerd Simons 3 months, 3 weeks ago
The Openwrt One has 3 status leds at the front (red, white, green) as
well as 2 software controlled leds for the LAN jack (amber, green).

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
---
 .../boot/dts/mediatek/mt7981b-openwrt-one.dts      | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts b/arch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts
index 4d1653c336e71..0c0878488ae98 100644
--- a/arch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts
+++ b/arch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts
@@ -43,6 +43,50 @@ reg_5v: regulator-5v {
 		regulator-boot-on;
 		regulator-always-on;
 	};
+
+	pwm-leds {
+		compatible = "pwm-leds";
+
+		led-0 {
+			color = <LED_COLOR_ID_WHITE>;
+			default-brightness = <0>;
+			function = LED_FUNCTION_STATUS;
+			max-brightness = <255>;
+			pwms = <&pwm 0 10000>;
+		};
+
+		led-1 {
+			color = <LED_COLOR_ID_GREEN>;
+			default-brightness = <0>;
+			function = LED_FUNCTION_STATUS;
+			max-brightness = <255>;
+			pwms = <&pwm 1 10000>;
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		led-0 {
+			color = <LED_COLOR_ID_RED>;
+			function = LED_FUNCTION_STATUS;
+			gpios = <&pio 9 GPIO_ACTIVE_HIGH>;
+		};
+
+		led-1 {
+			color = <LED_COLOR_ID_AMBER>;
+			function = LED_FUNCTION_LAN;
+			gpios = <&pio 34 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "netdev";
+		};
+
+		led-2 {
+			color = <LED_COLOR_ID_GREEN>;
+			function = LED_FUNCTION_LAN;
+			gpios = <&pio 35 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "netdev";
+		};
+	};
 };
 
 &eth {
@@ -109,6 +153,13 @@ mux {
 		};
 	};
 
+	pwm_pins: pwm-pins {
+		mux {
+			function = "pwm";
+			groups = "pwm0_0", "pwm1_1";
+		};
+	};
+
 	spi2_flash_pins: spi2-pins {
 		mux {
 			function = "spi";
@@ -152,6 +203,12 @@ conf {
 	};
 };
 
+&pwm {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pwm_pins>;
+	status = "okay";
+};
+
 &spi2 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&spi2_flash_pins>;

-- 
2.51.0
Re: [PATCH 15/15] arm64: dts: mediatek: mt7981b-openwrt-one: Enable leds
Posted by Andrew Lunn 3 months, 3 weeks ago
On Thu, Oct 16, 2025 at 12:08:51PM +0200, Sjoerd Simons wrote:
> The Openwrt One has 3 status leds at the front (red, white, green) as
> well as 2 software controlled leds for the LAN jack (amber, green).

A previous patch in this series added 2 PHY LEDs. Are they connected
to a LAN jack? Are there multiple RJ45 connectors? Is it clear from
/sys/class/leds what LED is what?

	Andrew
Re: [PATCH 15/15] arm64: dts: mediatek: mt7981b-openwrt-one: Enable leds
Posted by Sjoerd Simons 3 months, 2 weeks ago
Hey,

On Fri, 2025-10-17 at 19:35 +0200, Andrew Lunn wrote:
> On Thu, Oct 16, 2025 at 12:08:51PM +0200, Sjoerd Simons wrote:
> > The Openwrt One has 3 status leds at the front (red, white, green) as
> > well as 2 software controlled leds for the LAN jack (amber, green).
> 
> A previous patch in this series added 2 PHY LEDs. Are they connected
> to a LAN jack? Are there multiple RJ45 connectors? Is it clear from
> /sys/class/leds what LED is what?

Yeah there are two RJ45 jacks. One referred to as WAN in the openwrt one
documentation (2.5G), which uses phy integrated leds. One referred to as LAN,
which for some reason is using software controlled leds rather then the phy's
led controller, which this patch adds support for.

When applying this set you'll get:
```
root@openwrt-debian:/sys/class/leds# ls -1                                     
amber:lan                                                                      
green:lan                                                                      
green:status                                                                   
mdio-bus:0f:amber:wan                                                          
mdio-bus:0f:green:wan                                                          
mt76-phy0                                                                      
mt76-phy1                                                                      
red:status                                                                     
white:status                       
```

Which is hopefully clear enough



-- 
Sjoerd Simons <sjoerd@collabora.com>
Collabora
Re: [PATCH 15/15] arm64: dts: mediatek: mt7981b-openwrt-one: Enable leds
Posted by Andrew Lunn 3 months, 2 weeks ago
On Wed, Oct 22, 2025 at 09:26:11AM +0200, Sjoerd Simons wrote:
> Hey,
> 
> On Fri, 2025-10-17 at 19:35 +0200, Andrew Lunn wrote:
> > On Thu, Oct 16, 2025 at 12:08:51PM +0200, Sjoerd Simons wrote:
> > > The Openwrt One has 3 status leds at the front (red, white, green) as
> > > well as 2 software controlled leds for the LAN jack (amber, green).
> > 
> > A previous patch in this series added 2 PHY LEDs. Are they connected
> > to a LAN jack? Are there multiple RJ45 connectors? Is it clear from
> > /sys/class/leds what LED is what?
> 
> Yeah there are two RJ45 jacks. One referred to as WAN in the openwrt one
> documentation (2.5G), which uses phy integrated leds. One referred to as LAN,
> which for some reason is using software controlled leds rather then the phy's
> led controller, which this patch adds support for.
> 
> When applying this set you'll get:
> ```
> root@openwrt-debian:/sys/class/leds# ls -1                                     
> amber:lan                                                                      
> green:lan                                                                      
> green:status                                                                   
> mdio-bus:0f:amber:wan                                                          
> mdio-bus:0f:green:wan                                                          
> mt76-phy0                                                                      
> mt76-phy1                                                                      
> red:status                                                                     
> white:status                       
> ```
> 
> Which is hopefully clear enough

You can also get to the LEDs associated to a MAC via
/sys/class/net/eth42/leds, or a subdirectory.

Please could you expand the commit message with more details of the
different RJ45 connectors, and how the different LEDs map to them.

Thanks

	Andrew
Re: [PATCH 15/15] arm64: dts: mediatek: mt7981b-openwrt-one: Enable leds
Posted by AngeloGioacchino Del Regno 3 months, 3 weeks ago
Il 16/10/25 12:08, Sjoerd Simons ha scritto:
> The Openwrt One has 3 status leds at the front (red, white, green) as
> well as 2 software controlled leds for the LAN jack (amber, green).
> 
> Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
> ---
>   .../boot/dts/mediatek/mt7981b-openwrt-one.dts      | 57 ++++++++++++++++++++++
>   1 file changed, 57 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts b/arch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts
> index 4d1653c336e71..0c0878488ae98 100644
> --- a/arch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts
> +++ b/arch/arm64/boot/dts/mediatek/mt7981b-openwrt-one.dts
> @@ -43,6 +43,50 @@ reg_5v: regulator-5v {
>   		regulator-boot-on;
>   		regulator-always-on;
>   	};
> +
> +	pwm-leds {

Please keep the nodes ordered by name.

Cheers,
Angelo

> +		compatible = "pwm-leds";
> +
> +		led-0 {
> +			color = <LED_COLOR_ID_WHITE>;
> +			default-brightness = <0>;
> +			function = LED_FUNCTION_STATUS;
> +			max-brightness = <255>;
> +			pwms = <&pwm 0 10000>;
> +		};
> +
> +		led-1 {
> +			color = <LED_COLOR_ID_GREEN>;
> +			default-brightness = <0>;
> +			function = LED_FUNCTION_STATUS;
> +			max-brightness = <255>;
> +			pwms = <&pwm 1 10000>;
> +		};
> +	};
> +
> +	gpio-leds {
> +		compatible = "gpio-leds";
> +
> +		led-0 {
> +			color = <LED_COLOR_ID_RED>;
> +			function = LED_FUNCTION_STATUS;
> +			gpios = <&pio 9 GPIO_ACTIVE_HIGH>;
> +		};
> +
> +		led-1 {
> +			color = <LED_COLOR_ID_AMBER>;
> +			function = LED_FUNCTION_LAN;
> +			gpios = <&pio 34 GPIO_ACTIVE_LOW>;
> +			linux,default-trigger = "netdev";
> +		};
> +
> +		led-2 {
> +			color = <LED_COLOR_ID_GREEN>;
> +			function = LED_FUNCTION_LAN;
> +			gpios = <&pio 35 GPIO_ACTIVE_LOW>;
> +			linux,default-trigger = "netdev";
> +		};
> +	};
>   };
>   
>   &eth {
> @@ -109,6 +153,13 @@ mux {
>   		};
>   	};
>   
> +	pwm_pins: pwm-pins {
> +		mux {
> +			function = "pwm";
> +			groups = "pwm0_0", "pwm1_1";
> +		};
> +	};
> +
>   	spi2_flash_pins: spi2-pins {
>   		mux {
>   			function = "spi";
> @@ -152,6 +203,12 @@ conf {
>   	};
>   };
>   
> +&pwm {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pwm_pins>;
> +	status = "okay";
> +};
> +
>   &spi2 {
>   	pinctrl-names = "default";
>   	pinctrl-0 = <&spi2_flash_pins>;
>