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 <pr...@ti.com>
---
 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 <asm/mach-types.h>
 #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);
-- 
1.7.2.2

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to