From patchwork Mon Oct 28 20:24:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854070 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 063511DEFCF; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=oylZ/dXYShwT8/bh0XLjR7czUZ8/y6dssAZpD68PSL/Jl939VFKYAus/pE17kDNE1VxgaOcaBBmIcy9kuMVtA4rFF365/lVow0AN+pEttow6LRlY6ELY93W+hU73lTg/Wem1CKBjh2auIYmCd4x1I7oHKfy6B1ozvfj3ajjarqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=IpWxsYIfuuTJONyY6RJYpXgwIN5saxNVQGws4EoHP+4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G0GCIOBkn1BfmE0jQ6XNA5dJQDOSNa1zVr5lsVLKpuiM+YeIU6iiRWVDJVvrXDKLpnaIs8ba3yE+d6I1WtigjA2ggy92vJ+WdAUGnSRkEWaxyMQP5OdFaJf6fSIWixkzpV8oKOye9KY7K0dQ2wFvg+JzL32IRy/qL0kTkxLuTyI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HGbf39fZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HGbf39fZ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 40548C4CEE4; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147127; bh=IpWxsYIfuuTJONyY6RJYpXgwIN5saxNVQGws4EoHP+4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=HGbf39fZcUR5w52xcBPt5CiRR5TRL6rVTEWozmT0bffEKwL3/RgENSxi+cg+PIw5K 2HLwexEaa6A/OVsST91Pz8FPxvkluSWtUa0/HsUdf3vt68RJR329SWkDR6WGucRwau fXwRvn480kuJUmXZRk7bQn876V7SOPKlPO8Grg7BLdcyPggvDw81ummZgkOIKZBY74 vCMOZDG26w2aJcT3zUOeyquaG7s3lBhOO8hO1qqowcG3ZgdxGPJgFBw/tHFwejhxCJ mgqkPvSgjiAYHN4RKcNc9G23YYZ4nH/4++UQvY5ahNj0FsFiuCWyv6Hyz3h+a41y3m vXckUiDjYln3Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 221B2D5B148; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:43 +0100 Subject: [PATCH v4 01/16] net: driver: stmmac: Fix CSR divider comment Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-1-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" , Jacob Keller X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=958; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=YCKaeA/xV5exOeaV42TsvtvrFwKq5QOyi/twLXcBhk0=; b=ly73UvyKBxNkbGRXT/qdaY3nCOHU7De4UENA/7q8MZSZVdSurII2+gCsPJ1K1eSuNRTS08I8H kG3WG7uEmLBC3LXms0bijaX87ZVNyhEgu2KkS8tR8XpIif86lnim32n X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com From: "Jan Petrous (OSS)" The comment in declaration of STMMAC_CSR_250_300M incorrectly describes the constant as '/* MDC = clk_scr_i/122 */' but the DWC Ether QOS Handbook version 5.20a says it is CSR clock/124. Signed-off-by: Jan Petrous (OSS) Reviewed-by: Jacob Keller --- include/linux/stmmac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index d79ff252cfdc..75cbfb576358 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -33,7 +33,7 @@ #define STMMAC_CSR_20_35M 0x2 /* MDC = clk_scr_i/16 */ #define STMMAC_CSR_35_60M 0x3 /* MDC = clk_scr_i/26 */ #define STMMAC_CSR_150_250M 0x4 /* MDC = clk_scr_i/102 */ -#define STMMAC_CSR_250_300M 0x5 /* MDC = clk_scr_i/122 */ +#define STMMAC_CSR_250_300M 0x5 /* MDC = clk_scr_i/124 */ /* MTL algorithms identifiers */ #define MTL_TX_ALGORITHM_WRR 0x0 From patchwork Mon Oct 28 20:24:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854071 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 063AF1DFDB1; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=tMZqBbxcdf9LiFbDi6okjrbkvnNKjdgBJTGQZLPWZzhPfVvlkMV3+mkq/+ymxgYRmDfHi5jY0SXnlCnT+m8Oh/ozlfDjG4c6oBiImkp8pbL07/bVnQcax9yjPI24TUEPLN17Qwhd83G5mOLxf/MDf5YKtgr2tbR6SSyMmVpVrlI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=/HY98JCmDq6A/RzqUc/7qBJZ10w18XtngjjYcjamv2s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NocYtNG0ZQYEav/hty3NNscNTsEqpkDt0uE2LOnlqCvNdGG5360dWDrJWTlk20lSRgFR3Mr6pvCmdK2fawn7LqS9kTBRazUUGFJJ+RVX6ibRN+lji4orax53a0m3sf4nRZD7LfQJ8ab8MJK8JoW2oX/2dFYYsoy9GBDnFEPrvuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WX+E3Ik/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WX+E3Ik/" Received: by smtp.kernel.org (Postfix) with ESMTPS id 59C06C4CEEB; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147127; bh=/HY98JCmDq6A/RzqUc/7qBJZ10w18XtngjjYcjamv2s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WX+E3Ik/uBCXR8/6xR3qvCiO4ra1i4nI+vNgb2ZwyauFxDDVfXtjOnvsLkhROpeh+ MZBx09sIS/bVS54xkij+DRHO4U0i2UGrUpV/TM3qZTrjQK/Iwt95XtcMiH6s+eYSI+ Uoc+M2HyuxVFOFaIQA+GRZ3kSfpbSgBNCd9H52jEGFZDykWTez0/Ro/0azE1S3bp9o 8ECdFYoqATcdGV23F2cGEeo9xM4F/mmtn6FeXQaspeidM9K1gF4Plq+t2SwB33SBWz QI7jrBtDQ9jlr28XR54QAxqybvwJ1UN6f10nf5h6iinv3pgfWgYcBOUlBuFhNlJruE jKYHsNWBBf1lw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43A77D5B149; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:44 +0100 Subject: [PATCH v4 02/16] net: driver: stmmac: Extend CSR calc support Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-2-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" , Jacob Keller X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=2225; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=KCikXBvga2oq/pWon5eW8eJjp8QFlxmOB2nCnbje1+E=; b=SGGNw/CNGfDX9F/CKENWwskdnN4MUmkqyMd8shB0xX+pYitRmj6H89hGhdPvF0LcezEWcRcxR t+6JqSFxz5EDHY3+6TzTuRF0sUxsilEdS2PixMGSSr4yvzOjW9xW8BG X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Add support for CSR clock range up to 800 MHz. Signed-off-by: Jan Petrous (OSS) Reviewed-by: Jacob Keller --- drivers/net/ethernet/stmicro/stmmac/common.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++ include/linux/stmmac.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 684489156dce..e364cf99d1ff 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -257,6 +257,8 @@ struct stmmac_safety_stats { #define CSR_F_150M 150000000 #define CSR_F_250M 250000000 #define CSR_F_300M 300000000 +#define CSR_F_500M 500000000 +#define CSR_F_800M 800000000 #define MAC_CSR_H_FRQ_MASK 0x20 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d3895d7eecfc..f9cab62cfde9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -324,6 +324,10 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv) priv->clk_csr = STMMAC_CSR_150_250M; else if ((clk_rate >= CSR_F_250M) && (clk_rate <= CSR_F_300M)) priv->clk_csr = STMMAC_CSR_250_300M; + else if ((clk_rate >= CSR_F_300M) && (clk_rate < CSR_F_500M)) + priv->clk_csr = STMMAC_CSR_300_500M; + else if ((clk_rate >= CSR_F_500M) && (clk_rate < CSR_F_800M)) + priv->clk_csr = STMMAC_CSR_500_800M; } if (priv->plat->flags & STMMAC_FLAG_HAS_SUN8I) { diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 75cbfb576358..865d0fe26f98 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -34,6 +34,8 @@ #define STMMAC_CSR_35_60M 0x3 /* MDC = clk_scr_i/26 */ #define STMMAC_CSR_150_250M 0x4 /* MDC = clk_scr_i/102 */ #define STMMAC_CSR_250_300M 0x5 /* MDC = clk_scr_i/124 */ +#define STMMAC_CSR_300_500M 0x6 /* MDC = clk_scr_i/204 */ +#define STMMAC_CSR_500_800M 0x7 /* MDC = clk_scr_i/324 */ /* MTL algorithms identifiers */ #define MTL_TX_ALGORITHM_WRR 0x0 From patchwork Mon Oct 28 20:24:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854074 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 064AA1DFE29; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=NkrcTbMolemzUY4f1R6jGzGLn83XuNs5XgSIOSl8r6mbcG4RIvdWLxTm9PTRr1QK7dGR6teqfhUhc8bGTt+6dWLjx7uxLPrrVFnHkXSyrdERDw3mYJaASZS0CNQQHW60lSSuo51iONF/rH3QxbT9P3Z4GVU+O9iNUa7heq7S+wA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=OZDVkvTogOfx1SNJNUbfKqTdC9MuKfRnBJm0WNCy4MM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R3foVwzy1cjwsbP5mkmBXEsK6Ku87QaErx8KHXInmAn3Z8PKj4yxgAbDONUfF8FhwqJpQ0cBQgDVpMoTpHHqLaV6SuCPab7Z7M2+wSugcX5LhpSC/tBWJkKC9t8WlxT6rwoz3jG2R7vkzRSPDTxWHfLTg/6+dO9X/0xbfp6i5Ao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IMKqLMpm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IMKqLMpm" Received: by smtp.kernel.org (Postfix) with ESMTPS id 720A9C4CEEE; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147127; bh=OZDVkvTogOfx1SNJNUbfKqTdC9MuKfRnBJm0WNCy4MM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=IMKqLMpmGRwdB4zLaQfP55LwhuC0E1MR+Cco9y2sU/PwCesozRBmHW+Yu8b/l9m31 Ha749Qqld+LULF5MZ4e6JV4VF0Aipm+4ez6J8X3ywRz+1/TFLJbWlLVSS9GeK1fgto sptEZtSTiNRUMm1b377bsJQOs5osMCdLHleU4fpNAvdz0DgQCZilHkrbQCw+YBhB9p XJmXXo8lZ+GOA64e1U9rFWYEN5SBTbPPc0JoYIsPHzYdnq+33YGMJ1SM9Q8/6A+3i1 +ISM36o0yhdr4qtEAgFmuCNdGZSTxoiWypSTMrnubNqpCTI2eSEBrVXWOnZPlireM2 bN9D4JnweJ4hA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 635D7D5B14C; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:45 +0100 Subject: [PATCH v4 03/16] net: stmmac: Fix clock rate variables size Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-3-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" , Serge Semin X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=4015; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=mIeNJiyi6n/Hv9ZOI8kShW9icHU52wzue26ciP45ipU=; b=Gq0zrfkI7D01BXGuRtdqFuPEqAqrensYEbGc03Y4h+KANlAYXmPET/TUM0l3glKNVxIkYkkDU iz21jQPRNyvClD/B0NIaDboiSpaqhXW3Aed0j2/3olgRTPZutqbdWWx X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" The clock API clk_get_rate() returns unsigned long value. Expand affected members of stmmac platform data and convert the stmmac_clk_csr_set() and dwmac4_core_init() methods to defining the unsigned long clk_rate local variables. Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn Reviewed-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +- include/linux/stmmac.h | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 901a3c1959fa..2a5b38723635 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -777,7 +777,7 @@ static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv) netdev_err(priv->dev, "Failed to max out clk_ptp_ref: %d\n", err); plat_dat->clk_ptp_rate = clk_get_rate(plat_dat->clk_ptp_ref); - netdev_dbg(priv->dev, "PTP rate %d\n", plat_dat->clk_ptp_rate); + netdev_dbg(priv->dev, "PTP rate %lu\n", plat_dat->clk_ptp_rate); } static int qcom_ethqos_probe(struct platform_device *pdev) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index e65a65666cc1..ac0b02783889 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -26,7 +26,7 @@ static void dwmac4_core_init(struct mac_device_info *hw, struct stmmac_priv *priv = netdev_priv(dev); void __iomem *ioaddr = hw->pcsr; u32 value = readl(ioaddr + GMAC_CONFIG); - u32 clk_rate; + unsigned long clk_rate; value |= GMAC_CORE_INIT; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index f9cab62cfde9..dd155dd4903b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -300,7 +300,7 @@ static void stmmac_global_err(struct stmmac_priv *priv) */ static void stmmac_clk_csr_set(struct stmmac_priv *priv) { - u32 clk_rate; + unsigned long clk_rate; clk_rate = clk_get_rate(priv->plat->stmmac_clk); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index ad868e8d195d..b1e4df1a86a0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -639,7 +639,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) dev_info(&pdev->dev, "PTP uses main clock\n"); } else { plat->clk_ptp_rate = clk_get_rate(plat->clk_ptp_ref); - dev_dbg(&pdev->dev, "PTP rate %d\n", plat->clk_ptp_rate); + dev_dbg(&pdev->dev, "PTP rate %lu\n", plat->clk_ptp_rate); } plat->stmmac_rst = devm_reset_control_get_optional(&pdev->dev, diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 865d0fe26f98..c9878a612e53 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -252,8 +252,8 @@ struct plat_stmmacenet_data { struct clk *stmmac_clk; struct clk *pclk; struct clk *clk_ptp_ref; - unsigned int clk_ptp_rate; - unsigned int clk_ref_rate; + unsigned long clk_ptp_rate; + unsigned long clk_ref_rate; unsigned int mult_fact_100ns; s32 ptp_max_adj; u32 cdc_error_adj; @@ -265,7 +265,7 @@ struct plat_stmmacenet_data { int mac_port_sel_speed; int has_xgmac; u8 vlan_fail_q; - unsigned int eee_usecs_rate; + unsigned long eee_usecs_rate; struct pci_dev *pdev; int int_snapshot_num; int msi_mac_vec; From patchwork Mon Oct 28 20:24:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854072 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 064041DFE00; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=mczAopYWxRndE4cq4hc2Z5nK252gqb8Xe2TEjx8rQPUWM45xtBhmRjztIk97uq8mE2FGQU9rj61o6D0lOd+unCxm6OBANq6rHtc8JHvE2tvZ8m96dfRX568rD2X2yIsDWusPkHwjPUHCZ2z3VrxUhLom9I99fsYEOJqFr1f5BS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=WZ360woTqlKwEAB+mCUzTvQfH/YCNcvh0ZZPLL1DHzM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AZSLRNhqGdUM83QJ0qfy+OP/Gew763rCSVUCZEwoELRaI+j49ZpbeQHyu85j2WYb4bH2ozW1nkOivERqbc2hze03XfD2/IIMw+Sug0b1yk8NFeBRyytGuiN8JZrimcSba2vvn/pkMk1VGL2vzlLBE9WiVymfafwBHhMph/XE1v8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sqUGHS6E; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sqUGHS6E" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8043CC4CEF4; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147127; bh=WZ360woTqlKwEAB+mCUzTvQfH/YCNcvh0ZZPLL1DHzM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=sqUGHS6E9D8Cce/8hXHKu8q7oyPnEhsFn5fN7K8UA77yu5WXmV5O+RVLIPIBVvtrG /VQXlHV65lqZwiOzaCWUsPnRuRhbpkulxNDZxfXm8TTbb+YsmcXHc3+FI4eF9ruYxH wERKYB/bJUQaCJvWaAAnqw664G38jUFJzesLc1CpgFT1PGSvmNzhyJd+GlJ/0qDi/9 kCUO76Wt2VUXUVR2SnQmJ+3KDQ6px2n5Sr3sJacwvxzd+QmB+rroQiRja9OsZ7SIgj AUCY9in5XYjjDs5apnpwiavreYnhb2Kshd6eXkWIOD5qGaR83qozoYULeX0xoybUnC Vz2/vKKIu50tg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 774BCD5B148; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:46 +0100 Subject: [PATCH v4 04/16] net: phy: Add helper for mapping RGMII link speed to clock rate Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-4-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" , "Russell King (Oracle)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1401; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=iiWKJLaFCOsjPP4V/Ba8wScxk46hL1tc6KzIcyhY4QE=; b=a9z6WZPW3ibl1mYkhy6D4vsb7agV8md+c5fFx8SXTmlOkpCCbcb7sjHXivuW60pMPXXVbH2zP XV8gFEKPCteCW8WxxpY3MGLFe2PzPTgI5RfsmjcupWRZm67wFrIF7WB X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com From: "Jan Petrous (OSS)" The RGMII interface supports three data rates: 10/100 Mbps and 1 Gbps. These speeds correspond to clock frequencies of 2.5/25 MHz and 125 MHz, respectively. Many Ethernet drivers, including glues in stmmac, follow a similar pattern of converting RGMII speed to clock frequency. To simplify code, define the helper rgmii_clock(speed) to convert connection speed to clock frequency. Suggested-by: Russell King (Oracle) Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- include/linux/phy.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index a98bc91a0cde..e28c971d7616 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -298,6 +298,29 @@ static inline const char *phy_modes(phy_interface_t interface) } } +/** + * rgmii_clock - map link speed to the clock rate + * @speed: link speed value + * + * Description: maps RGMII supported link speeds + * into the clock rates. + * + * Returns: clock rate or negative errno + */ +static inline long rgmii_clock(int speed) +{ + switch (speed) { + case SPEED_10: + return 2500000; + case SPEED_100: + return 25000000; + case SPEED_1000: + return 125000000; + default: + return -EINVAL; + } +} + #define PHY_INIT_TIMEOUT 100000 #define PHY_FORCE_TIMEOUT 10 From patchwork Mon Oct 28 20:24:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854078 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 709721E0DB2; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=PngdWeS1mkaZ2CXULAzjtXjgQ0TQIyXUE/j9NeoUoLcAteIPNbcbfExLze2b1k5Ujq9JzTCndVk4R559HQ//aaauhleqDb1439Uc9FAw7OHbWmYBbnqKFaV89GvElC7oz0t2KaxJjzB9tr1tqRFeUL3PaYcKlRw1yc4IDV7b3Co= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=JRUUT/tVaHw7QrNHAqa5N8/R1Mo2990bjnD9KKasxCA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MsX1TCgRYZTpfryxeMjmM791pxfq2QsWWDj3XTkyMfkBlqqATin00xI1M5RGuJzhOqi+oOx2e5UbfpBDTNePNVLKnds6hemHxZAYK16/ZFo+DiU8fNd7qmpm/kgsjrwD1NfyrJUfSUrRo1mLr+dfGB1YmaaRZalsAgqDGSsJaRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jlxIgtu7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jlxIgtu7" Received: by smtp.kernel.org (Postfix) with ESMTPS id 96BEDC4CEF7; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147127; bh=JRUUT/tVaHw7QrNHAqa5N8/R1Mo2990bjnD9KKasxCA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jlxIgtu7V3cPBsySzGHkIQt2Pkpvu7zLFd+Sa//8HjxDN33wfX+tLPfl2Kh3smzyY F3gc/xFON//NvqVkzU3rHdwnuHLd8lNTRdHdy37WzKIGIM/L5sJ9YRFQrE6+vcn8c6 xyq/MG97S5pep1MSvjvyj0UPnQ2K1QzV09fXD/0lDdFr+sKLoh9PXwSN1FNYqdrEo1 Hy0iG1kPtJPr95Ok0jX21rVclqjlJPZIzGARF4WCXjpka+FQ1q7TNMCTMx2XztO9h6 a8wQ0+HbXcOwW4dQknRx1hALSYLUsgeEkJ1oah3Q/YPJIPq8kt2zD+16Y1xpBgggov djzUH3nAaghOQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89E78D5B14E; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:47 +0100 Subject: [PATCH v4 05/16] net: dwmac-dwc-qos-eth: Use helper rgmii_clock Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-5-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1182; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=o1k5Wm20ojlSERI184m4AqWRyn2wXW8vdr8AE9UuluE=; b=oQtSE7tZW80kMP1GQFVE/VJ3DQXVdxUvernNfz8S7tts1H1pzWxYq+pY4H/6cFR/3t/mgQzwK VU83o71HrGlDIwsxQJOrzQktrXXZKJkOmQfQ/PQPEbE1cI0wF88D7Jz X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Utilize a new helper function rgmii_clock(). Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 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 ec924c6c76c6..5080891c33e0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -181,24 +181,19 @@ 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; + 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; + fallthrough; case SPEED_10: - rate = 2500000; + rate = rgmii_clock(speed); break; default: From patchwork Mon Oct 28 20:24:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854076 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6EE9B1E0DB1; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=ZrKFOuIg00JpSpXh5Q9sCGX/4MOxtc0Ra/ioWzSozzudfncY0hIkuJ92JcfEG9vC/1M0utqsnCLD+TYCaOpw9WHKMwTqNGSeK2t2EtbNqoIIzVaqNcerh2QGQwcFHNA/EJvNkY2nM8cHaTpioJK3dZ4KMqDm8f2LtyFmnXNphF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=x9YYgAZ15JSdW22tDM7dkLfbcgZsmaNFRbtvGLiwf60=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bwVvAw5/PWNCpSFmRnrwop8be0xSEhfvbY+5TLNlL/Jhit6361JYviL2gA6Rv4qxSUqUlNzgvKD6rUcWeIn97xTI8kmKnDs7Rxfb1GbGWw3s/b2kRMvnDcCKf5qZ1ziMIPqe2ktnlA4R+F97y9P3FrdsYxdAoo8xFBI7X985gLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qeX0+YaK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qeX0+YaK" Received: by smtp.kernel.org (Postfix) with ESMTPS id B38C0C4CEF8; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147127; bh=x9YYgAZ15JSdW22tDM7dkLfbcgZsmaNFRbtvGLiwf60=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qeX0+YaK8EbVPzaFglwKWjf4e90hXL/NMsU4JTxbLbzhY2Zcx27fFvwlTHqsAEtnA eMGYpZPs/xPAdGJKbAwVGbh15e0/OlflrAQiLwgyqQjc+ErPLZi7fFQ6DFE1cOU0oS t2HvmT0YTd0+/XnDJjGCQaIa3a9lMOV9Mwq8kURAwoXzRks9TpMRxCR/9nt1cSjgeu ZIVgUbm5tMxKpviqOtVSkOKnP9/oSlDpT3GMi41MwugVjkTHGyYG2twJzBba3NBnRQ xKZtCXOEJcVrf6RVuxDTQvFUOvorsgFSFmmvzWac5/EpuNobq+rNYljsyc7CgER+lx 8dx4XiYQ4Gs6w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A570ED5B149; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:48 +0100 Subject: [PATCH v4 06/16] net: dwmac-imx: Use helper rgmii_clock Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-6-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1268; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=iLIsHvY+x5Xnx4GgOZhbVwuJPAuV0YL5laW2VrNYkBI=; b=xd40CP+YeaOmxmAXuqWIJ9bMLTDflKP9iPgxiFx/G1P2Bqk1kRHR9qzDm2YPIjQC/Dh2JsBwb 8tu9gDPZSXxAmZnehRbnfBs1n+H7hWG5tl1jyz/t09h1oN/uAgrsUn9 X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Utilize a new helper function rgmii_clock(). Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c index 6b65420e11b5..4147b56d40e1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c @@ -186,7 +186,7 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod { struct plat_stmmacenet_data *plat_dat; struct imx_priv_data *dwmac = priv; - unsigned long rate; + long rate; int err; plat_dat = dwmac->plat_dat; @@ -196,17 +196,8 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod (plat_dat->mac_interface == PHY_INTERFACE_MODE_MII)) return; - switch (speed) { - case SPEED_1000: - rate = 125000000; - break; - case SPEED_100: - rate = 25000000; - break; - case SPEED_10: - rate = 2500000; - break; - default: + rate = rgmii_clock(speed); + if (rate < 0) { dev_err(dwmac->dev, "invalid speed %u\n", speed); return; } From patchwork Mon Oct 28 20:24:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854075 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 93AE91E0DF0; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=Ju1RDfpzeG3Xuy4a7NLUekrnMz7f7+FZV1bXF5KOUtmULzh0AR8jmdQgusf6JlAcSW+MrmthlgdFjQOE6s2dfCokOZ6PTbqzOcnU47OiLwTaOiiSNUUYQqlCs/lgoLo5EIblQ3zzYiSVk5vDZzN7icDcAs56Sn8KqwcZWqfe11Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=xrfiQOPdzrIo1V7NLTraecdpuLxsHLhTDbnA8EiratQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ElQ3SBaY87qj2FpOOcJEdXOx4tq8RK8jk2E87ZV/l35x/MR7UmLCr1G6dplYZlx2bhfY9r71+lSaZS7CJ665e2QA9mOCui8+gRrtKOtDZA+7a3nfB2zyILEFqX0CfHiI0LUA87t0iuIo++YZKzc84O2KM6QdtnTHOeatoUUWi8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Le7Hpv5v; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Le7Hpv5v" Received: by smtp.kernel.org (Postfix) with ESMTPS id E6ADCC4CEE7; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147128; bh=xrfiQOPdzrIo1V7NLTraecdpuLxsHLhTDbnA8EiratQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Le7Hpv5v5gZeABJNLKhbCyghXKNU/TcnduTaLoWYESTCMC5Fzf54dF/6ULwnIWvC8 cUcKpukGLfQGvfYv97NadVE3ZisYGUNvYnK8/LatT5SM93a/FHcbVOMA5MISCCnqv0 KZwMKmAFSAz6XM1qQqGArDCqJG19PnuQoYtt/O4WL/Yo41xNH4gbK27IdEtf97syZB /Higycp4ZMBAuJAhiBelZpkQsPfP5Bp9FCWf7Gh5ufaR2lm0JLapOoP2xbzrO3Wfsf XGuHbLb6gFM1l5EdwUEL5Z+UIhKTyCKadHcpMoCUXENmHYlrjJpGNM//Jq+ysnundZ QIwoU9RopLC2g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA554D5B148; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:49 +0100 Subject: [PATCH v4 07/16] net: dwmac-intel-plat: Use helper rgmii_clock Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-7-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1184; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=PFDhkmjoo00nWgjGFIgy6f2ZWugg8o1JmR69WG1g8to=; b=CmH0IdloyBAamVxQah3syzKO6bDqelTA44O3cZ1QkM0KaYejvOCIX0/NRcQqc7jyNfwqxSe0P IU2rNOs9L96BfhfjhvgUnmq3WXjwD2N+3m4uXkGdfMTn2M+QsImpqPs X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Utilize a new helper function rgmii_clock(). Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- .../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c index d68f0c4e7835..ec62ed90a47e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c @@ -31,27 +31,15 @@ struct intel_dwmac_data { static void kmb_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) { struct intel_dwmac *dwmac = priv; - unsigned long rate; + long rate; int ret; rate = clk_get_rate(dwmac->tx_clk); - switch (speed) { - case SPEED_1000: - rate = 125000000; - break; - - case SPEED_100: - rate = 25000000; - break; - - case SPEED_10: - rate = 2500000; - break; - - default: + rate = rgmii_clock(speed); + if (rate < 0) { dev_err(dwmac->dev, "Invalid speed\n"); - break; + return; } ret = clk_set_rate(dwmac->tx_clk, rate); From patchwork Mon Oct 28 20:24:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854081 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B48181E104A; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=WkNXM4XWyPQdjYCFL/q+KCGjoatUEdYUgY/Mg+T3WVEYyRPY+AwMSux9QtURWawHdKTJD+cMhpe2AMIQVnKIwH1iem/JapZ67msY4qQgtI8/D1ONFNJdw2fxbSBUUiUu7pVo9sNKisJTkSyvnGbJmUgXLgRopJZeRdhvDClHs9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=XeWbUqW/+n7Y7W09gE65f3ElGGk8pXK2D2Agi9k8Udw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mncEnKD6Ej8PKiESWuQYnTJ2qkj/M+9esnIAt4gBeDC6X6FCeZSsZgYs87OWbqvZwdCkWylOkhkwyB6B5nmlYhMQx3Stw3S2kzHShO5MW+LeqG71jOM89qDkk9DjGgGOYhmLwetgsLYEB2i/jJJ8+FJ/JrWmcjFhM8o88+cOEmI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D1q8JgJY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D1q8JgJY" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0CF1AC4CEE9; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147128; bh=XeWbUqW/+n7Y7W09gE65f3ElGGk8pXK2D2Agi9k8Udw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=D1q8JgJYYEpMVU+3S0Tv3xMqVFqqkVLmvFOPox3AYRD6jmA4rdHkNILi1k4gYghNZ Cr34UGdd3omZPPRRq5Uy4qsTv1TJmDGCfGN4Nge5Wdqe3Tav/gGbLYOMg0lw9SvtaU T99BawblYIBtZ1p1BZ5dLq+W8SIzbn4/PbjV3X5S+PpfP6aFw1t7ImPKcDF/mLkKdm K6l/skNVlNdC9ioP6ygXoZ59YJ8jnUH9FT8XykG2fKrHWl7q4cRU4KVBFFOkYQVly0 Z2k+yHiAlmtHHK6iQWqm4LFjd6jWBxSadC0umccqccGvlltUrJJ3AVcv+bSpX88JQ0 6qAS3IYjVCkYg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id F40ECD5B14E; Mon, 28 Oct 2024 20:25:27 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:50 +0100 Subject: [PATCH v4 08/16] net: dwmac-rk: Use helper rgmii_clock Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-8-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1665; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=p818FBc7h3Q76HlCUWlShPBCXFvDmTCoSOPi3/tS6SA=; b=TJVMimqq1u4CFzpQYu/wodYi6KnQAaB6hrxTPbXvNPBkFoqi9J1Ilc7N3I9KL7asfPVO6W4r7 lT3pA9y1zYrAOGU2wIYg0abWf4aLHoDZEKmnyOE0yv4rsGjyJLUvOHv X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Utilize a new helper function rgmii_clock(). Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 30 ++++++-------------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 50073bdade46..2fd650b3bc5c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -1079,20 +1079,11 @@ 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; + long rate; int ret; - switch (speed) { - case 10: - rate = 2500000; - break; - case 100: - rate = 25000000; - break; - case 1000: - rate = 125000000; - break; - default: + rate = rgmii_clock(speed); + if (rate < 0) { dev_err(dev, "unknown speed value for GMAC speed=%d", speed); return; } @@ -1540,20 +1531,11 @@ 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; + long rate; int ret; - switch (speed) { - case 10: - rate = 2500000; - break; - case 100: - rate = 25000000; - break; - case 1000: - rate = 125000000; - break; - default: + rate = rgmii_clock(speed); + if (rate < 0) { dev_err(dev, "unknown speed value for RGMII speed=%d", speed); return; } From patchwork Mon Oct 28 20:24:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854077 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7A0C81E0DBB; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=mCpKOgeDt1SscHXMpEd5bM++/2V1nyVGLpzFuGZr6hB6rHabOaHkZt2/e8WhY40IPzm278CCXBlaHOzmV3wB6+zhjvGy7ws435ARm87zhVbDXPscP0c0TLNKHrjVE4DrBJ16ZpvmSYZLojKAi43BkDh4yXo5RPxnXr5iBfF7dO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=VSzM/Aqzd9ydOVExBs00GoWTm8h9XaWLXTka7dAqxhs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KAGXCw7yo/RDWZQxsqjUuEbgTZxqDpsnMYANtg+WOadv1hU3TjfhuBb9RUjq2SigJz/4cfQSuirnybgA2ut9cfQoa1PZ6hioMOB6JnydScHVeZyeGK1l/PzV3JTCAIUNH3eq7Xha3NwF9Eiof43NPGqOnSA3stIqsmBewzXGX/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ESbE2oFF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ESbE2oFF" Received: by smtp.kernel.org (Postfix) with ESMTPS id 244E8C4CEED; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147128; bh=VSzM/Aqzd9ydOVExBs00GoWTm8h9XaWLXTka7dAqxhs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ESbE2oFFZ4YC5RbGAWT9SmLuBvkOxsN+QoaMiUH0P2f/SH7IC20iwXZdcCi8teNlP Kfo60LBlbDGtFJmZE0lpkYwKedm/pFM4TpSFtVymm6Mj8L9GOTi2PAlXEvkQSSUyoc Q6844LUsb6sBYngqitm2an3qOxq9Myd0oVxdpT/RXd71TfrXyTWbK3m79zd15GVUSj +M5FNVk2rXQbP8Et0PtZGilPz3dB54yzPALy3WWiDHnOeh/fyrCF4sccyOh8Az/dY4 4Gj4zM+4pWkn+8tZC3JTEaWtaXB0HnnR/8/940UfKGKnevqC67Q5dHegl9j3tlMOC6 FbxZ+Ht7cbSTg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 176BCD5B148; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:51 +0100 Subject: [PATCH v4 09/16] net: dwmac-starfive: Use helper rgmii_clock Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-9-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1184; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=YVAUfNddfX6I63XBPKwqSvyB5DYz6NCjgmmbUf+1q5U=; b=BNQoqbyvZT9P3j86kVabLJTJzgQIuXduLBqYyOVc+Gr57eySX+k4bMLPlCea2Wnk0yTGB40XE Kpa0XUJEeEKCefuPgwqKRWjDXkRskERHGBHAu3AcDeKK9W3sxNzc0n6 X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Utilize a new helper function rgmii_clock(). Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c index 4e1076faee0c..d80461a721c1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c @@ -34,24 +34,13 @@ struct starfive_dwmac { static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) { struct starfive_dwmac *dwmac = priv; - unsigned long rate; + long rate; int err; - rate = clk_get_rate(dwmac->clk_tx); - - switch (speed) { - case SPEED_1000: - rate = 125000000; - break; - case SPEED_100: - rate = 25000000; - break; - case SPEED_10: - rate = 2500000; - break; - default: + rate = rgmii_clock(speed); + if (rate < 0) { dev_err(dwmac->dev, "invalid speed %u\n", speed); - break; + return; } err = clk_set_rate(dwmac->clk_tx, rate); From patchwork Mon Oct 28 20:24:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854084 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C1A8D1E1337; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=HpiaPgJKsTty6zXl0JUDpBB9f5d+7vzK+kCDOtcdVJImCMvwYqHE34AZinfi4TX+HagYY4EARV7bHuiNyYtiVd4U4kd0tSycoLb0zmzd6jd/DOTaI5brO/Jz1v+J1OHu7+HYdjZ4vBg86oRS3gsC4CZpUpWKUtVOuzkiv7frWL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=7vtG9pA+K21LkqN2C0YcqauzDbOJlo+/wO1OQf2lUPc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N/6eTefVp1urxXHQEvIvBL9LflO7+BVo02DPrB8bnNA0KQT9qIGsY9Z0GOJ48iI02Ih+gYxE/AbZR0e5DTlpopDjg1Z7eXxEO48CUHIGcep+wdw2En16B2npOr4SZk+0keBqK60sBqk2eyWxsgMW0cIZtn4A2gga+YFeUJDfBwc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VAShQeK6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VAShQeK6" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3E3DAC4CEC3; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147128; bh=7vtG9pA+K21LkqN2C0YcqauzDbOJlo+/wO1OQf2lUPc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VAShQeK6wELG+LJTexWCcsL1TQneZROGgzrIfSr6UuCISpLN1Eb8yxuGUFRN/JYtq kZheZ3xfL+7Xwt7nVqewMy++GvEQjYwDDarkx1W82vDnNyWj7tWh0P2wTBPGaO3iOL FIbu/Raoeou0teu2UfGfu+YqlkFFfVw/33MFSAv6Gm1L+YRQ+0gqJqKzDrVPNXmIME zQm3S07HZs2A9jYiGuKeqdC+lvMsgiIQv7Z/dc5OODvdJefzvgVXCk04KZmJbkxVw+ 2jhQSZnSlNobEpasVNYEEBmWv4VOLSoAx/Q3L2Uen20MHwvtNKho1+k9o5CBscgJoX t68KVVLzLFMnA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31F18D5B149; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:52 +0100 Subject: [PATCH v4 10/16] net: macb: Use helper rgmii_clock Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-10-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=953; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=cfFMV/oCv4h7wawq2S7/Nrlkv2gYpjiAbwErMMsRoC4=; b=QptE/ox0BP0PKywOxOQUJNHbaFkGlOwtL4gzNasllt2FkNCPLgOJtcm5hBk4sA9qKjsbrB7vG bmOOEU267emC22EuhsV56s5yzJKkM5Wj1cWcYefAtGxrAPjEGgUEKeV X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Utilize a new helper function rgmii_clock(). Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- drivers/net/ethernet/cadence/macb_main.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index f06babec04a0..f1e481264511 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -530,19 +530,9 @@ static void macb_set_tx_clk(struct macb *bp, int speed) if (bp->phy_interface == PHY_INTERFACE_MODE_MII) return; - switch (speed) { - case SPEED_10: - rate = 2500000; - break; - case SPEED_100: - rate = 25000000; - break; - case SPEED_1000: - rate = 125000000; - break; - default: + rate = rgmii_clock(speed); + if (rate < 0) return; - } rate_rounded = clk_round_rate(bp->tx_clk, rate); if (rate_rounded < 0) From patchwork Mon Oct 28 20:24:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854080 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B01E81E1042; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=XUQj7TEGlr1GM2M+XMXvL00MQVbU1yb7Vw5TE4wJp/tUyW6URN1icnAKuUWd3cCBJBBXFdIYfcMk9teL6il4+Vw4Jo9FFlHutUHMBm8aEHGfNZ73v0zh+ovyuqcR4uhRXjpoXYyvdcmhek61XuGa7gxtkvNnBRWRmKbVCrw7NQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=CQdMV8dkq/A9d6yVmrre2V2ErUvyIxE7venx1gnBvdA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C9rTBIru8U9eJ8aHT+REDrm3Ywo392dh6iXzioA7vzxW1xTZpj4PESLJALfR/L/J09Ok0UP16vWARd2iC0L8/XGAWjelmSqMsxDYmCV9JcHaPk/B383Wgzko0Nd0ArJYufNRgj/ipxGYtwXiqD80UTsmqnOYqdioGAVSVRUyWoA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cf8ffnyz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cf8ffnyz" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6D7B6C4CEEC; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147128; bh=CQdMV8dkq/A9d6yVmrre2V2ErUvyIxE7venx1gnBvdA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=cf8ffnyz0NwdfObRPIIyRfTW91wf+5WW0OyzBUOEjVCjo9DtaTThPs7NnDrhsGxM2 DEhQhyJAaRUz0bOI6NhdMIk3B0RX6llJ0rY13FZGnc75kuYohKaD417wlM+T4eSYyT aGGh1XWCjx2WFmNEDfPAwR0iI4Ko4+Hmy9RMT0aSrnjRVGuoVi/1DFXwQ6TbffUyCc +nssEeXDdKkZr2oTOu7V0UjGR2jN/3p7J5RQiZBE2B6gWJea3g1OYwW3Tsn6Qoc488 sUTsY/JRo0QeH9N1RrGKpPErTmquRwewUjL14O6hbJ+zZqkVTGPFBF02eaYcycze2Q 7Dgb09KHZLxtg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6189CD5B149; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:53 +0100 Subject: [PATCH v4 11/16] net: xgene_enet: Use helper rgmii_clock Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-11-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1083; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=ez2eUvox+NA2tsnzDHS2muudXDPXOUk289T76vN/OhU=; b=vEL45N1FGJLM+RgRwo1FmE4ffW8cGr8QBpLo+HpPla/E6gxsLRqEF5clGWKNsJcfwmEB/EFdC J46TAbaFEPaCIvJL9QEF3u576I1KQoIDnblJTsraa5S119/1WoOQ/RH X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Utilize a new helper function rgmii_clock(). Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c index e641dbbea1e2..b854b6b42d77 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c @@ -421,18 +421,12 @@ static void xgene_enet_configure_clock(struct xgene_enet_pdata *pdata) if (dev->of_node) { struct clk *parent = clk_get_parent(pdata->clk); + long rate = rgmii_clock(pdata->phy_speed); - switch (pdata->phy_speed) { - case SPEED_10: - clk_set_rate(parent, 2500000); - break; - case SPEED_100: - clk_set_rate(parent, 25000000); - break; - default: - clk_set_rate(parent, 125000000); - break; - } + if (rate < 0) + rate = 125000000; + + clk_set_rate(parent, rate); } #ifdef CONFIG_ACPI else { From patchwork Mon Oct 28 20:24:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854082 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D0CE61E1C2E; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; cv=none; b=MtEP59GOWQ1bP6heRxkVWFhe7/vCGGUbLqh+K9PcLtlLeiNyQcVQjDBJMO79rrw0iGA2Pny4WQr6KwrqG3VyTw00/+Uw/Ey8teB2G/8XsdiFm3LQuTHjmULpYz7HodBbmnfZIDg3kjUFY8VMX/33cXENdPudshdqRL4GOlOEzgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147128; c=relaxed/simple; bh=E9ULty73Jgr23JseBlTb1u5xTjkGJ7bBh0b7o4RFqUM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P74ldSOtiOH1lg9y2mR1OTVrXQVUSyJYFrIV55pEJHra0hzonx16RiG/2rj3kGwyOpqXqyDd13QnfwCDjWSwwu+gZ5oHbjHXLSQTF1pRjIWbAXldeWv4pXHi4Zk6YyOwu/JeRoeIEaFXYu3kS8kDiSeT++hMy2HXH/bvjjgTQbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AbOXTTyz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AbOXTTyz" Received: by smtp.kernel.org (Postfix) with ESMTPS id 956D8C4CEFD; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147128; bh=E9ULty73Jgr23JseBlTb1u5xTjkGJ7bBh0b7o4RFqUM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=AbOXTTyzym+DWlQGs3t69h/UbEzHEKCenp9BipeFj9TpNwY3B18UgFRE0GDC8enrv 8Usi+7z06/bzG90h1Zkfc/RQVLuTd4jgzBffoX7D1iLxkRVKV5qqnj0LGpgVU1xHn4 6RVThDnBWyxtavGrZk/kO7J/zGS0IYMpq5I8flXbbSgEE+IS2t1iYFAH9/ji4VnYtu 1LsyV6CpJRnDCmNva1aKi8sPCmfO6PAkD9O6tEyPoOSq6GZ9N/ZV9AdWO4b2zOBVEH ofvDo+dxRJUtGNpKuAE9auvLRCw/P7qnqB5a9O1Oo9oG/zgd8/pq1Q5ouc0m96WdtR jKi56deL07uWg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84099D5B148; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:54 +0100 Subject: [PATCH v4 12/16] net: dwmac-sti: Use helper rgmii_clock Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-12-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1909; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=60fcfoJkNR9bym1PAnUjGu1uGiLwTc5UPBVKqmcC8oU=; b=lUs9dc+jiRxR6QLLnEJgdeuWYoTygF+iYA2aIsL4A7ntIdP9Y/SeD+hVgdMKxXKtAfGxwhCFP /tnJdCg7pu0BITYtBydhE3oJ97uhPRe8VaW/0M5oqBI88vRtBqUQOlW X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Utilize a new helper function rgmii_clock(). Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c index 4445cddc4cbe..0b02d079360d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c @@ -21,10 +21,7 @@ #include "stmmac_platform.h" -#define DWMAC_125MHZ 125000000 #define DWMAC_50MHZ 50000000 -#define DWMAC_25MHZ 25000000 -#define DWMAC_2_5MHZ 2500000 #define IS_PHY_IF_MODE_RGMII(iface) (iface == PHY_INTERFACE_MODE_RGMII || \ iface == PHY_INTERFACE_MODE_RGMII_ID || \ @@ -140,7 +137,7 @@ static void stih4xx_fix_retime_src(void *priv, u32 spd, unsigned int mode) struct sti_dwmac *dwmac = priv; u32 src = dwmac->tx_retime_src; u32 reg = dwmac->ctrl_reg; - u32 freq = 0; + long freq = 0; if (dwmac->interface == PHY_INTERFACE_MODE_MII) { src = TX_RETIME_SRC_TXCLK; @@ -153,19 +150,14 @@ static void stih4xx_fix_retime_src(void *priv, u32 spd, unsigned int mode) } } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { /* On GiGa clk source can be either ext or from clkgen */ - if (spd == SPEED_1000) { - freq = DWMAC_125MHZ; - } else { + freq = rgmii_clock(spd); + + if (spd != SPEED_1000 && freq > 0) /* Switch to clkgen for these speeds */ src = TX_RETIME_SRC_CLKGEN; - if (spd == SPEED_100) - freq = DWMAC_25MHZ; - else if (spd == SPEED_10) - freq = DWMAC_2_5MHZ; - } } - if (src == TX_RETIME_SRC_CLKGEN && freq) + if (src == TX_RETIME_SRC_CLKGEN && freq > 0) clk_set_rate(dwmac->clk, freq); regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK, From patchwork Mon Oct 28 20:24:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854079 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E90AF1E25F5; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147129; cv=none; b=JQ/okDDJ2wuYqs0E+amMMj4wpyHj3ZXsAUS3X8YzKiaDfTKwLo5yo7c2SY7JvahxAjhcXooahL50U50Pp+l8aQTEcWg1dBbFb1825dCv9D/u0PoIMtmU8bqAikTV4ZL40W1mlEm+jtMwTZRUGspHIYmAOlxoBAIeLI/jOkIVbjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147129; c=relaxed/simple; bh=cPvePMfnaPEQj5/sKA/cCaO8jpaRAdh7gPRGzAy7CjY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bO8ITa3vipptRAUCsUDoRSbViPPU43qKPxaSW5DQ6nQQ9X85S6//dyk2djcdGEosIXxrxg7ikZR3DEhoSFFjbv6l1wgMXKMeqmxxGVFMCYFb5HUoVg1Xv6rBLY+vi542NuU57b4qUnZEHxXNFoIRWiKqTZW1AHDGSh/PlczojKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GhkWi7Of; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GhkWi7Of" Received: by smtp.kernel.org (Postfix) with ESMTPS id A4F00C4CEF7; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147128; bh=cPvePMfnaPEQj5/sKA/cCaO8jpaRAdh7gPRGzAy7CjY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GhkWi7OfWK2KVc8ocfPDOxt5HseCL+NtTC648xFlf6f8sELhXXNFQETQFnrtIJLul MRxhUg6l4QRnGBOQYnIUygyP3wy0a5tIHmSh05mTwi74ApHjvFyvkXYn9EQ7r1tP76 vkP9d68jCn+Vhj0587K/0eA5H4ayBkHWgwcZ2iHrc2IP3Y5Z8hVYClg0Xbb+BL7aQR M/XKNdRFrl+/Xl3IdJlwTOo1I15/8xWATxofWbInk2IcO1P1N5vMCfeDTupNMRBOxO sVC+8nrFx83m11rhqhkN5lzqt/41CVfox5SKeWM5OEm543PWfsmRntN+HXKJhQiImw OD99l0FsE+jAA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96FB0D5B152; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:55 +0100 Subject: [PATCH v4 13/16] dt-bindings: net: Add DT bindings for DWMAC on NXP S32G/R SoCs Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-13-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=3748; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=OaTND0Rf+SZZ/VYyQO119bzP3X9p8NKhjg7EhHcyyMU=; b=3s8Ebmm3y0Rp+JOqGEbp4CedSMHxPn2ixyWuU+bKGEoXqUPRhKV25aetLOhXm0JFnBkEcML2+ 9zNuG+etoM8AtB2Oj+FUZBQtqHijLXydbJwuvuFdbl7kSSSvaLZKVA1 X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" Add basic description for DWMAC ethernet IP on NXP S32G2xx, S32G3xx and S32R45 automotive series SoCs. Signed-off-by: Jan Petrous (OSS) --- .../devicetree/bindings/net/nxp,s32-dwmac.yaml | 98 ++++++++++++++++++++++ .../devicetree/bindings/net/snps,dwmac.yaml | 3 + 2 files changed, 101 insertions(+) diff --git a/Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml b/Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml new file mode 100644 index 000000000000..b11ba3bc4c52 --- /dev/null +++ b/Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml @@ -0,0 +1,98 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright 2021-2024 NXP +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/nxp,s32-dwmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP S32G2xx/S32G3xx/S32R45 GMAC ethernet controller + +maintainers: + - Jan Petrous (OSS) + +description: + This device is a Synopsys DWC IP, integrated on NXP S32G/R SoCs. + +properties: + compatible: + enum: + - nxp,s32g2-dwmac + - nxp,s32g3-dwmac + - nxp,s32r-dwmac + + reg: + items: + - description: Main GMAC registers + - description: GMAC PHY mode control register + + interrupts: + maxItems: 1 + + interrupt-names: + const: macirq + + clocks: + items: + - description: Main GMAC clock + - description: Transmit clock + - description: Receive clock + - description: PTP reference clock + + clock-names: + items: + - const: stmmaceth + - const: tx + - const: rx + - const: ptp_ref + +required: + - clocks + - clock-names + +allOf: + - $ref: snps,dwmac.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + #include + #include + bus { + #address-cells = <2>; + #size-cells = <2>; + + ethernet@4033c000 { + compatible = "nxp,s32g2-dwmac"; + reg = <0x0 0x4033c000 0x0 0x2000>, /* gmac IP */ + <0x0 0x4007c004 0x0 0x4>; /* GMAC_0_CTRL_STS */ + interrupt-parent = <&gic>; + interrupts = ; + interrupt-names = "macirq"; + snps,mtl-rx-config = <&mtl_rx_setup>; + snps,mtl-tx-config = <&mtl_tx_setup>; + clocks = <&clks 24>, <&clks 17>, <&clks 16>, <&clks 15>; + clock-names = "stmmaceth", "tx", "rx", "ptp_ref"; + phy-mode = "rgmii-id"; + phy-handle = <&phy0>; + + mtl_rx_setup: rx-queues-config { + snps,rx-queues-to-use = <5>; + }; + + mtl_tx_setup: tx-queues-config { + snps,tx-queues-to-use = <5>; + }; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + + phy0: ethernet-phy@0 { + reg = <0>; + }; + }; + }; + }; diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 4e2ba1bf788c..a88d1c236eaf 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -66,6 +66,9 @@ properties: - ingenic,x2000-mac - loongson,ls2k-dwmac - loongson,ls7a-dwmac + - nxp,s32g2-dwmac + - nxp,s32g3-dwmac + - nxp,s32r-dwmac - qcom,qcs404-ethqos - qcom,sa8775p-ethqos - qcom,sc8280xp-ethqos From patchwork Mon Oct 28 20:24:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854083 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 08FD71E32D3; Mon, 28 Oct 2024 20:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147129; cv=none; b=G4bdKoQaHW7mx5dcr+Qu5WIWquMN73K7fLzHrgj5W1KzxlABfRL/bCeABoLCRqph71Fw3DHiVKYePoxbgfmj+aod7lcPLEvciso0MZ/aojK6S3FBmTz8FvUbz+iRY+mWseR4IS8rJEwZTKIUxIc7QGXjveTsbt96GwZtBr9f2Ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147129; c=relaxed/simple; bh=6x7MJaIbmQGCDac2nVLi2ZlOPCkGDyApHo5qr+Po8+U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mqa9ePRj55xNY2STbUecaeiBsPUHW/ZXU4yw9OJyIyabugTcaabNvAGY7jkg1Dw2ADxTJMmurj1dhgCULZqtNNKz3+H/h4hV81JeUri27LVL2qnrn7EtgasNAdp84aTf91y5ywVt82v7jb8KPlkwmcMbEl+6VhfQAcW7ddCQMNw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iv+SHOfv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Iv+SHOfv" Received: by smtp.kernel.org (Postfix) with ESMTPS id D140DC4AF49; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147128; bh=6x7MJaIbmQGCDac2nVLi2ZlOPCkGDyApHo5qr+Po8+U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Iv+SHOfvJEZJreojsRUwjtSqUdkvFGL8Fxk6cfpREEkeNo+sYrBUfyUQNNmOfnBSh 22pICx59K73bJLPgGVdmhFARqjnC9U9HuaqdGMnzukVKbYRzTHX5W2IAwD9LcXvWuB kl6SFGxTRxob+JtvVi36rC4tDD8Nm6X3yX7c1yafqj15fo6vjPFIIjkFeidLObl0mx yjPHu3sU2Vrw/DVchh9RMsMhkAkRXv92EBGbrFPrTU2/oZAM+s+cP6/0S30x1eeuZf StL79FNj2uPKWEAAvpfWgd2x6Ct+CRJEQXQKziZ89m03MOH29RbbdjmXI+55nZaGG5 098L3YHXH0b8w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADC20D5B149; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:56 +0100 Subject: [PATCH v4 14/16] net: stmmac: dwmac-s32: add basic NXP S32G/S32R glue driver Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-14-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=8207; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=PIi/4YM9p4PJabk2pt/l+F6rlS3/NYcZVlroPRJVHhY=; b=o3GAssOv7MN6i+wt3hLAxuUaPWHKzwOnNw/wkumGV/4O+dnNb/vuL/8NUtVTlI07BjVaa1mTI BTAZq/nqIz2Ci70PvFyXgC71VW6kKaYp9KEqbQMK3MwuaI5jmbCP97N X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" NXP S32G2xx/S32G3xx and S32R45 are automotive grade SoCs that integrate one or two Synopsys DWMAC 5.10/5.20 IPs. The basic driver supports only RGMII interface. Signed-off-by: Jan Petrous (OSS) --- drivers/net/ethernet/stmicro/stmmac/Kconfig | 12 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c | 226 ++++++++++++++++++++++++ 3 files changed, 239 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 05cc07b8f48c..a6579377bedb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -154,6 +154,18 @@ config DWMAC_RZN1 the stmmac device driver. This support can make use of a custom MII converter PCS device. +config DWMAC_S32 + tristate "NXP S32G/S32R GMAC support" + default ARCH_S32 + depends on OF && (ARCH_S32 || COMPILE_TEST) + help + Support for ethernet controller on NXP S32CC SOCs. + + This selects NXP SoC glue layer support for the stmmac + device driver. This driver is used for the S32CC series + SOCs GMAC ethernet controller, ie. S32G2xx, S32G3xx and + S32R45. + config DWMAC_SOCFPGA tristate "SOCFPGA dwmac support" default ARCH_INTEL_SOCFPGA diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index c2f0e91f6bf8..1e87e2652c82 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_DWMAC_MESON) += dwmac-meson.o dwmac-meson8b.o obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-ethqos.o obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o +obj-$(CONFIG_DWMAC_S32) += dwmac-s32.o obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o obj-$(CONFIG_DWMAC_STARFIVE) += dwmac-starfive.o obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c new file mode 100644 index 000000000000..fba221c37594 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * NXP S32G/R GMAC glue layer + * + * Copyright 2019-2024 NXP + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "stmmac_platform.h" + +#define GMAC_TX_RATE_125M 125000000 /* 125MHz */ +#define GMAC_TX_RATE_25M 25000000 /* 25MHz */ +#define GMAC_TX_RATE_2M5 2500000 /* 2.5MHz */ + +/* SoC PHY interface control register */ +#define PHY_INTF_SEL_MII 0x00 +#define PHY_INTF_SEL_SGMII 0x01 +#define PHY_INTF_SEL_RGMII 0x02 +#define PHY_INTF_SEL_RMII 0x08 + +struct s32_priv_data { + void __iomem *ioaddr; + void __iomem *ctrl_sts; + struct device *dev; + phy_interface_t intf_mode; + struct clk *tx_clk; + struct clk *rx_clk; + bool rx_clk_enabled; +}; + +static int s32_gmac_write_phy_intf_select(struct s32_priv_data *gmac) +{ + u32 intf_sel; + + switch (gmac->intf_mode) { + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_TXID: + case PHY_INTERFACE_MODE_RGMII_RXID: + intf_sel = PHY_INTF_SEL_RGMII; + break; + default: + dev_err(gmac->dev, "Unsupported PHY interface: %s\n", + phy_modes(gmac->intf_mode)); + return -EINVAL; + } + + writel(intf_sel, gmac->ctrl_sts); + + dev_dbg(gmac->dev, "PHY mode set to %s\n", phy_modes(gmac->intf_mode)); + + return 0; +} + +static int s32_gmac_init(struct platform_device *pdev, void *priv) +{ + struct s32_priv_data *gmac = priv; + int ret; + + ret = clk_set_rate(gmac->tx_clk, GMAC_TX_RATE_125M); + if (!ret) + ret = clk_prepare_enable(gmac->tx_clk); + + if (ret) { + dev_err(&pdev->dev, "Can't set tx clock\n"); + return ret; + } + + ret = clk_prepare_enable(gmac->rx_clk); + if (ret) + dev_dbg(&pdev->dev, "Can't set rx, clock source is disabled.\n"); + else + gmac->rx_clk_enabled = true; + + ret = s32_gmac_write_phy_intf_select(gmac); + if (ret) { + clk_disable_unprepare(gmac->tx_clk); + if (gmac->rx_clk_enabled) { + clk_disable_unprepare(gmac->rx_clk); + gmac->rx_clk_enabled = false; + } + + dev_err(&pdev->dev, "Can't set PHY interface mode\n"); + return ret; + } + + return 0; +} + +static void s32_gmac_exit(struct platform_device *pdev, void *priv) +{ + struct s32_priv_data *gmac = priv; + + clk_disable_unprepare(gmac->tx_clk); + + if (gmac->rx_clk_enabled) { + clk_disable_unprepare(gmac->rx_clk); + gmac->rx_clk_enabled = false; + } +} + +static void s32_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) +{ + struct s32_priv_data *gmac = priv; + long tx_clk_rate; + int ret; + + if (!gmac->rx_clk_enabled) { + ret = clk_prepare_enable(gmac->rx_clk); + if (ret) { + dev_err(gmac->dev, "Can't set rx clock\n"); + return; + } + dev_dbg(gmac->dev, "rx clock enabled\n"); + gmac->rx_clk_enabled = true; + } + + tx_clk_rate = rgmii_clock(speed); + if (tx_clk_rate < 0) { + dev_err(gmac->dev, "Unsupported/Invalid speed: %d\n", speed); + return; + } + + dev_dbg(gmac->dev, "Set tx clock to %ld Hz\n", tx_clk_rate); + ret = clk_set_rate(gmac->tx_clk, tx_clk_rate); + if (ret) + dev_err(gmac->dev, "Can't set tx clock\n"); +} + +static int s32_dwmac_probe(struct platform_device *pdev) +{ + struct plat_stmmacenet_data *plat; + struct device *dev = &pdev->dev; + struct s32_priv_data *gmac; + struct stmmac_resources res; + int ret; + + gmac = devm_kzalloc(&pdev->dev, sizeof(*gmac), GFP_KERNEL); + if (!gmac) + return -ENOMEM; + + gmac->dev = &pdev->dev; + + ret = stmmac_get_platform_resources(pdev, &res); + if (ret) + return dev_err_probe(dev, ret, + "Failed to get platform resources\n"); + + plat = devm_stmmac_probe_config_dt(pdev, res.mac); + if (IS_ERR(plat)) + return dev_err_probe(dev, PTR_ERR(plat), + "dt configuration failed\n"); + + /* PHY interface mode control reg */ + gmac->ctrl_sts = devm_platform_get_and_ioremap_resource(pdev, 1, NULL); + if (IS_ERR(gmac->ctrl_sts)) + return dev_err_probe(dev, PTR_ERR(gmac->ctrl_sts), + "S32CC config region is missing\n"); + + /* tx clock */ + gmac->tx_clk = devm_clk_get(&pdev->dev, "tx"); + if (IS_ERR(gmac->tx_clk)) + return dev_err_probe(dev, PTR_ERR(gmac->tx_clk), + "tx clock not found\n"); + + /* rx clock */ + gmac->rx_clk = devm_clk_get(&pdev->dev, "rx"); + if (IS_ERR(gmac->rx_clk)) + return dev_err_probe(dev, PTR_ERR(gmac->rx_clk), + "rx clock not found\n"); + + gmac->intf_mode = plat->phy_interface; + gmac->ioaddr = res.addr; + + /* S32CC core feature set */ + plat->has_gmac4 = true; + plat->pmt = 1; + plat->flags |= STMMAC_FLAG_SPH_DISABLE; + plat->rx_fifo_size = 20480; + plat->tx_fifo_size = 20480; + + plat->init = s32_gmac_init; + plat->exit = s32_gmac_exit; + plat->fix_mac_speed = s32_fix_mac_speed; + + plat->bsp_priv = gmac; + + return stmmac_pltfr_probe(pdev, plat, &res); +} + +static const struct of_device_id s32_dwmac_match[] = { + { .compatible = "nxp,s32g2-dwmac" }, + { .compatible = "nxp,s32g3-dwmac" }, + { .compatible = "nxp,s32r-dwmac" }, + { } +}; +MODULE_DEVICE_TABLE(of, s32_dwmac_match); + +static struct platform_driver s32_dwmac_driver = { + .probe = s32_dwmac_probe, + .remove = stmmac_pltfr_remove, + .driver = { + .name = "s32-dwmac", + .pm = &stmmac_pltfr_pm_ops, + .of_match_table = s32_dwmac_match, + }, +}; +module_platform_driver(s32_dwmac_driver); + +MODULE_AUTHOR("Jan Petrous (OSS) "); +MODULE_DESCRIPTION("NXP S32G/R common chassis GMAC driver"); +MODULE_LICENSE("GPL"); + From patchwork Mon Oct 28 20:24:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854085 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3C7911EE010; Mon, 28 Oct 2024 20:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147129; cv=none; b=d04BZpXXOmR9rmRlB5iuwbu94mDn7GXFbqj1kIz1oAfNcTv5I/YnwcPu902FFZiKRFUmhEJsPmUtkkYfSZ2cCelvLRx8HEgIzHoj4BCqVfxWARlIANQoqZfA+/hQprrqzO1zapifoIgCP5V8+q7BM1uLbg/PyOFN2VO2LZo1wgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147129; c=relaxed/simple; bh=jxQx/kC5pg0vkeAlqNxn4N25veg7t15SHzEfOOwKjGw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iFOxKelN+syEaoX0knMJOcw96Jpy0+AqQqtE8gHF7s6mq+WRdTyRpEdrSoWlWRt62Y5FJ5u+BtDpnIbljI4mRZ1HtpeutFz/OGZLQgqN9HYiQMM3+x78xh/IQ8nXY1yHPbpiW3tZK6G9PjKnTHrBZfbMSVlm5kB0CIQHGEBYbbA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uo7E3Lzb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uo7E3Lzb" Received: by smtp.kernel.org (Postfix) with ESMTPS id E6FACC4AF0F; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147129; bh=jxQx/kC5pg0vkeAlqNxn4N25veg7t15SHzEfOOwKjGw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=uo7E3LzbY+3bzk8/RMso1OTbJVUsc4rOAtaC+Edpm+2ftPU3S0NTe6AnA5pHxzM3D xkdmfmbQ6vg99SUkcfJliTLm6GhYyrfNRhiUWKyd4YVhRWEVLgWbuJICyO0FZEGCu3 ibPMZe62+IrcPG8g5PUUmR1qoCq9mLEUsnF6monhHZq0OMskzJeIzrd34qMKnS25HJ 8gPvO1xYb2X4yyA8rj+QQ6hICH0g84ozexvwuCWWe46YUvDYM0XZhoBQCEsAslMUD7 tSAMN5qKpS3LfI4NrSuAXsfiHsJx7rpZhVHADUzn9aaUt3UJz7/DQ6TxbdzgTAgz8b N37SIJQIvYM8g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3A58D5B14E; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:57 +0100 Subject: [PATCH v4 15/16] MAINTAINERS: Add Jan Petrous as the NXP S32G/R DWMAC driver maintainer Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-15-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=872; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=VB/vrGkvv7jvc00z/vbTqiGVarHa+aZl+nYsucQdPaA=; b=bn7ewx0FKW2MErkpm0xYudN3oWv+jr9Xuygt0x2WfE6hXuiQu0ZgDPmA+22ZPkycgzAP1pLI/ dy9T9aaM1eICPVc+Z/UefbcOkZitkFT9+M0G4OQBd2LAniBQwYI+Mfo X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com From: "Jan Petrous (OSS)" Add myself as NXP S32G/R DWMAC Ethernet driver maintainer. Signed-off-by: Jan Petrous (OSS) Reviewed-by: Andrew Lunn --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7ad507f49324..9cc074f7ca7d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2803,6 +2803,13 @@ S: Maintained F: arch/arm64/boot/dts/freescale/s32g*.dts* F: drivers/pinctrl/nxp/ +ARM/NXP S32G/S32R DWMAC ETHERNET DRIVER +M: Jan Petrous +L: NXP S32 Linux Team +S: Maintained +F: Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml +F: drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c + ARM/Orion SoC/Technologic Systems TS-78xx platform support M: Alexander Clouter L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) From patchwork Mon Oct 28 20:24:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Petrous via B4 Relay X-Patchwork-Id: 13854086 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 38BBB1EE009; Mon, 28 Oct 2024 20:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147129; cv=none; b=fZxT+Uu6qS6OULZtyuZLnfCWMaD/si5UbjCFJyRtWDpv9yrmyxVcomrqFEM4b9CIQOzGsXAQciP6lEingsPiOsxMPRtVFo3dubpE4RMZpmsPZhEg+b7go9zEcbhnDMKICVULEyv7CFrKhJAOzX21yWgtf1yyoxs7qYTac7CZuIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730147129; c=relaxed/simple; bh=GkMDbekZjB413spSTR0VjgfWteczHDggEgGysKXOZNM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TyFOZrGRK7SntoZ/rLNjoM3MRYzTV9ZZYeT1O2Qne48iopp6aMwbKQ6nOr5x3U/3epTEP0Feugq0XWaE0H5XyhIvXZO+kvT5G7ZqR8TF5eVZDCZwmwhWf7WNAwI5u0si66LjwKHAZLVJpchcXJ56u2Ad4OIitouXrloTRUO1cJ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mXiL75m+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mXiL75m+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 01E3BC4CEE7; Mon, 28 Oct 2024 20:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730147129; bh=GkMDbekZjB413spSTR0VjgfWteczHDggEgGysKXOZNM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=mXiL75m+E7K8jMEWIDyuSqebPihtWwF+37c9GSBFVphIYJPXs7Hls4umuBzGO8xyp oOrUAycEYWUGuIovCuxndtWC8li5P5iTkne29rKP4C2cQrbnP2JmOXfXvSDLrl7i3b 3aM0ScUt04nmfnsv395mwpuXHtoLucOqQXN1mH20WZty17vT1Rs/0vSAdWE3Rh4Sy4 48lTbgc5FcKseURg5PFklQ+RZPNOuctBxBKDdjHsM9MhCXQhF49QgwkFt0Z1+WQp+1 WdJDX47zBffGlkj9cWvRsPxi9irNqLwVln3pi0+I+FNGlDOud17aF0d8fDKRZw1bwZ y0GSB/mArNVPw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3279D5B154; Mon, 28 Oct 2024 20:25:28 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Mon, 28 Oct 2024 21:24:58 +0100 Subject: [PATCH v4 16/16] net: stmmac: dwmac-s32: Read PTP clock rate when ready Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241028-upstream_s32cc_gmac-v4-16-03618f10e3e2@oss.nxp.com> References: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> In-Reply-To: <20241028-upstream_s32cc_gmac-v4-0-03618f10e3e2@oss.nxp.com> To: Maxime Coquelin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vinod Koul , Richard Cochran , Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Emil Renner Berthing , Minda Chen , Nicolas Ferre , Claudiu Beznea , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Giuseppe Cavallaro Cc: linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, NXP S32 Linux Team , "Jan Petrous (OSS)" , Andrei Botila , Jacob Keller X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730147124; l=1605; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=LsZsEsLk0S5TfmlHZCV6HTyBWNimPqjm1epTUQoYEEY=; b=UQ0dGVjkzm5GF1d8SPLrApbJm5eP1wcEFzCOmIZsO2S6Axeju/ihEdVNgR5Ymfi+y/1JYAjtu 8gaokdVXYkrAPmWNLUbafaETbKpSQPUHkt0TuYOSgaxtqsEpslpq/0U X-Developer-Key: i=jan.petrous@oss.nxp.com; a=ed25519; pk=Ke3wwK7rb2Me9UQRf6vR8AsfJZfhTyoDaxkUCqmSWYY= X-Endpoint-Received: by B4 Relay for jan.petrous@oss.nxp.com/20240922 with auth_id=217 X-Original-From: "Jan Petrous (OSS)" Reply-To: jan.petrous@oss.nxp.com X-Patchwork-Delegate: kuba@kernel.org From: "Jan Petrous (OSS)" The PTP clock is read by stmmac_platform during DT parse. On S32G/R the clock is not ready and returns 0. Postpone reading of the clock on PTP init. Co-developed-by: Andrei Botila Signed-off-by: Andrei Botila Signed-off-by: Jan Petrous (OSS) Reviewed-by: Jacob Keller --- drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c index fba221c37594..da2cdcfd0529 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c @@ -140,6 +140,18 @@ static void s32_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) dev_err(gmac->dev, "Can't set tx clock\n"); } +static void s32_dwmac_ptp_clk_freq_config(struct stmmac_priv *priv) +{ + struct plat_stmmacenet_data *plat = priv->plat; + + if (!plat->clk_ptp_ref) + return; + + plat->clk_ptp_rate = clk_get_rate(plat->clk_ptp_ref); + + netdev_dbg(priv->dev, "PTP rate %lu\n", plat->clk_ptp_rate); +} + static int s32_dwmac_probe(struct platform_device *pdev) { struct plat_stmmacenet_data *plat; @@ -195,6 +207,7 @@ static int s32_dwmac_probe(struct platform_device *pdev) plat->init = s32_gmac_init; plat->exit = s32_gmac_exit; plat->fix_mac_speed = s32_fix_mac_speed; + plat->ptp_clk_freq_config = s32_dwmac_ptp_clk_freq_config; plat->bsp_priv = gmac;