aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHongwei Zhang2020-12-10 18:11:09 -0500
committerTom Rini2021-01-19 09:15:02 -0500
commit0be3d1fafb54bc2fd3d5862304528d7a21e500d9 (patch)
tree51d605ec9daac7b8910582ee1a660a175ecd22fb /drivers
parentc1ab73814515c865896b0abc54d3071a1a273537 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ftgmac100.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
index 69e299d6a3d..0687230b4bb 100644
--- a/drivers/net/ftgmac100.c
+++ b/drivers/net/ftgmac100.c
@@ -271,6 +271,28 @@ static int ftgmac100_set_mac(struct ftgmac100_data *priv,
}
/*
+ * 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
*/
static void ftgmac100_stop(struct udevice *dev)
@@ -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);