Subject: [@num@/@total@] i.MX family: Separate current platform code
From: Juergen Beisert <j.beisert@pengutronix.de>

This patch separates the current code into i.MX2 and i.MX3 and modifies
the Kconfig files to reflect this separation in the menus.

Signed-off-by: Juergen Beisert <j.beisert@pengutronix.de>

---

 arch/arm/plat-mxc/Kconfig           |    8 ++-----
 include/asm-arm/arch-mxc/hardware.h |   24 +++------------------
 include/asm-arm/arch-mxc/mx31.h     |   41 +++++++++++++++++++++++++++++++++++-
 include/asm-arm/arch-mxc/mxc.h      |    5 ++++
 4 files changed, 52 insertions(+), 26 deletions(-)

Index: arch/arm/plat-mxc/Kconfig
===================================================================
--- arch/arm/plat-mxc/Kconfig.orig
+++ arch/arm/plat-mxc/Kconfig
@@ -1,10 +1,10 @@
-if ARCH_MXC
-
 menu "Freescale MXC Implementations"
+	depends on ARCH_MXC
 
 choice
 	prompt "MXC/iMX System Type"
-	default 0
+	depends on ARCH_MXC
+	default ARCH_MX3
 
 config ARCH_MX3
 	bool "MX3-based"
@@ -16,5 +16,3 @@ endchoice
 source "arch/arm/mach-mx3/Kconfig"
 
 endmenu
-
-endif
Index: include/asm-arm/arch-mxc/hardware.h
===================================================================
--- include/asm-arm/arch-mxc/hardware.h.orig
+++ include/asm-arm/arch-mxc/hardware.h
@@ -13,35 +13,19 @@
 
 #include <asm/sizes.h>
 
-#include <asm/arch/mx31.h>
+#ifdef CONFIG_ARCH_MX3
+# include <asm/arch/mx31.h>
+#endif
 
 #include <asm/arch/mxc.h>
 
-#define MXC_MAX_GPIO_LINES      (GPIO_NUM_PIN * GPIO_PORT_NUM)
-
 /*
  * ---------------------------------------------------------------------------
  * Board specific defines
  * ---------------------------------------------------------------------------
  */
-#define MXC_EXP_IO_BASE         (MXC_GPIO_INT_BASE + MXC_MAX_GPIO_LINES)
-
+#ifdef CONFIG_MACH_MX31ADS
 #include <asm/arch/board-mx31ads.h>
-
-#ifndef MXC_MAX_EXP_IO_LINES
-#define MXC_MAX_EXP_IO_LINES 0
 #endif
 
-#define MXC_MAX_VIRTUAL_INTS	16
-#define MXC_VIRTUAL_INTS_BASE	(MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES)
-#define MXC_SDIO1_CARD_IRQ	MXC_VIRTUAL_INTS_BASE
-#define MXC_SDIO2_CARD_IRQ	(MXC_VIRTUAL_INTS_BASE + 1)
-#define MXC_SDIO3_CARD_IRQ	(MXC_VIRTUAL_INTS_BASE + 2)
-
-#define MXC_MAX_INTS            (MXC_MAX_INT_LINES + \
-                                MXC_MAX_GPIO_LINES + \
-                                MXC_MAX_EXP_IO_LINES + \
-                                MXC_MAX_VIRTUAL_INTS)
-
 #endif /* __ASM_ARCH_MXC_HARDWARE_H__ */
-
Index: include/asm-arm/arch-mxc/mx31.h
===================================================================
--- include/asm-arm/arch-mxc/mx31.h.orig
+++ include/asm-arm/arch-mxc/mx31.h
@@ -329,7 +329,46 @@
 
 #define PROD_SIGNATURE		0x1	/* For MX31 */
 
+/* silicon revisions specific to i.MX31 */
+#define CHIP_REV_1_0		0x10
+#define CHIP_REV_1_1		0x11
+#define CHIP_REV_1_2		0x12
+#define CHIP_REV_1_3		0x13
+#define CHIP_REV_2_0		0x20
+#define CHIP_REV_2_1		0x21
+#define CHIP_REV_2_2		0x22
+#define CHIP_REV_2_3		0x23
+#define CHIP_REV_3_0		0x30
+#define CHIP_REV_3_1		0x31
+#define CHIP_REV_3_2		0x32
+
 #define SYSTEM_REV_MIN		CHIP_REV_1_0
 #define SYSTEM_REV_NUM		3
 
-#endif			/*  __ASM_ARCH_MXC_MX31_H__ */
+#if !defined(__ASSEMBLY__) && !defined(__MXC_BOOT_UNCOMPRESS)
+extern unsigned int system_rev;
+#define _is_rev(rev) ((system_rev == rev) ? 1 : ((system_rev < rev) ? -1 : 2))
+
+#define MXC_REV(type)				\
+static inline int type## _rev (int rev)		\
+{						\
+	return (type() ? _is_rev(rev) : 0);	\
+}
+
+/*
+ * Create inline functions to test for cpu revision
+ * Function name is cpu_is_<cpu name>_rev(rev)
+ *
+ * Returns:
+ *	 0 - not the cpu queried
+ *	 1 - cpu and revision match
+ *	 2 - cpu matches, but cpu revision is greater than queried rev
+ *	-1 - cpu matches, but cpu revision is less than queried rev
+ */
+MXC_REV(cpu_is_mx31);
+#endif
+
+/* this is a i.MX31 CPU */
+#define cpu_is_mx31()		(1)
+
+#endif /*  __ASM_ARCH_MXC_MX31_H__ */
Index: include/asm-arm/arch-mxc/mxc.h
===================================================================
--- include/asm-arm/arch-mxc/mxc.h.orig
+++ include/asm-arm/arch-mxc/mxc.h
@@ -15,6 +15,11 @@
 #error "Do not include directly."
 #endif
 
+/* clean up all things that are not used */
+#ifndef CONFIG_ARCH_MX3
+# define cpu_is_mx31() (0)
+#endif
+
 /*
  *****************************************
  * GPT  Register definitions             *
