From patchwork Thu Dec 2 11:20:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjeev Premi X-Patchwork-Id: 73953 X-Patchwork-Delegate: s-paulraj@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 A21821007D1 for ; Thu, 2 Dec 2010 22:20:28 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 444CD280D9; Thu, 2 Dec 2010 12:20:27 +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 oCBJgS1lBKwB; Thu, 2 Dec 2010 12:20:26 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A8E00280D0; Thu, 2 Dec 2010 12:20:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 269B3280D0 for ; Thu, 2 Dec 2010 12:20:24 +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 T6HJuJOqQkEN for ; Thu, 2 Dec 2010 12:20:22 +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 comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by theia.denx.de (Postfix) with ESMTPS id 06981280CC for ; Thu, 2 Dec 2010 12:20:19 +0100 (CET) Received: from dbdp31.itg.ti.com ([172.24.170.98]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id oB2BKFJk028081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 2 Dec 2010 05:20:17 -0600 Received: from psplinux050.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id oB2BKDnK004410; Thu, 2 Dec 2010 16:50:14 +0530 (IST) From: Sanjeev Premi To: u-boot@lists.denx.de Date: Thu, 2 Dec 2010 16:50:12 +0530 Message-Id: <1291288812-12653-1-git-send-email-premi@ti.com> X-Mailer: git-send-email 1.7.2.2 Subject: [U-Boot] [PATCH] omap3evm: Clean-up EVM detection code. 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 This patch does following changes: * Change the type (u8 -> int) for omap3_evm_version. * Introduce an 'undefined' board revision for init value. * Use of #define instead of magic numbers Signed-off-by: Sanjeev Premi --- board/ti/evm/evm.c | 39 +++++++++++++++++++++++---------------- board/ti/evm/evm.h | 17 +++++++---------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c index 09d14f7..8d9ce73 100644 --- a/board/ti/evm/evm.c +++ b/board/ti/evm/evm.c @@ -37,36 +37,43 @@ #include #include "evm.h" -static u8 omap3_evm_version; +static int omap3_evm_version = OMAP3EVM_BOARD_UNDEF; -u8 get_omap3_evm_rev(void) +int get_omap3_evm_rev(void) { return omap3_evm_version; } +/** + * The board revision can be ascertained only by identifying the + * Ethernet chipset used on the board. + * + * The revision can be read from ID_REV register on the PHY. + */ static void omap3_evm_get_revision(void) { -#if defined(CONFIG_CMD_NET) - /* - * Board revision can be ascertained only by identifying - * the Ethernet chipset. - */ - unsigned int smsc_id; +#define CONFIG_SMC911X_ID_REV (CONFIG_SMC911X_BASE + 0x50) - /* Ethernet PHY ID is stored at ID_REV register */ - smsc_id = readl(CONFIG_SMC911X_BASE + 0x50) & 0xFFFF0000; - printf("Read back SMSC id 0x%x\n", smsc_id); +#define SMSC_ID_9115 0x01150000 /* SMSC9115 chipset */ +#define SMSC_ID_9220 0x92200000 /* SMSC9220 chipset */ + +#if defined(CONFIG_CMD_NET) + unsigned int smsc_id = readl(CONFIG_SMC911X_ID_REV) & 0xFFFF0000; switch (smsc_id) { - /* SMSC9115 chipset */ - case 0x01150000: + case SMSC_ID_9115: omap3_evm_version = OMAP3EVM_BOARD_GEN_1; break; - /* SMSC 9220 chipset */ - case 0x92200000: + case SMSC_ID_9220: + omap3_evm_version = OMAP3EVM_BOARD_GEN_2; + break; default: + printf ("Unknown board revision."); + /* + * Assume the latest revision + */ omap3_evm_version = OMAP3EVM_BOARD_GEN_2; - } + } #else #if defined(CONFIG_STATIC_BOARD_REV) /* diff --git a/board/ti/evm/evm.h b/board/ti/evm/evm.h index a76deb8..de96504 100644 --- a/board/ti/evm/evm.h +++ b/board/ti/evm/evm.h @@ -34,18 +34,15 @@ const omap3_sysinfo sysinfo = { }; /* - * OMAP35x EVM revision - * Run time detection of EVM revision is done by reading Ethernet - * PHY ID - - * GEN_1 = 0x01150000 - * GEN_2 = 0x92200000 + * OMAP35x EVM Revision. + * The revision can be detected only based on Ethernet PHY ID. */ -enum { - OMAP3EVM_BOARD_GEN_1 = 0, /* EVM Rev between A - D */ - OMAP3EVM_BOARD_GEN_2, /* EVM Rev >= Rev E */ -}; +#define OMAP3EVM_BOARD_UNDEF -1 /* EVM revision not detected */ + +#define OMAP3EVM_BOARD_GEN_1 1 /* EVM Rev between A - D */ +#define OMAP3EVM_BOARD_GEN_2 2 /* EVM Rev >= Rev E */ -u8 get_omap3_evm_rev(void); +int get_omap3_evm_rev(void); #if defined(CONFIG_CMD_NET) static void setup_net_chip(void);