]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: stmmac: add stmmac_setup_ptp()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thu, 11 Sep 2025 11:10:18 +0000 (12:10 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sun, 14 Sep 2025 19:01:19 +0000 (12:01 -0700)
Add a function to setup PTP, which will enable the clock, initialise
the timestamping, and register with the PTP clock subsystem. Call this
when we want to register the PTP clock in stmmac_hw_setup(), otherwise
just call the

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 7cbac3ac2a9d29ca572ba81eceda0d410e8b8b78..ea2d3e555fe82560ef8e47309c46d6c865e273a7 100644 (file)
@@ -820,6 +820,20 @@ static int stmmac_init_timestamping(struct stmmac_priv *priv)
        return 0;
 }
 
+static void stmmac_setup_ptp(struct stmmac_priv *priv)
+{
+       int ret;
+
+       ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
+       if (ret < 0)
+               netdev_warn(priv->dev,
+                           "failed to enable PTP reference clock: %pe\n",
+                           ERR_PTR(ret));
+
+       if (stmmac_init_timestamping(priv) == 0)
+               stmmac_ptp_register(priv);
+}
+
 static void stmmac_release_ptp(struct stmmac_priv *priv)
 {
        stmmac_ptp_unregister(priv);
@@ -3494,16 +3508,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
 
        stmmac_mmc_setup(priv);
 
-       if (ptp_register) {
-               ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
-               if (ret < 0)
-                       netdev_warn(priv->dev,
-                                   "failed to enable PTP reference clock: %pe\n",
-                                   ERR_PTR(ret));
-       }
-
-       if (stmmac_init_timestamping(priv) == 0 && ptp_register)
-               stmmac_ptp_register(priv);
+       if (ptp_register)
+               stmmac_setup_ptp(priv);
+       else
+               stmmac_init_timestamping(priv);
 
        if (priv->use_riwt) {
                u32 queue;