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)