Skip to contentSkip to conversation

wifi: ath9k: ahb: add OF LED support

PATCH In review Rosen Penev 2 participants 6 messages Jul 4, 2025 – Jul 8, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover wifi: ath9k: ahb: add OF LED support

A port of the prior platform code to use OF.

Rosen Penev (3):
dt-bindings: net: wireless: ath9k: add led bindings
wifi: ath9k: ahb: add led pin OF support
mips: qca: use led-sources for WMAC LED

 .../bindings/net/wireless/qca,ath9k.yaml         | 16 ++++++++++++++++
 arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts | 10 +++++-----
 arch/mips/boot/dts/qca/ar9331_dragino_ms14.dts   | 10 ++++------
 arch/mips/boot/dts/qca/ar9331_tl_mr3020.dts      | 10 ++++------
 drivers/net/wireless/ath/ath9k/init.c            | 11 +++++++++++
 5 files changed, 40 insertions(+), 17 deletions(-)
Signature · 1 line
2.50.0
#1 lore raw

PATCH 1/3 dt-bindings: net: wireless: ath9k: add led bindings

This is used to override the various defaults the ath9k driver has for LED pin values.

---
 .../bindings/net/wireless/qca,ath9k.yaml         | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml +16 -0
index d16ca8e0a25d..58c7b873cecb 100644
@@ -50,6 +50,19 @@ properties:
 
   ieee80211-freq-limit: true
 
+  led:
+    type: object
+    $ref: /schemas/leds/common.yaml#
+    additionalProperties: false
+    properties:
+      led-active-low:
+        description:
+          LED is enabled with ground signal.
+        type: boolean
+
+      led-sources:
+        maxItems: 1
+
   qca,no-eeprom:
     $ref: /schemas/types.yaml#/definitions/flag
     description:
@@ -102,5 +115,8 @@ examples:
         compatible = "qca,ar9130-wifi";
         reg = <0x180c0000 0x230000>;
         interrupts = <2>;
+        led {
+          led-sources = <0>;
+        };
       };
     };
Signature · 1 line
2.50.0
maintainer
#2 lore raw

Re: [PATCH 1/3] dt-bindings: net: wireless: ath9k: add led bindings

Quoted 13 lines · Rosen Penev

This is used to override the various defaults the ath9k driver has for LED pin values.

---
 .../bindings/net/wireless/qca,ath9k.yaml         | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml +0 -0
index d16ca8e0a25d..58c7b873cecb 100644

Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml properties: · line 56

Quoted 7 lines
Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml +4 -0
@@ -50,6 +50,19 @@ properties:
 
   ieee80211-freq-limit: true
 
+  led:
+    type: object
+    $ref: /schemas/leds/common.yaml#
+    additionalProperties: false

You really don't want any other common properties? Like defining the function?

Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml properties: · line 64

Quoted 8 lines
Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml +8 -0
+    properties:
+      led-active-low:
+        description:
+          LED is enabled with ground signal.
+        type: boolean
+
+      led-sources:
+        maxItems: 1

This property is really for cases where the LED source is configurable from the LED instance. If that's not the case here just use 'reg' for each instance (assuming there's more than 1). I shouldn't be wondering what the h/w looks like though. Please describe it in the commit msg rather than what some driver does.

If you do need led-sources, you should define some constraints on the values, not just the length.

Rob

#3 lore raw

Re: [PATCH 1/3] dt-bindings: net: wireless: ath9k: add led bindings

Quoted 18 lines · Rob Herring
Quoted 16 lines · Rosen Penev

This is used to override the various defaults the ath9k driver has for LED pin values.

---
 .../bindings/net/wireless/qca,ath9k.yaml         | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml +0 -0
index d16ca8e0a25d..58c7b873cecb 100644
@@ -50,6 +50,19 @@ properties:
 
   ieee80211-freq-limit: true
 
Quoted 7 lines

Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml properties: · line 56

Quoted 4 lines
Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml +4 -0
+  led:
+    type: object
+    $ref: /schemas/leds/common.yaml#
+    additionalProperties: false

You really don't want any other common properties? Like defining the function?

All of this was copy/paste from mediatek,mt76.yaml , where the same binding is used for mostly the same purpose.

Quoted 10 lines

Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml properties: · line 64

Quoted 9 lines
Documentation/devicetree/bindings/net/wireless/qca,ath9k.yaml +8 -0
+    properties:
+      led-active-low:
+        description:
+          LED is enabled with ground signal.
+        type: boolean
+
+      led-sources:
+        maxItems: 1
Quoted 8 lines

This property is really for cases where the LED source is configurable from the LED instance. If that's not the case here just use 'reg' for each instance (assuming there's more than 1). I shouldn't be wondering what the h/w looks like though. Please describe it in the commit msg rather than what some driver does.

If you do need led-sources, you should define some constraints on the values, not just the length.

The original downstream version used a u8 for the number. But again, I'm just copy/pasting.

Quoted 3 lines

Rob

#4 lore raw

PATCH 2/3 wifi: ath9k: ahb: add led pin OF support

In reply to Rosen Penev

The old and removed platform code had support for assigning a value for the LED pin for when the default is not correct. Effectively a fix for a non working LED.

It seems that it's preferred to use led-sources as the binding for this instead of a vendor prefixed variant.

For setting an LED to active high, a negation of led-active-low is used, as two drivers currently use that and no drivers use led-active-high or something similar.

---
 drivers/net/wireless/ath/ath9k/init.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/wireless/ath/ath9k/init.c +11 -0
index 629f66a25307..4f967bc34460 100644
@@ -650,6 +650,17 @@ static int ath9k_of_init(struct ath_softc *sc)
 	if (ret == -EPROBE_DEFER)
 		return ret;
 
+	np = of_get_child_by_name(np, "led");
+	if (np && of_device_is_available(np)) {
+		u32 led_pin;
+
+		if (!of_property_read_u32(np, "led-sources", &led_pin))
+			ah->led_pin = led_pin;
+
+		ah->config.led_active_high = !of_property_read_bool(np, "led-active-low");
+		of_node_put(np);
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.50.0
#5 lore raw

PATCH 3/3 mips: qca: use led-sources for WMAC LED

In reply to Rosen Penev

The ath9k driver creates an LED unconditionally being driven with sometimes the wrong pin. Not only that, the current dts definitions have LEDs for the WMAC that do not behave in response to it. Fix both issues.

---
 arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts | 10 +++++-----
 arch/mips/boot/dts/qca/ar9331_dragino_ms14.dts   | 10 ++++------
 arch/mips/boot/dts/qca/ar9331_tl_mr3020.dts      | 10 ++++------
 3 files changed, 13 insertions(+), 17 deletions(-)
arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts +5 -5
index a7901bb040ce..ef4a08e1e35a 100644
@@ -56,11 +56,6 @@ led-2 {
 			label = "tp-link:green:qss";
 			gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
 		};
-
-		led-3 {
-			label = "tp-link:green:wlan";
-			gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
-		};
 	};
 };
 
@@ -111,4 +106,9 @@ partition@2 {
 
 &wifi {
 	status = "okay";
+
+	led {
+		led-sources = <9>;
+		led-active-low;
+	};
 };
arch/mips/boot/dts/qca/ar9331_dragino_ms14.dts +4 -6
index 37a74aabe4b4..ce04e767cd2b 100644
@@ -22,12 +22,6 @@ memory@0 {
 	leds {
 		compatible = "gpio-leds";
 
-		led-wlan {
-			label = "dragino2:red:wlan";
-			gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
-			default-state = "off";
-		};
-
 		led-lan {
 			label = "dragino2:red:lan";
 			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
@@ -101,4 +95,8 @@ spiflash: w25q128@0 {
 
 &wifi {
 	status = "okay";
+
+	led {
+		led-sources = <0>;
+	};
 };
arch/mips/boot/dts/qca/ar9331_tl_mr3020.dts +4 -6
index a7108c803eb3..e69a67284f6f 100644
@@ -22,12 +22,6 @@ memory@0 {
 	leds {
 		compatible = "gpio-leds";
 
-		led-wlan {
-			label = "tp-link:green:wlan";
-			gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
-			default-state = "off";
-		};
-
 		led-lan {
 			label = "tp-link:green:lan";
 			gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
@@ -117,4 +111,8 @@ spiflash: s25sl032p@0 {
 
 &wifi {
 	status = "okay";
+
+	led {
+		led-sources = <0>;
+	};
 };
Signature · 1 line
2.50.0