diff mbox series

[1/6] net: driver: stmmac: extend CSR calc support

Message ID AM9PR04MB850628457377A486554D718AE2BD2@AM9PR04MB8506.eurprd04.prod.outlook.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Add support for Synopsis DWMAC IP on NXP Automotive SoCs | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 6 maintainers not CCed: xiaolei.wang@windriver.com joabreu@synopsys.com edumazet@google.com kuba@kernel.org pabeni@redhat.com rmk+kernel@armlinux.org.uk
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 39 this patch: 39
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 38 this patch: 38
netdev/source_inline success Was 0 now: 0

Commit Message

Jan Petrous Aug. 4, 2024, 8:49 p.m. UTC
Add support for CSR clock range up to 800 MHz.

Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
 drivers/net/ethernet/stmicro/stmmac/common.h      | 2 ++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++++
 include/linux/stmmac.h                            | 4 +++-
 3 files changed, 9 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Aug. 4, 2024, 11:11 p.m. UTC | #1
>  #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 */

That should probably be called out in the commit message. It is not a
fix as such, since it is just a comment, but as a reviewer i had a
double take when i noticed this.,


    Andrew

---
pw-bot: cr
Serge Semin Aug. 6, 2024, 9:38 a.m. UTC | #2
Hi Andrew

On Mon, Aug 05, 2024 at 01:11:16AM +0200, Andrew Lunn wrote:
> >  #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 */
> 
> That should probably be called out in the commit message. It is not a
> fix as such, since it is just a comment, but as a reviewer i had a
> double take when i noticed this.,

Yes, this seems like a typo. I've checked the divider semantic in the DW
GMAC 3.50a/3.73a and DW QoS Eth 5.10a HW databooks. Both of them expect the
clk_scr_i ref clock being divided by 124. So the 122 value was
incorrect.

-Serge(y)

> 
> 
>     Andrew
> 
> ---
> pw-bot: cr
>
Jan Petrous Aug. 18, 2024, 6:38 p.m. UTC | #3
> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: Monday, 5 August, 2024 1:11
> To: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>; Alexandre Torgue
> <alexandre.torgue@foss.st.com>; dl-S32 <S32@nxp.com>; linux-
> kernel@vger.kernel.org; linux-stm32@st-md-mailman.stormreply.com; linux-
> arm-kernel@lists.infradead.org; Claudiu Manoil <claudiu.manoil@nxp.com>;
> netdev@vger.kernel.org
> Subject: Re: [PATCH 1/6] net: driver: stmmac: extend CSR calc support
> 
> >  #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 */
> 
> That should probably be called out in the commit message. It is not a
> fix as such, since it is just a comment, but as a reviewer i had a
> double take when i noticed this.,
> 

Will add the note to the commit message in v2.

/Jan
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index cd36ff4da68c..e90d3c5ac917 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -256,6 +256,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 f3a1b179aaea..ac80d8a2b743 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 84e13bd5df28..7caaa5ae6674 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -33,7 +33,9 @@ 
 #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 */
+#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