From: Peng Fan Date: Tue, 26 Jul 2022 08:41:17 +0000 (+0800) Subject: net: dwc_eth_qos: introduce eqos hook eqos_get_enetaddr X-Git-Url: http://git.dujemihanovic.xyz/html/static/git-favicon.png?a=commitdiff_plain;h=a624251461bf9750d8a11545972fe575fc4cbf85;p=u-boot.git net: dwc_eth_qos: introduce eqos hook eqos_get_enetaddr 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 --- diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index a4380d17d9..c1f2391d63 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 f470189e8d..b35e774263 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 2d1b5104af..42cb164ad1 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 = {