Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp679854rwb; Thu, 27 Jul 2023 20:33:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlFiG6melGz+C7H0qRshaM2FOEk5TSCovb/w8seBMJSdiSteB+qy32usVca36wSOcWrKYWTK X-Received: by 2002:aa7:c708:0:b0:522:2add:5841 with SMTP id i8-20020aa7c708000000b005222add5841mr1349839edq.7.1690515190346; Thu, 27 Jul 2023 20:33:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690515190; cv=none; d=google.com; s=arc-20160816; b=CQ21doGZcz+pdMCYETfrqBwL8X8JcHE8jdMfSoRsEvCNh9u6piAmiZMUu/VCcW7ihj j/fx1meWfo0tqAFqww03JCi8Xd4FQcwC1nl8qJdQP7B1zp76+MAkAPV/IIXCaQLx6mnR DU3YscYLa4KG9J+buVlVG3UG+U9v16fj+cXNT3Ef5WBFd3egs66nw17M2531qEpCTz46 bSMZUq3KP94ffN+f/6njz6YD2OJC+cBc2oCn3C2nlMuvJhZn5XEBwUy52V4tsEAGSWai YQZ1+kuVq9BWeXe6h0H9iSe80Ptwc47/J9otPOrjcAq+Yuv20oxpSCgTsaOM8TGYWhvj +1FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=NVcNsBAKcguHf60VNyFKcf1SSOWeVwHfHYiRahrpzP4=; fh=6uHf4Rb4DHDahIqS26h0Nic47hqd8K43WIkuK37Vo4Y=; b=EdrSutHRw01npMVxam4hzhu7flu/darzw8CkM3rsqJIPf3FnVNQlNuIpgWrW2Q0Jky slhuOit0tuQ2zPoXZLX0yg0FCUb7PtBPUPjM0RQXQ8j/D7CUTw3z39aQkKRSKGjq4mch c5WOIruXL3iT3+KmkE/xorRqwIRXsgto0CBmYtXFlwLGfu71IJhwr9IqLBOgGrr6Da7e x5naBI7itapir74eApPXR0x23ap0XuKIVOK7CmWfxTHNHI7BCou2DWoKKYZKmWrGbMNa Cje/mqx3GYnaIlCr8I4rtmrEcYP+Nqs1Vx8AIAefi/AseOR7NlbvS0A4BSYfxaNGDRUc nadA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a17-20020aa7d911000000b005221f6cd2cfsi941200edr.294.2023.07.27.20.32.51; Thu, 27 Jul 2023 20:33:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232198AbjG1Cvj (ORCPT + 59 others); Thu, 27 Jul 2023 22:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbjG1Cvi (ORCPT ); Thu, 27 Jul 2023 22:51:38 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4D4B2686; Thu, 27 Jul 2023 19:51:32 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1qPDZc-000096-2m; Fri, 28 Jul 2023 02:51:24 +0000 Date: Fri, 28 Jul 2023 03:51:16 +0100 From: Daniel Golle To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 2/2] wifi: mt76: support per-band MAC addresses from OF child nodes Message-ID: <4958730e4f88b91442fa96365785d467fad502de.1690512516.git.daniel@makrotopia.org> References: <6e9cfac5758dd06429fadf6c1c70c569c86f3a95.1690512516.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6e9cfac5758dd06429fadf6c1c70c569c86f3a95.1690512516.git.daniel@makrotopia.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- drivers/net/wireless/mediatek/mt76/eeprom.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 36564930aef12..c2b3386cada1c 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -161,9 +161,25 @@ 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 *np = dev->dev->of_node, *band_np; + bool found_mac = false; + u32 reg; + int ret; + + for_each_child_of_node(np, band_np) { + ret = of_property_read_u32(band_np, "reg", ®); + if (ret) + continue; + + if (reg == phy->band_idx) { + found_mac = !of_get_mac_address(band_np, phy->macaddr); + of_node_put(band_np); + break; + } + } - of_get_mac_address(np, phy->macaddr); + if (!found_mac) + of_get_mac_address(np, phy->macaddr); if (!is_valid_ether_addr(phy->macaddr)) { eth_random_addr(phy->macaddr); -- 2.41.0