From patchwork Mon Sep 11 15:29:11 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: 13379440 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 2E0CFEE7FF4 for ; Mon, 11 Sep 2023 15:29:57 +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=65kC/OuZsJOtkLhYdmwgd9CSu85rLBEPeREb7Fys5Eg=; b=1XabDxpoEEPITc FXbuY1ATqLWPgWU5BX136zGJgRmzF6XQ+Q4FgRxKMbXKRkKt3GWRKBh6W/KAt7By9Qe88jBJkVmmm IZV+zYc7PKL/P/c4di3lhfciKsL+l0/L+iktuoTwYIEbpKyBczhSQcInSlqTLGMEEcQOShpmcfZA6 fN2ViIafavUUjqOPgv4UzJdg3yBrKHqaCbx6qZmWEsgIZhSY1OtnDG49mxlsmdKf8/Gqj9qxON4wx HNI/vLC0jzm3i6mDIoSLo1GBcqFm6XCZbMXsHeKuY5roORKA03nC3L5E1IMXFSEgEQ9QCnWbi4tQe T3noVDo10VWjriSSwELA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfir2-000tQY-0F; Mon, 11 Sep 2023 15:29:36 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfiqx-000tN3-2Z for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:33 +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=P6DsgJ0EF8GDgyic7GQZdDjnAhVZ69mVqqsinIQxsnI=; b=GpHiMgVQdacjHXeMTXPnV0R9j0 uy+f8uOTRWmoWvPZg346b0tZjGMyNVG5BIpYLbOTQvzH7A4w5QoMM+PkFsl+XtWaBc2xJkj9m9V99 7V75J9qRRmRrxwowvgzEqJqxGIPAyNwGpnH0GVNf4/cgYZcdIwv8sMyBSUtUYUHH6J42UtmarjPdL vbztGxsIpWpyEB/EDdDk3YhTAiuGi6AG33GsRmQwQc+NOrBH0jktvQGNedSAVipDwpe7TDAL9AtrC hWS3XGWkpVcte6mb5Bf+34kApst9n3BoZEuZayDS7ZGDQek5H4T/H75suCnKDTepbYuMua1OH8JFV Cm//nYnA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:52158 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 1qfiqd-0008Da-0j; Mon, 11 Sep 2023 16:29:11 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqd-007TPL-7K; Mon, 11 Sep 2023 16:29:11 +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 platform library MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 11 Sep 2023 16:29:11 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082931_833062_C31A207E X-CRM114-Status: GOOD ( 14.11 ) 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 platform library of helper functions for common traits in the platform drivers. Currently, this is setting the tx clock. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- .../ethernet/stmicro/stmmac/stmmac_plat_lib.c | 29 +++++++++++++++++++ .../ethernet/stmicro/stmmac/stmmac_plat_lib.h | 8 +++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index 5b57aee19267..ba2cbfa0c9d1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -6,7 +6,7 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \ dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \ stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \ - stmmac_xdp.o \ + stmmac_xdp.o stmmac_plat_lib.o \ $(stmmac-y) stmmac-$(CONFIG_STMMAC_SELFTESTS) += stmmac_selftests.o diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c new file mode 100644 index 000000000000..abb9f512bb0e --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.c @@ -0,0 +1,29 @@ +#include +#include + +#include "stmmac_plat_lib.h" + +int dwmac_set_tx_clk_gmii(struct clk *tx_clk, 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(dwmac_set_tx_clk_gmii); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h new file mode 100644 index 000000000000..926fdce379b3 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_plat_lib.h @@ -0,0 +1,8 @@ +#ifndef STMMAC_PLAT_LIB_H +#define STMMAC_PLAT_LIB_H + +struct clk; + +int dwmac_set_tx_clk_gmii(struct clk *tx_clk, int speed); + +#endif From patchwork Mon Sep 11 15:29:16 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: 13379441 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 6E44BEE801F for ; Mon, 11 Sep 2023 15:29:58 +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=/fMMiat8Cl/8/Zv/fITdXG/rzufmPmBdHOM29m0fp/s=; b=hxJ5j3HXV53h0j orApShDzvZYkGPiKB5wL29WhvnwvWkKmIffe4O8l7+MQUfePCAjtlYm/hLD7dEnYMIczdobcyH8Vt IIQIzkkuttnpXqLxPs5Fgn+kvAIITweK5My4VwseGkXh1YJ1/PX+X8cVHdaYccWa9t96CNZg5TF2S KsLJvryRC4C0slhqagLpKAxwmF39V9eTiOi38/3fFaj/xLnDEoxvHaaGssHUKC5zywBDrRY7Xl95Z omkjVWdNWWBbZ9O8PejruUb048lI/UvbRySemVUQ6wqp1KHPTcPxP01egWMAJjBHBxncpNSGYCMBr HgZiDv10bxKz/TXm7uJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfir4-000tRv-2Q; Mon, 11 Sep 2023 15:29:38 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfir1-000tOu-1Z for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:37 +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=n8j/kmn+Ia/Kfu9cLc90F6mFrEGGGfC9nZYxAWE9saM=; b=khGXaNxzQ+7bn0daoCQtE0ZFJv i1UtyGGFk28yPgZ5LNMkBRqdhx/bJ5UXnsjbbgNMQtu3tFQHs9SEX6KXvI9eOUOQVBFLJ/aHzYPdt 0AFQfwYObGp+gA5Q4p2/lHCbPgGGk3PCRj6o+jiqHlvAiNfGO2m7JZ8N5beRm5BtziSJQW3aPpFiV OPvPj2ScidU/hDwPc6moOWRlQ0EXROF/pMl8Q1JSXlatthsEXZGEDHOrrbP3rRCSxKg8c5ET9dLVK yhLcPzq2v/f16PZ9lb5WWm8W1ciXUZn/jfCsql+1wU+adp7jPFwI5CJP81qRnQFN3XFv+LfOAtcDZ 9L7XDQzw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:58042 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 1qfiqh-0008E7-2J; Mon, 11 Sep 2023 16:29:15 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqi-007TPS-BZ; Mon, 11 Sep 2023 16:29:16 +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 dwmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 11 Sep 2023 16:29:16 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082935_521119_3FE98CFD X-CRM114-Status: GOOD ( 11.33 ) 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 Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/dwmac-imx.c | 27 ++++++------------- 1 file changed, 8 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..d2569faf7cc3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -21,6 +21,7 @@ #include #include "stmmac_platform.h" +#include "stmmac_plat_lib.h" #define GPR_ENET_QOS_INTF_MODE_MASK GENMASK(21, 16) #define GPR_ENET_QOS_INTF_SEL_MII (0x0 << 16) @@ -186,7 +187,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 +196,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 = dwmac_set_tx_clk_gmii(dwmac->clk_tx, speed); + if (err == -ENOTSUPP) + dev_err(dwmac->dev, "invalid speed %dMbps\n", speed); + else if (err) + dev_err(dwmac->dev, + "failed to set tx rate for speed %dMbps: %pe\n", + speed, ERR_PTR(err)); } static void imx93_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode) From patchwork Mon Sep 11 15:29:21 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: 13379442 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 07F41EE57DF for ; Mon, 11 Sep 2023 15:30: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=e2BxfCpjmMeIX6hOuMFhusbAentObbpTaB9I4Qd/vzI=; b=U4LoMuHgoxSzWH jd2A6C0o4jeG7xehFv6h8hFCDgSk1gG4JD8qGCuNO2dLR+TD/baxeJ5JP/j2fdIjpCaBVavSMgtdR DzyTT/4aUS4+HS6/6GdX+TTLYC2sQ/75ODmruu/BENLq3Haj36i+Qps1cxr+oPkIDqdzf7cVU/kYp amZ4h6aBSzLC7TIynHz5F9SjCiNTBBtdC2rufnuBHsWARAD7KxvhWeUeArFQPfEljbBw+b7r8tmsS lki3Q3Qq4BteSr8p5aMrgz6iYZENiXzaaZTrqvb3nZ2mJAZG+Xy4wtrOxnhq1HuZRUOoxSEfVtYtw RO/fyAxTuDeCDi2Su+2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfir9-000tUI-1I; Mon, 11 Sep 2023 15:29:43 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfir6-000tRk-02 for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:41 +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=xxAFmOFPowfCTWnGhmAR1kdsvUwVwDMZvbxX5Uff/dU=; b=swjus+QVqUNsxtG/Im9quGFkm/ GTxFnWWnojOzz0C+F3mczCeJG9TnQ93EJs1W3sbF4LfUPZso44qoyJy/dFMSUVbSGFfEFBSRQj/l7 uK229TSsg9j7GJ2KblqeX2RTjBEIFLxqbf6sgOHUMDtGtyylTupMq7QmbLOnhzGlnqKqqySgZs4GC stvKK9CaPllVsT3ZTBsjE4I2BXsk27+x21dWOm1jahA80Bftb9zw1MaXiRO1SJiIBNBTszgpuWhpb 22XofLui+pVqBNVWiubDwA/SsUs0m1w4DRSiLj2eyiyFY2vmn46TDZj1nvha6ZInA6djXLpqmBAzn FpKvL7+w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:58048 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 1qfiqq-0008EQ-2d; Mon, 11 Sep 2023 16:29:24 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqn-007TPY-Gn; Mon, 11 Sep 2023 16:29:21 +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 dwmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 11 Sep 2023 16:29:21 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082940_057944_9FCFA26D X-CRM114-Status: GOOD ( 11.65 ) 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 Signed-off-by: Russell King (Oracle) --- .../stmicro/stmmac/dwmac-intel-plat.c | 35 +++++-------------- 1 file changed, 9 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..8cc22f11072e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c @@ -14,6 +14,7 @@ #include "dwmac4.h" #include "stmmac.h" #include "stmmac_platform.h" +#include "stmmac_plat_lib.h" struct intel_dwmac { struct device *dev; @@ -31,32 +32,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 = dwmac_set_tx_clk_gmii(dwmac->tx_clk, speed); + if (err == -ENOTSUPP) + dev_err(dwmac->dev, "invalid speed %dMbps\n", speed); + else if (err) + dev_err(dwmac->dev, "failed to set tx rate for speed %dMbps: %pe\n", + speed, ERR_PTR(err)); } static const struct intel_dwmac_data kmb_data = { From patchwork Mon Sep 11 15:29:26 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: 13379444 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 65CBFEE57DF for ; Mon, 11 Sep 2023 15:30:05 +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=PdhWOoBmFKMgwvMxZahX+eWXWKEbbXlSGrqk7ITPvxg=; b=pSa47GHFIBKVS9 /y540NycyPYram6QQckYGG+7U8Lcyx409Mfwv8S7WMc5EXTfpi1B9UFdAz2msRFqBT2G/TWnV5Bnq z2dRvMwDy7O7KOFFEE1QOV1sIVEdpZwmSxozOfC0LVdwM434rBAZTqTTPXhsK3CdlIX7s6zgY7kZI plklu8LDeBugbEtZBz/3T46VHvg88rkwdGEvO6XsbIbPyAUIq3G88EG+dMSRUlwAa7zYjYLZpcd+D wyGbewJs7vpxgFTVz5PJvqOi81ta3IbwzMcMasmEnXlOOgVW9j0KO6nITNuXIB2WCkhEFkNThJzxL rdDdzJpkIU3dQEDfEyeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfirC-000tWU-2Y; Mon, 11 Sep 2023 15:29:46 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfir7-000tRo-2y for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29: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=5Bw3V6l7OAdGCcXOYDDsqxqV/1ww1WRoNiEO2wv3Q/8=; b=RJiWET2MHDWctlVVcsFfn5ix1R m0nXj7KKH8ih0U5Y4kTSHGg6cN/NiPlQitQfMXT/oXvPXOzESoWSFVfUBSsVqb1q4W9bORGNXFHXa Ay41NSHe4Y9rhRXWEFyCcPGeD07jrMXnFeesGg8bgQ4BjlsojnzSh+POwkq6Qy+B8sqBXZAjG02gg qYGv0TGJVnxOS8f5GPZ1uq+gDXG8odvbCx81ozafH3a4CyjOqGA/Hq8e/HaH30046pZ8EUHHYRhJn MWU+74YnqeHkaIAL0FJ9b9OFd+xnpPQGtiMPXi6AQORKFLYnu/Pp9VIiOGBGuaZGSqREac0e8QPSV Dv8+pfFA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39316 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 1qfiqu-0008Em-2w; Mon, 11 Sep 2023 16:29:28 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqs-007TPg-LS; Mon, 11 Sep 2023 16:29:26 +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 dwmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 11 Sep 2023 16:29:26 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082941_978560_99DFA29A X-CRM114-Status: GOOD ( 11.94 ) 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 Signed-off-by: Russell King (Oracle) --- .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 61 ++++++------------- 1 file changed, 17 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..30172ca3bd06 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -24,6 +24,7 @@ #include #include "stmmac_platform.h" +#include "stmmac_plat_lib.h" struct rk_priv_data; struct rk_gmac_ops { @@ -1081,28 +1082,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 = dwmac_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 const struct rk_gmac_ops rk3568_ops = { @@ -1387,28 +1374,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 = dwmac_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 Mon Sep 11 15:29:31 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: 13379445 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 49E18EE801F for ; Mon, 11 Sep 2023 15:30:08 +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=sGoaw27n0rE5fH7TBrn5qIw21J98bHDxP4HivZbWkvw=; b=RtQVr4SI46fdjw r1cNJ1+CcL8y5PveID5Isyvr4kjOAMnhjtwm2gG7SfChttdAl32ey52qXAdqLAXEkSkZ0C95T/vCu lHjnyW+5XecCMKmwyqqzdGVzYlskvaHONA9lWnkl869pkEXQQ3y0tssXno5GaPkOTqVi2t14zoWko +1D7aB8lsAHDoA345SC9IDbTB/osJDbjA08RvMZFhu0BvwEnl+aR1HfFiPjjo5Tl3WykkbWTUAguN AzW0KscXJ9xHl+N+QFr4zr+OGwBUdicv0KjXbgWaD+ISSr6dK6oTwt0biODr1cW4C8McA0iRCLs0P /0CjxIISD5Mkc51sEiFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfirF-000tYp-1k; Mon, 11 Sep 2023 15:29:49 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfirC-000tV7-26 for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:48 +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=2UMKl9n6SLgFdjTeNxnsUryhc1R/WooK+tuMaErZ3oE=; b=sQz49DVOjuMAE64jkvHTULutx3 3PnTJRDmZh3EKIkkkwzlQ5dXDxuvOmXeJ0woodUXoMtr5N2jEEL76S/3JS2++BGK5xcRIxXTRRqy9 oRAlF6GfMdwm/4GMbsBjMLQgYRlAPmJAv7/7zEJhKSqLMBYh0Cv8ToVzlrjhRuPX/dP5+AdRTU0xC 7QD3winBsom+zmuAfOuxeK3rIkd41e1aK/l/7Mv3ustFd8YBKPGNjQCnQatGjeuYx7Eo/8Cknm5Pq NcYUxxX6LrkVgwzN0eSuK3JRAJ8lx1DinrhgCfVBlvLYJTtqvHPBdNxHI4q6KggwztB/NmJhghgev nE+2V63A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39320 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 1qfiqx-0008FD-1O; Mon, 11 Sep 2023 16:29:31 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqx-007TPm-QD; Mon, 11 Sep 2023 16:29:31 +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 dwmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 11 Sep 2023 16:29:31 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082946_701754_EA253AAC X-CRM114-Status: GOOD ( 11.25 ) 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 Signed-off-by: Russell King (Oracle) --- .../ethernet/stmicro/stmmac/dwmac-starfive.c | 29 +++++-------------- 1 file changed, 8 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..3dc04017e3d3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c @@ -14,6 +14,7 @@ #include #include "stmmac_platform.h" +#include "stmmac_plat_lib.h" #define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 #define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 @@ -27,29 +28,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 = dwmac_set_tx_clk_gmii(dwmac->clk_tx, speed); + if (err == -ENOTSUPP) + dev_err(dwmac->dev, "invalid speed %dMbps\n", speed); + else if (err) + dev_err(dwmac->dev, + "failed to set tx rate for speed %dMbps: %pe\n", + speed, ERR_PTR(err)); } static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) From patchwork Mon Sep 11 15:29:36 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: 13379446 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 5F1AEEE7FF4 for ; Mon, 11 Sep 2023 15:30:14 +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=DNNU/rZAxoAwx8uTgCl9XlxSpH1l8GIwq4Z5ERBPh5U=; b=e5jD4PJjQ0lE6f 0DroSszOwdX1ATpYjxPUAyGC1iUk8QDy9XwC+uE4412rznC/IeSee22ZWPSgU8WeZagYmPG8sAEbA yKHKg7Zm8vZTmB4itPrqTHJAW/b+/tOU3ZixiO8NJ8oiu7DqL6pJrcruCTOmwFNzwGb8lCboOuemC 6LNN98KpZSVcOcvMZtWEnNgNMWtAOESr+/L3RiFDFAwiSTj/bB/vMz2nZ9stmMt0ANbm+ZfIn1Uyx 3JhPrqBl1cb7SiLpdGlhxTiVexXLsBLn0riHDFEv4LzAndgDn/q+/gejdAevJQaxktrpYdUqRm/Ri 8WVxlkGuULHBtjx5PvMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfirG-000tZJ-0I; Mon, 11 Sep 2023 15:29:50 +0000 Received: from [2001:4d48:ad52:32c8:5054:ff:fe00:142] (helo=pandora.armlinux.org.uk) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfirD-000tWa-21 for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:48 +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=dXrJls0KWbEugGzjnIOny5aYJAM0fzmrBdmbDeg7HCA=; b=GW2t32hFPeEyNgoQFTqWEfL/DX t+PzvKDl1IsKj/WzzIe7GK7wcJ6Vxy5IJBlJPclQzHy+O97aZGosvg9pmoHJBbgMHQTdwzsadCyzS 5/hRN3awfrq7xI1HfmHKz65cw3AuVf3Z6veeVE3DcmGnPPU3p2/Fhashhjy2QAuNoq+r9P0JiS7LA B27UHX7tCeykDWkZ7raGVHOmZ89TGCNZvOldYzvBJM3B2/e+vxvTXxE4qp9e0ohAA1eAAR1f/gvQC wbj52whrDXNRJUesOBMLUfWiCU6w7XU9/15yLYGUCrTQytSjgbUPwHcZBEsLFecqFEGWWakxRegzF 7GDNoOOQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43984 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 1qfir2-0008Fp-0z; Mon, 11 Sep 2023 16:29:36 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfir2-007TPt-Uw; Mon, 11 Sep 2023 16:29:37 +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 dwmac_set_tx_clk_gmii() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 11 Sep 2023 16:29:36 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082947_661635_75B3D7B6 X-CRM114-Status: GOOD ( 13.04 ) 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 Signed-off-by: Russell King (Oracle) --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 37 ++++++------------- 1 file changed, 11 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..a8fae37b9858 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -22,6 +22,7 @@ #include #include "stmmac_platform.h" +#include "stmmac_plat_lib.h" #include "dwmac4.h" struct tegra_eqos { @@ -181,32 +182,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 +225,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 = dwmac_set_tx_clk_gmii(eqos->clk_tx, speed); + if (err == -ENOTSUPP) { + dev_err(eqos->dev, "invalid speed %dMbps\n", speed); + err = dwmac_set_tx_clk_gmii(eqos->clk_tx, SPEED_1000); + } else if (err) { + dev_err(eqos->dev, + "failed to set tx rate for speed %dMbps: %pe\n", + speed, ERR_PTR(err)); + } } static int tegra_eqos_init(struct platform_device *pdev, void *priv)