From patchwork Tue Nov 19 15:00:07 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: 13880050 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 791521CF5FD; Tue, 19 Nov 2024 15:01:04 +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=1732028464; cv=none; b=YhyuZC0045lxwWKoU7CJPohUmdbrFW5+TSG+EoQLAKHCZvNPi+bV4oE3B2Aj4APTXzZoGsj+aTTGpnVI5L9m5A8fogxtiCQwtD5+k0SId7i22p/GhUja7w5DfwddGovNGXZyoI9OC34Pf8+/j4gU0dvugmozk8mqiVs7nfE6GmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028464; c=relaxed/simple; bh=zonr3mCcTyCgwR7d1gZNImuy1doROORC9hQH8Wi0Qyg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c7NE2eW9C8JxUX37k3P55B4Ado9tlhwgXQSJK7VAmPqYG/3GitRO5/pF36M9wc9XpOO/kgbGx3iowVuhgw0GaNVmpICHN4CHeVuzXC8HZV9oA0QIdo0wPtHnvCB+YQL7GQ828qLG6ALTfNl08wo+MxNa6r9h6iWvpx5Isneb5tg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RDVV4hcp; 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="RDVV4hcp" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1A2D2C4CECF; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=zonr3mCcTyCgwR7d1gZNImuy1doROORC9hQH8Wi0Qyg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RDVV4hcp4eUvDGQRhU6ETJwU7idAdmiPrXhEQm3KRR2JFLdvXHySvFjXt8qMtdUFK 3Rpa3MfFQZz0rNn0H7wzOhA3lgFTB/MjvEY8ZrfFQ0GnfHeB9fzuSvqpyenAtIGYsh U7Mm6t/ucrRB4o2m0jViNqV8oDd8dKtexoPdpWK7FNWOW1HZdJqcrsBCicje4HUdbC UhqPX0+ELsZ18Yegy5Dvim62OJF4efTFvqnIcORXD43zR5FeR3xMS/SZLNrw4dmmh8 NG0ONGaBcNi6iqqg75GB6FCVKAB/Lx4ouJs9dQLP5TTSPHY4jT8ply9Zu/3GUJTZ+N tJKFo5q/FiRIQ== 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 09662D44165; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:07 +0100 Subject: [PATCH v5 01/16] net: driver: stmmac: Fix CSR divider comment Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-1-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=958; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=2KaIHv/oSTo3FOtKPvkHjEF7Z3D3rI5ymtYbTqdzAuo=; b=VzXyPPkdD5MNgXPIsgGgKyikwTPOcuqi1aJQqTrQ5YJTNgwosCPyciyjVICWmxvJfZ5ZXqQFd YttUk4CqsfaBSEM3a7vTlKy8vS6gzRhr2Z4pcsxZrVfQdEZZrLOBg1+ 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 Tue Nov 19 15:00:08 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: 13880053 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 B8C1B1CFEA1; Tue, 19 Nov 2024 15:01:04 +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=1732028464; cv=none; b=rE1DqD3S1NvcTp1bmsS3bFPX2bDdC6KY5mFD6txX4cNMn7L8v80dls8c5in3inH55u+u22cp86PX6vISFdIOMi9Bw/QHRSaFDi3FXJc+tLI6vqYaGzwgJo7WbzYzpHmv3v7WVR13KzQG/vJXDt8aOObOj7mzsQ8BQgK6+spp91Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028464; c=relaxed/simple; bh=IosRVsOhXaWuKtna+S7TTj7J8IIDP2TBXfqtgenJkPY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QqU3e16KnTEbdaXPHTRoIto5MrJzppwZx7ou1CI93HuWSfQQFlvWt3xtiB74l3ILKSOxNeQdlqhyJRqyE54lyd02YpV2DB/07vDcSh/JGf2ZAUPoF7v+4AWTMO+EtvZw0b5ycZHmQ9oUd2vsU+7q68woKBqzus7yC4xLUvKQwus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rHmW8pyz; 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="rHmW8pyz" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2C4EFC4CED2; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=IosRVsOhXaWuKtna+S7TTj7J8IIDP2TBXfqtgenJkPY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=rHmW8pyzYESo0w1Bh0OvU2MjWhCyLjMvDfeLfvzyQteYRnJSV7OwbQUwfrh0iiJDc BnV8vzJEAabyNT7Q9lAzrjSMaZepbOzslZ3a8KcbwFs3s9IdjjAjZe4kADrV5qVUPj cZ5EQurVs5mDOVHCL7kJJBEl021RRganQhLXMo0TsriMR7zZW21nhVvoXIBdIYJro4 meyaK5vxsErcdbE4RyA76Azg3ld6aNV9oHt472Dh8rBWlkbVDqE9PpFA9ChNhiZ/ih JG+C2BmrgMHyV7llKWR2JsNl+7Py6nqhN7KHQaMk1zImgnDmOwqr45mrf83qB8SHHa bImfoWAJ22amg== 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 1DE76D44167; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:08 +0100 Subject: [PATCH v5 02/16] net: driver: stmmac: Extend CSR calc support Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-2-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=2225; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=50kRIgWTZi5wCMka5I1DSABnnyKmmvDBzkE8UY/BAAc=; b=pMklRc3dp+NTaxkgKq7mLlrrefkInnF9GNFsD5SvbHHqshUcFJtH3UvED4kFZ69nTWOQHBVTX uKHpEoqqbP9BHh40hpxQr935ovrjlsPOE4NcZG8dF3iTKl9fX4IenzL 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 support for CSR clock range up to 800 MHz. Signed-off-by: Jan Petrous (OSS) Reviewed-by: Jacob Keller Reviewed-by: Russell King (Oracle) --- 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 7bf275f127c9..85fa75fa6abe 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 Tue Nov 19 15:00:09 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: 13880052 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 B74241CFEA0; Tue, 19 Nov 2024 15:01:04 +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=1732028464; cv=none; b=rFsZCz5kGPbwATCaKLhR/KnMvQPiMlTbd5YU94n19w7vqp5yrebU9+h+/PZlDnZjN0rbf/+vpWk/5v9bwXIkym4j48QlbtTNMByHSvF3hBMgqL1IPtcF6/wwCqT2W4H7ltZyy9JIKVkSCoEYmTN/yCm5nBwSdpNBNN1jnwyYeiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028464; c=relaxed/simple; bh=axOruUYC/TxQCwOqg+9pJVARKk+8imeW6v4uMk1inlc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cDwgyVdNIQg7/wohJJDGJwOeRswXr3r0+vZEdTKu2Qir044q+++PTvf3mwJMYbRk9v/MGEouVW1o9Yg2Asi45j/IOZD+in1ejSj/+C92oRvzj0eyh+e7aYR9lC7aTrD9g75w9chWzcXO2xQRLH9/HF73AS61IiN78ZTJ2N1Eg6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d7cqK3zq; 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="d7cqK3zq" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3F918C4CED8; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=axOruUYC/TxQCwOqg+9pJVARKk+8imeW6v4uMk1inlc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=d7cqK3zqTfRZuxLTPRJByUqJ6m02je2wZS0CYbmb/bt1RARGkW9pwzvpoy/OAzUCT sPh1SJKFmBN/Cwww/hmpWbewq9osjbudpHf30jTPnrz2EBHjrjQS3K6BqGiOeDsDtk npfF0RyNi8KlXAYxS1v6VPI4ScOkMwIucv+GCj+cYRYCaRfhgbxXquBLjaW9E3ccXY Ud0HGjphdj+oBR2WdOWAdv0VwERadjjXe9VD+yVTOFhO/7fvyiMkhzBUleQRAYq1Mk oFMT91/dWNrpP3B96751ynGYsxw72JoxYFwRflt3OMCc6xZ4G68202mC16RfVGxY82 CwXhu2o3BwfSw== 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 31DD8D44162; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:09 +0100 Subject: [PATCH v5 03/16] net: stmmac: Fix clock rate variables size Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-3-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=4015; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=2zBIP1pqWbxljDYVW6XJp7WZLnEFiMk2GjNFgE+0EQQ=; b=WKYcQ/jJlzzzivMKrlny4nPDPO+laFcQ6yCq1HdncJmHKRIdn5VtMEEtXnhHjsbS79ApUS//Z JDAIj8BSSNBC4Gg9d7xoROCmB8sOjyOpce2lTZj7WNy4Rv4deaQrHPy 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 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 Reviewed-by: Russell King (Oracle) --- 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 85fa75fa6abe..5eeff3ef7095 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 Tue Nov 19 15:00:10 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: 13880054 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 CB5D31CF293; Tue, 19 Nov 2024 15:01:04 +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=1732028464; cv=none; b=BVCLI/Li7xfkZrneu54nDsFOPn/aOIVfvGO9nDpWDFwWBr85pxaUYHDEpPnuDDsvJmr4H4K7jya66/4tYKpJXUS720wBgSvsAsYsNoJZ0SUA9CdJp3Ka7a/fQb4+5RvEuTRSqxOr5o9gT7ZpZIJy0WT0vzAMkOH16qOdaGzdQZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028464; c=relaxed/simple; bh=6xMLlIpSN0JBvla5nTP1dqcG6Ed1UwqOOxwMgbKzQ0A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qACUdn8nTWYYt53dcb0ucMcsolR5gZMP09Go6us95tVuEl99RYC5rywVPbs7zLQMh+2PfTkhXZntbL+yKrsrvFm/GUNzAXibW92N1v0oFKYoCEpTH6NtGxk8MeHORoqn1M4LFVIzR9P8VqANK1DYsR0WqI2JbG0rhzLK4ZVFP+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Cjb8vBoW; 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="Cjb8vBoW" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4F7F5C4CEE0; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=6xMLlIpSN0JBvla5nTP1dqcG6Ed1UwqOOxwMgbKzQ0A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Cjb8vBoWvTq7UCm8IA2PWVqLbNSVrqjByOM5WR/sCrWEg+eGO7VD85jZmsotPVpL+ JMSzlg5q1ty/1SFQUGC7VRDSam04nEeag4ccEUbPCj1LjPX5Dn1bLOZ5h/cAbWLSIS pV8pUMxb0sLr5aJrxrTIWXRqBaugh7U6RhWz0o834ZzuF4LSnIaZoGMKIB7ifAnEC3 5xgM49YuW69HyCqvMkDbt/3uLeEQK5sU9ff29wmwhDQrxQiMEXH5UktmsOvuZes5QV 1Q9ABK+pa3veCWQpGYnVV7vBGFo/gvOGyi/6a3SV9EouZpO/xwn2E6eMpC4HSWwphB OfPgczluSJb7w== 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 43740D44166; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:10 +0100 Subject: [PATCH v5 04/16] net: phy: Add helper for mapping RGMII link speed to clock rate Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-4-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1444; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=9P0ry2iOu969sx+k09VLkaOhf19TsKhJriPqamf/d5Q=; b=3x1pZvA190M4/JSVKA6683Fqp6WmSzqEWmYvvett/32O9XyIAaAkbscj0re5YlXILhFY1HZEn +qAywTHv1c2BOioB2wL4dAHT4KiTNVvLwyHWaBz2kKoAR8J4QSJ4x9D 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) Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) Reviewed-by: Russell King (Oracle) --- 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 Tue Nov 19 15:00:11 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: 13880055 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 E6F901CFEDC; Tue, 19 Nov 2024 15:01:04 +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=1732028465; cv=none; b=DXzfc1FyoitYJYFJSMsGgqF8uhQfMNv6gY9DGiRPOkizYAcUoA8eiLe72JU4JYEstbepV4Vv4uS6G/FEPtbUeZmZnWqO8yl5dXYa5RNC/Swq9qPZC1NiLRdT95OO76pmcB4V0+7aPi62cZ9QJp3cy/Jbp59R6R8ElySb5LY8i1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=47ocNny3+THfoYlUnqJ9gsF8ebTxJoWAO/GuXYIY3B0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MdbVAIHDAMovp/PnJ5L67W+yMttsTXhGIFUtPSh0f009J3o5+1JSgjXNtvAX8pLbBkaJnzJoMTNm2RZgvdzSqdA1tGT7CiO3PIy29runpPp7UL6w78+Fk5ruyy6ZNga1M2vjggQi2XGKPNpDdzfFFZjTdyBeRzwfFyXCKeeXHM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SGsp/Uhr; 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="SGsp/Uhr" Received: by smtp.kernel.org (Postfix) with ESMTPS id 60916C4CEE1; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=47ocNny3+THfoYlUnqJ9gsF8ebTxJoWAO/GuXYIY3B0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SGsp/UhrrpGZWNInllKhgiz/SsSQSHLeuVI00Dwk6CPQScdeONgh9Vyx7q5p/dUWx P3hLZnBhXyRX9fZp0odty1ugtH/vHTqgBWu3UELA5Bo7rm3Pawb4J0W1aW2BFeGugh PMQPIew5X7y5fafaqX337G6Vo0M11a/V8zB+XFP8PLlCCmvEFSt+GkdeQ9kigYSxbj L13o78vn9J2PR19kkk0dNlyjazJzXH0kJz38EUuhkEyN/h+fXrjfvM4FcxE+8wEAL0 iDS4xZ0zVTeijE6AHJX0s9fGzdhfgGZlofnZtlY4ZeZR3UyMtF69cbPrmOZVmHnL4d PpaN0uhXDH3+Q== 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 56328D44165; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:11 +0100 Subject: [PATCH v5 05/16] net: dwmac-dwc-qos-eth: Use helper rgmii_clock Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-5-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1225; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=w8qKMUbePd0dbgi97IzRvhmqA046iGgBejOkw++o5yw=; b=FMYBRt/A42Qa4Z7krGr0OpDcK1HAoTIvhUKlceHXBBPZmS7ounwtwMYDRVL2veeohiXghfahL QOTdDUwh03cAVnGXFV5f0n+fVcuokSl/Ri+59pCCK6DspQVe8FuC+T2 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)" Utilize a new helper function rgmii_clock(). Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) Reviewed-by: Russell King (Oracle) --- 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..6fd59338ce85 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; bool needs_calibration = false; + long rate = 125000000; 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 Tue Nov 19 15:00:12 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: 13880058 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 12E991D042D; Tue, 19 Nov 2024 15:01:04 +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=1732028465; cv=none; b=HcTyKC+Jk12W+i95CCttwgc7akVxtU8WcqEEPqfpNtqyxyrfxu5jvILfjJVcZfsHHrBfObG7mfNTjiPt8RbfJPWSfbygdcjcx1S+2+o9KvextqDXuL7xZmr9ik6CGcQvZqStC6sJxsntc99xRLlhJCvP1vxUCcqygvifyOLmp1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=3hMV+dFZIlXdDhyi3/I8ldvy/zJY9dzk9sLcu+SoBms=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Cgoc11UDufzcnYnrAfgHI+2H0wabyjeuTHyvT/7BDn01EqC+IbWbt2ziEvQLDf4xRsrLohiMQoXxJCcCGbE1IZjGZwmvz9yJWltdxyLnAlTHY70uiPLrEF76J1Pcr4u0jjZKAaFuMSidUpgjEBdzvLDUX+biQ7FKUC1tmF5bb0E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C4PiwW3+; 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="C4PiwW3+" Received: by smtp.kernel.org (Postfix) with ESMTPS id 71A84C4CEEA; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=3hMV+dFZIlXdDhyi3/I8ldvy/zJY9dzk9sLcu+SoBms=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=C4PiwW3+MLR/P02zydOw/ZSD8yxLpCBMUX+2u6hta557zhuiclR4C1e7iC9jSaI49 a5EwOvnUwop5TQWzDpZa2ASIjw3+4kjK/LFjBE99s9SuzTjQvQ2pT5x5jtHNvJ7EWt 1x8JO362QhI4ZGF+RMe99LfGoJyrMZ2pbe1txpI+ZarlSM8hC1FgHmxgurQkjwjdpH INaE8f9Kc/te1BZ9MIBqbGkJEyW4XVf5dJT8B5pXRqdT+d54IK49iiNthYZMTE/WUL h9amQccdz5vRbv9mNBDveijynOTxrhIHEtr3TuilE4qtQyjCoGI3KHEWFjBYQ0qpuy D9KpQ2qfwft2A== 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 68150D44162; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:12 +0100 Subject: [PATCH v5 06/16] net: dwmac-imx: Use helper rgmii_clock Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-6-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1311; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=RMVTH3hvh5z3jXZFII2jqlp8hQsgh3kxOOMPagrwF3g=; b=dQnFrCsQGyOKB3ADiDaFhX22HH/kYW8anN5LeDqQvsHDyOqQMAyG7LnAD8YtZxHTxyASzcmTr dJosg2cfywGAj/+rRC6ZylDwKZatdHlRaV/oKj1sI/jLTsBiNSiOh1R 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)" Utilize a new helper function rgmii_clock(). Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) Reviewed-by: Russell King (Oracle) --- 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 Tue Nov 19 15:00:13 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: 13880057 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 28D991D0784; Tue, 19 Nov 2024 15:01:04 +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=1732028465; cv=none; b=ZpadLYoJEF9NXL/dnoxhhMQSS26m4b42NjYJOrXLWEe8OmRIi4XFlCrQi36gQBFfZF7Jk0ljCzxPhmrMGqKPMqdv1OOpVHTt5blIXSFNSmKxkmWJ88Y7u/iOgmoVBaVBAKUFuZLjZVsFmmXFZ4vr4OClLPCCEiNkH9vT9ESyPR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=515UImMIUwY1iiiy/6ZmqrgD+7ijxpfASmzHkHswzhk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YRTWBaK2SPc75plWJ3Am6cuSUal4aVzaa8t+/N4DQNV7FtJ5O3H+MM5TIhPcqDP7geEsp3X3HkAZjYIYnYZmUQ9EUmL/n0wqy56HelZd2kz6TekZr6mGrhLdbMhzP+ywU5HSZMF8u0mxPpwim6KovcYyOWQd6JUHD4LIFlU9sDA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jcav2wRA; 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="jcav2wRA" Received: by smtp.kernel.org (Postfix) with ESMTPS id 84D3BC4CEEB; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=515UImMIUwY1iiiy/6ZmqrgD+7ijxpfASmzHkHswzhk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jcav2wRAiavU678iNu9xPGuzu5a55RyALlwMuqhoGJ5NE3BLeX84JA6jmBH+w0Krd CgoGM/Y6PHEZgLyvqpQ8WARACpXmi4sjYxNFLPCiYAVAlEi6thxBghV3qhJ5gBEHc1 4NIu3U4r9VmOYFM+qTlPoYe6A9Ovmwje7pZFeYitljflRBh7cFHl9KwV4a4gg74MDd fPSngu9Dt3l2DdLdvvzRqBsQ7unhxHBDqeW1+tnU1V3cISYm76TD/ZesHU/Vl/h8+u 57koGWO1pm6ckIsqvqdxNNBx+hUGTpEte0ui9YTYQNZDs27+YcDlQ3IwxuKJAzZO85 hd/TeT7VeEXHg== 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 7B802D44167; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:13 +0100 Subject: [PATCH v5 07/16] net: dwmac-intel-plat: Use helper rgmii_clock Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-7-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1227; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=slqRw7objjurz553hpNnHk7Oq3u52m0s/u20cRgTiOo=; b=X/dVu48GWo9o+7QqgePHJElMkzsTJa1PUZuhR9ytxNevODjPxQO/lj6gznC/I2xcocEtOv6kP +VdcspNoLSlCdmCkNPIdyCDtr+4lSb0R2aZ0D9qDZaqKCJnP0mJw4Zd 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)" Utilize a new helper function rgmii_clock(). Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) --- .../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 9739bc9867c5..71dbb8031506 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 Tue Nov 19 15:00:14 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: 13880061 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 3F1441D07B2; Tue, 19 Nov 2024 15:01:04 +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=1732028465; cv=none; b=AJsmjc7fM3rpLnYCXhnqat5/xYYvHx3CssdpzGrzBKL6th5bo/dBncB7U5SFAG5Bz0jXtKw8YGOAVrtdE3Xhy7EFG4MtHRuqGjezNvc7/ACkhcR08CF5urQHbkUrmmQ/fxwAfQlWOWb6/P7ff1Cm5BSM5fkXcWgb3rKTXOk1+xk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=taKk9Siw72UIT4YDaZOax2tfVMCp4G8cx27SIGcTiEU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QeLBH+rCKlJiUp0JUUD5OVAyPmQysosmYWvIld/zn2tMktd9xM+Y6r2lzkL/9PuMrw9tKGG2vXbYLrbtyAD5RMusEJU6PLf4W/pbVWUVsKLmj0vxnIblUOITSMDFFnhsf32TG8cNVH+1hvVPpdYkdxuFNVS5fOiocgPahai+D+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fx59a3jy; 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="Fx59a3jy" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9B5AEC4CEDD; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=taKk9Siw72UIT4YDaZOax2tfVMCp4G8cx27SIGcTiEU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Fx59a3jyQuxNDAR0PIYynzsjl8JfKja15cn7qYKBli6fRs7OzVPXvljuLL5W10LaN /tT/b7eavBU/LWQixHtpbehkjw4IAo3aXPW4sd/3MhBcjPSedoq24ZtdC/H461c12p PP/k2cVXu4A7Ju1oLTzejhlwquqv963av1Lhom1LQr+SysZFIQ4XF3pBmcskKKhUfE 89vqRFdb2Rwyk9R0c8CiXhSeMMGvO4BJRDBi5EEz4MU7ADEfxSZd9OGp/yDztSmGej dIRp4V/21wCvjdFLLUeWJkWbuPNqREhCBHvLqVYOeUuBvhqYwHo1jaSxukVzEj7qVU O7Jf0r4c84kUw== 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 8FE89D44168; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:14 +0100 Subject: [PATCH v5 08/16] net: dwmac-rk: Use helper rgmii_clock Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-8-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1708; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=qgV3Pn8mQViI9wI7w0SXeEm8aXeN4r9kNedskC88Gbw=; b=7MX3L571k5Y4YP2dBvgCCHyWPFDCquMX+NbR+SdC1/iy+YsgRPUhs1scm81+GpypUxG1j3HkH FiIQY0h2X7IDkVQDQgMM9uSR7Q52Bz3v4WJCSF2n1ENS4nYrFmvZNpc 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)" Utilize a new helper function rgmii_clock(). Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) Reviewed-by: Russell King (Oracle) --- 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 Tue Nov 19 15:00:15 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: 13880060 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 3DEA71D07AB; Tue, 19 Nov 2024 15:01:05 +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=1732028465; cv=none; b=NW5cvya2KOtDx2TLQforps4oor47ylkP3PDhuLXl/ciui+giPiIa/HcbJVNeyy5DliBYrRD6vnI5rq7pVWH7vIvpyT/O/duvOyKieHD5W5BxEmy7h+han9HV83DEXmwkr7YWLsqHKfUzATK7NBpbDc5q7gcUEfovqnJ3KedUAAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=iVihXo58CtO4IGuy+SiR8hXCaTbK3CdRsA01yVjIYGk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ARMNc+E1S4ldhwblVZvrSU87f4v4Umqg8qor+R0pi6hb0u3yMxq5+5N8bSoiZZW3Zot8APXYSs6qk3w/YxrGlMLLg9MPgSJbwS+IImtslRWz6JtP5InUsWLFAiwqBxwb0QxgPboNaIddNZGxHlTQyOTxXZ3HXf3YJen4PVRAFAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PvIvqPmM; 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="PvIvqPmM" Received: by smtp.kernel.org (Postfix) with ESMTPS id B7051C4CECF; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=iVihXo58CtO4IGuy+SiR8hXCaTbK3CdRsA01yVjIYGk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=PvIvqPmMxmJo18fVQIHoXLMG6dyx0Xb0jHu5FCH6LGuuKkEgNwCzZwelJZlcE8PbH yNIDD4OQKXlDu8zXMshJC4cwJJXnwvYic/nKEYrO80F2UuLLFXF3cA/Y6ZELWCzEPR 1/nEaYetKnDif2UR6qAYoMxPDlk1jH5G3h04//cmfR+oe0lROlFYeMG6tsPB1N9ckJ b8gY+lmD1bRukfVXReCXxm/pikN6CSVMEIKn3hw3+WSkZD7DBWb9aJ1AVMU9KhREFE 1RQRN3mrSXvNKrpDyFYD9qySS1KU55TTFRILoV2u4WG14kIwVEdHaBQOuPTX8/z1qt 9EWLuwKCiJr0Q== 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 A4BCBD44167; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:15 +0100 Subject: [PATCH v5 09/16] net: dwmac-starfive: Use helper rgmii_clock Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-9-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1227; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=bBoQpMQEMIZkvVLzY+cPIJeDILU+K5uktEDmkyEIirY=; b=VykuawcU4fgIfqEBtyRRZ3cazgs4UBBxKbDLVqgpAhgUdP/6Qn1gegY5BEGZUKsyvr94YnXk7 rww5Y7nRP/7BWX2sZ6Amd/iuP7+bGvy0dogXTu0If44pwpnfdW8qdEO 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)" Utilize a new helper function rgmii_clock(). Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) Reviewed-by: Russell King (Oracle) --- 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 Tue Nov 19 15:00:16 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: 13880056 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 24CCA1D04B9; Tue, 19 Nov 2024 15:01:05 +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=1732028465; cv=none; b=KL4fdxhfGGGIUNSlgQUhXs4SOcIzvrX2Zu09m3z8htW8WjAqa9dxcOWcFGAuT2ufb856+BzWVzm48ze0lwqig9odKLgc7YQNs9l2BStiquvELWBa3g4ka6AuMlgnBs282sMDI10WSG6UmWZJGQkUxBShcwDfoMHy5Ne4I8LQFXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=yiJTTdbSCBehVA/L/eEZohJ92LRA5AN12VTV8Lrt+K8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=D6V5mnQj7A7afSHWAR1RlGK3nH3mw39hBJ1n0O79FzBgPrc7nM81ImJVBklQxPCT6L1sZ0dIK78E/OhgsyNM0BcanM9Tecd48vlJlPEXWfWSyf5VEvLp0/jT1IhDLxY5YSDRNrfVo0bL+RgHUb82X+GAUUxCvfxjtpuoV2opJ0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h1d8HCI9; 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="h1d8HCI9" Received: by smtp.kernel.org (Postfix) with ESMTPS id C3455C4CEE4; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=yiJTTdbSCBehVA/L/eEZohJ92LRA5AN12VTV8Lrt+K8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=h1d8HCI9MTIQdG0KAGKuo6f8fNNEVireKaBtDcaxUs6jPHbcHBbsq9B/rIDEPyYDW TPmytZcAFTZ2m74CJvXHlkagHICv6s5u1ArQ+i39mEwQ5JXpEZunIG8/Ee/XyFvTtn QrCIcwi34y69U/VF79m34fRUD62rJGSc3VbUsI2r8tsW16/EWsuIebm0jMNS8g5Gsc Nbk53MinSIiWXey4Cp+daV9dRaydDnk6B/pQA9zSA3fRvJx8XAEi1FZVyuQqVbO8uV EhPUYu4MPslPzcthqao4v/vzqnSBY5CJCUKDs1QCUPRAyam4CF+j6eLQ2ZwYsDtfeK xV/tL0c4YYOHQ== 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 B9C90D44162; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:16 +0100 Subject: [PATCH v5 10/16] net: macb: Use helper rgmii_clock Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-10-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=996; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=U+5Hu4M7x0TrRD8qVcOZhTAwOuugFLfhyCNLJdF27x8=; b=LhgGR7PHLpII+75vmV9SAGzHIxvTr1dj0O5nQgbUB25EX1V8sKH1Tz+8pNTq4LLulryU/A+Ne svTyjwEjOpFAaGvIR5A4ZF6+vfU41ysuUW6JmQ35/SZFMujM54+Iueq 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)" Utilize a new helper function rgmii_clock(). Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) Reviewed-by: Russell King (Oracle) --- 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 56901280ba04..ba9d9567a3ec 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 Tue Nov 19 15:00:17 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: 13880059 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 33F6122067; Tue, 19 Nov 2024 15:01:05 +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=1732028465; cv=none; b=sPsmpxeKiqTt9tIqaJH2srAp+746QgiHi/MifM9qV3F6wkug8to6lxadL1IjmnVWcIM179gA+huNHyloQBGa9MAmErXja77cm2lpy2VLLTZnyDXUz+cWoY0ua2u/xwyym11esr7valwxQRfoTDqAhYl71PnsTYbzXDDtCl8FLFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=vGm8hB4/TmiszLf3bN85rR5cGy6kkIlZPmQ53rGOh3A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IEx3rgmkrhEydR37eBifBGEit0gx4exaV24RER4Y5LUeDlLjymvN/+sq1cmc+sa8CtLBdEiIpuQsUK50Dhgk0jlRDHf+WDAbR81emjmov5uN9yj3kaTrmWIYtwxgZvi0a6zBJNAv/55IgOLk2wMo4ZFcDYzac0a5HsHMPTCR3wI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AaarjyLg; 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="AaarjyLg" Received: by smtp.kernel.org (Postfix) with ESMTPS id D27EAC4CED7; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028464; bh=vGm8hB4/TmiszLf3bN85rR5cGy6kkIlZPmQ53rGOh3A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=AaarjyLgg6oCB49a2uPBY4p14sbonxiS+m0nRJo7XhliAbN/naZ1/X1lXo0na8jWs lv4cV5mZUe8jdH4/cP9xPBBdlFmisN5sxLz5hqeUIcUQo2fsuUz0x61B3hbDyGob0U xGFuVCArfxvmiAtoTXG4JlVcj8TGAoqCuY1ikW183cuL4GbUpCIx+mr5QK0w8aT7Zh EsTHghaLxVv2t5pjnMk4ahJ23HKDTM5P1kelTwp6+lzPDPYoh/QxAF1VQcK/ZfjZOs Pvf9FhZu5wH/oL5TGEa6vRE+GRspQ00goHhpSkw8fvgvKvJj6/1zAhNf8C6c3lfLcW alFNg8V1rQRhw== 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 C9A64D44166; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:17 +0100 Subject: [PATCH v5 11/16] net: xgene_enet: Use helper rgmii_clock Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-11-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1126; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=5u/M7E6Kz6sq/3FES3HGKltEz82lb2lsX0TwarooLQI=; b=I2sS6+ZpuCoSD34wTzDfurzGofqnJ+HMEz/fYxG6rNuFV1NQ5qcTjw+f8QevvHxV7tVt5UQe+ 5RXFZ/W2w37A+g8Nn32B6SfBxCREbO6oW1HPtuAsQfoQI1HbHtx/5Gt 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)" Utilize a new helper function rgmii_clock(). Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) Reviewed-by: Russell King (Oracle) --- 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 Tue Nov 19 15:00:18 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: 13880063 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 512391D0950; Tue, 19 Nov 2024 15:01:05 +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=1732028465; cv=none; b=feI19TooDvUtwl8agCmAoBJkDLFjTcbwKtMIKPjQnhi9G1vIlEiaUuPX5AqrVDQwb5G7KEE08NpAk/dNvOt9NDevkqyaQ8T57Pk18MQQonC8pF6u4La9amHCKG9HBk4c1hrCAWLweJNftWIFVQhlaRgUQ91F+zr7xP014iSd3zw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=4b0PrTZ2o36QkT6qbk1Xf7bzJq0U14n0yE8jb+fnAyI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FzCZzrrAVlexm2bBipls0aecOt0R7EL2AFfbJwYupJpGmLkbItACQAqVj/tVjNL0eMuoEjXFJoHVELveigM9VYzBrnuoDV6foP9a/0zANIUMnoRJp6OUFimE+I1BFC+hF/h39RayY3Ygb2LUgJf5lSPUUW7OGDIKvV7h7MDSexU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gAH/f+sR; 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="gAH/f+sR" Received: by smtp.kernel.org (Postfix) with ESMTPS id EE332C4CEDB; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028465; bh=4b0PrTZ2o36QkT6qbk1Xf7bzJq0U14n0yE8jb+fnAyI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gAH/f+sRoFcI/T2ojjuGNvA7NjK8OriwM98+76bkDeZxh89glMtCb7CBS4TiZm6XH /r198i1p9w4X8zD0XulocnjUEX6eyRFKBnWsalectEMxprdakNtt1TUQru4hm1e3vY DPz/Lf55UfgLlsqKEHN4RcA2nOE7NEX/WYyJFfnZqsfpDeh7hFgmPLVGwTxvuGa/To 86cKVbdrt4YTsUBbzMJN1a8VCQoaS01gSjtjUvRHAC9dIjmFwtdQ4RsxTkOCZ/tu9l jBn4tsCNkTmH9EZQlyuLmv7QyHpZXq/Hul7oj2hL7npeb5Zt8Qvcirdzc2UrKTsEas dIFzSbUovj9rQ== 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 DC2FBD4416E; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:18 +0100 Subject: [PATCH v5 12/16] net: dwmac-sti: Use helper rgmii_clock Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-12-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1952; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=4WAcRIbJeVrGoUYNaNKyXpe1e/1nCZz3HHyJvSF+DTE=; b=QJSE/uwH7qbGZ5Pt5AlP3qUpMisqMtOtJGoWm3nKCyRZm+VVvwzalJgkarLJiS7GZuaJMR0bp 4HZaWtP8UDeArvf21s/WgqOVmBTKD3sAUrVX6YwxBF7twnxzAib/NSm 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)" Utilize a new helper function rgmii_clock(). Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) Reviewed-by: Russell King (Oracle) --- 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 Tue Nov 19 15:00:19 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: 13880062 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 565981D095E; Tue, 19 Nov 2024 15:01:05 +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=1732028465; cv=none; b=Fn94m6S/EVzHkT3/4Lqw60P8w88DW3a7WgAgX3SkeDDhxY0afPcxrNRaVKlbl+9kFUPNe5osYbUoJ60PN17qFNjrucM/tGSFDMsuhYHDuwkaxS4oVgujIcLyu8R6ZHazA4jdYgnFD3sHG6vS48QqzRZe2PG280IVk8s85E4Ho4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=OmhoPxBbW2h8GuBsgibA6xugOaiXQl/SNjprceISX24=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kwrRas17gWXDtKokAR+sR+qkECqWxZbra23ioSrXQmyPS+sH+s+MrqFaxr/bABv04zzrh+qARL1LXS4XJECcJLp1/3oXUcfVwnqfKhwUGWIsa679lHpGjd8J/BqCsikxEW2S8WCmWnxIemfZ4hfaFsAfJN6Qw6JNqiOTGjbx00w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RkBYdbFV; 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="RkBYdbFV" Received: by smtp.kernel.org (Postfix) with ESMTPS id 09E8AC4AF10; Tue, 19 Nov 2024 15:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028465; bh=OmhoPxBbW2h8GuBsgibA6xugOaiXQl/SNjprceISX24=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=RkBYdbFVF2kJFYxglbrq1cixQ8DxB02h/9tzJO4xw43qLqtGTaAGYToVIxtls/tyB a4zej2rsLvWoGx60mvaaGpFj+fGpyMqB8eHWtaT9G8OyqkKkzihGCuiBrArimi3eBZ cNL3zyRDHePyKUG0md4r15EHmaInkFahmQBDNoAfYM/ifD5Z135oqNKAY0v5E/Cu+W gNh27QAXnpGnPCcSvgooMCoWlml31vHDqzH9Eu1/4pkBwZeonM4yza75tCToDFjMHx 4sDmDsFvRAT9Djw2xMRb+YsK70rpbPB2nPxNXWBXtoHn6kPReCEGLTJ1rpauAcFOVz oefMbJJnzwtRw== 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 F088ED44167; Tue, 19 Nov 2024 15:01:04 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:19 +0100 Subject: [PATCH v5 13/16] dt-bindings: net: Add DT bindings for DWMAC on NXP S32G/R SoCs Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-13-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=4093; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=1xROYlylzwH8UK0iKW6W31OAoU/xH+M2AeMY1t7N71A=; b=egKGCJN7L7SfDPwLAkt0D8PQm2WbSjgetnAwUx7ajU6wFMX7ZykF4MeT4vQGiic4QS3j4HY7g dukyTfF5/bgCfzXADaOQyoGgrz6ag4THqvIlg54jUjvEv7bGItftnQy 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 basic description for DWMAC ethernet IP on NXP S32G2xx, S32G3xx and S32R45 automotive series SoCs. Signed-off-by: Jan Petrous (OSS) Reviewed-by: Rob Herring (Arm) --- .../devicetree/bindings/net/nxp,s32-dwmac.yaml | 105 +++++++++++++++++++++ .../devicetree/bindings/net/snps,dwmac.yaml | 3 + 2 files changed, 108 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..a141e826a295 --- /dev/null +++ b/Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml @@ -0,0 +1,105 @@ +# 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. + The SoC series S32G2xx and S32G3xx feature one DWMAC instance, + the SoC S32R45 has two instances. The devices can use RGMII/RMII/MII + interface over Pinctrl device or the output can be routed + to the embedded SerDes for SGMII connectivity. + +properties: + compatible: + oneOf: + - const: nxp,s32g2-dwmac + - items: + - enum: + - nxp,s32g3-dwmac + - nxp,s32r45-dwmac + - const: nxp,s32g2-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 Tue Nov 19 15:00:20 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: 13880064 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 884EE1D0DF4; Tue, 19 Nov 2024 15:01:05 +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=1732028465; cv=none; b=td0/9SFbI/h4a6XPSnjkguCc96FI8IxYSPOao/B9WhqLAUBs/uD9W8ylrnr35H7/BFl7iDoaiFnOHMsiUvMBuC1MQsg4DQ6yB90OuEmfwDMxpeeGYfu2gsxKbsGlF4/MvvEwmQPexeZpOR+Q/0pddLYGQc46iFKxcpkFsmZ3qHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=d4fUt4ohwOwt27HaP1g9j1w9etYy9PaxiBoA9dsWn7w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Agr36C05zADJ2pdYGpp+woEghBMqU0M4mlyP5mm4hFBgse5TaeceSRX2mxZdjKMIz/UfS9FIBN7xeW7HSj68O88RjBvJX+LyRxE7TvO9f+zWm8JCpieL5xPJ77xfKuJUPKjKpYv7tTlSqoxOKXZuVroYLpLIupSpFzGyciQjp5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OPVuSBlw; 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="OPVuSBlw" Received: by smtp.kernel.org (Postfix) with ESMTPS id 54352C4CED8; Tue, 19 Nov 2024 15:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028465; bh=d4fUt4ohwOwt27HaP1g9j1w9etYy9PaxiBoA9dsWn7w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OPVuSBlwEJlcPQh4xsheoAi+WuVHcOwRzKNYXz3bSiVCHpjCtNk9d+QV8B7o+IDs8 quBpMmdvZG14Nm7J+jzujJ7J/YcyLI59H5PiiKp1D8y52dOCWro3PFXiL7ARbjLlJf EX1BW5BLFhr2jt1CCo5qCZKu0zqt5Qw/qPOUPwQt2cV3LoVjdjevf6Hfkrvt1Gg8aU ElLcQdw8QkR3fNOgTeAgBjE2dzxTr0NToTDqLw0s6CGxQY+VLMcsEKMf9gpZe//gQv DcMGO+5BSqQTF+fgSJ8NRn1KimWmmTqnFXEpN57dqPR24TN3gRqzHaQtvo0WYKtlsa pSDTeJ1OFmJRQ== 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 42E95D44166; Tue, 19 Nov 2024 15:01:05 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:20 +0100 Subject: [PATCH v5 14/16] net: stmmac: dwmac-s32: add basic NXP S32G/S32R glue driver Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-14-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=7569; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=diGzoOJV0UPq0bB6YF/HzTwqhERonWdgDAGXFRPFA9A=; b=x2PtksvUtZddCarVgLHJ5/8WP1jN3uGyIaxLGD1CA35BWv3kiJY791XsQkQbB7X6iepc6mbzf CncpWqXaDjLDSYkdfMkF+cJbbfEmzT9iSYeIujfmuVVfIPQRuAz+oeC 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)" 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 | 204 ++++++++++++++++++++++++ 3 files changed, 217 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..9af7cd093100 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c @@ -0,0 +1,204 @@ +// 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 */ + +/* 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; +}; + +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) { + clk_disable_unprepare(gmac->tx_clk); + dev_err(&pdev->dev, "Can't set rx clock\n"); + return ret; + } + + ret = s32_gmac_write_phy_intf_select(gmac); + if (ret) { + clk_disable_unprepare(gmac->tx_clk); + clk_disable_unprepare(gmac->rx_clk); + 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); + clk_disable_unprepare(gmac->rx_clk); +} + +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; + + 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 stmmac_resources res; + struct s32_priv_data *gmac; + 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" }, + { } +}; +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 Tue Nov 19 15:00:21 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: 13880065 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 A7F1F1D0E23; Tue, 19 Nov 2024 15:01:05 +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=1732028465; cv=none; b=HFhVQQEZxLJtlzS+BitWu1tzFjoKKpKWLUX2QnF7Q8OS/M/OawO8f6CjdEgmJ/prXFE3EghPSZdeGuliz0qkuvjn+QcK1nc8Gs9sQrOMPL36r5fWiGGxobUcKPLIc/t55OUA+BbR5y5ns4gTx6CMasQIFcyM/i0VMZL2kf/coeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=Jr5TibAxKlW6LPtn2UpIAws+Jljaxx/IUAbIela8acc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aDJsgaIR5LfPok8L0hvU90gn9Pn/xfUcX1t52zR30l+lAD1XRCF1AbIi3KeQiPByJtIrGtH3mkvZJp0hm/SpOI+CZXnJJ+64RvovMzW5wFAl3RwPGqW+t9OcNVxQylF7dMMSL7gtqgYFkCn7SamoFggI5bZ9aYS7jRu4k8RYHRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u/68oNb7; 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="u/68oNb7" Received: by smtp.kernel.org (Postfix) with ESMTPS id 5FB55C4CEF9; Tue, 19 Nov 2024 15:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028465; bh=Jr5TibAxKlW6LPtn2UpIAws+Jljaxx/IUAbIela8acc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=u/68oNb7CkfZKhPlsIU9LN0uIefJVa3Rem3KlFpTm4daxg27ET7sDvfths89ghFmH 6vRrhosKyqz411NyZ/PRV0DOOD/bGD2LPTzHDfys+DXN79as9MC2/6HsnN9DCo5gin gTwC81LNAKGlESVBN49n9vWaaeodJ5T5NhFpYlprr13ZW62l960G2f8NXeyi1xss4a nqmFCOloDhqOuV1rUrhrpDHhfqwGXwAK8NcM9xIo53QEm/HduKBjsWUFCzcLdYs+gt qj3UfE0gks/mFpjAluiyUQoL2BLxhuEplo+O8L2kJo48vr1V/ZAqGhcqX/k9euCqHu BWKZM0DvKWPiw== 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 56486D44162; Tue, 19 Nov 2024 15:01:05 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:21 +0100 Subject: [PATCH v5 15/16] MAINTAINERS: Add Jan Petrous as the NXP S32G/R DWMAC driver maintainer Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-15-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=915; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=pHfq2w2j/SBgXCktQF2QqXPe5W6F70KOUcF5p5w2GsQ=; b=kg29ciDxOYgCtpwUA3BwC8OyW9MWH36GrRkyP2aoXLaiP8YzLpujxXXK+dVU1O7XUH5tRKMmO 50nCIVDiH+9CkW1LffGBetnJYKNNZxBRWJIyA9rTWuO9O0z8R/ZHoE1 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. Reviewed-by: Andrew Lunn Signed-off-by: Jan Petrous (OSS) --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 82161bc70b51..c65d8f904871 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2791,6 +2791,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 Tue Nov 19 15:00:22 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: 13880066 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 A84A11D0E24; Tue, 19 Nov 2024 15:01:05 +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=1732028465; cv=none; b=mewPxSQGKgCZwDClJXbbgmnZIpXBxKc+WlOn1/nPzai9KyUvQIe+If0zuVFlsd6VyeKYKZvkarrLPhDJrbjgDm4l+k6FTJ4l5M1dRN7yO5i6NITzkFHMNl0ZeV2IgdTgMRdoDkElwfEGR/HeBnV41Acf96t7cAqbXp3Ajj9YpAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732028465; c=relaxed/simple; bh=OHxB9rBJfD9alhtYQwEZOwU5JQFBquZocPkNzhxXMqo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qe6SbzYGiEmtkMj5ZzRUgQGDiXiJvN7eAnqOLlC7XTnbXG11Nb57cJ6GK4qzCxQxCUJgTiYm78TlgYoYxJyDHwF2vqv7sES0cbVYPC7q6Wjc8dYRNx7F/IBOhteW+Vip5somHFgLFqSgZbWaVOo9sXoAASXbxqK8FDDKTWEyxzU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VKGrz6wi; 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="VKGrz6wi" Received: by smtp.kernel.org (Postfix) with ESMTPS id 712E1C4AF09; Tue, 19 Nov 2024 15:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732028465; bh=OHxB9rBJfD9alhtYQwEZOwU5JQFBquZocPkNzhxXMqo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=VKGrz6wipn/LFmH8fMXXJyLXayMB+Im0igBI4lrMWMm7pR1cBZbT80UjZuAv/xa2u ile6rQTSgvXm4ZZhfiYpcmcUmPtvSZUabEMkz5HmmVmaknYqcs8ICsX9CoDOHZmakj VFvcmsxIRIRqfheLUNWRDWfFMWFoEDociWQzyWmirCQI16asY8ZkMLkj3GUUaAz9hy PePdUFHT8kuvOxazr6Cs7SP9Cwk/J+5lSwzJUFQte76Zn7miBAfPXUlifQJJCeS+Pq VsiV9ufJJmcK9BxrEpSMqBQq1JGXeACKMo5GHYRmVR4ncvF38kZWP942lT5gusUurO ABtPQ6wQ+tuiw== 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 64FDAD44167; Tue, 19 Nov 2024 15:01:05 +0000 (UTC) From: Jan Petrous via B4 Relay Date: Tue, 19 Nov 2024 16:00:22 +0100 Subject: [PATCH v5 16/16] net: stmmac: platform: Fix PTP clock rate reading Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241119-upstream_s32cc_gmac-v5-16-7dcc90fcffef@oss.nxp.com> References: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@oss.nxp.com> In-Reply-To: <20241119-upstream_s32cc_gmac-v5-0-7dcc90fcffef@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=1732028461; l=1264; i=jan.petrous@oss.nxp.com; s=20240922; h=from:subject:message-id; bh=SPtatx8x0ZkbtjnD8HA6OeWFeo+DZZ7ciHEBKeYJXkM=; b=2UaIZd/gCwdI5kIGbU8BJj5qpiNrj2FL1GF/utf3Q9uRD7+lnoiRcKDO9pbhMhMM611X5TL1E toRgEv2X5geDhoQ+eHY+2G/4K1Vn3mTfArX/V9Hwli6Rqyvby60GyYU 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 stmmac driver supports many vendors SoCs using Synopsys-licensed Ethernet controller IP. Most of these vendors reuse the stmmac_platform codebase, which has a potential PTP clock initialization issue. The PTP clock rate reading might require ungating what is not provided. Fix the PTP clock initialization by enabling it immediately. Signed-off-by: Jan Petrous (OSS) --- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index b1e4df1a86a0..db3e8ef4fc3a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -632,7 +632,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) clk_prepare_enable(plat->pclk); /* Fall-back to main clock in case of no PTP ref is passed */ - plat->clk_ptp_ref = devm_clk_get(&pdev->dev, "ptp_ref"); + plat->clk_ptp_ref = devm_clk_get_enabled(&pdev->dev, "ptp_ref"); if (IS_ERR(plat->clk_ptp_ref)) { plat->clk_ptp_rate = clk_get_rate(plat->stmmac_clk); plat->clk_ptp_ref = NULL;