summaryrefslogtreecommitdiff
path: root/board/LaCie/netspace_v2
diff options
context:
space:
mode:
authorSimon Guinot <simon.guinot@sequanux.org>2011-11-08 11:31:14 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2011-12-06 23:59:30 +0100
commit0bfb66b6d1497046aac9c4d61f4478a403659f5a (patch)
tree7982cc5558e3d6e3ffe9b6c03db07fccc30e8be7 /board/LaCie/netspace_v2
parent35e3f6d7693fe11718850511ef729bf692c6260b (diff)
downloadu-boot-imx-0bfb66b6d1497046aac9c4d61f4478a403659f5a.zip
u-boot-imx-0bfb66b6d1497046aac9c4d61f4478a403659f5a.tar.gz
u-boot-imx-0bfb66b6d1497046aac9c4d61f4478a403659f5a.tar.bz2
netspace_v2: Read Ethernet MAC address from EEPROM
Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Diffstat (limited to 'board/LaCie/netspace_v2')
-rw-r--r--board/LaCie/netspace_v2/netspace_v2.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
index 7c4b15e..6938a43 100644
--- a/board/LaCie/netspace_v2/netspace_v2.c
+++ b/board/LaCie/netspace_v2/netspace_v2.c
@@ -24,6 +24,7 @@
#include <miiphy.h>
#include <netdev.h>
#include <command.h>
+#include <i2c.h>
#include <asm/arch/cpu.h>
#include <asm/arch/kirkwood.h>
#include <asm/arch/mpp.h>
@@ -89,6 +90,48 @@ int board_init(void)
return 0;
}
+int misc_init_r(void)
+{
+#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
+ if (!getenv("ethaddr")) {
+ ushort version;
+ uchar mac[6];
+ int ret;
+
+ /* I2C-0 for on-board EEPROM */
+ i2c_set_bus_num(0);
+
+ /* Check layout version for EEPROM data */
+ ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0,
+ CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
+ (uchar *) &version, 2);
+ if (ret != 0) {
+ printf("Error: failed to read I2C EEPROM @%02x\n",
+ CONFIG_SYS_I2C_EEPROM_ADDR);
+ return ret;
+ }
+ version = be16_to_cpu(version);
+ if (version < 1 || version > 3) {
+ printf("Error: unknown version %d for EEPROM data\n",
+ version);
+ return -1;
+ }
+
+ /* Read Ethernet MAC address from EEPROM */
+ ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 2,
+ CONFIG_SYS_I2C_EEPROM_ADDR_LEN, mac, 6);
+ if (ret != 0) {
+ printf("Error: failed to read I2C EEPROM @%02x\n",
+ CONFIG_SYS_I2C_EEPROM_ADDR);
+ return ret;
+ }
+ eth_setenv_enetaddr("ethaddr", mac);
+ }
+#endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_EEPROM_ADDR */
+
+ return 0;
+}
+
void mv_phy_88e1116_init(char *name)
{
u16 reg;