Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5690413rwb; Tue, 1 Aug 2023 06:41:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzy5LgES7Y1d/t0FXWmTXjolQ2Nw1m2o45N2uxVFUV9GGFKJesifsQeAFd3TxAZErJaM49 X-Received: by 2002:a05:6a21:4984:b0:132:a85f:b20c with SMTP id ax4-20020a056a21498400b00132a85fb20cmr13106901pzc.38.1690897265225; Tue, 01 Aug 2023 06:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690897265; cv=none; d=google.com; s=arc-20160816; b=mZ4HME+58of9qqw4ErPM+OxH5w7wF+yv2LBc2j4Z7lA6U7rjV1LdrhbCHP4Nc0Us66 SdLzBQUBVVYa7UP0bCY12oRew8iYeLWq4xnbC/4j7X5ANK6SwR7r58DmML24HI8cDq00 ZiZVQ/LDCCz9AvGPpOm9uwxYD1B0fTumBpvhwdwILMJ4/iBjVboGEX1sAZ2Pyyl+IRgj 71AeeOUCRo7FyTMG8WayFjPs8mySqyCub3pbTiZlxw52rkQwHeej7U7HZVpRtM1fRf6w dpnsLhL29/zSFaeVbt3pnRJk7lj4hWZU9kz3KmPMzB7WayxVRmv2ZzKirv+v704EJ1fR 6wDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=WxjVnUx2y1pygiIbgsfYPmbjlPhESd4/xb6DF3Rkir0=; fh=OUr36MR3gTBH42k6vhVvnXWGnjej7tlKiTsZB0fWXvU=; b=xwerXLs+ib8xCLUVM0OE1WF02OJLrSCGpJceFmhfmRnqxUgwqObKrjtzEAtm63SaW1 izAF+GB+X+vXW6XaINcwpxa31l9bkFHfY1jp90ZXhtlEZLWhHETqcwtU5rumatlSZwlw ytP+5/Cyyfywq5q+RyGjoRyr9vgssY3e0jlk6lpDuMLR5qgB69S5kHVAf9u18Y+fG+vy 82epgEnlrmQECamZunCTtugzb0n1QvwZq1JITjcY8v1tS17/RlXJPYO/O7hiYny78abS FoWBUdUsBa1BJRlZD7pWFcy9crED6l2UN+TdLP2O8z/AqaOwMi/raQW9zK1Q8W13ATS6 i42g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a633716000000b00564233887a2si6394101pga.763.2023.08.01.06.40.52; Tue, 01 Aug 2023 06:41:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231604AbjHAMsl (ORCPT + 99 others); Tue, 1 Aug 2023 08:48:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbjHAMsk (ORCPT ); Tue, 1 Aug 2023 08:48:40 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D35E6 for ; Tue, 1 Aug 2023 05:48:39 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1qQonB-0004wo-0E; Tue, 01 Aug 2023 14:48:01 +0200 Message-ID: Date: Tue, 1 Aug 2023 14:47:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.1 Subject: Re: [PATCH v3 net 2/2] net: stmmac: dwmac-imx: pause the TXC clock in fixed-link Content-Language: en-US, de-DE To: Shenwei Wang , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Shawn Guo , Sascha Hauer , Neil Armstrong , Kevin Hilman , Vinod Koul , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Jerome Brunet , Martin Blumenstingl , Bhupesh Sharma , Nobuhiro Iwamatsu , Simon Horman , Andrew Halaney , Bartosz Golaszewski , Wong Vee Khee , Revanth Kumar Uppala , Jochen Henneberg , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, imx@lists.linux.dev, Frank Li References: <20230731161929.2341584-1-shenwei.wang@nxp.com> <20230731161929.2341584-3-shenwei.wang@nxp.com> From: Johannes Zink In-Reply-To: <20230731161929.2341584-3-shenwei.wang@nxp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: j.zink@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Shenwei, thanks for your patch. On 7/31/23 18:19, Shenwei Wang wrote: > When using a fixed-link setup, certain devices like the SJA1105 require a > small pause in the TXC clock line to enable their internal tunable > delay line (TDL). If this is only required for some devices, is it safe to enforce this behaviour unconditionally for any kind of fixed link devices connected to the MX93 EQOS or could this possibly break for other devices? Best regards Johannes > > To satisfy this requirement, this patch temporarily disables the TX clock, > and restarts it after a required period. This provides the required > silent interval on the clock line for SJA1105 to complete the frequency > transition and enable the internal TDLs. > > So far we have only enabled this feature on the i.MX93 platform. > > Signed-off-by: Shenwei Wang > Reviewed-by: Frank Li > --- > .../net/ethernet/stmicro/stmmac/dwmac-imx.c | 42 +++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c > index 53ee5a42c071..2e4173d099f3 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c > @@ -32,6 +32,7 @@ > #define GPR_ENET_QOS_RGMII_EN (0x1 << 21) > > #define MX93_GPR_ENET_QOS_INTF_MODE_MASK GENMASK(3, 0) > +#define MX93_GPR_ENET_QOS_INTF_MASK GENMASK(3, 1) > #define MX93_GPR_ENET_QOS_INTF_SEL_MII (0x0 << 1) > #define MX93_GPR_ENET_QOS_INTF_SEL_RMII (0x4 << 1) > #define MX93_GPR_ENET_QOS_INTF_SEL_RGMII (0x1 << 1) > @@ -40,6 +41,7 @@ > #define DMA_BUS_MODE 0x00001000 > #define DMA_BUS_MODE_SFT_RESET (0x1 << 0) > #define RMII_RESET_SPEED (0x3 << 14) > +#define CTRL_SPEED_MASK GENMASK(15, 14) > > struct imx_dwmac_ops { > u32 addr_width; > @@ -56,6 +58,7 @@ struct imx_priv_data { > struct regmap *intf_regmap; > u32 intf_reg_off; > bool rmii_refclk_ext; > + void __iomem *base_addr; > > const struct imx_dwmac_ops *ops; > struct plat_stmmacenet_data *plat_dat; > @@ -212,6 +215,42 @@ static void imx_dwmac_fix_speed(void *priv, uint speed, uint mode) > dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); > } > > +static void imx_dwmac_fix_speed_mx93(void *priv, uint speed, uint mode) > +{ > + struct imx_priv_data *dwmac = priv; > + int ctrl, old_ctrl, iface; > + > + imx_dwmac_fix_speed(priv, speed, mode); > + > + if (!dwmac || mode != MLO_AN_FIXED) > + return; > + > + if (regmap_read(dwmac->intf_regmap, dwmac->intf_reg_off, &iface)) > + return; > + > + iface &= MX93_GPR_ENET_QOS_INTF_MASK; > + if (iface != MX93_GPR_ENET_QOS_INTF_SEL_RGMII) > + return; > + > + old_ctrl = readl(dwmac->base_addr + MAC_CTRL_REG); > + ctrl = old_ctrl & ~CTRL_SPEED_MASK; > + regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, > + MX93_GPR_ENET_QOS_INTF_MODE_MASK, 0); > + writel(ctrl, dwmac->base_addr + MAC_CTRL_REG); > + > + /* Ensure the settings for CTRL are applied and avoid CPU/Compiler > + * reordering. > + */ > + wmb(); > + > + usleep_range(10, 20); > + iface |= MX93_GPR_ENET_QOS_CLK_GEN_EN; > + regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, > + MX93_GPR_ENET_QOS_INTF_MODE_MASK, iface); > + > + writel(old_ctrl, dwmac->base_addr + MAC_CTRL_REG); > +} > + > static int imx_dwmac_mx93_reset(void *priv, void __iomem *ioaddr) > { > struct plat_stmmacenet_data *plat_dat = priv; > @@ -317,8 +356,11 @@ static int imx_dwmac_probe(struct platform_device *pdev) > plat_dat->exit = imx_dwmac_exit; > plat_dat->clks_config = imx_dwmac_clks_config; > plat_dat->fix_mac_speed = imx_dwmac_fix_speed; > + if (of_machine_is_compatible("fsl,imx93")) > + plat_dat->fix_mac_speed = imx_dwmac_fix_speed_mx93; > plat_dat->bsp_priv = dwmac; > dwmac->plat_dat = plat_dat; > + dwmac->base_addr = stmmac_res.addr; > > ret = imx_dwmac_clks_config(dwmac, true); > if (ret) -- Pengutronix e.K. | Johannes Zink | Steuerwalder Str. 21 | https://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686| Fax: +49-5121-206917-5555 |