From patchwork Sat Jan 29 01:00:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Spang X-Patchwork-Id: 80914 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 CEEF7B70EF for ; Sat, 29 Jan 2011 12:11:25 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 31E00280AC; Sat, 29 Jan 2011 02:10:56 +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 nfnnqzZAlSTj; Sat, 29 Jan 2011 02:10:56 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DCD7A280AD; Sat, 29 Jan 2011 02:10:34 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0856B28087 for ; Sat, 29 Jan 2011 02:10:22 +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 0mNf153jxxAn for ; Sat, 29 Jan 2011 02:10:20 +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 23A4028083 for ; Sat, 29 Jan 2011 02:10:16 +0100 (CET) Received: from caffeine.csclub.uwaterloo.ca (localhost [127.0.0.1]) by caffeine.csclub.uwaterloo.ca (Postfix) with ESMTP id 4650B816CB; Fri, 28 Jan 2011 20:01:04 -0500 (EST) Received: from corn-syrup (corn-syrup.csclub.uwaterloo.ca [129.97.134.72]) by caffeine.csclub.uwaterloo.ca (Postfix) with SMTP id 2E11F816D9; Fri, 28 Jan 2011 20:01:03 -0500 (EST) Received: by corn-syrup (sSMTP sendmail emulation); Fri, 28 Jan 2011 20:01:03 -0500 From: Michael Spang To: u-boot@lists.denx.de Date: Fri, 28 Jan 2011 20:00:38 -0500 Message-Id: <1296262841-8819-5-git-send-email-mspang@csclub.uwaterloo.ca> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1296262841-8819-1-git-send-email-mspang@csclub.uwaterloo.ca> References: <1296262841-8819-1-git-send-email-mspang@csclub.uwaterloo.ca> X-Virus-Scanned: ClamAV using ClamSMTP Cc: Michael Spang , Alexander Clouter Subject: [U-Boot] [PATCH 5/8] 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..0e0dae1 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) @@ -718,6 +734,9 @@ error1: return -1; } +#if defined(CONFIG_PRESERVE_LOCAL_MAC) + port_uc_addr_get(dmvgbe->regs, dmvgbe->dev.enetaddr); +#else while (!eth_getenv_enetaddr(s, dev->enetaddr)) { /* Generate Private MAC addr if not set */ dev->enetaddr[0] = 0x02; @@ -736,6 +755,7 @@ error1: #endif eth_setenv_enetaddr(s, dev->enetaddr); } +#endif dev->init = (void *)mvgbe_init; dev->halt = (void *)mvgbe_halt;