Skip to contentSkip to conversation

net: phy: mscc: consolidate a common RGMII delay implementation

PATCH Applied Vladimir Oltean 4 participants 5 messages Mar 24, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: mscc: consolidate a common RGMII delay implementation

From: Vladimir Oltean <[email protected]>

It looks like the VSC8584 PHY driver is rolling its own RGMII delay configuration code, despite the fact that the logic is mostly the same.

In fact only the register layout and position for the RGMII controls has changed. So we need to adapt and parameterize the PHY-dependent bit fields when calling the new generic function.

---
Changes in v2:
Added back a comment containing the information from Antoine's patch.

 drivers/net/phy/mscc/mscc.h      | 28 ++++--------
 drivers/net/phy/mscc/mscc_main.c | 78 ++++++++++++++++----------------
 2 files changed, 49 insertions(+), 57 deletions(-)
drivers/net/phy/mscc/mscc.h +9 -19
index d983d3af66d6..030bf8b600df 100644
@@ -161,25 +161,15 @@ enum rgmii_clock_delay {
 /* Extended Page 2 Registers */
 #define MSCC_PHY_CU_PMD_TX_CNTL		  16
 
-#define MSCC_PHY_RGMII_SETTINGS		  18
-#define RGMII_SKEW_RX_POS		  1
-#define RGMII_SKEW_TX_POS		  4
-
-/* RGMII skew values, in ns */
-#define VSC8584_RGMII_SKEW_0_2		  0
-#define VSC8584_RGMII_SKEW_0_8		  1
-#define VSC8584_RGMII_SKEW_1_1		  2
-#define VSC8584_RGMII_SKEW_1_7		  3
-#define VSC8584_RGMII_SKEW_2_0		  4
-#define VSC8584_RGMII_SKEW_2_3		  5
-#define VSC8584_RGMII_SKEW_2_6		  6
-#define VSC8584_RGMII_SKEW_3_4		  7
-
-#define MSCC_PHY_RGMII_CNTL		  20
-#define RGMII_RX_CLK_DELAY_MASK		  0x0070
-#define RGMII_RX_CLK_DELAY_POS		  4
-#define RGMII_TX_CLK_DELAY_MASK		  0x0007
-#define RGMII_TX_CLK_DELAY_POS		  0
+/* RGMII setting controls at address 18E2, for VSC8572 and similar */
+#define VSC8572_RGMII_CNTL		  18
+#define VSC8572_RGMII_RX_DELAY_MASK	  0x000E
+#define VSC8572_RGMII_TX_DELAY_MASK	  0x0070
+
+/* RGMII controls at address 20E2, for VSC8502 and similar */
+#define VSC8502_RGMII_CNTL		  20
+#define VSC8502_RGMII_RX_DELAY_MASK	  0x0070
+#define VSC8502_RGMII_TX_DELAY_MASK	  0x0007
 
 #define MSCC_PHY_WOL_LOWER_MAC_ADDR	  21
 #define MSCC_PHY_WOL_MID_MAC_ADDR	  22
drivers/net/phy/mscc/mscc_main.c +40 -38

114 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

It looks like the VSC8584 PHY driver is rolling its own RGMII delay configuration code, despite the fact that the logic is mostly the same.

In fact only the register layout and position for the RGMII controls has changed. So we need to adapt and parameterize the PHY-dependent bit fields when calling the new generic function.

Andrew

Tested-by
#2 lore raw

Hi Vladimir,

Quoting Andrew Lunn (2020-03-24 15:18:29)

Quoted 6 lines · Vladimir Oltean
Quoted 5 lines

From: Vladimir Oltean <[email protected]>

It looks like the VSC8584 PHY driver is rolling its own RGMII delay configuration code, despite the fact that the logic is mostly the same.

Quoted 7 lines
Quoted 5 lines

In fact only the register layout and position for the RGMII controls has changed. So we need to adapt and parameterize the PHY-dependent bit fields when calling the new generic function.

Thanks!
Antoine

Signature · 3 lines
Antoine Ténart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw
Quoted 20 lines · Antoine Tenart

Hi Vladimir,

Quoting Andrew Lunn (2020-03-24 15:18:29)

Quoted 6 lines · Vladimir Oltean
Quoted 5 lines

From: Vladimir Oltean <[email protected]>

It looks like the VSC8584 PHY driver is rolling its own RGMII delay configuration code, despite the fact that the logic is mostly the same.

Quoted 7 lines
Quoted 5 lines

In fact only the register layout and position for the RGMII controls has changed. So we need to adapt and parameterize the PHY-dependent bit fields when calling the new generic function.

Quoted 7 lines

Thanks!
Antoine

--
Antoine Ténart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Thanks for testing, Antoine!

maintainer Applied
#4 lore raw
In reply to Antoine Tenart

From: Antoine Tenart <[email protected]>
Date: Tue, 24 Mar 2020 15:49:37 +0100

Quoted 13 lines

Hi Vladimir,

Quoting Andrew Lunn (2020-03-24 15:18:29)

Quoted 10 lines · Vladimir Oltean
Quoted 9 lines

From: Vladimir Oltean <[email protected]>

It looks like the VSC8584 PHY driver is rolling its own RGMII delay configuration code, despite the fact that the logic is mostly the same.

In fact only the register layout and position for the RGMII controls has changed. So we need to adapt and parameterize the PHY-dependent bit fields when calling the new generic function.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Applied, thanks everyone.