]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: phy: dp83822: Add optional external PHY clock
authorStefan Wahren <wahrenst@gmx.net>
Thu, 28 May 2026 18:46:42 +0000 (20:46 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 2 Jun 2026 18:38:00 +0000 (11:38 -0700)
In some cases, the PHY can use an external ref clock source instead of a
crystal.

Add an optional clock in the PHY node to make sure that the clock source
is enabled, if specified, before probing.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20260528184642.33424-3-wahrenst@gmx.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/dp83822.c

index d8c5b5cd1bc0ebfddcf50942f294610a659b7b2f..6fc86be9d593c79067298bb5f8b46288a2ffa032 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 2017 Texas Instruments Inc.
  */
 
+#include <linux/clk.h>
 #include <linux/ethtool.h>
 #include <linux/etherdevice.h>
 #include <linux/kernel.h>
@@ -986,11 +987,18 @@ static int dp8382x_probe(struct phy_device *phydev)
 {
        struct device *dev = &phydev->mdio.dev;
        struct dp83822_private *dp83822;
+       struct clk *clk;
 
        dp83822 = devm_kzalloc(dev, sizeof(*dp83822), GFP_KERNEL);
        if (!dp83822)
                return -ENOMEM;
 
+       clk = devm_clk_get_optional_enabled(dev, NULL);
+       if (IS_ERR(clk)) {
+               return dev_err_probe(dev, PTR_ERR(clk),
+                                    "Failed to request ref clock\n");
+       }
+
        dp83822->tx_amplitude_100base_tx_index = -1;
        dp83822->mac_termination_index = -1;
        phydev->priv = dp83822;