[U-Boot] [PATCH 3/4] dm: net: fec: Add .read_rom_hwaddr
Jagan Teki
jagan at openedev.com
Thu Nov 3 20:43:33 CET 2016
From: Jagan Teki <jagan at amarulasolutions.com>
Add .read_rom_hwaddr on dm eth_ops.
Cc: Stefano Babic <sbabic at denx.de>
Cc: Matteo Lisi <matteo.lisi at engicam.com>
Cc: Michael Trimarchi <michael at amarulasolutions.com>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
drivers/net/fec_mxc.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 23fa609..746faed 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -348,12 +348,6 @@ static void fec_rbd_clean(int last, struct fec_bd *prbd)
writew(0, &prbd->data_length);
}
-static int fec_get_hwaddr(int dev_id, unsigned char *mac)
-{
- imx_get_mac_from_fuse(dev_id, mac);
- return !is_valid_ethaddr(mac);
-}
-
static int _fec_set_hwaddr(struct fec_priv *fec, uchar *mac)
{
writel(0, &fec->eth->iaddr1);
@@ -975,6 +969,12 @@ static int fec_init(struct eth_device *dev, bd_t *bd)
return _fec_init(fec, mac);
}
+static int fec_get_hwaddr(int dev_id, unsigned char *mac)
+{
+ imx_get_mac_from_fuse(dev_id, mac);
+ return !is_valid_ethaddr(mac);
+}
+
#ifdef CONFIG_PHYLIB
int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
struct mii_dev *bus, struct phy_device *phydev)
@@ -1128,6 +1128,16 @@ int fecmxc_register_mii_postcall(struct eth_device *dev, int (*cb)(int))
#else
+static int fec_read_rom_mac(struct udevice *dev)
+{
+ struct fec_priv *fec = dev_get_priv(dev);
+ struct eth_pdata *pdata = dev_get_platdata(dev);
+
+ imx_get_mac_from_fuse(fec->dev_id, pdata->enetaddr);
+
+ return 0;
+}
+
static int fec_set_hwaddr(struct udevice *dev)
{
struct fec_priv *fec = dev_get_priv(dev);
@@ -1175,6 +1185,7 @@ static const struct eth_ops fecmxc_ops = {
.recv = fec_recv,
.stop = fec_halt,
.write_hwaddr = fec_set_hwaddr,
+ .read_rom_hwaddr = fec_read_rom_mac,
};
static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
@@ -1204,7 +1215,6 @@ static int fecmxc_probe(struct udevice *dev)
struct fec_priv *priv = dev_get_priv(dev);
struct mii_dev *bus = NULL;
int dev_id = -1;
- unsigned char ethaddr[6];
uint32_t start;
int ret;
@@ -1238,14 +1248,6 @@ static int fecmxc_probe(struct udevice *dev)
fec_reg_setup(priv);
priv->dev_id = (dev_id == -1) ? 0 : dev_id;
- ret = fec_get_hwaddr(dev_id, ethaddr);
- if (!ret) {
- debug("got MAC%d address from fuse: %pM\n", dev_id, ethaddr);
- memcpy(pdata->enetaddr, ethaddr, 6);
- if (!getenv("ethaddr"))
- eth_setenv_enetaddr("ethaddr", ethaddr);
- }
-
return 0;
err_timeout:
--
1.9.1
More information about the U-Boot
mailing list