[PATCH 47/49] net: dwc_eth_qos: intrdouce eqos hook eqos_get_enetaddr

Peng Fan (OSS) peng.fan at oss.nxp.com
Mon Jun 6 13:24:19 CEST 2022


From: Peng Fan <peng.fan at nxp.com>

i.MX has specific hook to get MAC address, so introduce a hook and move
i.MX code to its own driver

Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 drivers/net/dwc_eth_qos.c     |  9 ++++++---
 drivers/net/dwc_eth_qos.h     |  1 +
 drivers/net/dwc_eth_qos_imx.c | 12 +++++++++++-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index a4380d17d9c..c1f2391d635 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -712,10 +712,13 @@ static int eqos_write_hwaddr(struct udevice *dev)
 static int eqos_read_rom_hwaddr(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_plat(dev);
+	struct eqos_priv *eqos = dev_get_priv(dev);
+	int ret;
+
+	ret = eqos->config->ops->eqos_get_enetaddr(dev);
+	if (ret < 0)
+		return ret;
 
-#ifdef CONFIG_ARCH_IMX8M
-	imx_get_mac_from_fuse(dev_seq(dev), pdata->enetaddr);
-#endif
 	return !is_valid_ethaddr(pdata->enetaddr);
 }
 
diff --git a/drivers/net/dwc_eth_qos.h b/drivers/net/dwc_eth_qos.h
index f470189e8d4..b35e7742634 100644
--- a/drivers/net/dwc_eth_qos.h
+++ b/drivers/net/dwc_eth_qos.h
@@ -240,6 +240,7 @@ struct eqos_ops {
 	int (*eqos_calibrate_pads)(struct udevice *dev);
 	int (*eqos_disable_calibration)(struct udevice *dev);
 	int (*eqos_set_tx_clk_speed)(struct udevice *dev);
+	int (*eqos_get_enetaddr)(struct udevice *dev);
 	ulong (*eqos_get_tick_clk_rate)(struct udevice *dev);
 };
 
diff --git a/drivers/net/dwc_eth_qos_imx.c b/drivers/net/dwc_eth_qos_imx.c
index 2d1b5104af2..42cb164ad14 100644
--- a/drivers/net/dwc_eth_qos_imx.c
+++ b/drivers/net/dwc_eth_qos_imx.c
@@ -92,6 +92,15 @@ static int eqos_set_tx_clk_speed_imx(struct udevice *dev)
 	return 0;
 }
 
+static int eqos_get_enetaddr_imx(struct udevice *dev)
+{
+	struct eth_pdata *pdata = dev_get_plat(dev);
+
+	imx_get_mac_from_fuse(dev_seq(dev), pdata->enetaddr);
+
+	return 0;
+}
+
 static struct eqos_ops eqos_imx_ops = {
 	.eqos_inval_desc = eqos_inval_desc_generic,
 	.eqos_flush_desc = eqos_flush_desc_generic,
@@ -106,7 +115,8 @@ static struct eqos_ops eqos_imx_ops = {
 	.eqos_calibrate_pads = eqos_null_ops,
 	.eqos_disable_calibration = eqos_null_ops,
 	.eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_imx,
-	.eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_imx
+	.eqos_get_enetaddr = eqos_get_enetaddr_imx,
+	.eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_imx,
 };
 
 struct eqos_config __maybe_unused eqos_imx_config = {
-- 
2.36.0



More information about the U-Boot mailing list