diff mbox

[U-Boot,11/11] arm: cm4008, cm41xx: read MAC address from flash

Message ID 1349438998-10954-12-git-send-email-yann.vernier@orsoc.se
State Deferred
Delegated to: Albert ARIBAUD
Headers show

Commit Message

Yann Vernier Oct. 5, 2012, 12:09 p.m. UTC
Previously code to do this was in the Ethernet driver itself.
Since it is board specific, moved it here, and altered it to
support preset MAC from environment.
---
 board/cm4008/cm4008.c |   12 ++++++++++++
 board/cm41xx/cm41xx.c |   12 ++++++++++++
 2 files changed, 24 insertions(+)

Comments

Albert ARIBAUD Oct. 18, 2012, 7:14 p.m. UTC | #1
Hi Yann,

On Fri,  5 Oct 2012 14:09:58 +0200, Yann Vernier
<yann.vernier@orsoc.se> wrote:

> Previously code to do this was in the Ethernet driver itself.
> Since it is board specific, moved it here, and altered it to
> support preset MAC from environment.
> ---
>  board/cm4008/cm4008.c |   12 ++++++++++++
>  board/cm41xx/cm41xx.c |   12 ++++++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/board/cm4008/cm4008.c b/board/cm4008/cm4008.c
> index 6c0da9a..e14f8f4 100644
> --- a/board/cm4008/cm4008.c
> +++ b/board/cm4008/cm4008.c
> @@ -75,10 +75,22 @@ int board_late_init (void)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_DRIVER_KS8695ETH
>  int board_eth_init(bd_t *bis)
>  {
> +	uchar enetaddr[6];
> +	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
> +
> +	/* read MAC address from flash */
> +	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
> +		memcpy(&enetaddr[0], fp, 6);
> +		if (is_valid_ether_addr(enetaddr))
> +			eth_setenv_enetaddr("ethaddr", enetaddr);
> +	}
> +
>  	return ks8695_eth_initialize();
>  }
> +#endif
>  
>  int board_init (void)
>  {
> diff --git a/board/cm41xx/cm41xx.c b/board/cm41xx/cm41xx.c
> index 6aef617..771701d 100644
> --- a/board/cm41xx/cm41xx.c
> +++ b/board/cm41xx/cm41xx.c
> @@ -75,10 +75,22 @@ int board_late_init (void)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_DRIVER_KS8695ETH
>  int board_eth_init(bd_t *bis)
>  {
> +	uchar enetaddr[6];
> +	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;

Magic number here.

> +
> +	/* read MAC address from flash */
> +	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
> +		memcpy(&enetaddr[0], fp, 6);
> +		if (is_valid_ether_addr(enetaddr))
> +			eth_setenv_enetaddr("ethaddr", enetaddr);
> +	}
> +
>  	return ks8695_eth_initialize();
>  }
> +#endif
>  
>  int board_init (void)
>  {



Amicalement,
diff mbox

Patch

diff --git a/board/cm4008/cm4008.c b/board/cm4008/cm4008.c
index 6c0da9a..e14f8f4 100644
--- a/board/cm4008/cm4008.c
+++ b/board/cm4008/cm4008.c
@@ -75,10 +75,22 @@  int board_late_init (void)
 	return 0;
 }
 
+#ifdef CONFIG_DRIVER_KS8695ETH
 int board_eth_init(bd_t *bis)
 {
+	uchar enetaddr[6];
+	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+	/* read MAC address from flash */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(&enetaddr[0], fp, 6);
+		if (is_valid_ether_addr(enetaddr))
+			eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
 	return ks8695_eth_initialize();
 }
+#endif
 
 int board_init (void)
 {
diff --git a/board/cm41xx/cm41xx.c b/board/cm41xx/cm41xx.c
index 6aef617..771701d 100644
--- a/board/cm41xx/cm41xx.c
+++ b/board/cm41xx/cm41xx.c
@@ -75,10 +75,22 @@  int board_late_init (void)
 	return 0;
 }
 
+#ifdef CONFIG_DRIVER_KS8695ETH
 int board_eth_init(bd_t *bis)
 {
+	uchar enetaddr[6];
+	const uchar * const fp=CONFIG_SYS_FLASH_BASE+0x1c000;
+
+	/* read MAC address from flash */
+	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+		memcpy(&enetaddr[0], fp, 6);
+		if (is_valid_ether_addr(enetaddr))
+			eth_setenv_enetaddr("ethaddr", enetaddr);
+	}
+
 	return ks8695_eth_initialize();
 }
+#endif
 
 int board_init (void)
 {