From patchwork Thu Jul 13 02:50:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 119489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1555312vqm; Wed, 12 Jul 2023 20:02:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlG+CRZc0Q/L0csspDYYPLwYKNZo/lKYoVjut0dq2ZfOinHhz4hTic2afBdBqxZ7cREQU5iy X-Received: by 2002:a05:6870:6194:b0:1b0:19ee:88f2 with SMTP id a20-20020a056870619400b001b019ee88f2mr603295oah.36.1689217358293; Wed, 12 Jul 2023 20:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689217358; cv=none; d=google.com; s=arc-20160816; b=sAJusivwqRYvdBfoxhnAOm7nc4vtCN6ybMyk/8ZdyraPvGr6+brVSpqILdCQ13TAnh fYDiikqmPIBF2q9gMzvDuQTQb2Rr+HQxrW1ISRNEFHMhbRMUsbbX6bwRHxuSB1Uo+1Jz X9mdq+JIoRQsN9By0q+5FwiUTD8ttbDlJe3mHtfReuJ9TE1fJgv5KtEPCFo0hpfwpx52 S7HuzVuhiMGVTddzmmKn43K0qkGKBgUu6hnXdMA39eYN9Z2Zpd86VmhmnmioZPP2ZC6U M1NRG2uwWLh6u/TqlAOGWO8JwW5jbzAWhseqowrHZMTMnPx2LjmvXK5RaCdcuiFCXUBe aEng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=d197LBnjbRXHb/QGpoPJCxQrRojLUgnZLht9gin6T6s=; fh=soAzU8juyNUtfUApW29Ct8X0yqO2msqUa2KgtyQofuQ=; b=cIWj71UxRcJUGDB4yQ9VKg7dxcKZByhOgpSU050tUnaPeDvouV+wboc6avXGECeZ08 5iPe9/Zi/ZpvvRJPDzFjWv7PkokvASd5P8dvgqJ0EWu+2Byn2C3UgL/rR/ixc/6jOYtq 3V0CFCyIXb9jpADmjb0wjpf8Ovv/NNVDQkbIXumqXNo+ea16QVrSxmf06QRghBPlo9+I 7Pb4yYlbAP9X4ipNtnypo8cD5YLzvubN22VGiT/B8IMR88Qtzm15+Ku9saCl0tJwsztG p34hjUVTeOqcJpTUcTJrmAxwF8Jg8SqHXcR7hIRJO7ax61dhOBJIr6vk72Fm2gM333Y4 i4aA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cx21-20020a17090afd9500b0025e9a3124c7si11697687pjb.143.2023.07.12.20.02.24; Wed, 12 Jul 2023 20:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233465AbjGMCuV (ORCPT + 99 others); Wed, 12 Jul 2023 22:50:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232177AbjGMCuU (ORCPT ); Wed, 12 Jul 2023 22:50:20 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B518310EC; Wed, 12 Jul 2023 19:50:19 -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 1qJmPJ-0005jB-0P; Thu, 13 Jul 2023 02:50:17 +0000 Date: Thu, 13 Jul 2023 03:50:04 +0100 From: Daniel Golle To: linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno Cc: Christian Marangi , John Crispin Subject: [PATCH] wifi: mt76: support per-band MAC addresses from OF child nodes Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771272780418825801 X-GMAIL-MSGID: 1771272780418825801 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 Tested-by: Shiji Yang --- 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);