[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZK9mXE00xEHZV4fi@makrotopia.org>
Date: Thu, 13 Jul 2023 03:50:04 +0100
From: Daniel Golle <daniel@...rotopia.org>
To: linux-wireless@...r.kernel.org, linux-mediatek@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Felix Fietkau <nbd@....name>,
Lorenzo Bianconi <lorenzo@...nel.org>,
Ryder Lee <ryder.lee@...iatek.com>,
Shayne Chen <shayne.chen@...iatek.com>,
Sean Wang <sean.wang@...iatek.com>,
Kalle Valo <kvalo@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>
Cc: Christian Marangi <ansuelsmth@...il.com>,
John Crispin <john@...ozen.org>
Subject: [PATCH] wifi: mt76: support per-band MAC addresses from OF child
nodes
With dual-band-dual-congruent front-ends which appear as two independent
radios it is desirable to assign a per-band MAC address from device-tree,
eg. using nvmem-cells.
Support specifying MAC-address related properties in band-specific child
nodes, e.g.
mt7915@0,0 {
reg = <0x0000 0 0 0 0>;
#addr-cells = <1>;
#size-cells = <0>;
band@0 {
/* 2.4 GHz */
reg = <0>;
nvmem-cells = <&macaddr 2>;
nvmem-cell-names = "mac-address";
};
band@1 {
/* 5 GHz */
reg = <1>;
nvmem-cells = <&macaddr 3>;
nvmem-cell-names = "mac-address";
};
};
Signed-off-by: Daniel Golle <daniel@...rotopia.org>
---
drivers/net/wireless/mediatek/mt76/eeprom.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
index dce851d42e083..90ee138843a55 100644
--- a/drivers/net/wireless/mediatek/mt76/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
@@ -106,7 +106,20 @@ void
mt76_eeprom_override(struct mt76_phy *phy)
{
struct mt76_dev *dev = phy->dev;
- struct device_node *np = dev->dev->of_node;
+ struct device_node *child_np, *np = dev->dev->of_node;
+ u32 reg;
+ int ret;
+
+ for_each_child_of_node(np, child_np) {
+ ret = of_property_read_u32(child_np, "reg", ®);
+ if (ret)
+ continue;
+
+ if (reg == phy->band_idx) {
+ np = child_np;
+ break;
+ }
+ }
of_get_mac_address(np, phy->macaddr);
--
2.41.0
Powered by blists - more mailing lists