* [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes
@ 2023-07-13 2:50 Daniel Golle
2023-07-26 13:53 ` Shiji Yang
2023-07-26 16:04 ` Jonas Gorski
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Golle @ 2023-07-13 2:50 UTC (permalink / raw)
To: linux-wireless, linux-mediatek, linux-arm-kernel, linux-kernel,
Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Kalle Valo, Matthias Brugger,
AngeloGioacchino Del Regno
Cc: Christian Marangi, John Crispin
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@makrotopia.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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes
2023-07-13 2:50 [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes Daniel Golle
@ 2023-07-26 13:53 ` Shiji Yang
2023-07-26 16:04 ` Jonas Gorski
1 sibling, 0 replies; 3+ messages in thread
From: Shiji Yang @ 2023-07-26 13:53 UTC (permalink / raw)
To: daniel
Cc: angelogioacchino.delregno, ansuelsmth, john, kvalo,
linux-arm-kernel, linux-kernel, linux-mediatek, linux-wireless,
lorenzo, matthias.bgg, nbd, ryder.lee, sean.wang, shayne.chen,
Shiji Yang
Thanks.
Works well on MT7615D and MT7915D.
Tested-by: Shiji Yang <yangshiji66@outlook.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes
2023-07-13 2:50 [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes Daniel Golle
2023-07-26 13:53 ` Shiji Yang
@ 2023-07-26 16:04 ` Jonas Gorski
1 sibling, 0 replies; 3+ messages in thread
From: Jonas Gorski @ 2023-07-26 16:04 UTC (permalink / raw)
To: Daniel Golle
Cc: linux-wireless, linux-mediatek, linux-arm-kernel, linux-kernel,
Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Kalle Valo, Matthias Brugger,
AngeloGioacchino Del Regno, Christian Marangi, John Crispin
Hi,
On Thu, 13 Jul 2023 at 04:53, Daniel Golle <daniel@makrotopia.org> wrote:
>
> 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@makrotopia.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;
When breaking out of the loop here you still hold an additional
reference to child_np, so you need to call of_node_put() for it,
probably after calling of_get_mac_address().
> + }
> + }
>
> of_get_mac_address(np, phy->macaddr);
>
probably just add a of_node_put(child_np); here, of_node_put() seems
to be NULL safe.
Regards,
Jonas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-26 16:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-13 2:50 [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes Daniel Golle
2023-07-26 13:53 ` Shiji Yang
2023-07-26 16:04 ` Jonas Gorski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®