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)