summaryrefslogtreecommitdiff
path: root/board/davinci
diff options
context:
space:
mode:
authorHadli, Manjunath <manjunath.hadli@ti.com>2012-02-09 20:22:25 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2012-02-27 21:19:24 +0100
commit206a1038f74cddf71e54c237fee2087d3b26d8e8 (patch)
tree8f4eccb70012d7e4fa52ad6776eb6f97e467b172 /board/davinci
parent38fed6ee95ee5b0dba9f91380267ed998cee2f62 (diff)
da850evm: read mac address from I2C EEPROM on AM18x EVM
add support to read mac address for AM18x EVM manufactured from Spectrum digital which have mac address stored in I2C EEPROM manufactured by WINBOND. This patch reads mac address from I2C EEPROM and sets the environment variable if not set, If mac address is already present in environment compare it with the mac address in EEPROM and warn on mismatch.Introduced a config option CONFIG_MAC_ADDR_IN_EEPROM to where to look for the mac address. Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com> Cc: Tom Rini <trini@ti.com> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Wolfgang Denk <wd@denx.de>
Diffstat (limited to 'board/davinci')
-rw-r--r--board/davinci/da8xxevm/da850evm.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c
index beb56575e3b..004d5ad6d49 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -132,13 +132,17 @@ int misc_init_r(void)
{
dspwake();
-#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+#if defined(CONFIG_MAC_ADDR_IN_SPIFLASH) || defined(CONFIG_MAC_ADDR_IN_EEPROM)
+
uchar env_enetaddr[6];
int enetaddr_found;
+
+ enetaddr_found = eth_getenv_enetaddr("ethaddr", env_enetaddr);
+
+#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
int spi_mac_read;
uchar buff[6];
- enetaddr_found = eth_getenv_enetaddr("ethaddr", env_enetaddr);
spi_mac_read = get_mac_addr(buff);
/*
@@ -170,6 +174,33 @@ int misc_init_r(void)
printf("Default using MAC address from environment\n");
}
#endif
+ uint8_t enetaddr[8];
+ int eeprom_mac_read;
+
+ /* Read Ethernet MAC address from EEPROM */
+ eeprom_mac_read = dvevm_read_mac_address(enetaddr);
+
+ /*
+ * MAC address not present in the environment
+ * try and read the MAC address from EEPROM flash
+ * and set it.
+ */
+ if (!enetaddr_found) {
+ if (eeprom_mac_read)
+ /* Set Ethernet MAC address from EEPROM */
+ davinci_sync_env_enetaddr(enetaddr);
+ } else {
+ /*
+ * MAC address present in environment compare it with
+ * the MAC address in EEPROM and warn on mismatch
+ */
+ if (eeprom_mac_read && memcmp(enetaddr, env_enetaddr, 6))
+ printf("Warning: MAC address in EEPROM don't match "
+ "with the MAC address in the environment\n");
+ printf("Default using MAC address from environment\n");
+ }
+
+#endif
return 0;
}