Skip to contentSkip to conversation

dt-bindings: net: wireless: qcom,ath11k: allow describing radios

PATCH In review Rafał Miłecki 2 participants 4 messages Apr 18, 2023 – Apr 19, 2023

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

PATCH v2 1/3 dt-bindings: net: wireless: qcom,ath11k: allow describing radios

From: Rafał Miłecki <[email protected]>

Qualcomm ath11k chipsets can have up to 3 radios. Each radio may need to be additionally described by including its MAC or available frequency ranges.

---
V2: Fix dt_binding_check (add address + size cells & reg)

---
 .../bindings/net/wireless/qcom,ath11k.yaml    | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)
Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml +36 -0
index 7d5f982a3d09..6a03638d20f1 100644
@@ -78,6 +78,34 @@ properties:
     items:
       - const: wlan-smp2p-out
 
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+patternProperties:
+  "^radio@[0-2]$":
+    type: object
+
+    allOf:
+      - $ref: ieee80211.yaml#
+
+    properties:
+      reg:
+        maxItems: 1
+        description: Radio index
+
+      nvmem-cells:
+        items:
+          - description: NVMEM cell with the MAC address
+
+      nvmem-cell-names:
+        items:
+          - const: mac-address
+
+    unevaluatedProperties: false
+
 required:
   - compatible
   - reg
@@ -378,6 +406,14 @@ examples:
                           "wbm2host-tx-completions-ring1",
                           "tcl2host-status-ring";
         qcom,rproc = <&q6v5_wcss>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        radio@0 {
+            reg = <0x0>;
+            nvmem-cells = <&mac>;
+            nvmem-cell-names = "mac-address";
+        };
     };
 
   - |
Signature · 7 lines
2.34.1


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#1 lore raw

PATCH v2 2/3 wifi: ath11k: look for DT node for each radio

From: Rafał Miłecki <[email protected]>

Updated DT binding allows describing each chip radio.

---
 drivers/net/wireless/ath/ath11k/core.h |  2 ++
 drivers/net/wireless/ath/ath11k/mac.c  | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)
drivers/net/wireless/ath/ath11k/core.h +2 -0
index 0830276e5028..1a583adf2ab1 100644
@@ -13,6 +13,7 @@
 #include <linux/bitfield.h>
 #include <linux/dmi.h>
 #include <linux/ctype.h>
+#include <linux/of.h>
 #include <linux/rhashtable.h>
 #include <linux/average.h>
 #include "qmi.h"
@@ -592,6 +593,7 @@ struct ath11k_per_peer_tx_stats {
 struct ath11k {
 	struct ath11k_base *ab;
 	struct ath11k_pdev *pdev;
+	struct device_node *np;
 	struct ieee80211_hw *hw;
 	struct ieee80211_ops *ops;
 	struct ath11k_pdev_wmi *wmi;
drivers/net/wireless/ath/ath11k/mac.c +20 -0
index cad832e0e6b8..ad5a22d12bd3 100644
@@ -9344,6 +9344,25 @@ int ath11k_mac_register(struct ath11k_base *ab)
 	return ret;
 }
 
+static struct device_node *ath11k_mac_find_radio_node(struct ath11k_base *ab, int i)
+{
+	struct device_node *np;
+
+	for_each_child_of_node(ab->dev->of_node, np) {
+		u32 reg;
+		int err;
+
+		if (strcmp(np->name, "radio"))
+			continue;
+
+		err = of_property_read_u32(np, "reg", &reg);
+		if (!err && reg == i)
+			return np;
+	}
+
+	return NULL;
+}
+
 int ath11k_mac_allocate(struct ath11k_base *ab)
 {
 	struct ieee80211_hw *hw;
@@ -9369,6 +9388,7 @@ int ath11k_mac_allocate(struct ath11k_base *ab)
 		ar->ab = ab;
 		ar->pdev = pdev;
 		ar->pdev_idx = i;
+		ar->np = ath11k_mac_find_radio_node(ab, i);
 		ar->lmac_id = ath11k_hw_get_mac_from_pdev_id(&ab->hw_params, i);
 
 		ar->wmi = &ab->wmi_ab.wmi[i];
Signature · 7 lines
2.34.1


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#2 lore raw

PATCH v2 3/3 wifi: ath11k: support reading radio MAC from DT

In reply to Rafał Miłecki

From: Rafał Miłecki <[email protected]>

On some devices (most routers) MAC is stored in an NVMEM cell. Support reading it.

---
 drivers/net/wireless/ath/ath11k/mac.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +10 -5
index ad5a22d12bd3..6550bb5b2ece 100644
@@ -8,6 +8,7 @@
 #include <linux/etherdevice.h>
 #include <linux/bitfield.h>
 #include <linux/inetdevice.h>
+#include <linux/of_net.h>
 #include <net/if_inet6.h>
 #include <net/ipv6.h>
 
@@ -9292,7 +9293,7 @@ int ath11k_mac_register(struct ath11k_base *ab)
 	struct ath11k_pdev *pdev;
 	int i;
 	int ret;
-	u8 mac_addr[ETH_ALEN] = {0};
+	u8 device_mac_addr[ETH_ALEN] = {0};
 
 	if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
 		return 0;
@@ -9305,18 +9306,22 @@ int ath11k_mac_register(struct ath11k_base *ab)
 	if (ret)
 		return ret;
 
-	device_get_mac_address(ab->dev, mac_addr);
+	device_get_mac_address(ab->dev, device_mac_addr);
 
 	for (i = 0; i < ab->num_radios; i++) {
+		u8 radio_mac_addr[ETH_ALEN];
+
 		pdev = &ab->pdevs[i];
 		ar = pdev->ar;
-		if (ab->pdevs_macaddr_valid) {
+		if (!of_get_mac_address(ar->np, radio_mac_addr)) {
+			ether_addr_copy(ar->mac_addr, radio_mac_addr);
+		} else if (ab->pdevs_macaddr_valid) {
 			ether_addr_copy(ar->mac_addr, pdev->mac_addr);
 		} else {
-			if (is_zero_ether_addr(mac_addr))
+			if (is_zero_ether_addr(device_mac_addr))
 				ether_addr_copy(ar->mac_addr, ab->mac_addr);
 			else
-				ether_addr_copy(ar->mac_addr, mac_addr);
+				ether_addr_copy(ar->mac_addr, device_mac_addr);
 			ar->mac_addr[4] += i;
 		}
 
Signature · 7 lines
2.34.1


-- 
ath11k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath11k
#3 lore raw
In reply to Rafał Miłecki
Quoted 5 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Qualcomm ath11k chipsets can have up to 3 radios. Each radio may need to be additionally described by including its MAC or available frequency ranges.

The binding looks fine, but I wonder what is the radio here? It feels like one antenna, e.g. 2.4 or 5 GHz, but you added $ref to ieee80211.yaml which is used for entire device. What is the "radio" here?

Quoted 5 lines

---
V2: Fix dt_binding_check (add address + size cells & reg)
---

Best regards,
Krzysztof