From patchwork Mon Jan 2 14:01:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Grinberg X-Patchwork-Id: 133850 X-Patchwork-Delegate: trini@ti.com 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 9B062B6F74 for ; Tue, 3 Jan 2012 01:03:42 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1F65C28310; Mon, 2 Jan 2012 15:03: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 V6nrUGz1hvOS; Mon, 2 Jan 2012 15:03:15 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 68FF828325; Mon, 2 Jan 2012 15:03:01 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8DFBE282EF for ; Mon, 2 Jan 2012 15:02:57 +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 dYUt3agX8DwZ for ; Mon, 2 Jan 2012 15:02:57 +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 softlayer.compulab.co.il (50.23.254.54-static.reverse.softlayer.com [50.23.254.54]) by theia.denx.de (Postfix) with ESMTPS id 5D0A2282F5 for ; Mon, 2 Jan 2012 15:02:39 +0100 (CET) Received: from [62.90.235.247] (port=60791 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.69) (envelope-from ) id 1RhiTF-0006mC-3A; Mon, 02 Jan 2012 16:02:37 +0200 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 1D57B644199; Mon, 2 Jan 2012 16:02:36 +0200 (IST) X-Virus-Scanned: amavisd-new at compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1EpZTdaEnTOo; Mon, 2 Jan 2012 16:02:35 +0200 (IST) Received: from grinberg-linux (grinberg-pc.compulab.local [10.1.1.13]) by zimbra-mta.compulab.co.il (Postfix) with SMTP id 086B3644190; Mon, 2 Jan 2012 16:02:34 +0200 (IST) Received: by grinberg-linux (sSMTP sendmail emulation); Mon, 02 Jan 2012 16:02:29 +0200 From: Igor Grinberg To: Tom Rini Date: Mon, 2 Jan 2012 16:01:35 +0200 Message-Id: <1325512895-10917-7-git-send-email-grinberg@compulab.co.il> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1325512895-10917-1-git-send-email-grinberg@compulab.co.il> References: <1325512895-10917-1-git-send-email-grinberg@compulab.co.il> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il Cc: u-boot@lists.denx.de, Sandeep Paulraj Subject: [U-Boot] [PATCH 6/6] cm-t35: use the new EEPROM module to read the MAC address X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 From: Nikita Kiryanov Switch to the new EEPROM module and fix the problem of MAC address being read from the wrong offset due to lack of distinction between EEPROM layouts. Signed-off-by: Nikita Kiryanov Signed-off-by: Igor Grinberg --- board/cm_t35/cm_t35.c | 6 +++--- board/cm_t35/eeprom.c | 18 ++++++++++++++++++ board/cm_t35/eeprom.h | 9 ++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/board/cm_t35/cm_t35.c b/board/cm_t35/cm_t35.c index ff372d8..caafe06 100644 --- a/board/cm_t35/cm_t35.c +++ b/board/cm_t35/cm_t35.c @@ -41,6 +41,8 @@ #include #include +#include "eeprom.h" + DECLARE_GLOBAL_DATA_PTR; const omap3_sysinfo sysinfo = { @@ -382,11 +384,9 @@ static int handle_mac_address(void) if (rc) return 0; -#ifdef CONFIG_DRIVER_OMAP34XX_I2C - rc = i2c_read(0x50, 0, 1, enetaddr, 6); + rc = cm_t3x_eeprom_read_mac_addr(enetaddr); if (rc) return rc; -#endif if (!is_valid_ether_addr(enetaddr)) return -1; diff --git a/board/cm_t35/eeprom.c b/board/cm_t35/eeprom.c index 8386d18..e975855 100644 --- a/board/cm_t35/eeprom.c +++ b/board/cm_t35/eeprom.c @@ -31,6 +31,8 @@ #define BOARD_REV_OFFSET_LEGACY 6 #define BOARD_REV_SIZE 4 #define BOARD_REV_SIZE_LEGACY 2 +#define MAC_ADDR_OFFSET 4 +#define MAC_ADDR_OFFSET_LEGACY 0 #define LAYOUT_INVALID 0 #define LAYOUT_LEGACY 0xff @@ -83,6 +85,22 @@ void get_board_serial(struct tag_serialnr *serialnr) } /* + * Routine: cm_t3x_eeprom_read_mac_addr + * Description: read mac address and store it in buf. + */ +int cm_t3x_eeprom_read_mac_addr(uchar *buf) +{ + uint offset; + + if (eeprom_setup_layout()) + return 0; + + offset = (eeprom_layout != LAYOUT_LEGACY) ? + MAC_ADDR_OFFSET : MAC_ADDR_OFFSET_LEGACY; + return cm_t3x_eeprom_read(offset, buf, 6); +} + +/* * Routine: get_board_rev * Description: read system revision */ diff --git a/board/cm_t35/eeprom.h b/board/cm_t35/eeprom.h index 97a002a..e8680d7 100644 --- a/board/cm_t35/eeprom.h +++ b/board/cm_t35/eeprom.h @@ -23,7 +23,9 @@ #include -#ifndef CONFIG_DRIVER_OMAP34XX_I2C +#ifdef CONFIG_DRIVER_OMAP34XX_I2C +int cm_t3x_eeprom_read_mac_addr(uchar *buf); +#else void get_board_serial(struct tag_serialnr *serialnr) { /* @@ -33,6 +35,11 @@ void get_board_serial(struct tag_serialnr *serialnr) serialnr->low = 0; serialnr->high = 0; }; + +int cm_t3x_eeprom_read_mac_addr(uchar *buf) +{ + return 1; +} #endif /* CONFIG_DRIVER_OMAP34XX_I2C */ #endif