Patchwork [U-Boot,3/3] netspace_v2: Read Ethernet MAC address from EEPROM

login
register
mail settings
Submitter Simon Guinot
Date Oct. 31, 2011, 1:58 p.m.
Message ID <1320069516-2105-4-git-send-email-simon@sequanux.org>
Download mbox | patch
Permalink /patch/122812/
State Superseded
Delegated to: Prafulla Wadaskar
Headers show

Comments

Simon Guinot - Oct. 31, 2011, 1:58 p.m.
From: Simon Guinot <simon.guinot@sequanux.org>

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
---
 board/LaCie/netspace_v2/netspace_v2.c         |   43 +++++++++++++++++++++++++
 include/configs/netspace_v2.h                 |    1 +
 2 files changed, 44 insertions(+), 0 deletions(-)
 delete mode 100644 arch/arm/cpu/arm926ejs/kirkwood/asm-offsets.s
Simon Guinot - Nov. 5, 2011, 12:29 p.m.
Hi Prafulla,

On Mon, Oct 31, 2011 at 02:58:36PM +0100, Simon Guinot wrote:
> From: Simon Guinot <simon.guinot@sequanux.org>
> 
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> ---
>  board/LaCie/netspace_v2/netspace_v2.c         |   43 +++++++++++++++++++++++++
>  include/configs/netspace_v2.h                 |    1 +
>  2 files changed, 44 insertions(+), 0 deletions(-)
>  delete mode 100644 arch/arm/cpu/arm926ejs/kirkwood/asm-offsets.s

Do you want me to repost this patch with some modifications ?

Regards,

Simon

> 
> diff --git a/arch/arm/cpu/arm926ejs/kirkwood/asm-offsets.s b/arch/arm/cpu/arm926ejs/kirkwood/asm-offsets.s
> deleted file mode 100644
> index e69de29..0000000
> diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
> index 7c4b15e..a7717b9 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)
> +{
> +#ifdef CONFIG_CMD_I2C
> +	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 */
> +
> +	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@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Prafulla Wadaskar - Nov. 8, 2011, 8:28 a.m.
> -----Original Message-----
> From: Simon Guinot [mailto:simon@sequanux.org]
> Sent: Saturday, November 05, 2011 6:00 PM
> To: Prafulla Wadaskar
> Cc: u-boot@lists.denx.de; Simon Guinot
> Subject: Re: [U-Boot] [PATCH 3/3] netspace_v2: Read Ethernet
> MAC address from EEPROM
> 
> Hi Prafulla,
> 
> On Mon, Oct 31, 2011 at 02:58:36PM +0100, Simon Guinot wrote:
> > From: Simon Guinot <simon.guinot@sequanux.org>
> >
> > Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
> > ---
> >  board/LaCie/netspace_v2/netspace_v2.c         |   43
> +++++++++++++++++++++++++
> >  include/configs/netspace_v2.h                 |    1 +
> >  2 files changed, 44 insertions(+), 0 deletions(-)
> >  delete mode 100644 arch/arm/cpu/arm926ejs/kirkwood/asm-
> offsets.s
> 
> Do you want me to repost this patch with some modifications ?

Since asm-offsets.s is already removed
Please resend the patch with re-syncing with u-boot-marvell.git

Regards..
Prafulla . . .

Patch

diff --git a/arch/arm/cpu/arm926ejs/kirkwood/asm-offsets.s b/arch/arm/cpu/arm926ejs/kirkwood/asm-offsets.s
deleted file mode 100644
index e69de29..0000000
diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
index 7c4b15e..a7717b9 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)
+{
+#ifdef CONFIG_CMD_I2C
+	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 */
+
+	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