[2/6] net: phy: maxio: parse and enable PHY clock from generic DT binding

Message ID 20260803101452.2993721-3-andre.przywara@arm.com (mailing list archive)
State New
Headers
Series sunxi: net: add Ethernet support for X96QPro+ |

Commit Message

Andre Przywara Aug. 3, 2026, 10:14 a.m. UTC
The generic PHY DT binding features a clocks property, which describes
the clock input to the PHY. Typically this is a crystal oscillator, so
it works without software interaction. But some boards want to save some
pennies on that part, and let a clock fanout pin from the SoC provide this
clock signal. In this case the PHY probe routine needs to enable this
clock explicitly.

Look for a "clocks" property inside the PHY node and enable that clock,
if one is provided.

This allows boards with a SoC-driven PHY clock to use the PHY. Please
note that without the clock enabled, the PHY will not be detected on the
MDIO bus, so the PHY-ID needs to be explicitly named in the PHY
compatible string:
	compatible = "ethernet-phy-id7b74.4411";

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 drivers/net/phy/maxio.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Andrew Lunn Aug. 4, 2026, 2:43 a.m. UTC | #1
On Mon, Aug 03, 2026 at 12:14:48PM +0200, Andre Przywara wrote:
> The generic PHY DT binding features a clocks property, which describes
> the clock input to the PHY. Typically this is a crystal oscillator, so
> it works without software interaction. But some boards want to save some
> pennies on that part, and let a clock fanout pin from the SoC provide this
> clock signal. In this case the PHY probe routine needs to enable this
> clock explicitly.
> 
> Look for a "clocks" property inside the PHY node and enable that clock,
> if one is provided.
> 
> This allows boards with a SoC-driven PHY clock to use the PHY. Please
> note that without the clock enabled, the PHY will not be detected on the
> MDIO bus, so the PHY-ID needs to be explicitly named in the PHY
> compatible string:
> 	compatible = "ethernet-phy-id7b74.4411";
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
  

Patch

diff --git a/drivers/net/phy/maxio.c b/drivers/net/phy/maxio.c
index 95a2169f25df..5fabf99fb90f 100644
--- a/drivers/net/phy/maxio.c
+++ b/drivers/net/phy/maxio.c
@@ -2,6 +2,7 @@ 
 /* Driver for Maxio Ethernet PHYs. */
 
 #include <linux/bitops.h>
+#include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/phy.h>
 #include <linux/property.h>
@@ -15,6 +16,7 @@ 
 #define MAXIO_MAE0621A_CLKOUT_ENABLE	BIT(0)
 
 struct maxio_priv {
+	struct clk *clk;
 	bool clk_out_125m;
 };
 
@@ -55,6 +57,11 @@  static int maxio_mae0621a_probe(struct phy_device *phydev)
 		return ret;
 	}
 
+	/* PHY clock from the generic PHY binding */
+	priv->clk = devm_clk_get_optional_enabled(&phydev->mdio.dev, NULL);
+	if (IS_ERR(priv->clk))
+		return PTR_ERR(priv->clk);
+
 	return 0;
 }