From patchwork Mon Mar 21 07:02:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 87706 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 C9C11B6F76 for ; Mon, 21 Mar 2011 18:17:07 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 11761280AC; Mon, 21 Mar 2011 08:15:52 +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 RT0fQ7IpNPme; Mon, 21 Mar 2011 08:15:51 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 99A70280EE; Mon, 21 Mar 2011 08:13:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 446D72808F for ; Mon, 21 Mar 2011 08:13:21 +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 2UCMG-eDV9mJ for ; Mon, 21 Mar 2011 08:13:21 +0100 (CET) X-policyd-weight: IN_SBL_XBL_SPAMHAUS=4.35 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from pollux.denx.de (p4FF078D1.dip.t-dialin.net [79.240.120.209]) by theia.denx.de (Postfix) with ESMTP id 0767728082 for ; Mon, 21 Mar 2011 08:13:10 +0100 (CET) Received: by pollux.denx.de (Postfix, from userid 515) id A0057185E1BAE; Mon, 21 Mar 2011 08:02:23 +0100 (CET) From: Heiko Schocher To: u-boot@lists.denx.de Date: Mon, 21 Mar 2011 08:02:15 +0100 Message-Id: <1300690939-31511-20-git-send-email-hs@denx.de> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1300690939-31511-1-git-send-email-hs@denx.de> References: <1299591018-8944-1-git-send-email-hs@denx.de> <1300690939-31511-1-git-send-email-hs@denx.de> Cc: Valentin Longchamp , Heiko Schocher , Holger Brunck Subject: [U-Boot] [PATCH v3 19/23] keymile boards: add CONFIG_PIGGY_MAC_ADRESS_OFFSET 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 Normaly the PIGGY_MAC_ADRESS can be read directly from the IVM on keymile boards. On mgcoge3 it differs. Because there are two piggy boards deployed the second MAC adress must be calculated with the IVM mac adress and an offset. This patch allows to set such a offset in the board config. Signed-off-by: Holger Brunck cc: Valentin Longchamp cc: Heiko Schocher --- Changes for v2: - fix checkpatch.pl errors and warnings changes for v3 - rebased - use %pM in sprintf for mac address handling as Wolfgang Denk suggested. board/keymile/common/common.c | 13 +++++++++++++ board/keymile/common/common.h | 4 ++++ 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index 6600e08..8392a64 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -228,8 +228,21 @@ static int ivm_analyze_block2(unsigned char *buf, int len) /* IVM_MacAddress */ sprintf((char *)valbuf, "%pM", buf); ivm_set_value("IVM_MacAddress", (char *)valbuf); + /* if an offset is defined, add it */ +#if defined(CONFIG_PIGGY_MAC_ADRESS_OFFSET) + if (CONFIG_PIGGY_MAC_ADRESS_OFFSET > 0) { + unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; + + val += CONFIG_PIGGY_MAC_ADRESS_OFFSET; + buf[4] = (val >> 16) & 0xff; + buf[5] = (val >> 8) & 0xff; + buf[6] = val & 0xff; + sprintf((char *)valbuf, "%pM", buf); + } +#endif if (getenv("ethaddr") == NULL) setenv((char *)"ethaddr", (char *)valbuf); + /* IVM_MacCount */ count = (buf[10] << 24) + (buf[11] << 16) + diff --git a/board/keymile/common/common.h b/board/keymile/common/common.h index e0d2603..03838fe 100644 --- a/board/keymile/common/common.h +++ b/board/keymile/common/common.h @@ -38,6 +38,10 @@ struct km_bec_fpga { unsigned char pgy_out; }; +#if !defined(CONFIG_PIGGY_MAC_ADRESS_OFFSET) +#define CONFIG_PIGGY_MAC_ADRESS_OFFSET 0 +#endif + int ethernet_present(void); int ivm_read_eeprom(void);