net: ftgmac100: Read and retain MAC address

Read and retain MAC address across flash and QEMU support.

Signed-off-by: Hongwei Zhang <hongweiz@ami.com>
This commit is contained in:
Hongwei Zhang 2020-12-10 18:11:09 -05:00 committed by Tom Rini
parent c1ab738145
commit 0be3d1fafb

View file

@ -270,6 +270,28 @@ static int ftgmac100_set_mac(struct ftgmac100_data *priv,
return 0;
}
/*
* Get MAC address
*/
static int ftgmac100_get_mac(struct ftgmac100_data *priv,
unsigned char *mac)
{
struct ftgmac100 *ftgmac100 = priv->iobase;
unsigned int maddr = readl(&ftgmac100->mac_madr);
unsigned int laddr = readl(&ftgmac100->mac_ladr);
debug("%s(%x %x)\n", __func__, maddr, laddr);
mac[0] = (maddr >> 8) & 0xff;
mac[1] = maddr & 0xff;
mac[2] = (laddr >> 24) & 0xff;
mac[3] = (laddr >> 16) & 0xff;
mac[4] = (laddr >> 8) & 0xff;
mac[5] = laddr & 0xff;
return 0;
}
/*
* disable transmitter, receiver
*/
@ -511,6 +533,14 @@ static int ftgmac100_write_hwaddr(struct udevice *dev)
return ftgmac100_set_mac(priv, pdata->enetaddr);
}
static int ftgmac_read_hwaddr(struct udevice *dev)
{
struct eth_pdata *pdata = dev_get_plat(dev);
struct ftgmac100_data *priv = dev_get_priv(dev);
return ftgmac100_get_mac(priv, pdata->enetaddr);
}
static int ftgmac100_of_to_plat(struct udevice *dev)
{
struct eth_pdata *pdata = dev_get_plat(dev);
@ -571,6 +601,8 @@ static int ftgmac100_probe(struct udevice *dev)
goto out;
}
ftgmac_read_hwaddr(dev);
out:
if (ret)
clk_release_bulk(&priv->clks);