From patchwork Mon Sep 11 15:28: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: 13379435 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 F2533EE57DF for ; Mon, 11 Sep 2023 15:29:24 +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: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=65kC/OuZsJOtkLhYdmwgd9CSu85rLBEPeREb7Fys5Eg=; b=ZkABlwXeiZGE/5 npqyqMRM5IqoxMFttr6Wmw6PL144yJgJu9PuwR/2beWqNB5I0T6Q86alfxaNpvrDVrFf/XGbROTej lYr7Smu8Tb72gR39vukHKe725ugRm5v+vIMVJOvV+56NQvf6ajDAC905zcs31zl7Iq1roJ32rvy/V f3WjWbapIdMhKLIOIDqlfxVzoBs8XLYljf/W7Ag4Xetl3qwRyHEiz0O4pbfrkndmLiqJPO/vUyB8q 85IHeMxFe179D4Ma+sXQC/72GQxcG6d3RtwajMvpgmB98K3LzmcS+KX+nz+QXqv0IdkdDGqlaIk3m g+iPndKMPkUrtP+CJE7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfiqP-000tDa-0d; Mon, 11 Sep 2023 15:28:57 +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 1qfiqM-000tCf-1a for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:28:55 +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:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=P6DsgJ0EF8GDgyic7GQZdDjnAhVZ69mVqqsinIQxsnI=; b=xZu3Ajjq2TSvy0DyIJCfkWSo3k 7br7UoFE1XZmxm0LZPslxVl5WlKtO0zNzP8jZUZn4Jefzkq3tqRdEM3PpdZu1+SAuegInzBDn5/k3 7BUf2CFw9jyeSA8B88ekRLYE81o94jBtRcEkiM8rvUA5CwDrXBNS9vJ0QNwHFK6SqBM35GtTDPlW3 t1oiqyAHxta6r1R41wrx/OaqBetCbZJz3VVS1vQ4Z71jCVNokwNI2qQPImYz2+59N6Yla55ST+0zm yFhg6D8WE2nUMcNzufxbPZhl5dcwbfg3iMXn/DldsWreh2uFhJf1pte5RrR3lXzS2swfMsAT0kgac HHpFES6Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57004 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 1qfiq7-0008Bi-1y; Mon, 11 Sep 2023 16:28:39 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiq8-007TOe-9F; Mon, 11 Sep 2023 16:28:40 +0100 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:28:40 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082854_548182_02BBB167 X-CRM114-Status: GOOD ( 13.66 ) 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:28: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: 13379436 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 774CCEE7FF4 for ; Mon, 11 Sep 2023 15:29:25 +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: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=/fMMiat8Cl/8/Zv/fITdXG/rzufmPmBdHOM29m0fp/s=; b=JsO8QcpDkqEowN QJP0P+uZJcpiEH8sweEWgdOZzYM+9mGlL9SWNgF6UVBTl+XDcn8/l+3UzvzoQ7lPVlskIknjd7DSl el5o+foZLu6O62ue722wWO4KTvWkNE7wMA7VXBTvZWxJxOWZqa0ElIx7Aftt5dgOEN+LQ3vr0XOoZ LDuJZp+dHLSndc1tf/b8oXs2jeQd4rf+ev8vQXmlodUHCkqZBz0lD5tyMY7wY4smwVIRoNnFIs49g MsgWQxq1+kbRLe7BhtT+2EjLinl4i/bGLTIqXvf7Kh9kQTeiKmAxoN29+rrogzRUIb27f+hQm+g+s QbtnY5DEpdnWAT4cLEvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfiqT-000tEU-2f; Mon, 11 Sep 2023 15:29:01 +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 1qfiqO-000tD4-0F for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:28:58 +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:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=n8j/kmn+Ia/Kfu9cLc90F6mFrEGGGfC9nZYxAWE9saM=; b=wCwejzc2F9nHFGVle8SODF74qO f6LYiM9drBFbzuPIlU2b8/iRxadKoeytX+FfSp1gP59Z8q01WsrjAQPqJTllKTRtKk6nb5wpxw4ld +dWJljKpsqfHRo6H5OGaYMQhWM1aFJ4K+2/WPeSLNyuMEy/7fmBONa8s22lx2R0Gf0wnu1y6Snxf6 0g8B7M2MGT7DvvAdCYr1kuNE+9eQ9sHecnlyVvY4ejtSrM+nWo/SS7rgdCFpb/OCNCl1xaGu6hYk6 tyPQYLzKATKc59bddK7V4B4J28gjK4/C82+LF2wqCddc6ri8zIqHHMKx7NMnVKRZCFBoosdFg1QHk 4HLyQXYw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:56330 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 1qfiqC-0008Bx-2L; Mon, 11 Sep 2023 16:28:44 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqD-007TOl-DS; Mon, 11 Sep 2023 16:28:45 +0100 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:28:45 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082856_112723_C5D6AA2B X-CRM114-Status: GOOD ( 10.98 ) 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:28:50 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: 13379443 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 C076AEE7FF4 for ; Mon, 11 Sep 2023 15:30: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: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=e2BxfCpjmMeIX6hOuMFhusbAentObbpTaB9I4Qd/vzI=; b=MOUfwS0JibZ70a J/DOaSNWY+qx+ZN0JW9LnnOBp80NvCY/WUjD3EBgbpV1ys3vvmrFbF+NtM3PPa6vKJZGVpIY6RbyN kWDxOpacLquwkrIBbSwo4nCP5B/iEzYCJxLpwF+Pa8fOCC56YrOL5YRtQp3dWMweXZXvK17CT4YwS KCdxQpwspPntOSLgSe29MQUZWVSggnxNbQeJt/1warL7jNy7wF4DkSYF5jX+yBRgsh61pr1lJmIA+ Ow++dRLKE3aA6RjOQamsHyIL4TEygrbzZmgXbsLfKLla2/1E/9gUrPvA3scY1J8WVlBwixsv2Vyyn CgdvVZj75juHuTYdCvUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfiqe-000tHF-23; Mon, 11 Sep 2023 15:29:12 +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 1qfiqc-000tFc-0E for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:11 +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:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xxAFmOFPowfCTWnGhmAR1kdsvUwVwDMZvbxX5Uff/dU=; b=eIPOXqcFyI5TyK6jXBjbR+q/bB +Yq4ylRiCzg7JFuBzoo0H+AAWYrLg1uR8jS/wZsUvirsyZOvvGzU6+GxgXoEmT16vg4CIZuOxle02 oasmcnPKtXnNCvGyg9kir4eJ1Ll8/Rju/KZjphrp123Ne0HAMuBMVHLvh+lj8PwBhkeNy93zYhtmt QPI3fH2mHWNpvodJ4K8wbzrZdAw3FTOfqH63B2z20NQ/A4RD9tuhp3OeToKpqcpHmbIR8OG/hh93k jZAXclKzAe5rf5LP+Okwu206Lbk3jT+mmfFMQDaMJJ3j3RkZyFn5xviNHuT9+/52EhJ0OdJgAwXXc r9LD3XxQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:56338 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-0008CF-2r; Mon, 11 Sep 2023 16:28:49 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqI-007TOr-I5; Mon, 11 Sep 2023 16:28:50 +0100 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:28:50 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082910_104998_09D96F67 X-CRM114-Status: GOOD ( 11.30 ) 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:28:55 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: 13379437 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 AD1CCEE57DF for ; Mon, 11 Sep 2023 15:29:35 +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: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=PdhWOoBmFKMgwvMxZahX+eWXWKEbbXlSGrqk7ITPvxg=; b=sO4cC9ADu1Ql+d uJQ0DxfoQF9QuZn4JCZVl+QBud5AvCi7O0FJafcKw9CW9SmBObA2K6F3TdIXP/gawUByNtloKhXhl SZ5CEYwD6Sb5er1/sAXiuyIOXcYAFIAaJbUyqCF+YHNTIwq/QIh8BYwSqZJDpsK4hsb8ZpQMG+zMz WhxutQ7GjIunWu8fLrFUbcuvToa28Ws0ke6t+8d3W8wUe/BcozvElV1y7DVVcBH5fRq9MOBMh/Sk4 kzGX1VsrNXZWOkdZEBCluhQ1qhpoqKZ6p56KInUvgPVGIe+CLggPxd1TxiyGV04xA3BlP4u4uSrFT 53C8pSQjgiqKUa/Z0AuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfiqh-000tI1-0q; Mon, 11 Sep 2023 15:29:15 +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 1qfiqe-000tGW-1W for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:14 +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:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5Bw3V6l7OAdGCcXOYDDsqxqV/1ww1WRoNiEO2wv3Q/8=; b=DfoA6Bup2Ibmll4Kg6OopirYQF ZCcJvC5k2l422MRSQDMAT0Dum8ewrb+DTsGvdxOZ7FyzfVtPd4HZlDo1ME0bEBQniXxDwT6D0ok9R KQSBL77cJE7QI3qsinx6LxIsOooo+mdTf/SJ/i0RJFtzBUB56BEdsb6WgBZqluoyMQwTPwT+3ClAh XAWFS2nPjj5l3rcLRys2g9Yib5D6QMTgFb5QOHAmyjJCpo+hSeC4Mc5a8qc6yrdm8ZtJHp77sO8bo 6xwDeREsx81o4ITRj5h8Isa6G3qoaQJES58wCCFRwR6CRQAb6JuCfxr5lNmHBafG6EdlGScoUjcrZ kX4DYYFw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:53338 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 1qfiqN-0008Cd-03; Mon, 11 Sep 2023 16:28:55 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqN-007TP3-Mo; Mon, 11 Sep 2023 16:28:55 +0100 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:28:55 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082912_509155_C02C5AEB X-CRM114-Status: GOOD ( 11.49 ) 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:00 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: 13379438 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 12739EE7FF4 for ; Mon, 11 Sep 2023 15:29:46 +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: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=sGoaw27n0rE5fH7TBrn5qIw21J98bHDxP4HivZbWkvw=; b=UqnH4LhtC/e0Ls UIPZobXKDmx0flMxnf6TqzaArTyOYh7NPIKOG4J2LsMSbcpDcrW2xwtkAEi/HD1drZb+Q2dDJ7GOa 7aF86hlh62NTaTt20utLLe/qjziTfS+R+qOo4H4iypjlmGzjEVBtnDPCVU//cyNwmsAikpGakPdE8 jjAd8d1TwJfativn6QnInLTZahI3e1QAgRCmD4ZupDk0zzWyzqMzrQuM/jR9QUVMqRhxjXNV9bkMj xPH1RkgZ/e5A1J+a0BhOvEqp2nosxyWtwCVhCO/XPxJDYOoh3OQGZ0TKljJHGy9GsoIXj016L3+zk Cmsc2yjKRm/gF08m/SGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfiqq-000tLO-2B; Mon, 11 Sep 2023 15:29:24 +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 1qfiqo-000tIn-0r for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:23 +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:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2UMKl9n6SLgFdjTeNxnsUryhc1R/WooK+tuMaErZ3oE=; b=qEj1+bc93rj+0epYihxDOqx4/Z mABGVEXvtjKGP28VeYvOHb8c5lYoO4rO2u9cdMXUQHxwHCUK1AMgxyFAUlfGmkpjpsCEuL/C/ajLo AfdJtzm06H66VbnRnvBf7WF9ZCHfBxo/dDdw+J4g/r+zdhm1uDUySpQRFA29lP5sBfPjIvomAgNLQ T3iQo/jbcMsXN+z3hmCS7Kk9hKE0FYFTH7twLVnioR87uRRjw6MShRTuwHL+OcW+VtZlQPGBaKvsH /hXW1/XZKncoZCgLmFHmD7AWVGr2Wx8gTOzBxTEcs83sR5qD93Fjjz0jnxRanANuHQR3WsmPbIl8X dZ33r9YQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:53346 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 1qfiqV-0008Cu-31; Mon, 11 Sep 2023 16:29:04 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqS-007TP9-Rp; Mon, 11 Sep 2023 16:29:00 +0100 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:00 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082922_303693_1C884355 X-CRM114-Status: GOOD ( 10.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 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:06 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: 13379439 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 F3C83EE57DF for ; Mon, 11 Sep 2023 15:29:50 +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: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=DNNU/rZAxoAwx8uTgCl9XlxSpH1l8GIwq4Z5ERBPh5U=; b=wPDZPp13WfG4pf 7Qn9djVCP4YXvz+KnsK8gjwvfT18bRGtMyYNOh3gXH21pqLb36ctC51RX2DdEB+VpL6FVakddLIiT L7vW/f/rftKYHc9uRYyv7zuv+acrA/spiihffRGSGMDer0VR9abgeyZFplsA5ebidgjsrfJUE1R2/ v7LtI2whzcD9NU6NcY4Wbf60TKzxyA/almYe+lxvDjgjGGJz9UUqdiz0H64sTVzuI9EChr/qGY8F2 jfPHFJx/zPWq5n+ceWB+XuRyTfrXJaolTukCOiVimSgIubKz4RLHGwgxIpK2Dusl3OGnajVTAL/01 HF7NLldqvgk4AXXLHwog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfiqy-000tOc-1L; Mon, 11 Sep 2023 15:29:32 +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 1qfiqv-000tKu-2b for linux-arm-kernel@lists.infradead.org; Mon, 11 Sep 2023 15:29:31 +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:Reply-To:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dXrJls0KWbEugGzjnIOny5aYJAM0fzmrBdmbDeg7HCA=; b=BveGPcgcG8RVR4PGBCXXGT63QF QNhTdMNEQQUfo+Xd1DMbx4H6b943q4S9sjiuQLfo2yNhIUwtGeHf8q9jwrdQfvsp0LjRoNLGctpWA VX7C9H4UyW26wabScfmcgoMRSscvKTxGFivX1dN54U0jr8YUPotl7tTncDgnUB1AYO98asfw/jWMU eYMDY06iUjQk5XTdWHiVoiTY0BEk2oJVc2FcOmQvfVmQlcuNuj7Cr77RuLSqLnT4USV9BDojOVMnF C8O8QLyRqQHMIrCvaKNxQxJyvjGACSvOuV88G2RkufJwziaYnqrtaEYYU9+kwxZJMqKgnmUnHFbkE m53krzJQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:52148 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 1qfiqZ-0008D6-1X; Mon, 11 Sep 2023 16:29:07 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qfiqY-007TPF-2f; Mon, 11 Sep 2023 16:29:06 +0100 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:06 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_082929_842265_2417C366 X-CRM114-Status: GOOD ( 12.69 ) 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)