From patchwork Thu Sep 14 13:51:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13385472 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 22978EEAA44 for ; Thu, 14 Sep 2023 13:54:02 +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:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yn/qhU1ZDSp3Te2X2SSc0LEjUH6f14LdERLEz2J8I8E=; b=nY1IL4t8V6Mee8 VbELYq/YN1nOBUuCOfxFTbOIGasn40RtW2zpNSZNloD3KB2P5PpSkQOqezNVqKTFtCm2qOdamECxn lDfVVBsUVvBIkakfB4utH3i+lnAqTGFGwXKNWco4035Y2mvR/jREOEmPCO+uu3N9VaTist5SEPi+V 6hKbpnivjcM9F3YQGCNOmo9D62JKpsnub05tbyW51NJRbWnl+4Z0VRBCKdJ4UwIhFpxyBFe1sI7l4 vYljnz7CCv8B+diujE+xPa83tnpkHVrj+kYnvwTwvzvYLlARELN6jDr/NkaY0jej5T00QN1YeJmdI 1MYjnWpDa/ZFboVA7NVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgmml-008YUi-0I; Thu, 14 Sep 2023 13:53:35 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgmmh-008YBb-1a for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2023 13:53:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8fReHoJYksbbxqknkvPfNrb5e3cqgf2PgJTyjFj+x+Y=; b=cGroKfB7bVzGWXQukapi2TIE/o RKThpImDI0Q543380fqqnxbRYDEgqnUHMPcnksXnsS9TMjL52K2GxtXIquB3dnAsvg5TDQIxNybhB pnw0WX3L2/ymrLrPQRDFGCyAgQln0t1eeQEaqt3Z41mefQ6F19LbnVuZWWYXwCLERz7Gg0fi8MPPO bkWmsmQwU7vuJw9GtYSBZiWacg6Lw7pEXVilBknwdI2N7bvxA7zig0qmnRQohJWfC5MgGC6RHgcfO AQe/Fhb2ARjP5Hs/1XpWe1f6DDZbazamPlwgNVuiblVn1dKKDbdGLuC87bSOFXWez4kwiPH6ATPlr b+eDqUNQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:59538 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qgmkZ-0004FZ-15; Thu, 14 Sep 2023 14:51:19 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qgmka-007Z4Z-1E; Thu, 14 Sep 2023 14:51:20 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Alexandre Torgue , Jose Abreu Cc: Alexei Starovoitov , bpf@vger.kernel.org, Daniel Borkmann , "David S. Miller" , Emil Renner Berthing , Eric Dumazet , Fabio Estevam , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, NXP Linux Team , Paolo Abeni , Pengutronix Kernel Team , Samin Guo , Sascha Hauer , Shawn Guo Subject: [PATCH net-next 1/6] net: stmmac: add stmmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 14 Sep 2023 14:51:20 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_065331_529864_893177A3 X-CRM114-Status: GOOD ( 10.02 ) 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 Add a helper function for setting the transmit clock for GMII interfaces. This handles 1G, 100M and 10M using the standard clock rates of 125MHz, 25MHz and 2.5MHz. Signed-off-by: Russell King (Oracle) Reviewed-by: Serge Semin --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 25 +++++++++++++++++++ .../ethernet/stmicro/stmmac/stmmac_platform.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 0f28795e581c..f7635ed2b255 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -700,6 +700,31 @@ EXPORT_SYMBOL_GPL(stmmac_probe_config_dt); EXPORT_SYMBOL_GPL(devm_stmmac_probe_config_dt); EXPORT_SYMBOL_GPL(stmmac_remove_config_dt); +int stmmac_set_tx_clk_gmii(struct clk *tx_clk, unsigned int speed) +{ + unsigned long rate; + + switch (speed) { + case SPEED_1000: + rate = 125000000; + break; + + case SPEED_100: + rate = 25000000; + break; + + case SPEED_10: + rate = 2500000; + break; + + default: + return -ENOTSUPP; + } + + return clk_set_rate(tx_clk, rate); +} +EXPORT_SYMBOL_GPL(stmmac_set_tx_clk_gmii); + int stmmac_get_platform_resources(struct platform_device *pdev, struct stmmac_resources *stmmac_res) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h index c5565b2a70ac..8dc2287c6724 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h @@ -11,6 +11,7 @@ #include "stmmac.h" +int stmmac_set_tx_clk_gmii(struct clk *tx_clk, unsigned int speed); struct plat_stmmacenet_data * stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac); struct plat_stmmacenet_data *