[PATCH 2/3] net: cadence: macb: Expose REFCLK as a device tree property

Ryan.Wanner@microchip.com posted 3 patches 3 months, 3 weeks ago
There is a newer version of this series
[PATCH 2/3] net: cadence: macb: Expose REFCLK as a device tree property
Posted by Ryan.Wanner@microchip.com 3 months, 3 weeks ago
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;
 
 	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);
 }
 
-- 
2.43.0
Re: [PATCH 2/3] net: cadence: macb: Expose REFCLK as a device tree property
Posted by Simon Horman 3 months, 2 weeks ago
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");

...