From patchwork Fri Jul 28 02:50:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 127291 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp157429vqg; Thu, 27 Jul 2023 20:06:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlGh2C+b/6h/OYVyXzJ0IQ/rbXmeqzGO//1T2vyOgLupSaoD4y3FcOZWIClnWWuTJUcjD6gO X-Received: by 2002:a17:906:19:b0:991:f489:3d24 with SMTP id 25-20020a170906001900b00991f4893d24mr929721eja.32.1690513594607; Thu, 27 Jul 2023 20:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690513594; cv=none; d=google.com; s=arc-20160816; b=doWNVUxBBEe4D+X8i5w+BL4USEc4nhPwd8c7qfHmmfZOD21P9mQT/qjHr3anz46jQX opfdtXZjS+vD/Bl41c7oN8HXS2wZUxyQkFNtOQZCWSNdhzbAzKMSuzxBVPbQlmRP0Bqn AUXf6jNrc9YcXM58DP6Q7kEB6EF+96w4qYX0GTmGdRlhGWA0w7u5dlsSjikJNtKh2UFk be/fSQVxqsqritunQyAQu6MNCOpvxr100xYNKMyPtNiVUq9Pf6oiaLFmR1dRmHcTGZcy tga3FlMEjYfAp3CzFVAmJUhA/h9/RBjcKazFZ9NRFzgPyfufzmb+/DFSyIWzRp8slyLi uSgw== 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:to:from:date; bh=s5czhoY0QA5LabiZCh+g7FAzobi8i+egQsMxPk6ZR+w=; fh=6uHf4Rb4DHDahIqS26h0Nic47hqd8K43WIkuK37Vo4Y=; b=Rra8olyidbZM7Or6VtDgRSPcXqBn7tHW5cU0Sx0DxHrAMwTUo8FqaRvYVJZP8/Tkka Zi5XqIDoB1F+jo9G8YgYOX2UwNI/oLuL2bqCusOpkVbYxauyQdlQD7UxV3PymtQwDf1e 5jO0YVVrOorOlo9etawCoiyC2EgiQzb4K4nHxufqCHPo/2jubcJzeLdVTXszN+POo5ux 8QZ+ttTHv8VMjeKEqr8nh+BI/75SfcnbLVLWwTXNlHaWl4KpzwbBqyFbfT90WTsljIdY XH22oN+wgcXOcWplmW1bErNNjE8/Ok++AyYxMZwtgwIedv3DIS3BD5wqeEVPBgndfLCI cNHg== 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 ks13-20020a170906f84d00b0099233867740si1964123ejb.144.2023.07.27.20.06.11; Thu, 27 Jul 2023 20:06:34 -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 S231978AbjG1CvS (ORCPT + 99 others); Thu, 27 Jul 2023 22:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbjG1CvQ (ORCPT ); Thu, 27 Jul 2023 22:51:16 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C12CE2139; Thu, 27 Jul 2023 19:51:13 -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 1qPDZ9-00008m-1J; Fri, 28 Jul 2023 02:50:55 +0000 Date: Fri, 28 Jul 2023 03:50:47 +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 1/2] dt-bindings: mt76: support setting per-band MAC address Message-ID: <6e9cfac5758dd06429fadf6c1c70c569c86f3a95.1690512516.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772631982800199459 X-GMAIL-MSGID: 1772631982800199459 Introduce support for setting individual per-band MAC addresses using NVMEM cells by adding a 'bands' object with enumerated child nodes representing the 2.4 GHz, 5 GHz and 6 GHz bands. In case it is defined, call of_get_mac_address for the per-band child node, otherwise try with of_get_mac_address on the main device node and fall back to a random address like it used to be. While at it, add MAC address related properties also for the main node and update example to use EEPROM via nvmem-cells instead of deprecated mediatek,mtd-eeprom property. Signed-off-by: Daniel Golle --- .../bindings/net/wireless/mediatek,mt76.yaml | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml index 252207adbc54c..2474f4f7e34b0 100644 --- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml @@ -37,6 +37,12 @@ properties: description: MT7986 should contain 3 regions consys, dcm, and sku, in this order. + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + interrupts: maxItems: 1 @@ -72,13 +78,23 @@ properties: ieee80211-freq-limit: true + address: true + + local-mac-address: true + + mac-address: true + nvmem-cells: + minItems: 1 items: - description: NVMEM cell with EEPROM + - description: NVMEM cell with the MAC address nvmem-cell-names: + minItems: 1 items: - const: eeprom + - const: mac-address mediatek,eeprom-data: $ref: /schemas/types.yaml#/definitions/uint32-array @@ -213,6 +229,30 @@ properties: description: Half-dBm power delta for different numbers of antennas +patternProperties: + '^band@[0-2]+$': + type: object + additionalProperties: false + properties: + reg: + maxItems: 1 + + address: true + local-mac-address: true + mac-address: true + + nvmem-cells: + description: NVMEM cell with the MAC address + + nvmem-cell-names: + items: + - const: mac-address + + required: + - reg + + unevaluatedProperties: false + required: - compatible - reg @@ -225,10 +265,13 @@ examples: #address-cells = <3>; #size-cells = <2>; wifi@0,0 { + #address-cells = <1>; + #size-cells = <0>; compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; ieee80211-freq-limit = <5000000 6000000>; - mediatek,mtd-eeprom = <&factory 0x8000>; + nvmem-cells = <&factory_eeprom>; + nvmem-cell-names = "eeprom"; big-endian; led { @@ -257,6 +300,20 @@ examples: }; }; }; + + band@0 { + /* 2.4 GHz */ + reg = <0>; + nvmem-cells = <&macaddr 0x4>; + nvmem-cell-names = "mac-address"; + }; + + band@1 { + /* 5 GHz */ + reg = <1>; + nvmem-cells = <&macaddr 0xa>; + nvmem-cell-names = "mac-address"; + }; }; }; From patchwork Fri Jul 28 02:51:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 127288 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp157292vqg; Thu, 27 Jul 2023 20:06:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGNSfsQKoMt98ZdGkDJH4UZ90LnDsIe7Oy+dQuMCst8hpds3vcSGeLOxYJojBhh4VnSjKgp X-Received: by 2002:a17:903:186:b0:1bb:9efe:b1be with SMTP id z6-20020a170903018600b001bb9efeb1bemr740370plg.30.1690513570034; Thu, 27 Jul 2023 20:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690513570; cv=none; d=google.com; s=arc-20160816; b=v6Yh+aud6Kx/IHCGernDJ+wBpULJ8vTGBFydzs6YtmJo6qsWZZIdmkG1BEHx3wVCgm R6JoM2+6SUU1EHpDRpeaF/3XJi9tcwC0NI8XQ3LRMzPPf1ZDbEOM+wkyuMrFeESz6347 igNtERR5+HG24PGUhkvxAA9fZOizCu53xMdSIjPJwshxTWZOCHbt+BsZvN61X43NFLs+ rpuKHBgoZGBRIcYxNq1dowAk2dldlfAyUHRCZHH8Ybcn+SfS//Pjn37XDpeCNd5Ncm/w Uup9aiV9utMyKhRTZqc3m6kjtX3O2IluHGiIzWZ2MttlZ83QyIyN+PGmr8V7Di8w5lAY lz+A== 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=WyKNDq2yT8WhM0gfUiLegqLBgZeUy98688G4XC/HfirgQgmwvZ3fOf2Poa2fSg/llg mTgBt1icTTzNp22MrL0jP2i+NEqNFyef4yUJz5QRhr3MFDHF2tjNG874v+0fGDFVB5Tw SCnSQjaBZuQYODShfy3zSAWbWGQH0n9nsLv28sEtEAJofic9AaQWEWjljPc6bgZg5jUY g5PhH6DbLC/P94xYQeq1A/JScyD3UFjVWEwEmLfnXR9F+Lnd3xVJtzgE8icsdpv6jdVu iDyDXG44wvsUgo32x658D8tHmRsSLWLjsdD3WghPTdyZK45+LiuquJd+/0Xe74Rv+RPb P+Tg== 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 u8-20020a17090341c800b001b8987f4004si2274926ple.541.2023.07.27.20.05.35; Thu, 27 Jul 2023 20:06:10 -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 S232666AbjG1Cvk (ORCPT + 99 others); Thu, 27 Jul 2023 22:51:40 -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-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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772631957080021759 X-GMAIL-MSGID: 1772631957080021759 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);