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 * From patchwork Thu Sep 14 13:51:25 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: 13385473 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 71BC5EEAA40 for ; Thu, 14 Sep 2023 13:54:04 +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=+OUUmXX8Ei9uKs/sLbWJGWsctabsIsIpTGLp2rl3lR4=; b=4QlJw09WQnFU0l HleyOd3YF7V35J+b8xCUIaSnFQfp/sKCSpW7RYQHa7EZaPlq8oss32ptmWcyNGjYJKBuXZzR7IUZH +Mxw8N47fH59IQ39elm/5jVm1UO6l9MBZNg/xlL+XA0Xnhic64VikCHk2gc0X3ktmyFq4G2jCipiK DaTQtV/bp2FS+4C9wWVjBaFr+SJpW96eawgvy6lcjqSFR5gb68iHo8i0uZpNbhdAhjunBxkGfHq0C 6YLE/QEvoJKBYvG9D3HhKuIUxwEbFoBpNBSqioXP0MGl2DaCNkCT/sI187Et/QjftJNwylxZdx0fk gKvwXx6Tv864YpDwiXmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgmmo-008YVM-2L; Thu, 14 Sep 2023 13:53:38 +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 1qgmmk-008YBl-0G for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2023 13:53:35 +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=4Ggzd6KKNjZJlZVC4V4b37NrE+RHUSzuLGhRyYhd788=; b=IcEV4FdGM9shNwxOpListlONWh fy4VPSRWxmMABXIgOPvdf8MUazPc6Kr9XHhjAeaoKMSgSQ1oo/tBbR0yGrYJEDd62y7ujqWnTkdbL 2UFXgwULFg9PN7nDmWaT+SKWFo2OF6PyU44WQhowM6qP6SEtH3XtrUmgeM/g+WaCknoqA54IbjQ8A 3+bsp6dytCli9qrjk4Q4axHWiDUwvHbl7Vp+HklzRgIaCyFnqF4iVme9Cj3hATBphAuO29hiKY7Ms U17OpNfciuSXr15s/fDIafC6OAcvYIbgV6SZJ2dkuYFyFxwj/QPdAklaQFGlh43PKBUQl20JjpPrA T0LEPlMA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44262 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 1qgmke-0004Fl-1T; Thu, 14 Sep 2023 14:51:24 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qgmkf-007Z4f-6i; Thu, 14 Sep 2023 14:51:25 +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 2/6] net: stmmac: imx: use stmmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 14 Sep 2023 14:51:25 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_065334_116258_F1218555 X-CRM114-Status: GOOD ( 10.24 ) 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 Use stmmac_set_tx_clk_gmii(). Signed-off-by: Russell King (Oracle) Reviewed-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/dwmac-imx.c | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index df34e34cc14f..cb56f9523acc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -186,7 +186,6 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod { struct plat_stmmacenet_data *plat_dat; struct imx_priv_data *dwmac = priv; - unsigned long rate; int err; plat_dat = dwmac->plat_dat; @@ -196,24 +195,13 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod (plat_dat->mac_interface == PHY_INTERFACE_MODE_MII)) return; - switch (speed) { - case SPEED_1000: - rate = 125000000; - break; - case SPEED_100: - rate = 25000000; - break; - case SPEED_10: - rate = 2500000; - break; - default: - dev_err(dwmac->dev, "invalid speed %u\n", speed); - return; - } - - err = clk_set_rate(dwmac->clk_tx, rate); - if (err < 0) - dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); + err = stmmac_set_tx_clk_gmii(dwmac->clk_tx, speed); + if (err == -ENOTSUPP) + dev_err(dwmac->dev, "invalid speed %uMbps\n", speed); + else if (err) + dev_err(dwmac->dev, + "failed to set tx rate for speed %uMbps: %pe\n", + speed, ERR_PTR(err)); } static void imx93_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode) From patchwork Thu Sep 14 13:51:30 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: 13385474 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 ADA57EEAA41 for ; Thu, 14 Sep 2023 13:54:07 +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=dDs1lANSHoFO8faAxd93Gsy6h5TtM/Qbb+hf0juYVc8=; b=aUc0IOKj7J1Wzu asWTryjacdEHDMoeGF5eBF+srrkBCzZffGAV+UFjCs9dnCdJvj1uNFQ1RHEK1Lipwm4rqOUProvnx a0Fd05MxpLSnyzKCI7/+lg2AqtlaY51OlypcsTGjEDHrUL3VrnZvH+NUsdPBZq21ToNVJsnSBoKrL fmJo/r0i8QvbsiKtJwark9GcP9WRRZP8bpkB0wT/NpqkvGptMPaFh8xDNTEM/k9hwvZ07/GgMjArO qgOZH8/Ye1/5MOVGdMKbtDNvapljkNtbPH9tFr/Bs1xhaUeh2YRijUY4uhSKSWOlf8IheUB1j0i0Q M7CTp5p3lzqGTbSthanQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgmmu-008YWi-1H; Thu, 14 Sep 2023 13:53:44 +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 1qgmmr-008YCF-31 for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2023 13:53:43 +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=DhArgv95jqcFUTmgufM+4MILeoaknnMkgqhkyROEjtk=; b=MwadJQzn6QxRzlXbIa9qLC3A61 8bUsqbfYuVkcIe8BP4Lqmh74fDO6DsUWhA+GNJYM46EXjXeuOcuMeWFjhako49FJBBnk4FbMpC+WE XfVstYhzBZPGJRo6jfICGS29VAOu4j4XioEMp1YzivcITaXALvGDFdJYEEbdS3/ugf4WXwYtpBSDN cKs4zLu9Xpul6uQRMnum3P6WNrEyRg/1Cm/y8NADDknsu3SgcDkSB2Iz9THyNDnXA0ZdVj6PPu5gJ hBBdNw/AJCrf6AIqqgHG1Xdyuipu1owbJDKZqCT5a4t3Ww/iuGk8PnGaZX1xdryOotI40hsM/BFq6 SudPpvVQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44274 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 1qgmkj-0004G7-1u; Thu, 14 Sep 2023 14:51:29 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qgmkk-007Z4l-BK; Thu, 14 Sep 2023 14:51:30 +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 3/6] net: stmmac: intel-plat: use stmmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 14 Sep 2023 14:51:30 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_065341_993457_9BD7F863 X-CRM114-Status: GOOD ( 10.99 ) 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 Use stmmac_set_tx_clk_gmii(). Signed-off-by: Russell King (Oracle) Reviewed-by: Serge Semin --- .../stmicro/stmmac/dwmac-intel-plat.c | 34 +++++-------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c index d352a14f9d48..c6ebd1d91f38 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c @@ -31,32 +31,14 @@ struct intel_dwmac_data { static void kmb_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) { struct intel_dwmac *dwmac = priv; - unsigned long rate; - int ret; - - rate = clk_get_rate(dwmac->tx_clk); - - switch (speed) { - case SPEED_1000: - rate = 125000000; - break; - - case SPEED_100: - rate = 25000000; - break; - - case SPEED_10: - rate = 2500000; - break; - - default: - dev_err(dwmac->dev, "Invalid speed\n"); - break; - } - - ret = clk_set_rate(dwmac->tx_clk, rate); - if (ret) - dev_err(dwmac->dev, "Failed to configure tx clock rate\n"); + int err; + + err = stmmac_set_tx_clk_gmii(dwmac->tx_clk, speed); + if (err == -ENOTSUPP) + dev_err(dwmac->dev, "invalid speed %uMbps\n", speed); + else if (err) + dev_err(dwmac->dev, "failed to set tx rate for speed %uMbps: %pe\n", + speed, ERR_PTR(err)); } static const struct intel_dwmac_data kmb_data = { From patchwork Thu Sep 14 13:51:35 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: 13385475 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 2A381EEAA40 for ; Thu, 14 Sep 2023 13:54:21 +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=tVZm00Az0w8uPVLVZmdc6I7s8+V4vrN+Zoo7/AUgvfA=; b=hkFwig/B+b/zKp EcTIvO/uIWvDQXyuoTGf+yh20GeMWQLJjYEeXxsOuByiBokNLwiL9zxDA/Ty0vawNh/w/fWfdy8QJ dMKjXzzZdizHZbauH69NukV33qn5OYBV5gIO9vb7GH9QofKeezNkQN1WTJIRZKy0cLD44dqFisNyE 8dR5fC3cMoWAzK8PtyjfEqFiglZfgLojvEhEagL5BkBhrhqJcEv2uCBlMwainDZvg2ylVGqYifVyP xTG6BgCetwSKeXPC8DulgaJ1dsFe9YHtxQtYR7l5fjalKBdQm74NJU52eM/700CHS76fOJ+8W3x20 SBNIQcNWCd/WtSJfvlew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgmn9-008YaU-16; Thu, 14 Sep 2023 13:53:59 +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 1qgmn6-008YEX-2H for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2023 13:53:57 +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=n0O/JhnMAmLKmowqIXtwIhLE2/WUxnsTqzz4U77JWG4=; b=JeDY6eUQxgZHJ1fH4tdWsu37ko Ak/DH3XAgEm/W4JO8vxnyT+wfmphzwfEcNiJM5rH83XCEgei1Bxvv55kJddYTZg7iJoW6Y40mv0/C em/WL6VvXAz/68x0HZyKaFNliZ+IIcBeKDBGQduMhDviZ4PmAe9xfRoCpQKrh0cplMUoQJvlf7OfQ WwukDKMgN38QXC3IJ+CL3AVIWK6C6o2o33RyhqPH3nt3Fw4GYtMDMQZLhAxAY4warjgt7j9kb9iP0 2B18/IRXSvt29Hn2/xX9f+MMJobI+kJRMCxMWgaeMiS5nO+QcJdE7IkAjXjwBeJ80TP7DYR3yLTsa slJHDIZw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:58036 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 1qgmko-0004GR-2L; Thu, 14 Sep 2023 14:51:34 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qgmkp-007Z4s-GL; Thu, 14 Sep 2023 14:51:35 +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 4/6] net: stmmac: rk: use stmmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 14 Sep 2023 14:51:35 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_065356_745930_83FB5B2D X-CRM114-Status: GOOD ( 11.06 ) 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 Use stmmac_set_tx_clk_gmii(). Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 60 +++++-------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index d920a50dd16c..5731a73466eb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -1081,28 +1081,14 @@ static void rk3568_set_gmac_speed(struct rk_priv_data *bsp_priv, int speed) { struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED].clk; struct device *dev = &bsp_priv->pdev->dev; - unsigned long rate; - int ret; - - switch (speed) { - case 10: - rate = 2500000; - break; - case 100: - rate = 25000000; - break; - case 1000: - rate = 125000000; - break; - default: - dev_err(dev, "unknown speed value for GMAC speed=%d", speed); - return; - } - - ret = clk_set_rate(clk_mac_speed, rate); - if (ret) - dev_err(dev, "%s: set clk_mac_speed rate %ld failed %d\n", - __func__, rate, ret); + int err; + + err = stmmac_set_tx_clk_gmii(clk_mac_speed, speed); + if (err == -ENOTSUPP) + dev_err(dev, "invalid speed %uMbps\n", speed); + else if (err) + dev_err(dev, "failed to set tx rate for speed %uMbps: %pe\n", + speed, ERR_PTR(err)); } static const struct rk_gmac_ops rk3568_ops = { @@ -1387,28 +1373,14 @@ static void rv1126_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed) { struct clk *clk_mac_speed = bsp_priv->clks[RK_CLK_MAC_SPEED].clk; struct device *dev = &bsp_priv->pdev->dev; - unsigned long rate; - int ret; - - switch (speed) { - case 10: - rate = 2500000; - break; - case 100: - rate = 25000000; - break; - case 1000: - rate = 125000000; - break; - default: - dev_err(dev, "unknown speed value for RGMII speed=%d", speed); - return; - } - - ret = clk_set_rate(clk_mac_speed, rate); - if (ret) - dev_err(dev, "%s: set clk_mac_speed rate %ld failed %d\n", - __func__, rate, ret); + int err; + + err = stmmac_set_tx_clk_gmii(clk_mac_speed, speed); + if (err == -ENOTSUPP) + dev_err(dev, "invalid speed %dMbps\n", speed); + else if (err) + dev_err(dev, "failed to set tx rate for speed %dMbps: %pe\n", + speed, ERR_PTR(err)); } static void rv1126_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed) From patchwork Thu Sep 14 13:51:40 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: 13385470 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 9CE4CEEAA41 for ; Thu, 14 Sep 2023 13:52:32 +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=ypTlio+FfVqXaahkqGq4DKI0q4IxKd1sDpRvp8VY+jk=; b=y4prhU+yC2v0Di 8pBaCuaU6A2UVREEidUW9/+an3CLC/f/2C7ucW7MMmgZJP6wsDzLR1jlOAs/mduZKC9bDrIWbIK60 75KROHiPJ64hoNGNB2Mz6plZ9pl9g8N3RtH3WXPONjUXrS8entkDJ+i5q2PvNFNpPhf1K2ZJ1TGSe LnnnL86R+R7P6BlMQngB808FAC4YuH6N8Qfy87d9mVV1Ng4AQjWFYEN5OZe/v9FXoNWk4r/hEvrGA Ek35Gk58qJDJHiy4/fOylJuE6qpoQqwchr6cT0NgavMgy6EDFeNSq/K/rzwFz43oCOHGLE6GfxSJH kQUBFgnSRDKsNdEl6rnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgmlF-008YGg-2Q; Thu, 14 Sep 2023 13:52:01 +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 1qgmlC-008YEx-14 for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2023 13:51:59 +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=MTFeBWXpqjY6Op3UJSYX2O9whn/P1P3QnzWrdNdnLB0=; b=cMI4UeIwU4a36nXtnqf6PAqI+Z J4dThbcCx7APHUiAfjfamrDlnihT6bCC382AcMw24/CBqIGI/bQu5d8TnqxslfOVZVVMwkR+hRwtN J/PaGM1L3bFcWamjAo2ULTi4cRvT8+fo6+8HiKym6rkLXkRwD09DsMRs+T2JFww5hFHiEVTx/HFd7 eWymRrA2Uv4AZzG6eU7/uKG9fttppWHh2qAKRSDeCLJt9xLda8ngByqBYQCd46UGA/7G53+ilHh2A ud2bRG7RY5E3EOuQGb/LapvhuRh0GqGWLwIdhLsbBc9Ffxz9ZnSVNZmOxSQERiTHIyr7WAfocIVD1 RULy6a8g==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:58052 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 1qgmku-0004Gj-34; Thu, 14 Sep 2023 14:51:41 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qgmku-007Z4y-KM; Thu, 14 Sep 2023 14:51:40 +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 5/6] net: stmmac: starfive: use stmmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 14 Sep 2023 14:51:40 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_065158_367679_86DADE33 X-CRM114-Status: GOOD ( 10.27 ) 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 Use stmmac_set_tx_clk_gmii(). Signed-off-by: Russell King (Oracle) Reviewed-by: Serge Semin --- .../ethernet/stmicro/stmmac/dwmac-starfive.c | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c index 9289bb87c3e3..c2931464e977 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c @@ -27,29 +27,15 @@ struct starfive_dwmac { static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) { struct starfive_dwmac *dwmac = priv; - unsigned long rate; int err; - rate = clk_get_rate(dwmac->clk_tx); - - switch (speed) { - case SPEED_1000: - rate = 125000000; - break; - case SPEED_100: - rate = 25000000; - break; - case SPEED_10: - rate = 2500000; - break; - default: - dev_err(dwmac->dev, "invalid speed %u\n", speed); - break; - } - - err = clk_set_rate(dwmac->clk_tx, rate); - if (err) - dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); + err = stmmac_set_tx_clk_gmii(dwmac->clk_tx, speed); + if (err == -ENOTSUPP) + dev_err(dwmac->dev, "invalid speed %uMbps\n", speed); + else if (err) + dev_err(dwmac->dev, + "failed to set tx rate for speed %uMbps: %pe\n", + speed, ERR_PTR(err)); } static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) From patchwork Thu Sep 14 13:51:45 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: 13385471 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 38262EEAA40 for ; Thu, 14 Sep 2023 13:52:33 +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=gVHzS9PSoo9QVjdB4iHenoHPnI1FglrWVusbvy85IP8=; b=iQrqgRdvbtG9G3 6O2U5X4pvDQIRwXI0gx6LpeCIiJ07tE9UcFWhiFCcF/Ju3iSRmkrw4l5Xpzn7dCeUsaQCJ/bYXNPA sktyeIZphmFdG0iOEKMLzBVmlck2y9p597g1/N9eU80bfcYF18WKAAafoq+e+ZxnmIESOBevdjvHl mCNEF9ApFiLKMJjTPcugGKu5nQPRXlRTiP2HeG3n9n9zyRAK8nDf4xu+dZV8GpvritycpUQmvtoOl Nzj27cJW8s/9hxgg8hTiJLMtPFo4XbbX+29xSZdlRfIx/4OeOGVGnvGd+eObkJ3TYw4PHm5k+TwJv m0LBpxe5VXn8hPKG4dEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgmlG-008YH2-0o; Thu, 14 Sep 2023 13:52:02 +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 1qgmlC-008YFQ-2g for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2023 13:52:00 +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=blBCZ/n7JwsBPVsYbstO8SD+/phIKgnPgDwevzXDKaM=; b=Mu1CG0VkGeF/qC0Q9tfXvBQeSz faafrqhFFvCEqjC5NmQGvN1Gp6ml3Iwtwzh9kl2IomWp1tw9+sODmsMWE4EnKsCgzIwPLGazqNVqL RTcPKrCN3wqgCcScIrPeR18qn+VLnE9h95eCevcu6ROG31UpNaFX+gTgUhAPHbceTaGxi2aMvDFmW 29AyFtVrWW4eWTOX2q26/otD/AXlFM3znfwtsxoGC5Q6J4Hh5QD4e/06HbHykIWu/no8LW1wNLIAK zbHuRPERR1whdXqf9y3KuimKFvQHoxmjbJWreLc3dhJouETQ0JAsoTjw2cXSixPoVR7NS6Da95wtX mSdBh/sA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:59460 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 1qgml0-0004Gx-2q; Thu, 14 Sep 2023 14:51:46 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qgmkz-007Z54-P3; Thu, 14 Sep 2023 14:51:45 +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 6/6] net: stmmac: qos-eth: use stmmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Thu, 14 Sep 2023 14:51:45 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_065158_868992_633C1538 X-CRM114-Status: GOOD ( 11.70 ) 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 Use stmmac_set_tx_clk_gmii(). Signed-off-by: Russell King (Oracle) --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index 61ebf36da13d..bc9b054e10af 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -181,32 +181,10 @@ static void dwc_qos_remove(struct platform_device *pdev) static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mode) { struct tegra_eqos *eqos = priv; - unsigned long rate = 125000000; - bool needs_calibration = false; u32 value; int err; - switch (speed) { - case SPEED_1000: - needs_calibration = true; - rate = 125000000; - break; - - case SPEED_100: - needs_calibration = true; - rate = 25000000; - break; - - case SPEED_10: - rate = 2500000; - break; - - default: - dev_err(eqos->dev, "invalid speed %u\n", speed); - break; - } - - if (needs_calibration) { + if (speed == SPEED_1000 || speed == SPEED_100) { /* calibrate */ value = readl(eqos->regs + SDMEMCOMPPADCTRL); value |= SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD; @@ -246,9 +224,15 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mo writel(value, eqos->regs + AUTO_CAL_CONFIG); } - err = clk_set_rate(eqos->clk_tx, rate); - if (err < 0) - dev_err(eqos->dev, "failed to set TX rate: %d\n", err); + err = stmmac_set_tx_clk_gmii(eqos->clk_tx, speed); + if (err == -ENOTSUPP) { + dev_err(eqos->dev, "invalid speed %uMbps\n", speed); + err = stmmac_set_tx_clk_gmii(eqos->clk_tx, SPEED_1000); + } else if (err) { + dev_err(eqos->dev, + "failed to set tx rate for speed %uMbps: %pe\n", + speed, ERR_PTR(err)); + } } static int tegra_eqos_init(struct platform_device *pdev, void *priv)