Commit d301425fbfc7a0c13df2a2965a289c829e2b1ba3

Authored by Hannes Petermaier
Committed by Tom Rini
1 parent fbd5aeda48

board/BuR/common: try to setup cpsw mac-address from the devicetree

since we have a dtb blob programmed on the board we try to setup the cpsw
interface with the programmed mac.
If this method fails, we fall back to the device-fuses.

Signed-off-by: Hannes Petermaier <oe5hpm@oevsv.at>

Showing 1 changed file with 15 additions and 10 deletions Side-by-side Diff

board/BuR/common/common.c
... ... @@ -591,9 +591,9 @@
591 591 int board_eth_init(bd_t *bis)
592 592 {
593 593 int rv = 0;
594   - uint8_t mac_addr[6];
  594 + char mac_addr[6];
  595 + const char *mac = 0;
595 596 uint32_t mac_hi, mac_lo;
596   -
597 597 /* try reading mac address from efuse */
598 598 mac_lo = readl(&cdev->macid0l);
599 599 mac_hi = readl(&cdev->macid0h);
600 600  
... ... @@ -607,14 +607,19 @@
607 607 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
608 608 (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
609 609 if (!getenv("ethaddr")) {
610   - printf("<ethaddr> not set. Validating first E-fuse MAC ... ");
  610 + #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_USE_FDT)
  611 + printf("<ethaddr> not set. trying DTB ... ");
  612 + mac = dtbmacaddr(0);
  613 + #endif
  614 + if (!mac) {
  615 + printf("<ethaddr> not set. validating E-fuse MAC ... ");
  616 + if (is_valid_ether_addr((const u8 *)mac_addr))
  617 + mac = (const char *)mac_addr;
  618 + }
611 619  
612   - if (is_valid_ether_addr(mac_addr)) {
613   - printf("using: %02X:%02X:%02X:%02X:%02X:%02X.\n",
614   - mac_addr[0], mac_addr[1], mac_addr[2],
615   - mac_addr[3], mac_addr[4], mac_addr[5]
616   - );
617   - eth_setenv_enetaddr("ethaddr", mac_addr);
  620 + if (mac) {
  621 + printf("using: %pM on ", mac);
  622 + eth_setenv_enetaddr("ethaddr", (const u8 *)mac);
618 623 }
619 624 }
620 625 writel(MII_MODE_ENABLE, &cdev->miisel);