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 <peng.fan@nxp.com>
This commit is contained in:
Peng Fan 2022-07-26 16:41:17 +08:00 committed by Stefano Babic
parent a6acf95508
commit a624251461
3 changed files with 18 additions and 4 deletions

View file

@ -712,10 +712,13 @@ static int eqos_write_hwaddr(struct udevice *dev)
static int eqos_read_rom_hwaddr(struct udevice *dev) static int eqos_read_rom_hwaddr(struct udevice *dev)
{ {
struct eth_pdata *pdata = dev_get_plat(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); return !is_valid_ethaddr(pdata->enetaddr);
} }

View file

@ -240,6 +240,7 @@ struct eqos_ops {
int (*eqos_calibrate_pads)(struct udevice *dev); int (*eqos_calibrate_pads)(struct udevice *dev);
int (*eqos_disable_calibration)(struct udevice *dev); int (*eqos_disable_calibration)(struct udevice *dev);
int (*eqos_set_tx_clk_speed)(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); ulong (*eqos_get_tick_clk_rate)(struct udevice *dev);
}; };

View file

@ -92,6 +92,15 @@ static int eqos_set_tx_clk_speed_imx(struct udevice *dev)
return 0; 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 = { static struct eqos_ops eqos_imx_ops = {
.eqos_inval_desc = eqos_inval_desc_generic, .eqos_inval_desc = eqos_inval_desc_generic,
.eqos_flush_desc = eqos_flush_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_calibrate_pads = eqos_null_ops,
.eqos_disable_calibration = eqos_null_ops, .eqos_disable_calibration = eqos_null_ops,
.eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_imx, .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 = { struct eqos_config __maybe_unused eqos_imx_config = {