]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: stmmac: Fix PTP ref clock for Tegra234
authorJon Hunter <jonathanh@nvidia.com>
Wed, 1 Apr 2026 10:29:39 +0000 (11:29 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 3 Apr 2026 23:02:21 +0000 (16:02 -0700)
Since commit 030ce919e114 ("net: stmmac: make sure that ptp_rate is not
0 before configuring timestamping") was added the following error is
observed on Tegra234:

 ERR KERN tegra-mgbe 6800000.ethernet eth0: Invalid PTP clock rate
 WARNING KERN tegra-mgbe 6800000.ethernet eth0: PTP init failed

It turns out that the Tegra234 device-tree binding defines the PTP ref
clock name as 'ptp-ref' and not 'ptp_ref' and the above commit now
exposes this and that the PTP clock is not configured correctly.

In order to update device-tree to use the correct 'ptp_ref' name, update
the Tegra MGBE driver to use 'ptp_ref' by default and fallback to using
'ptp-ref' if this clock name is present.

Fixes: d8ca113724e7 ("net: stmmac: tegra: Add MGBE support")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260401102941.17466-2-jonathanh@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c

index d765acbe375481312c5595856ec390fc13236b44..21a0a11fc0118be05b0dc147b9d5bdc81c4e1ef4 100644 (file)
@@ -9,7 +9,7 @@
 #include "stmmac_platform.h"
 
 static const char *const mgbe_clks[] = {
-       "rx-pcs", "tx", "tx-pcs", "mac-divider", "mac", "mgbe", "ptp-ref", "mac"
+       "rx-pcs", "tx", "tx-pcs", "mac-divider", "mac", "mgbe", "ptp_ref", "mac"
 };
 
 struct tegra_mgbe {
@@ -215,6 +215,7 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
 {
        struct plat_stmmacenet_data *plat;
        struct stmmac_resources res;
+       bool use_legacy_ptp = false;
        struct tegra_mgbe *mgbe;
        int irq, err, i;
        u32 value;
@@ -257,9 +258,23 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
        if (!mgbe->clks)
                return -ENOMEM;
 
-       for (i = 0; i <  ARRAY_SIZE(mgbe_clks); i++)
+       /* Older device-trees use 'ptp-ref' rather than 'ptp_ref'.
+        * Fall back when the legacy name is present.
+        */
+       if (of_property_match_string(pdev->dev.of_node, "clock-names",
+                                    "ptp-ref") >= 0)
+               use_legacy_ptp = true;
+
+       for (i = 0; i < ARRAY_SIZE(mgbe_clks); i++) {
                mgbe->clks[i].id = mgbe_clks[i];
 
+               if (use_legacy_ptp && !strcmp(mgbe_clks[i], "ptp_ref")) {
+                       dev_warn(mgbe->dev,
+                                "Device-tree update needed for PTP clock!\n");
+                       mgbe->clks[i].id = "ptp-ref";
+               }
+       }
+
        err = devm_clk_bulk_get(mgbe->dev, ARRAY_SIZE(mgbe_clks), mgbe->clks);
        if (err < 0)
                return err;