]> git.sur5r.net Git - u-boot/blobdiff - board/ti/ti816x/evm.c
net: Move enetaddr env access code to env config instead of net config
[u-boot] / board / ti / ti816x / evm.c
index 577e60f875f4d27d2dd38d6751ec434c6a67e267..abc961a86e06c5f7183e4c74ade85a145f5a8aee 100644 (file)
@@ -8,7 +8,9 @@
  */
 
 #include <common.h>
+#include <environment.h>
 #include <spl.h>
+#include <netdev.h>
 #include <asm/cache.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
@@ -31,6 +33,33 @@ int board_init(void)
        return 0;
 }
 
+int board_eth_init(bd_t *bis)
+{
+       uint8_t mac_addr[6];
+       uint32_t mac_hi, mac_lo;
+       struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
+
+       if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+               printf("<ethaddr> not set. Reading from E-fuse\n");
+               /* try reading mac address from efuse */
+               mac_lo = readl(&cdev->macid0l);
+               mac_hi = readl(&cdev->macid0h);
+               mac_addr[0] = mac_hi & 0xFF;
+               mac_addr[1] = (mac_hi & 0xFF00) >> 8;
+               mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
+               mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
+               mac_addr[4] = mac_lo & 0xFF;
+               mac_addr[5] = (mac_lo & 0xFF00) >> 8;
+
+               if (is_valid_ethaddr(mac_addr))
+                       eth_env_set_enetaddr("ethaddr", mac_addr);
+               else
+                       printf("Unable to read MAC address. Set <ethaddr>\n");
+       }
+
+       return davinci_emac_initialize();
+}
+
 #ifdef CONFIG_SPL_BUILD
 static struct module_pin_mux mmc_pin_mux[] = {
        { OFFSET(pincntl157), PULLDOWN_EN | PULLUDDIS | MODE(0x0) },