Expose REFCLK for RMII and enable RMII
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.
Ryan Wanner (3):
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
Documentation/devicetree/bindings/net/cdns,macb.yaml | 7 +++++++ drivers/net/ethernet/cadence/macb_main.c | 6 ++++++ 2 files changed, 13 insertions(+)
Signature · 1 line
2.43.0
PATCH 1/3 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
@@ -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
Re: [PATCH 1/3] dt-bindings: net: cdns,macb: Add external REFCLK property
Quoted 17 lines · On Thu, Jun 19, 2025 at 10:04:13AM -0700, [email protected] wrote:
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.
Signed-off-by Ryan Wanner <[email protected]>--- Documentation/devicetree/bindings/net/cdns,macb.yaml | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/net/cdns,macb.yaml +0
-0
Documentation/devicetree/bindings/net/cdns,macb.yaml properties: · line 122
Quoted 9 lines
Documentation/devicetree/bindings/net/cdns,macb.yaml +6
-0@@ -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.
If this gets a v2, is the distinction between RMII and RGMII worth mentioning? Or is that mentioned because the property has no effect for !{RGMII,RMII} usecases?
I'm okay with the property existing, though so
if it's the latter or with an improved description for the former.
Quoted 7 lines
Documentation/devicetree/bindings/net/cdns,macb.yaml +1
-0+ cdns,rx-watermark: $ref: /schemas/types.yaml#/definitions/uint32 description:Signature · 1 line
2.43.0
PATCH 2/3 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 | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +5 -0
@@ -4109,6 +4109,8 @@ 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 =of_property_present (np,"cdns,refclk-ext" );u32 dcfg;if (dt_conf)
@@ -4141,6 +4143,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
Simon Horman
reviewerRe: [PATCH 2/3] net: cadence: macb: Expose REFCLK as a device tree property
Quoted 20 lines · On Thu, Jun 19, 2025 at 10:04:14AM -0700, [email protected] wrote:
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.
Signed-off-by Ryan Wanner <[email protected]>--- drivers/net/ethernet/cadence/macb_main.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/cadence/macb_main.c +0
-0
drivers/net/ethernet/cadence/macb_main.c static const struct net_device_ops macb_netdev_ops = { · line 4114
Quoted 6 lines
drivers/net/ethernet/cadence/macb_main.c +2
-0@@ -4109,6 +4109,8 @@ 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 =of_property_present (np,"cdns,refclk-ext" );u32 dcfg;
Hi Ryan,
Some minor feedback from my side.
1. of_property_read_bool() seems slightly more appropriate here
2. Please consider arranging local variables in Networking code in reverse xmas tree order - longest line to shortest.
This tool can be helpful for this
https://github.com/ecree-solarflare/xmastree
struct device_node *np = bp->pdev->dev.of_node; bool refclk_ext; u32 dcfg; refclk_ext = of_property_read_bool(np, "cdns,refclk-ext");
...
PATCH 3/3 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
@@ -5101,6 +5101,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
Quoted 6 lines · On Thu, Jun 19, 2025 at 10:04:12AM -0700, [email protected] 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.
What board is going to use this? Do you have a patch for a .dts file?
Andrew
Quoted 11 lines · Andrew Lunn
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 6 lines · On Thu, Jun 19, 2025 at 10:04:12AM -0700, [email protected] 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.
What board is going to use this? Do you have a patch for a .dts file?
Our SAMA7D65_curiosity board has a connector that allows us to change ethernet phys. Since some of the phys we have provide their own REFCLK while others do not, this property needs to be added so we are able to use all of these.
I do not have an exact .dts patch for this since our default is MPU provides the REFCLK, this property will be used with dt-overlays that match each phy that is connected.
Ryan
Quoted 2 lines
Andrew
Quoted 8 lines
Our
SAMA7D65_curiosityboard has a connector that allows us to change ethernet phys. Since some of the phys we have provide their own REFCLK while others do not, this property needs to be added so we are able to use all of these.I do not have an exact .dts patch for this since our default is MPU provides the REFCLK, this property will be used with dt-overlays that match each phy that is connected.
We generally don't allow a feature without a user. So please re-submit this when you submit a DT overlay which can actually use it.
Andrew
---
pw-bot: cr