From patchwork Mon Jul 31 22:23: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: 128901 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2323154vqg; Mon, 31 Jul 2023 16:21:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlGyQgolJ30hbKahmsXa9+49s0AWvthRYIOd5iVs6x6D8XwoIBwEKniuqbewGGYtLLTm+aO4 X-Received: by 2002:a05:6a00:1ac9:b0:668:6445:8931 with SMTP id f9-20020a056a001ac900b0066864458931mr14252511pfv.29.1690845662175; Mon, 31 Jul 2023 16:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690845662; cv=none; d=google.com; s=arc-20160816; b=czNVp+0Leknhzor+ZLmzeRQ8bzpmhBq9LH0xxx4D0FbTu9kdGuLd6g4ICuQE9ko4MN l/8eu7u3buMf+IglrXa7EAJpQ3srRUUauJoKC7/q+PdbPhS2xoW1oe254jU5Iz1yVL/7 hPg8kWSJbJK61gvTnxrxwV6HQwqS/pd/iEXNyWIv/HFrQ5++mwy1vGCPu1pRnPeG/fyV YoufJ+LzhxPgb75f3ZY03nSa6Q0PLJokIij6OR2ZRzxGE4Vr7dVs2pfUG0Fhhu1YDBk2 GnXG5R9LIxZA5ELOtQGm3a9KY/Z7LYKWG/tI6NdnVCxHNs+4tjymRutxSBbBI2LnfErM K43g== 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=uZCgaHt6y0G9LY7vDaFQJNWdSmXIsLwJ73MJZVfrRMs=; fh=6uHf4Rb4DHDahIqS26h0Nic47hqd8K43WIkuK37Vo4Y=; b=YYLPxptLZPwCyi48ioe1QFPXO/yh0ldGJMPDZU2imTsoNGjf3k9qmwa73XeXRiXJrK ja0BBozWl+3KjjEtsEeMI716QN3HjS89jdjuJe0+YrVZbiYWjNJuLbkJqE3hK4IShOeq BoaLMcv+66i+0ZVw47R7UEStK5LhPnQhJZPCc6QkgnfDrfKTEUg1KE6eSlR6h/kdtbwS aZndX2P8ilk7QNBsfoEoPznRvPCcw+SYGv98jsvjRb01JEbP3ZE/tYTNuYAK3uus9kmM 33OYkEvgsSk3Xopz5M78gpNBhCVnYy9V0ZRjooBczY7SNV8azKrPeLEYx3Xg7grwodnT LsEQ== 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 dw27-20020a056a00369b00b00686f9327e71si7378541pfb.359.2023.07.31.16.20.49; Mon, 31 Jul 2023 16:21:02 -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 S231244AbjGaWXz (ORCPT + 99 others); Mon, 31 Jul 2023 18:23:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjGaWXy (ORCPT ); Mon, 31 Jul 2023 18:23:54 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4549812B; Mon, 31 Jul 2023 15:23:53 -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 1qQbIe-0002Rs-10; Mon, 31 Jul 2023 22:23:37 +0000 Date: Mon, 31 Jul 2023 23:23: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 net-next v3 1/2] dt-bindings: mt76: support setting per-band MAC address 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: 1772980180769359927 X-GMAIL-MSGID: 1772980180769359927 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. Signed-off-by: Daniel Golle --- Changes since v2: * drop items list with only a single item Changes since v1: * add dt-bindings .../bindings/net/wireless/mediatek,mt76.yaml | 58 ++++++++++++++++++- 1 file changed, 57 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..7eafed53da1de 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,29 @@ 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: + const: mac-address + + required: + - reg + + unevaluatedProperties: false + required: - compatible - reg @@ -225,10 +264,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 +299,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 Mon Jul 31 22:24:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 128898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2321937vqg; Mon, 31 Jul 2023 16:17:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFx3A9X34+RbKjZWBZQcqbzYAqkkdwzvHMazjHCCyzI1HUe4xKdf7RXgrE9dtWfaoO0mFLG X-Received: by 2002:a05:6a00:1d02:b0:67b:77e7:f467 with SMTP id a2-20020a056a001d0200b0067b77e7f467mr11088685pfx.16.1690845473894; Mon, 31 Jul 2023 16:17:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690845473; cv=none; d=google.com; s=arc-20160816; b=u4mkc4nRCXMvs2v1DECCkUWo0oxG0Tu7PVb+I7XFjI8dE5Uhvr6sU/X/XIciVc5JZn pmUKt0CpSmzNIf5z/2xGk2oG8K2xDpdFBECn3Kc9n/qSwZ7Q+xHooNhjF1rc2FJ5rZAv BI2DAuwlQoD4EA0aHL1FUpsl0MKWajtkO+NTvikMmomVExCydHfPbVHcQyNnzAhnm77x YSsjwg9zpbGCLt/JjysrA06YJY0hrmWvjt0a8FBCTUfKjjXneQzqQ4S2/83BaSV/QGES rUyfPFDy8KOQiXGdSPO/MeJGYSiF69DuyB+38G5BnQJLf40Qyr02RRDvPHp4Okb4az+Q LbKg== 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=1H6mPQ3alg3Emw+HZc9CdW62mp7i071++WD9xSrtVFo=; fh=6uHf4Rb4DHDahIqS26h0Nic47hqd8K43WIkuK37Vo4Y=; b=Jd5qIV+U7gWHQTjP+E2H3RFkbsGw/i6HDXcBum815n0sf3IlKdYfVRbGTxnfbwxf/X hVZj43BRe/x92QKgFIEH5Py9gJBpBKRHz02KLXUYY1BckfLYfn6RNJQuJivMv7FtXfXs D0hONgItvJNe2r2J+2SGCeu/cn7OV1xPbnct0g2/A9sGB6vVLgUd5IYZc4n5mm1ncI8R i6LIE53LkNIJf7wUF0q/vV1d9pYOC7a7b2ppNGrZNNZ0FpnQzeWIlSGuIUO3MwszZk1N h7Fd94+HqLUOZ/xO3N8UZleXy7W0WVhv79ANk4Qpw7uk62o4A441QZWrCvDiP5/fIKS5 +ksA== 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 j20-20020a634a54000000b0056357ea1d1dsi7673762pgl.532.2023.07.31.16.17.41; Mon, 31 Jul 2023 16:17:53 -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 S231492AbjGaWYf (ORCPT + 99 others); Mon, 31 Jul 2023 18:24:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjGaWYd (ORCPT ); Mon, 31 Jul 2023 18:24:33 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0BA112B; Mon, 31 Jul 2023 15:24: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 1qQbJO-0002SO-38; Mon, 31 Jul 2023 22:24:23 +0000 Date: Mon, 31 Jul 2023 23:24:06 +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 v3 2/2] wifi: mt76: support per-band MAC addresses from OF child nodes Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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: 1772979983678886190 X-GMAIL-MSGID: 1772979983678886190 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. wifi@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 --- Changes since v2: * none Changes since v1: * refactor and add missing of_node_put() 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);