Skip to contentSkip to conversation

net: fsl_enetc: Enable optional ENETREF clock on i.MX95

PATCH Applied Marek Vasut 2 participants 2 messages Jan 27, 2025 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: fsl_enetc: Enable optional ENETREF clock on i.MX95

The ENETCv4 port DT nodes on i.MX95 may contain optional clock phandle to IMX95_CLK_ENETREF "ref" clock. These "ref" clock must be enabled for the ethernet to work. These "ref" clock are enabled after cold boot, but when the system booted Linux and rebooted, those "ref" clock might have been disabled in the process, which would make ethernet inoperable after reboot. Make sure those "ref" clock are always correctly enabled.

---
Cc: Alice Guo <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Joe Hershberger <[email protected]>
Cc: Ramon Fried <[email protected]>
Cc: Tim Harvey <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Ye Li <[email protected]>
Cc: [email protected]

---
 drivers/net/fsl_enetc.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/net/fsl_enetc.c +22 -1
index 67ef5f34a8a..52fa820f518 100644
@@ -5,6 +5,7 @@
  * Copyright 2023-2025 NXP
  */
 
+#include <clk.h>
 #include <dm.h>
 #include <errno.h>
 #include <fdt_support.h>
@@ -981,11 +982,31 @@ static const struct eth_ops enetc_ops_imx = {
 	.read_rom_hwaddr	= enetc_read_rom_hwaddr,
 };
 
+static int enetc_probe_imx(struct udevice *dev)
+{
+	struct clk *clk;
+	int ret;
+
+	clk = devm_clk_get_optional(dev, "ref");
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	ret = clk_enable(clk);
+	if (ret)
+		return ret;
+
+	ret = enetc_probe(dev);
+	if (ret)
+		clk_disable(clk);
+
+	return ret;
+}
+
 U_BOOT_DRIVER(eth_enetc_imx) = {
 	.name		= ENETC_DRIVER_NAME,
 	.id		= UCLASS_ETH,
 	.bind		= enetc_bind,
-	.probe		= enetc_probe,
+	.probe		= enetc_probe_imx,
 	.remove		= enetc_remove,
 	.ops		= &enetc_ops_imx,
 	.priv_auto	= sizeof(struct enetc_priv),
Signature · 1 line
2.45.2
#1 lore raw
Quoted 9 lines · Marek Vasut

The ENETCv4 port DT nodes on i.MX95 may contain optional clock phandle to IMX95_CLK_ENETREF "ref" clock. These "ref" clock must be enabled for the ethernet to work. These "ref" clock are enabled after cold boot, but when the system booted Linux and rebooted, those "ref" clock might have been disabled in the process, which would make ethernet inoperable after reboot. Make sure those "ref" clock are always correctly enabled.

Applied, thanks.