]> git.sur5r.net Git - u-boot/commitdiff
display5: net: Add function to read ethaddr from iMX6 fuses
authorLukasz Majewski <lukma@denx.de>
Fri, 11 May 2018 14:51:14 +0000 (16:51 +0200)
committerStefano Babic <sbabic@denx.de>
Mon, 18 Jun 2018 13:44:21 +0000 (15:44 +0200)
Signed-off-by: Lukasz Majewski <lukma@denx.de>
board/liebherr/display5/display5.c

index 4bade476a55be476264a151fb5c292be7a66dc37..a3deba216c72038599b3ac1ac58143dbbbab2b29 100644 (file)
@@ -254,6 +254,25 @@ static void setup_iomux_enet(void)
        gpio_direction_input(IMX_GPIO_NR(1, 28)); /*INT#_GBE*/
 }
 
+static int setup_mac_from_fuse(void)
+{
+       unsigned char enetaddr[6];
+       int ret;
+
+       ret = eth_env_get_enetaddr("ethaddr", enetaddr);
+       if (ret)        /* ethaddr is already set */
+               return 0;
+
+       imx_get_mac_from_fuse(0, enetaddr);
+
+       if (is_valid_ethaddr(enetaddr)) {
+               eth_env_set_enetaddr("ethaddr", enetaddr);
+               return 0;
+       }
+
+       return 0;
+}
+
 int board_eth_init(bd_t *bd)
 {
        struct phy_device *phydev;
@@ -268,6 +287,8 @@ int board_eth_init(bd_t *bd)
        if (ret)
                return ret;
 
+       setup_mac_from_fuse();
+
        bus = fec_get_miibus(IMX_FEC_BASE, -1);
        if (!bus)
                return -ENODEV;