From patchwork Tue Nov 8 21:31:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guinot X-Patchwork-Id: 124436 X-Patchwork-Delegate: prafulla@marvell.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 49082B6F93 for ; Wed, 9 Nov 2011 08:31:25 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CB4BC28E2B; Tue, 8 Nov 2011 22:31:22 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WYhSid5AA0HX; Tue, 8 Nov 2011 22:31:22 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4277128E34; Tue, 8 Nov 2011 22:31:20 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 115F228E34 for ; Tue, 8 Nov 2011 22:31:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c95nTs0c2KeI for ; Tue, 8 Nov 2011 22:31:17 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from vm1.sequanux.org (vm1.sequanux.org [188.165.36.56]) by theia.denx.de (Postfix) with ESMTP id 6BECA28E2B for ; Tue, 8 Nov 2011 22:31:15 +0100 (CET) Received: from localhost (unknown [78.250.254.121]) by vm1.sequanux.org (Postfix) with ESMTPSA id 2007310813F; Tue, 8 Nov 2011 22:31:15 +0100 (CET) From: Simon Guinot To: Prafulla Wadaskar Date: Tue, 8 Nov 2011 22:31:14 +0100 Message-Id: <1320787874-4382-1-git-send-email-simon@sequanux.org> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: References: Cc: u-boot@lists.denx.de, Simon Guinot Subject: [U-Boot] [PATCH v2] netspace_v2: Read Ethernet MAC address from EEPROM X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Simon Guinot Signed-off-by: Simon Guinot --- Changes in v2: - fix asm-offsets.s removal - make MAC address setup conditional to CONFIG_SYS_I2C_EEPROM_ADDR board/LaCie/netspace_v2/netspace_v2.c | 43 +++++++++++++++++++++++++++++++++ include/configs/netspace_v2.h | 1 + 2 files changed, 44 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 #include #include +#include #include #include #include @@ -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; diff --git a/include/configs/netspace_v2.h b/include/configs/netspace_v2.h index bb27ed7..1ddf4b4 100644 --- a/include/configs/netspace_v2.h +++ b/include/configs/netspace_v2.h @@ -87,6 +87,7 @@ * Ethernet Driver configuration */ #ifdef CONFIG_CMD_NET +#define CONFIG_MISC_INIT_R /* Call misc_init_r() to initialize MAC address */ #define CONFIG_MVGBE_PORTS {1, 0} /* enable port 0 only */ #define CONFIG_NETCONSOLE #endif