Skip to content

Commit 1caa871

Browse files
committed
Merge branch 'net-stmmac-fix-tegra234-mgbe-clock'
Jon Hunter says: ==================== net: stmmac: Fix Tegra234 MGBE clock The name of the PTP ref clock for the Tegra234 MGBE ethernet controller does not match the generic name in the stmmac platform driver. Despite this basic ethernet is functional on the Tegra234 platforms that use this driver and as far as I know, we have not tested PTP support with this driver. Hence, the risk of breaking any functionality is low. The previous attempt to fix this in the stmmac platform driver, by supporting the Tegra234 PTP clock name, was rejected [0]. The preference from the netdev maintainers is to fix this in the DT binding for Tegra234. This series fixes this by correcting the device-tree binding to align with the generic name for the PTP clock. I understand that this is breaking the ABI for this device, which we should never do, but this is a last resort for getting this fixed. I am open to any better ideas to fix this. Please note that we still maintain backward compatibility in the driver to allow older device-trees to work, but we don't advertise this via the binding, because I did not see any value in doing so. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 5c14a19 + fb22b1f commit 1caa871

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

Documentation/devicetree/bindings/net/nvidia,tegra234-mgbe.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ properties:
4242
- const: mgbe
4343
- const: mac
4444
- const: mac-divider
45-
- const: ptp-ref
45+
- const: ptp_ref
4646
- const: rx-input-m
4747
- const: rx-input
4848
- const: tx
@@ -133,7 +133,7 @@ examples:
133133
<&bpmp TEGRA234_CLK_MGBE0_RX_PCS_M>,
134134
<&bpmp TEGRA234_CLK_MGBE0_RX_PCS>,
135135
<&bpmp TEGRA234_CLK_MGBE0_TX_PCS>;
136-
clock-names = "mgbe", "mac", "mac-divider", "ptp-ref", "rx-input-m",
136+
clock-names = "mgbe", "mac", "mac-divider", "ptp_ref", "rx-input-m",
137137
"rx-input", "tx", "eee-pcs", "rx-pcs-input", "rx-pcs-m",
138138
"rx-pcs", "tx-pcs";
139139
resets = <&bpmp TEGRA234_RESET_MGBE0_MAC>,

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)