From patchwork Thu Jul 27 15:25:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shenwei Wang X-Patchwork-Id: 13330321 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 4F7C0C001DC for ; Thu, 27 Jul 2023 15:41:15 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f5xYt4KK8J/v9u+kqY5tVWeGGWyj7G3i38R4H3J9zaM=; b=Sy2Yrc4pIcmF6F w7ygsZ7Vg/vFMuDBdcMeUFr/Ckhs5L2QatHJpIEqbSMG9g1K/tablMX0ZRfo6t1jASL/tax8m1B1E nnitVVAuvLgBHYikgWtTtzgPNid3FjglKqqdtXvP8aKTtNUR9myRVZXAMHJ7HKhX49ykRKVGoOJMn 1HAXvIVOfV7E4HHqSL39oark6frO1UuKHVr93TpJwZz+4nGXuQpFuUV7J29zg5UxTW7dFOyMCPapM Qd1Kwz6q/rDmMljZo0+FzT83MjsJbrOsdDbG374rWPhEzsIO4vldrNs2SkdhgwTvERXEOczSUPCUL LjKkYhqrmckN7sVE3ewA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qP36n-00G1sa-0I; Thu, 27 Jul 2023 15:40:57 +0000 Received: from mail-vi1eur04on0625.outbound.protection.outlook.com ([2a01:111:f400:fe0e::625] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qP36k-00G1oV-1C; Thu, 27 Jul 2023 15:40:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ACnDVclZpu3PdlECoxLgg0d/OUaNUMULAMnObIwE9GJ5B3DvdIXxDm8d/WbEWplRI09hLQQW2r+BERzJW0OVNF9u4PH4Ecs19acK38tXywfh9eZ3wqZKwiykESVHs7STbaTsTOGnVNqdn6EAGYCeELfWDZ4tv+yUO05UyfZrgN/Lvv9pPvrx55HVklUz/Aks9CQEzL+8vsWY13SVYvzcWs5a7JkG28kPXa5fWSKznYZaRiZIBWATQp4ykRRB+RJdVXtXrEKuotkDF5xFJm9zFnnJnD3/p7+70d5FjtfuVxk9YAY1umZnXzw8IORPu/AjBfYzDqcrRaGn9M70sQOdBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DnGeXiHXIDBm7s0zSh+ex4FGI2w1k84IOe+fdQrfUQc=; b=cbnGmkzgve2FUitgBvD8AdS3aak4+91PnRIE3x4dIzE9rkATVpCLZVkkdD3GefVS9fCspF2huNoFpVV47wbjZQYrvn12kq60IGfXCviAOIlD/+p16FnVc+NrTGVa0j6GW5eKNOaxToKaeagbZdfOZpqH8P/TPnR4c8YaJZPOmYmSlOO01Vdhp0LfPwNKcQv5BGhrymN/njddRqh30OLEZfzUrbkd1HDn2AFGSdpnvShp1aUmF6BtgvAm2cDm+vHu683ECv2wRTEIze3hqOqluqrTutb4anDHpAuZj4nl7wsKfY5BSV6erE1XD1j5s9ARrDgr6lOYG2SXoVNnGXOi5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DnGeXiHXIDBm7s0zSh+ex4FGI2w1k84IOe+fdQrfUQc=; b=d9vYQWTtuSUvJ3Cc+ToihoGfgttG1ppFD+9pKfp7IW4zlxzR3pZvTpS6sLqezLxk+MmMJ6ywv7lzzBvs/0RLyAuN8WsE/xZCgUD4z6BnNvNMKV/JInkgRdlyg1VEqoDDCF5I78TzYBgpdEph5V6TqML0QH7ApFvcjw8L/NQHe/Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) by AM9PR04MB8257.eurprd04.prod.outlook.com (2603:10a6:20b:3b6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Thu, 27 Jul 2023 15:25:39 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::d4ee:8daa:92f4:9671]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::d4ee:8daa:92f4:9671%3]) with mapi id 15.20.6631.026; Thu, 27 Jul 2023 15:25:39 +0000 From: Shenwei Wang To: 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 , Shenwei Wang , 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 Subject: [PATCH v2 net 2/2] net: stmmac: dwmac-imx: pause the TXC clock in fixed-link Date: Thu, 27 Jul 2023 10:25:03 -0500 Message-Id: <20230727152503.2199550-3-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230727152503.2199550-1-shenwei.wang@nxp.com> References: <20230727152503.2199550-1-shenwei.wang@nxp.com> X-ClientProxiedBy: SJ0PR03CA0284.namprd03.prod.outlook.com (2603:10b6:a03:39e::19) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|AM9PR04MB8257:EE_ X-MS-Office365-Filtering-Correlation-Id: 2406c8b9-6464-4d13-73b7-08db8eb5bb6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1HzAltImfwT2KWSEyKjTvWw93tLTtwwvGXKhw0yyubT6Fh4A3EP/pofhnHUqpifCqw2SE/+Z1osEhJmBLKZVrl4GTJrabRWkUzv9asLUilS3n9bJNoT5n9+3G54GPkYTFl2OUiGhzN3198xTGipXHD2kT++CrEganp+t3hyoaeMEjs5H842P7qHS5lRXa89LveH+wYLANUoQ1Ivtv8TtMW68yapKeW82n8Qo8nRf79XK2aU9xX6QwAUFdxRA1qE+ghvCg4iroXl7qoKVg8o7ycacGosi+s0mR+mNmL6V0SHjdRy54xV2ble2ezq+5VSERhqtsT74e8LbHJe/81b9iBOKZx8y7zFvPvyRpIvju7dk3pXUXJgyWm6za+/XKTJkkMAr57NDEBYuQ6Sq0ZGl4pcNSqKfQcPK6/nJ5JLia/FB0jkds3G7HmmJSahUP1yvd+HgxIq8uiuvjO4kkRpaotMH2D3kXHi0gFk+zEYOdzhF8GxsAZju9yxMp1U9ksUMIn46rLxMB4u/LhVMXYop2bEOuPV721iTkjP/+hghttSwGhW1nxaTMY6FlzYVXIEuTUtYqzA/gEwjYjOx9bwTA1U7Ag91uTm1lxIce7xmz42Nfw95QczzwdDwAxrgcP8X2Uzyrw5lP8cC6kiZwSGTtQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9185.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(366004)(346002)(396003)(136003)(451199021)(316002)(2906002)(8676002)(8936002)(7416002)(7406005)(5660300002)(41300700001)(44832011)(36756003)(86362001)(6506007)(26005)(6512007)(1076003)(55236004)(6666004)(921005)(478600001)(52116002)(6486002)(83380400001)(186003)(2616005)(4326008)(66476007)(38350700002)(66556008)(38100700002)(54906003)(110136005)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qiWK1I4S9TV3jFnT3UlhNIfhqxYTgRO2uJ32epQdKzr7vdvJi8Tzik2CmV4Yl/24b600tFS0AF5RNGYkMM/pyq+gp81CTSKYwlWfr6t+aO+asRMxw/mow+amJVt5fpmWBtZPCiK+pTYTsNR8eRa1zE/Uig2Kl4iqh7iamZrxIq3t917T5nXlo/tCUhGGVZnAX6RKbl0xFy22bl60tw9J1Z1jakt0AaEoji97aBREHIjfQkIAqCRW7okx1nKajS6unHddfvsbp8Ur6zdhGXG06zrhaJfSJ6OmjSHKQ5Ucu+0Oxoszgjxz7JAnLaINg+kUIDU/oZxjF6X6j++a9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/pyPryIcdMT6O0A0cPUgUvM3D8IUIjcQqb0uU2GzpZXZUwfMZkvosGQUI3soUOC6A6igJvxCor43EcWNzrRlZZEi+hxGVLCrV5FnRreDb85d3OmouGO/CUSI41fVLLp113anLbYG5uiuauB2keQkrIj6GxQeN4F3IrVGBqgS7LW+oketmrhEJSoyM7Qyy1D X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2406c8b9-6464-4d13-73b7-08db8eb5bb6f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2023 15:25:38.9832 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oZqQqDflAO/+LocWExD9G9Fnw5JoKJCmrjMOtwBNuNVYSovyGQDgMJcLuhHNkafG8j7VQhNzYaE3ArNfiN4Z+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8257 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230727_084054_425461_CB1FB982 X-CRM114-Status: GOOD ( 16.34 ) 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 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). 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 | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index 53ee5a42c071..e7819960128e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -40,6 +40,9 @@ #define DMA_BUS_MODE 0x00001000 #define DMA_BUS_MODE_SFT_RESET (0x1 << 0) #define RMII_RESET_SPEED (0x3 << 14) +#define MII_RESET_SPEED (0x2 << 14) +#define RGMII_RESET_SPEED (0x0 << 14) +#define CTRL_SPEED_MASK (0x3 << 14) struct imx_dwmac_ops { u32 addr_width; @@ -56,6 +59,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 +216,44 @@ 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_MODE_MASK; + old_ctrl = readl(dwmac->base_addr + MAC_CTRL_REG); + ctrl = old_ctrl & ~CTRL_SPEED_MASK; + + /* by default ctrl will be RGMII */ + if (iface == MX93_GPR_ENET_QOS_INTF_SEL_RMII) + ctrl |= RMII_RESET_SPEED; + if (iface == MX93_GPR_ENET_QOS_INTF_SEL_MII) + ctrl |= MII_RESET_SPEED; + + writel(ctrl, dwmac->base_addr + MAC_CTRL_REG); + + /* Ensure the settings for CTRL are applied */ + wmb(); + + regmap_update_bits(dwmac->intf_regmap, dwmac->intf_reg_off, + MX93_GPR_ENET_QOS_INTF_MODE_MASK, 0); + usleep_range(50, 100); + 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 +359,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)