Skip to contentSkip to conversation

Expose REFCLK for RMII and enable RMII

PATCH In review [email protected] 3 participants 12 messages Jul 14, 2025 – Jul 31, 2025

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

v2 cover Expose REFCLK for RMII and enable RMII

From: Ryan Wanner <[email protected]>

This set allows the REFCLK property to be exposed as a dt-property to properly reflect the correct RMII layout. RMII can take an external or internal provided REFCLK, since this is not SoC dependent but board dependent this must be exposed as a DT property for the macb driver.

This set also enables RMII mode for the SAMA7 SoCs gigabit mac.

V1 is here [1]

changes v1 -> v2:
- Add device tree changes to use the new REFCLK property.
- Remove USARIO_HAS_CLKEN from the sama7g54 emac node to use the exposed REFCLK propterty.
- Use property_read_bool() instead of property_present check.
- Adjust variables to follow reverse xmas tree

1) https://lore.kernel.org/all/[email protected]/

Ryan Wanner (5):
dt-bindings: net: cdns,macb: Add external REFCLK property
net: cadence: macb: Expose REFCLK as a device tree property
net: cadence: macb: Enable RMII for SAMA7 gem
net: cadence: macb: sama7g5_emac: Remove USARIO CLKEN flag
ARM: dts: microchip: sama7g5: Add RMII ext refclk flag

 Documentation/devicetree/bindings/net/cdns,macb.yaml |  7 +++++++
 arch/arm/boot/dts/microchip/at91-sama7g5ek.dts       |  1 +
 drivers/net/ethernet/cadence/macb_main.c             | 11 +++++++++--
 3 files changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/5 dt-bindings: net: cdns,macb: Add external REFCLK property

From: Ryan Wanner <[email protected]>

REFCLK can be provided by an external source so this should be exposed by a DT property. The REFCLK is used for RMII and in some SoCs that use this driver the RGMII 125MHz clk can also be provided by an external source.

---
 Documentation/devicetree/bindings/net/cdns,macb.yaml | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/net/cdns,macb.yaml +7 -0
index 8d69846b2e09..e69f60c37793 100644
@@ -114,6 +114,13 @@ properties:
   power-domains:
     maxItems: 1
 
+  cdns,refclk-ext:
+    type: boolean
+    description:
+      This selects if the REFCLK for RMII is provided by an external source.
+      For RGMII mode this selects if the 125MHz REF clock is provided by an external
+      source.
+
   cdns,rx-watermark:
     $ref: /schemas/types.yaml#/definitions/uint32
     description:
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/5 net: cadence: macb: Expose REFCLK as a device tree property

In reply to [email protected]

From: Ryan Wanner <[email protected]>

The RMII and RGMII can both support internal or external provided REFCLKs 50MHz and 125MHz respectively. Since this is dependent on the board that the SoC is on this needs to be set via the device tree.

This property flag is checked in the MACB DT node so the REFCLK cap is configured the correct way for the RMII or RGMII is configured on the board.

---
 drivers/net/ethernet/cadence/macb_main.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +7 -0
index d1f1ae5ea161..9ebe1062b359 100644
@@ -4109,8 +4109,12 @@ static const struct net_device_ops macb_netdev_ops = {
 static void macb_configure_caps(struct macb *bp,
 				const struct macb_config *dt_conf)
 {
+	struct device_node *np = bp->pdev->dev.of_node;
+	bool refclk_ext;
 	u32 dcfg;
 
+	refclk_ext = of_property_read_bool(np, "cdns,refclk-ext");
+
 	if (dt_conf)
 		bp->caps = dt_conf->caps;
 
@@ -4141,6 +4145,9 @@ static void macb_configure_caps(struct macb *bp,
 		}
 	}
 
+	if (refclk_ext)
+		bp->caps |= MACB_CAPS_USRIO_HAS_CLKEN;
+
 	dev_dbg(&bp->pdev->dev, "Cadence caps 0x%08x\n", bp->caps);
 }
 
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/5 net: cadence: macb: Enable RMII for SAMA7 gem

In reply to [email protected]

From: Ryan Wanner <[email protected]>

This macro enables the RMII mode bit in the USRIO register when RMII mode is requested.

---
 drivers/net/ethernet/cadence/macb_main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/cadence/macb_main.c +1 -0
index 9ebe1062b359..51667263c01d 100644
@@ -5103,6 +5103,7 @@ static const struct macb_config mpfs_config = {
 
 static const struct macb_config sama7g5_gem_config = {
 	.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_CLK_HW_CHG |
+		MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |
 		MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP,
 	.dma_burst_length = 16,
 	.clk_init = macb_clk_init,
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 4/5 net: cadence: macb: sama7g5_emac: Remove USARIO CLKEN flag

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Remove USARIO_CLKEN flag since this is now a device tree argument and not fixed to the SoC.

This will instead be selected by the "cdns,refclk-ext" device tree property.

---
 drivers/net/ethernet/cadence/macb_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +1 -2
index 51667263c01d..cd54e4065690 100644
@@ -5113,8 +5113,7 @@ static const struct macb_config sama7g5_gem_config = {
 
 static const struct macb_config sama7g5_emac_config = {
 	.caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |
-		MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_MIIONRGMII |
-		MACB_CAPS_GEM_HAS_PTP,
+		MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP,
 	.dma_burst_length = 16,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
Signature · 1 line
2.43.0
maintainer
#5 lore raw

Re: [PATCH v2 4/5] net: cadence: macb: sama7g5_emac: Remove USARIO CLKEN flag

Hi, Ryan,

Quoted 3 lines · On 14.07.2025 19:37, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Remove USARIO_CLKEN flag since this is now a device tree argument and

s/USARIO_CLKEN/USRIO_HAS_CLKEN here and in title as well.

Quoted 15 lines

not fixed to the SoC.

This will instead be selected by the "cdns,refclk-ext" device tree property.

---
 drivers/net/ethernet/cadence/macb_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +0 -0
index 51667263c01d..cd54e4065690 100644

drivers/net/ethernet/cadence/macb_main.c static const struct macb_config sama7g5_gem_config = { · line 5116

Quoted 4 lines
drivers/net/ethernet/cadence/macb_main.c +0 -1
@@ -5113,8 +5113,7 @@ static const struct macb_config sama7g5_gem_config = {
 
 static const struct macb_config sama7g5_emac_config = {
 	.caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |
-		MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_MIIONRGMII |

Will old DTBs still work with new kernels with this change?

Thank you,
Claudiu

Quoted 5 lines
drivers/net/ethernet/cadence/macb_main.c +1 -1
-		MACB_CAPS_GEM_HAS_PTP,
+		MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP,
 	.dma_burst_length = 16,
 	.clk_init = macb_clk_init,
 	.init = macb_init,
#6 lore raw

Re: [PATCH v2 4/5] net: cadence: macb: sama7g5_emac: Remove USARIO CLKEN flag

Quoted 27 lines · Claudiu Beznea

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi, Ryan,

Quoted 3 lines · On 14.07.2025 19:37, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Remove USARIO_CLKEN flag since this is now a device tree argument and

s/USARIO_CLKEN/USRIO_HAS_CLKEN here and in title as well.

Quoted 16 lines

not fixed to the SoC.

This will instead be selected by the "cdns,refclk-ext" device tree property.

---
 drivers/net/ethernet/cadence/macb_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +0 -0
index 51667263c01d..cd54e4065690 100644
@@ -5113,8 +5113,7 @@ static const struct macb_config sama7g5_gem_config = {
 
Quoted 5 lines

drivers/net/ethernet/cadence/macb_main.c static const struct macb_config sama7g5_gem_config = { · line 5116

Quoted 3 lines
drivers/net/ethernet/cadence/macb_main.c +0 -1
 static const struct macb_config sama7g5_emac_config = {
      .caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |
-             MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_MIIONRGMII |

Will old DTBs still work with new kernels with this change?

That was my assumption, but it seems it would be safer to keep this property for this IP and implement this dt flag property on IPs that do not already have MACB_CAPS_USRIO_HAS_CLKEN property.

Ryan

Quoted 10 lines

Thank you,
Claudiu

Quoted 5 lines
drivers/net/ethernet/cadence/macb_main.c +1 -1
-             MACB_CAPS_GEM_HAS_PTP,
+             MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP,
      .dma_burst_length = 16,
      .clk_init = macb_clk_init,
      .init = macb_init,
maintainer
#7 lore raw

Re: [PATCH v2 4/5] net: cadence: macb: sama7g5_emac: Remove USARIO CLKEN flag

Hi, Ryan,

Quoted 34 lines · On 7/21/25 18:39, [email protected] wrote:
Quoted 27 lines · Claudiu Beznea

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi, Ryan,

Quoted 3 lines · On 14.07.2025 19:37, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Remove USARIO_CLKEN flag since this is now a device tree argument and

s/USARIO_CLKEN/USRIO_HAS_CLKEN here and in title as well.

Quoted 16 lines

not fixed to the SoC.

This will instead be selected by the "cdns,refclk-ext" device tree property.

---
  drivers/net/ethernet/cadence/macb_main.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +0 -0
index 51667263c01d..cd54e4065690 100644
@@ -5113,8 +5113,7 @@ static const struct macb_config sama7g5_gem_config = {
 
Quoted 5 lines

drivers/net/ethernet/cadence/macb_main.c static const struct macb_config sama7g5_gem_config = { · line 5116

Quoted 3 lines
drivers/net/ethernet/cadence/macb_main.c +0 -1
  static const struct macb_config sama7g5_emac_config = {
       .caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |
-             MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_MIIONRGMII |

Will old DTBs still work with new kernels with this change?

Quoted 3 lines

That was my assumption, but it seems it would be safer to keep this property for this IP and implement this dt flag property on IPs that do not already have MACB_CAPS_USRIO_HAS_CLKEN property.

So, this patch should be reverted, right?

Thank you,
Claudiu

Quoted 13 lines

Ryan

Quoted 10 lines

Thank you,
Claudiu

Quoted 5 lines
drivers/net/ethernet/cadence/macb_main.c +1 -1
-             MACB_CAPS_GEM_HAS_PTP,
+             MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP,
       .dma_burst_length = 16,
       .clk_init = macb_clk_init,
       .init = macb_init,
#8 lore raw

Re: [PATCH v2 4/5] net: cadence: macb: sama7g5_emac: Remove USARIO CLKEN flag

Quoted 43 lines · claudiu beznea

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi, Ryan,

Quoted 37 lines · On 7/21/25 18:39, [email protected] wrote:
Quoted 35 lines · Claudiu Beznea

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi, Ryan,

Quoted 3 lines · On 14.07.2025 19:37, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Remove USARIO_CLKEN flag since this is now a device tree argument and

s/USARIO_CLKEN/USRIO_HAS_CLKEN here and in title as well.

Quoted 19 lines

not fixed to the SoC.

This will instead be selected by the "cdns,refclk-ext" device tree property.

---
  drivers/net/ethernet/cadence/macb_main.c | 3 +--

  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ renamed from drivers/net/ethernet/cadence/macb_main.c +0 -0

ethernet/cadence/macb_main.c
index 51667263c01d..cd54e4065690 100644

drivers/net/ethernet/cadence/macb_main.c +0 -0
@@ -5113,8 +5113,7 @@ static const struct macb_config
 sama7g5_gem_config = {
 
   static const struct macb_config sama7g5_emac_config = {
Quoted 2 lines

       .caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |
-             MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_MIIONRGMII |

Will old DTBs still work with new kernels with this change?

Quoted 5 lines
Quoted 3 lines

That was my assumption, but it seems it would be safer to keep this property for this IP and implement this dt flag property on IPs that do not already have  MACB_CAPS_USRIO_HAS_CLKEN property.

So, this patch should be reverted, right?

Yes you are right, more testing I see that this could break older DTs. I am new to reverting patches, do I send a patch to revert this and would it be an issue now?

Ryan

Quoted 18 lines

Thank you,
Claudiu

Quoted 13 lines

Ryan

Quoted 10 lines

Thank you,
Claudiu

Quoted 5 lines

-             MACB_CAPS_GEM_HAS_PTP,
+             MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP, .dma_burst_length = 16,
       .clk_init = macb_clk_init,
       .init = macb_init,

maintainer
#9 lore raw

Re: [PATCH v2 4/5] net: cadence: macb: sama7g5_emac: Remove USARIO CLKEN flag

Quoted 48 lines · Ryan Wanner
Quoted 47 lines · claudiu beznea

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi, Ryan,

Quoted 40 lines · On 7/21/25 18:39, [email protected] wrote:
Quoted 30 lines · Claudiu Beznea

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi, Ryan,

Quoted 3 lines · On 14.07.2025 19:37, [email protected] wrote:

From: Ryan Wanner <[email protected]>

Remove USARIO_CLKEN flag since this is now a device tree argument and

s/USARIO_CLKEN/USRIO_HAS_CLKEN here and in title as well.

Quoted 18 lines

not fixed to the SoC.

This will instead be selected by the "cdns,refclk-ext" device tree property.

---
  drivers/net/ethernet/cadence/macb_main.c | 3 +--

  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ renamed from drivers/net/ethernet/cadence/macb_main.c +0 -0

ethernet/cadence/macb_main.c
index 51667263c01d..cd54e4065690 100644

drivers/net/ethernet/cadence/macb_main.c +0 -0
@@ -5113,8 +5113,7 @@ static const struct macb_config
 sama7g5_gem_config = {
 
Quoted 5 lines
Quoted 3 lines
drivers/net/ethernet/cadence/macb_main.c +0 -0
   static const struct macb_config sama7g5_emac_config = {

       .caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |
-             MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_MIIONRGMII |

Will old DTBs still work with new kernels with this change?

That was my assumption, but it seems it would be safer to keep this property for this IP and implement this dt flag property on IPs that do not already have  MACB_CAPS_USRIO_HAS_CLKEN property.

Quoted 5 lines
Quoted 1 line

So, this patch should be reverted, right?

Yes you are right, more testing I see that this could break older DTs. I am new to reverting patches, do I send a patch to revert this and would it be an issue now?

Not sure about the approach now! Looks like this has already been merged
https://lore.kernel.org/all/[email protected]/

Thank you,
Claudiu

Quoted 21 lines

Ryan

Quoted 18 lines

Thank you,
Claudiu

Quoted 13 lines

Ryan

Quoted 10 lines

Thank you,
Claudiu

Quoted 5 lines

-             MACB_CAPS_GEM_HAS_PTP,
+             MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP, .dma_burst_length = 16,
       .clk_init = macb_clk_init,
       .init = macb_init,

#10 lore raw

PATCH v2 5/5 ARM: dts: microchip: sama7g5: Add RMII ext refclk flag

In reply to [email protected]

From: Ryan Wanner <[email protected]>

The REFCLK for the RMII interface is provided by an extrenal source.

This flag matches the change in the macb driver to determine the REFCLK source.

---
 arch/arm/boot/dts/microchip/at91-sama7g5ek.dts | 1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/microchip/at91-sama7g5ek.dts +1 -0
index 2543599013b1..3c898afdc313 100644
@@ -542,6 +542,7 @@ &pinctrl_gmac1_mdio_default
 	phy-mode = "rmii";
 	nvmem-cells = <&eeprom1_eui48>;
 	nvmem-cell-names = "mac-address";
+	cdns,refclk-ext;
 	status = "okay"; /* Conflict with pdmc0. */
 
 	ethernet-phy@0 {
Signature · 1 line
2.43.0
#11 lore raw
In reply to [email protected]
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Mon, 14 Jul 2025 09:36:58 -0700 you wrote:

From: Ryan Wanner <[email protected]>

This set allows the REFCLK property to be exposed as a dt-property to properly reflect the correct RMII layout. RMII can take an external or internal provided REFCLK, since this is not SoC dependent but board dependent this must be exposed as a DT property for the macb driver.

[...]

Here is the summary with links:
- [v2,1/5] dt-bindings: net: cdns,macb: Add external REFCLK property

    https://git.kernel.org/netdev/net-next/c/1b7531c094c8
  - [v2,2/5] net: cadence: macb: Expose REFCLK as a device tree property
    https://git.kernel.org/netdev/net-next/c/dce32ece3bb8
  - [v2,3/5] net: cadence: macb: Enable RMII for SAMA7 gem
    https://git.kernel.org/netdev/net-next/c/eb4f50ddfdd3
  - [v2,4/5] net: cadence: macb: sama7g5_emac: Remove USARIO CLKEN flag
    https://git.kernel.org/netdev/net-next/c/db400061b5e7

- [v2,5/5] ARM: dts: microchip: sama7g5: Add RMII ext refclk flag (no matching commit)

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html