Skip to content

Commit 1345e9f

Browse files
jonhunterkuba-moo
authored andcommitted
net: stmmac: Fix PTP ref clock for Tegra234
Since commit 030ce91 ("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: d8ca113 ("net: stmmac: tegra: Add MGBE support") Signed-off-by: Jon Hunter <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5c14a19 commit 1345e9f

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "stmmac_platform.h"
1010

1111
static const char *const mgbe_clks[] = {
12-
"rx-pcs", "tx", "tx-pcs", "mac-divider", "mac", "mgbe", "ptp-ref", "mac"
12+
"rx-pcs", "tx", "tx-pcs", "mac-divider", "mac", "mgbe", "ptp_ref", "mac"
1313
};
1414

1515
struct tegra_mgbe {
@@ -215,6 +215,7 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
215215
{
216216
struct plat_stmmacenet_data *plat;
217217
struct stmmac_resources res;
218+
bool use_legacy_ptp = false;
218219
struct tegra_mgbe *mgbe;
219220
int irq, err, i;
220221
u32 value;
@@ -257,9 +258,23 @@ static int tegra_mgbe_probe(struct platform_device *pdev)
257258
if (!mgbe->clks)
258259
return -ENOMEM;
259260

260-
for (i = 0; i < ARRAY_SIZE(mgbe_clks); i++)
261+
/* Older device-trees use 'ptp-ref' rather than 'ptp_ref'.
262+
* Fall back when the legacy name is present.
263+
*/
264+
if (of_property_match_string(pdev->dev.of_node, "clock-names",
265+
"ptp-ref") >= 0)
266+
use_legacy_ptp = true;
267+
268+
for (i = 0; i < ARRAY_SIZE(mgbe_clks); i++) {
261269
mgbe->clks[i].id = mgbe_clks[i];
262270

271+
if (use_legacy_ptp && !strcmp(mgbe_clks[i], "ptp_ref")) {
272+
dev_warn(mgbe->dev,
273+
"Device-tree update needed for PTP clock!\n");
274+
mgbe->clks[i].id = "ptp-ref";
275+
}
276+
}
277+
263278
err = devm_clk_bulk_get(mgbe->dev, ARRAY_SIZE(mgbe_clks), mgbe->clks);
264279
if (err < 0)
265280
return err;

0 commit comments

Comments
 (0)