From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Thu, 18 Oct 2012 21:14:21 +0200 Subject: [U-Boot] [PATCH 11/11] arm: cm4008, cm41xx: read MAC address from flash In-Reply-To: <1349438998-10954-12-git-send-email-yann.vernier@orsoc.se> References: <1349438998-10954-1-git-send-email-yann.vernier@orsoc.se> <1349438998-10954-12-git-send-email-yann.vernier@orsoc.se> Message-ID: <20121018211421.06a09cfb@lilith> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Yann, On Fri, 5 Oct 2012 14:09:58 +0200, Yann Vernier 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, -- Albert.