From patchwork Thu Mar 17 19:46:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Spang X-Patchwork-Id: 87418 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 8C9A9B6FBB for ; Fri, 18 Mar 2011 06:55:27 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 31BA02812B; Thu, 17 Mar 2011 20:55:26 +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 qXunsCDSPT2o; Thu, 17 Mar 2011 20:55:25 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5A88528106; Thu, 17 Mar 2011 20:55:18 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 55E7428113 for ; Thu, 17 Mar 2011 20:55:16 +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 fveXUYfaYFHx for ; Thu, 17 Mar 2011 20:55:15 +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 caffeine.csclub.uwaterloo.ca (caffeine.csclub.uwaterloo.ca [129.97.134.17]) by theia.denx.de (Postfix) with ESMTP id 095CE280CD for ; Thu, 17 Mar 2011 20:55:13 +0100 (CET) Received: from corn-syrup (corn-syrup.csclub.uwaterloo.ca [129.97.134.72]) by caffeine.csclub.uwaterloo.ca (Postfix) with SMTP id 19458D86; Thu, 17 Mar 2011 15:47:07 -0400 (EDT) Received: by corn-syrup (sSMTP sendmail emulation); Thu, 17 Mar 2011 15:47:07 -0400 From: Michael Spang To: u-boot@lists.denx.de Date: Thu, 17 Mar 2011 15:46:56 -0400 Message-Id: <1300391223-11879-3-git-send-email-mspang@csclub.uwaterloo.ca> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1300391223-11879-1-git-send-email-mspang@csclub.uwaterloo.ca> References: <1300391223-11879-1-git-send-email-mspang@csclub.uwaterloo.ca> Cc: Michael Spang , Alexander Clouter Subject: [U-Boot] [PATCH 2/9] mvgbe: Support preserving the existing MAC address 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 The MVGBE driver either gets the MAC from the environment, or invents one. This allows the driver to leave the existing address alone in case it is initialized before U-Boot starts. Signed-off-by: Michael Spang --- drivers/net/mvgbe.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c index c701f43..bab55b3 100644 --- a/drivers/net/mvgbe.c +++ b/drivers/net/mvgbe.c @@ -380,6 +380,22 @@ static void port_uc_addr_set(struct mvgbe_registers *regs, u8 * p_addr) } /* + * port_uc_addr_get - This function gets the port unicast address. + */ +static void port_uc_addr_get(struct mvgbe_registers *regs, u8 * p_addr) +{ + u32 mac_l = MVGBE_REG_RD(regs->macal); + u32 mac_h = MVGBE_REG_RD(regs->macah); + + p_addr[0] = (mac_h >> 24); + p_addr[1] = (mac_h >> 16); + p_addr[2] = (mac_h >> 8); + p_addr[3] = (mac_h >> 0); + p_addr[4] = (mac_l >> 8); + p_addr[5] = (mac_l >> 0); +} + +/* * mvgbe_init_rx_desc_ring - Curve a Rx chain desc list and buffer in memory. */ static void mvgbe_init_rx_desc_ring(struct mvgbe_device *dmvgbe) @@ -719,6 +735,9 @@ error1: } while (!eth_getenv_enetaddr(s, dev->enetaddr)) { +#if defined(CONFIG_PRESERVE_LOCAL_MAC) + port_uc_addr_get(dmvgbe->regs, dmvgbe->dev.enetaddr); +#else /* Generate Private MAC addr if not set */ dev->enetaddr[0] = 0x02; dev->enetaddr[1] = 0x50; @@ -734,6 +753,7 @@ error1: dev->enetaddr[4] = get_random_hex(); dev->enetaddr[5] = get_random_hex(); #endif +#endif eth_setenv_enetaddr(s, dev->enetaddr); }