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: 13385467 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C15461D556; Thu, 14 Sep 2023 13:51:53 +0000 (UTC) Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E411B1FC8; Thu, 14 Sep 2023 06:51:52 -0700 (PDT) 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() Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Thu, 14 Sep 2023 14:51:45 +0100 X-Patchwork-Delegate: kuba@kernel.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)