2023-04-14 21:26:19

by Rafał Miłecki

[permalink] [raw]
Subject: [PATCH 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.

Signed-off-by: Rafał Miłecki <[email protected]>
---
.../bindings/net/wireless/qcom,ath11k.yaml | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml b/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml
index 7d5f982a3d09..ed660d563e09 100644
--- a/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml
+++ b/Documentation/devicetree/bindings/net/wireless/qcom,ath11k.yaml
@@ -78,6 +78,24 @@ properties:
items:
- const: wlan-smp2p-out

+patternProperties:
+ "^radio@[0-2]$":
+ type: object
+
+ allOf:
+ - $ref: ieee80211.yaml#
+
+ properties:
+ nvmem-cells:
+ items:
+ - description: NVMEM cell with the MAC address
+
+ nvmem-cell-names:
+ items:
+ - const: mac-address
+
+ unevaluatedProperties: false
+
required:
- compatible
- reg
@@ -378,6 +396,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";
+ };
};

- |
--
2.34.1


2023-04-14 21:26:29

by Rafał Miłecki

[permalink] [raw]
Subject: [PATCH 3/3] wifi: ath11k: support reading radio MAC from DT

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

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

Signed-off-by: Rafał Miłecki <[email protected]>
---
drivers/net/wireless/ath/ath11k/mac.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index ad5a22d12bd3..6550bb5b2ece 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -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;
}

--
2.34.1