]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: fec_mxc: specify the registered eth index by dev_id
authorAndy Duan <fugang.duan@nxp.com>
Mon, 10 Apr 2017 11:44:35 +0000 (19:44 +0800)
committerStefano Babic <sbabic@denx.de>
Tue, 18 Apr 2017 13:59:58 +0000 (15:59 +0200)
Specify the registered eth index by dev_id.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
drivers/net/fec_mxc.c

index d67a69b87945dd95bde5f6604ad02a1b9e2c29b5..08bea8b05213e96ef5585f017c07ae57c1e75861 100644 (file)
@@ -1023,6 +1023,7 @@ static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
        struct eth_device *edev;
        struct fec_priv *fec;
        unsigned char ethaddr[6];
+       char mac[16];
        uint32_t start;
        int ret = 0;
 
@@ -1085,12 +1086,18 @@ static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
        fec->phy_id = phy_id;
 #endif
        eth_register(edev);
+       /* only support one eth device, the index number pointed by dev_id */
+       edev->index = fec->dev_id;
 
        if (fec_get_hwaddr(fec->dev_id, ethaddr) == 0) {
                debug("got MAC%d address from fuse: %pM\n", fec->dev_id, ethaddr);
                memcpy(edev->enetaddr, ethaddr, 6);
-               if (!getenv("ethaddr"))
-                       eth_setenv_enetaddr("ethaddr", ethaddr);
+               if (fec->dev_id)
+                       sprintf(mac, "eth%daddr", fec->dev_id);
+               else
+                       strcpy(mac, "ethaddr");
+               if (!getenv(mac))
+                       eth_setenv_enetaddr(mac, ethaddr);
        }
        return ret;
 err4: