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: 13311220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFB03EB64DA for ; Thu, 13 Jul 2023 02:50:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zMrjiQs73juaMHT5CNVlfnJDgCyWMZ7LlZz27q9Y8hg=; b=gSpxUmF6TAYiXg Xl/pJlWEaReSh/YxHJayBIDzajmcgnjRKlGqg5C1c/vZGdVSmNA3hd45DdDsrBAdhGVlYG2RjL8yW g57UQjicXDKCRVkLz/4DhbGh02zQZlcgZrARXhonECS8KOnjgOVJUjEUjrTSw3nT08HcfBF/otM6U UtCeJIMRg3dlOnZ5yrvV9B53/F/CX3qUVnqGsGUEJHmQAYjST+BKSivle5S6q9yENi0aWp8o7MkZk 4yaMCm7qPyOBBlzQLELCk4r5Igk2gKDtetVRbsG3yDwg3wehFRWuSlIQg/dj/4VkP3HRvb2MX8VGK rQLsVFO5577jsYC1oUYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJmPO-001laG-2e; Thu, 13 Jul 2023 02:50:22 +0000 Received: from pidgin.makrotopia.org ([185.142.180.65]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJmPL-001lZF-24; Thu, 13 Jul 2023 02:50:20 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230712_195019_676791_C0285AA7 X-CRM114-Status: GOOD ( 10.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 | 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);