Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10941078rwp; Fri, 21 Jul 2023 07:09:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlHpAiX+tByThNhYmoPRMlJOF1g1h5iA9pOInrrroJVnCna9r/dIXW51/Zh7TjjcR6kerZN0 X-Received: by 2002:a05:6358:c16:b0:135:7c30:51a with SMTP id f22-20020a0563580c1600b001357c30051amr163711rwj.0.1689948569028; Fri, 21 Jul 2023 07:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689948568; cv=none; d=google.com; s=arc-20160816; b=jwCxnSrdTxrsazJenE3ZfjWFOxZz6R00ZPV8RgF8MHayIBbD093UbG0PRn8vNoGam5 bBtMyc7UvKnejZ74pzs6NH4sJ8Nge09p0MCUQcIwQ0Cwz6Wg61eD2y3TSU+TETEvlxMN mrp7mL/vEb2/E1N4Wh0sczrX3k4WHqe5V1+EC8tZZw4QQ0SQvVjdWtweY0rtpxNAPUeO axPcX8GA5iFJpQqGGI7P8dKR3w9amC2Na/Nw3MgWbYVPSVA+zr1FBtuQMKkrvdCW06G4 omh7YVWZz8x1oxYgVpX6jp3uMN1GEY5YjWJVjD4nEWoThCtsTL+eRs1z4MEK29A/JuKC /3fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=T4vNAC/E026Y+XWj9QNO95YMB3KUobeaIzAQ2G9fpZA=; fh=d9XFsL0QiW7mB0yy/Dn7n/CVmKRQqLnFoPiaUGJewck=; b=QFK2UgPxcelL3y3b50rPuWvmK5nYu6+TYOS++4P238vn4S3fQqVLmFRSKoDuVo2PSB BN5k3002hXObLvw8QSoQrVFvIs6iz/33pX7COufbGwC9SkNYDzYWUFAUYAh/f2EUkcc9 AaeFVufLZ7Tb26eO5smeZeN9NtQAycTI9qLBZIbeXHomXiU6daHbdSgiedIVoJA0awlX oA8yviT4r3uhPTRNvqsj6QGCXrGQo/zXXukajKGiB72aHWf6//aceQULFSj9f6wXYF6R NSzaMJ+nLViKpCf1rDYgD0WqjFFdpTaS9Hj3+ioU/UKIqKPKtyKmuqdCPrjPJjdF0MW+ bzNg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w28-20020a63935c000000b0056348503817si3228801pgm.96.2023.07.21.07.09.15; Fri, 21 Jul 2023 07:09:28 -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 S231699AbjGUN4E (ORCPT + 99 others); Fri, 21 Jul 2023 09:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbjGUNzu (ORCPT ); Fri, 21 Jul 2023 09:55:50 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACAB130D2 for ; Fri, 21 Jul 2023 06:55:31 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qMqb3-0005Rt-W0; Fri, 21 Jul 2023 15:55:06 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qMqb1-00150e-Ii; Fri, 21 Jul 2023 15:55:03 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qMqb0-0068zi-29; Fri, 21 Jul 2023 15:55:02 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , Arun Ramadoss , Conor Dooley , Krzysztof Kozlowski , Rob Herring Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, "Russell King (Oracle)" , devicetree@vger.kernel.org Subject: [PATCH net-next v2 6/6] net: dsa: microchip: ksz9477: make switch MAC address configurable Date: Fri, 21 Jul 2023 15:55:01 +0200 Message-Id: <20230721135501.1464455-7-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230721135501.1464455-1-o.rempel@pengutronix.de> References: <20230721135501.1464455-1-o.rempel@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org 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 The switch MAC address is used for sending pause frames and for Wake on Magic Packet. So, make use of local-mac-address property in the switch node root and configure it in the HW. Signed-off-by: Oleksij Rempel --- drivers/net/dsa/microchip/ksz9477.c | 8 ++++++++ drivers/net/dsa/microchip/ksz_common.c | 7 +++++++ drivers/net/dsa/microchip/ksz_common.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 69909241b1f44..427176c1441f7 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1211,6 +1211,14 @@ int ksz9477_setup(struct dsa_switch *ds) if (dev->wakeup_source) ksz_write8(dev, REG_SW_PME_CTRL, PME_ENABLE); + if (is_valid_ether_addr(dev->mac_addr)) { + int i; + + for (i = 0; i < ETH_ALEN; i++) + ksz_write8(dev, REG_SW_MAC_ADDR_0 + i, + dev->mac_addr[i]); + } + return 0; } diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index a7b298838932c..4de2456b5a349 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -3684,6 +3684,8 @@ int ksz_switch_register(struct ksz_device *dev) for (port_num = 0; port_num < dev->info->port_cnt; ++port_num) dev->ports[port_num].interface = PHY_INTERFACE_MODE_NA; if (dev->dev->of_node) { + const u8 *mac; + ret = of_get_phy_mode(dev->dev->of_node, &interface); if (ret == 0) dev->compat_interface = interface; @@ -3718,6 +3720,11 @@ int ksz_switch_register(struct ksz_device *dev) dev->wakeup_source = of_property_read_bool(dev->dev->of_node, "wakeup-source"); + + mac = of_get_property(dev->dev->of_node, "local-mac-address", + NULL); + if (mac) + memcpy(dev->mac_addr, mac, ETH_ALEN); } ret = dsa_register_switch(dev->ds); diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 589f8b582a415..bdfcd1dc02ee9 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -171,6 +171,8 @@ struct ksz_device { struct mutex lock_irq; /* IRQ Access */ struct ksz_irq girq; struct ksz_ptp_data ptp_data; + + u8 mac_addr[ETH_ALEN]; }; /* List of supported models */ -- 2.39.2