From: Simon Guinot <simon@sequanux.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] netspace_v2: Read Ethernet MAC address from EEPROM
Date: Wed, 16 Nov 2011 11:32:22 +0100 [thread overview]
Message-ID: <20111116103222.GG29864@kw.sim.vm.gnt> (raw)
In-Reply-To: <1320787874-4382-1-git-send-email-simon@sequanux.org>
Hi Prafulla,
On Tue, Nov 08, 2011 at 10:31:14PM +0100, Simon Guinot wrote:
> From: Simon Guinot <simon.guinot@sequanux.org>
>
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> ---
>
> 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(-)
Do you want me for some other modifications on this patch ?
Regards,
Simon
>
> 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;
> 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
> --
> 1.7.5.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111116/1b06a305/attachment.pgp
next prev parent reply other threads:[~2011-11-16 10:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-31 13:58 [U-Boot] [PATCH 0/3] netspace_v2: fixes and features Simon Guinot
2011-10-31 13:58 ` [U-Boot] [PATCH 1/3] netspace_v2: fix SDRAM configuration Simon Guinot
2011-11-01 7:36 ` Prafulla Wadaskar
2011-10-31 13:58 ` [U-Boot] [PATCH 2/3] netspace_v2: enable I2C EEPROM support Simon Guinot
2011-11-01 7:36 ` Prafulla Wadaskar
2011-10-31 13:58 ` [U-Boot] [PATCH 3/3] netspace_v2: Read Ethernet MAC address from EEPROM Simon Guinot
2011-11-05 12:29 ` Simon Guinot
2011-11-08 8:28 ` Prafulla Wadaskar
2011-11-08 21:31 ` [U-Boot] [PATCH v2] " Simon Guinot
2011-11-16 10:32 ` Simon Guinot [this message]
2011-11-16 12:25 ` Prafulla Wadaskar
2011-11-21 10:34 ` Prafulla Wadaskar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111116103222.GG29864@kw.sim.vm.gnt \
--to=simon@sequanux.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.