mbox series

[0/3] Expose REFCLK for RMII and enable RMII

Message ID cover.1750346271.git.Ryan.Wanner@microchip.com
Headers show
Series Expose REFCLK for RMII and enable RMII | expand

Message

Ryan Wanner June 19, 2025, 5:04 p.m. UTC
From: Ryan Wanner <Ryan.Wanner@microchip.com>

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(+)

Comments

Simon Horman June 20, 2025, 10:25 a.m. UTC | #1
On Thu, Jun 19, 2025 at 10:04:14AM -0700, Ryan.Wanner@microchip.com wrote:
> From: Ryan Wanner <Ryan.Wanner@microchip.com>
> 
> 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 <Ryan.Wanner@microchip.com>
> ---
>  drivers/net/ethernet/cadence/macb_main.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index d1f1ae5ea161..146e532543a1 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -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");

...
Andrew Lunn June 21, 2025, 7:24 a.m. UTC | #2
On Thu, Jun 19, 2025 at 10:04:12AM -0700, Ryan.Wanner@microchip.com wrote:
> From: Ryan Wanner <Ryan.Wanner@microchip.com>
> 
> 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
Ryan Wanner June 23, 2025, 4:16 p.m. UTC | #3
On 6/21/25 00:24, Andrew Lunn wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Thu, Jun 19, 2025 at 10:04:12AM -0700, Ryan.Wanner@microchip.com wrote:
>> From: Ryan Wanner <Ryan.Wanner@microchip.com>
>>
>> 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
> 
>         Andrew
Andrew Lunn June 23, 2025, 5:47 p.m. UTC | #4
> 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.

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