[2/3] wifi: ath11k: look for DT node for each radio
Commit Message
From: Rafał Miłecki <rafal@milecki.pl>
Updated DT binding allows describing each chip radio.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
drivers/net/wireless/ath/ath11k/core.h | 2 ++
drivers/net/wireless/ath/ath11k/mac.c | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+)
@@ -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;
@@ -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", ®);
+ 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];