[PATCH 2/8] ARM i.MX: streamline imx_silicon_revision

Sascha Hauer s.hauer at pengutronix.de
Fri Oct 5 06:53:30 EDT 2012


All i.MX SoCs now use the same imx_silicon_revision() function to get
the revision. Add a separate header file for it and a common function
used on all SoCs.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/ccxmx51/ccxmx51.c               |    1 +
 arch/arm/boards/freescale-mx35-3-stack/3stack.c |    1 +
 arch/arm/boards/freescale-mx51-pdk/board.c      |    1 +
 arch/arm/boards/freescale-mx53-loco/board.c     |    1 +
 arch/arm/mach-imx/Makefile                      |    2 +-
 arch/arm/mach-imx/clk-imx27.c                   |    1 +
 arch/arm/mach-imx/imx.c                         |   27 +++++++++++++++++++++++
 arch/arm/mach-imx/imx21.c                       |    8 -------
 arch/arm/mach-imx/imx27.c                       |   24 +++++++++++++++-----
 arch/arm/mach-imx/imx35.c                       |    7 ++++--
 arch/arm/mach-imx/imx51.c                       |   15 ++++++-------
 arch/arm/mach-imx/imx53.c                       |   15 ++++++-------
 arch/arm/mach-imx/include/mach/generic.h        |    2 --
 arch/arm/mach-imx/include/mach/imx-regs.h       |   14 ------------
 arch/arm/mach-imx/include/mach/revision.h       |   22 ++++++++++++++++++
 15 files changed, 92 insertions(+), 49 deletions(-)
 create mode 100644 arch/arm/mach-imx/imx.c
 create mode 100644 arch/arm/mach-imx/include/mach/revision.h

diff --git a/arch/arm/boards/ccxmx51/ccxmx51.c b/arch/arm/boards/ccxmx51/ccxmx51.c
index 0b450d6..b391df1 100644
--- a/arch/arm/boards/ccxmx51/ccxmx51.c
+++ b/arch/arm/boards/ccxmx51/ccxmx51.c
@@ -45,6 +45,7 @@
 #include <mach/iim.h>
 #include <mach/clock-imx51_53.h>
 #include <mach/imx5.h>
+#include <mach/revision.h>
 
 #include "ccxmx51.h"
 
diff --git a/arch/arm/boards/freescale-mx35-3-stack/3stack.c b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
index 9a01424..1a5bf5b 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
@@ -47,6 +47,7 @@
 #include <mach/imx-ipu-fb.h>
 #include <mach/generic.h>
 #include <mach/devices-imx35.h>
+#include <mach/revision.h>
 
 #include <i2c/i2c.h>
 #include <mfd/mc13xxx.h>
diff --git a/arch/arm/boards/freescale-mx51-pdk/board.c b/arch/arm/boards/freescale-mx51-pdk/board.c
index 3a8e5ea..61e635a 100644
--- a/arch/arm/boards/freescale-mx51-pdk/board.c
+++ b/arch/arm/boards/freescale-mx51-pdk/board.c
@@ -37,6 +37,7 @@
 #include <mach/generic.h>
 #include <mach/iomux-mx51.h>
 #include <mach/devices-imx51.h>
+#include <mach/revision.h>
 #include <mach/iim.h>
 
 static struct fec_platform_data fec_info = {
diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
index 0d71555..8e9b030 100644
--- a/arch/arm/boards/freescale-mx53-loco/board.c
+++ b/arch/arm/boards/freescale-mx53-loco/board.c
@@ -35,6 +35,7 @@
 #include <mach/imx-nand.h>
 #include <mach/iim.h>
 #include <mach/imx5.h>
+#include <mach/revision.h>
 
 #include <i2c/i2c.h>
 #include <mfd/mc34708.h>
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index e43f92e..54703f3 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -14,5 +14,5 @@ obj-$(CONFIG_NAND_IMX) += nand.o
 obj-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
 pbl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
 obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-pfd.o
-obj-y += devices.o
+obj-y += devices.o imx.o
 obj-y += boot.o
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c
index 74d70db..e406228 100644
--- a/arch/arm/mach-imx/clk-imx27.c
+++ b/arch/arm/mach-imx/clk-imx27.c
@@ -7,6 +7,7 @@
 #include <linux/err.h>
 #include <mach/imx27-regs.h>
 #include <mach/generic.h>
+#include <mach/revision.h>
 
 #include "clk.h"
 
diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c
new file mode 100644
index 0000000..1bc6e23
--- /dev/null
+++ b/arch/arm/mach-imx/imx.c
@@ -0,0 +1,27 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <mach/revision.h>
+
+static int __imx_silicon_revision = IMX_CHIP_REV_UNKNOWN;
+
+int imx_silicon_revision(void)
+{
+	return __imx_silicon_revision;
+}
+
+void imx_set_silicon_revision(int revision)
+{
+	__imx_silicon_revision = revision;
+}
diff --git a/arch/arm/mach-imx/imx21.c b/arch/arm/mach-imx/imx21.c
index 7ed0809..58895da 100644
--- a/arch/arm/mach-imx/imx21.c
+++ b/arch/arm/mach-imx/imx21.c
@@ -23,14 +23,6 @@ void imx21_setup_eimcs(size_t cs, unsigned upper, unsigned lower)
 	writel(lower, MX21_EIM_BASE_ADDR + 4 + cs * 8);
 }
 
-int imx_silicon_revision(void)
-{
-	// Known values:
-	//   0x101D101D : mask set ID 0M55B
-	//   0x201D101D : mask set ID 1M55B or M55B
-	return CID;
-}
-
 static int imx21_init(void)
 {
 	add_generic_device("imx21-ccm", 0, NULL, MX21_CCM_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
diff --git a/arch/arm/mach-imx/imx27.c b/arch/arm/mach-imx/imx27.c
index cd429d0..3d7b21d 100644
--- a/arch/arm/mach-imx/imx27.c
+++ b/arch/arm/mach-imx/imx27.c
@@ -12,28 +12,38 @@
  */
 
 #include <common.h>
-#include <mach/imx-regs.h>
+#include <mach/imx27-regs.h>
 #include <mach/weim.h>
 #include <sizes.h>
+#include <mach/revision.h>
 #include <init.h>
 #include <io.h>
 
-int imx_silicon_revision(void)
+static int imx27_silicon_revision(void)
 {
 	uint32_t val;
+	int rev;
 
 	val = readl(MX27_SYSCTRL_BASE_ADDR);
 
 	switch (val >> 28) {
 	case 0:
-		return IMX_CHIP_REV_1_0;
+		rev = IMX_CHIP_REV_1_0;
+		break;
 	case 1:
-		return IMX_CHIP_REV_2_0;
+		rev = IMX_CHIP_REV_2_0;
+		break;
 	case 2:
-		return IMX_CHIP_REV_2_1;
+		rev = IMX_CHIP_REV_2_1;
+		break;
 	default:
-		return IMX_CHIP_REV_UNKNOWN;
+		rev = IMX_CHIP_REV_UNKNOWN;
+		break;
 	}
+
+	imx_set_silicon_revision(rev);
+
+	return 0;
 }
 
 void imx27_setup_weimcs(size_t cs, unsigned upper, unsigned lower,
@@ -86,6 +96,8 @@ static void imx27_init_max(void)
 
 static int imx27_init(void)
 {
+	imx27_silicon_revision();
+
 	add_generic_device("imx_iim", 0, NULL, MX27_IIM_BASE_ADDR, SZ_4K,
 			IORESOURCE_MEM, NULL);
 
diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index 722dd4c..1575d54 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -18,6 +18,7 @@
 #include <mach/weim.h>
 #include <mach/imx-regs.h>
 #include <mach/iim.h>
+#include <mach/revision.h>
 #include <mach/generic.h>
 
 void imx35_setup_weimcs(size_t cs, unsigned upper, unsigned lower,
@@ -28,14 +29,14 @@ void imx35_setup_weimcs(size_t cs, unsigned upper, unsigned lower,
 	writel(additional, MX35_WEIM_BASE_ADDR + (cs * 0x10) + 0x8);
 }
 
-int imx_silicon_revision()
+static void imx35_silicon_revision(void)
 {
 	uint32_t reg;
 	reg = readl(MX35_IIM_BASE_ADDR + IIM_SREV);
 	/* 0×00 = TO 1.0, First silicon */
 	reg += IMX_CHIP_REV_1_0;
 
-	return (reg & 0xFF);
+	imx_set_silicon_revision(reg & 0xFF);
 }
 
 /*
@@ -58,6 +59,8 @@ core_initcall(imx35_l2_fix);
 
 static int imx35_init(void)
 {
+	imx35_silicon_revision();
+
 	add_generic_device("imx_iim", 0, NULL, MX35_IIM_BASE_ADDR, SZ_4K,
 			IORESOURCE_MEM, NULL);
 
diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
index 8709c43..3850001 100644
--- a/arch/arm/mach-imx/imx51.c
+++ b/arch/arm/mach-imx/imx51.c
@@ -18,21 +18,17 @@
 #include <io.h>
 #include <mach/imx5.h>
 #include <mach/imx-regs.h>
+#include <mach/revision.h>
 #include <mach/clock-imx51_53.h>
 
 #define SI_REV 0x48
 
-static u32 mx51_silicon_revision;
 static char *mx51_rev_string = "unknown";
 
-int imx_silicon_revision(void)
-{
-	return mx51_silicon_revision;
-}
-
-static int query_silicon_revision(void)
+static int imx51_silicon_revision(void)
 {
 	void __iomem *rom = MX51_IROM_BASE_ADDR;
+	u32 mx51_silicon_revision;
 	u32 rev;
 
 	rev = readl(rom + SI_REV);
@@ -57,9 +53,10 @@ static int query_silicon_revision(void)
 		mx51_silicon_revision = 0;
 	}
 
+	imx_set_silicon_revision(mx51_silicon_revision);
+
 	return 0;
 }
-core_initcall(query_silicon_revision);
 
 static int imx51_print_silicon_rev(void)
 {
@@ -71,6 +68,8 @@ device_initcall(imx51_print_silicon_rev);
 
 static int imx51_init(void)
 {
+	imx51_silicon_revision();
+
 	add_generic_device("imx_iim", 0, NULL, MX51_IIM_BASE_ADDR, SZ_4K,
 			IORESOURCE_MEM, NULL);
 
diff --git a/arch/arm/mach-imx/imx53.c b/arch/arm/mach-imx/imx53.c
index 88b4274..4aa3f61 100644
--- a/arch/arm/mach-imx/imx53.c
+++ b/arch/arm/mach-imx/imx53.c
@@ -18,22 +18,18 @@
 #include <sizes.h>
 #include <mach/imx5.h>
 #include <mach/imx-regs.h>
+#include <mach/revision.h>
 #include <mach/clock-imx51_53.h>
 
 #define SI_REV 0x48
 
-static u32 mx53_silicon_revision;
 static char *mx53_rev_string = "unknown";
 
-int imx_silicon_revision(void)
-{
-	return mx53_silicon_revision;
-}
-
-static int query_silicon_revision(void)
+static int imx53_silicon_revision(void)
 {
 	void __iomem *rom = MX53_IROM_BASE_ADDR;
 	u32 rev;
+	u32 mx53_silicon_revision;
 
 	rev = readl(rom + SI_REV);
 	switch (rev) {
@@ -53,9 +49,10 @@ static int query_silicon_revision(void)
 		mx53_silicon_revision = 0;
 	}
 
+	imx_set_silicon_revision(mx53_silicon_revision);
+
 	return 0;
 }
-core_initcall(query_silicon_revision);
 
 static int imx53_print_silicon_rev(void)
 {
@@ -67,6 +64,8 @@ device_initcall(imx53_print_silicon_rev);
 
 static int imx53_init(void)
 {
+	imx53_silicon_revision();
+
 	add_generic_device("imx_iim", 0, NULL, MX53_IIM_BASE_ADDR, SZ_4K,
 			IORESOURCE_MEM, NULL);
 
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index 018ea91..691a146 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -1,6 +1,4 @@
 
-int imx_silicon_revision(void);
-
 u64 imx_uid(void);
 
 
diff --git a/arch/arm/mach-imx/include/mach/imx-regs.h b/arch/arm/mach-imx/include/mach/imx-regs.h
index 2b836c9..08ee957 100644
--- a/arch/arm/mach-imx/include/mach/imx-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx-regs.h
@@ -103,18 +103,4 @@
 
 #define GPIO_GIUS      (1<<16)
 
-/* silicon revisions  */
-#define IMX_CHIP_REV_1_0	0x10
-#define IMX_CHIP_REV_1_1	0x11
-#define IMX_CHIP_REV_1_2	0x12
-#define IMX_CHIP_REV_1_3	0x13
-#define IMX_CHIP_REV_2_0	0x20
-#define IMX_CHIP_REV_2_1	0x21
-#define IMX_CHIP_REV_2_2	0x22
-#define IMX_CHIP_REV_2_3	0x23
-#define IMX_CHIP_REV_3_0	0x30
-#define IMX_CHIP_REV_3_1	0x31
-#define IMX_CHIP_REV_3_2	0x32
-#define IMX_CHIP_REV_UNKNOWN	0xff
-
 #endif				/* _IMX_REGS_H */
diff --git a/arch/arm/mach-imx/include/mach/revision.h b/arch/arm/mach-imx/include/mach/revision.h
new file mode 100644
index 0000000..b6b06ef
--- /dev/null
+++ b/arch/arm/mach-imx/include/mach/revision.h
@@ -0,0 +1,22 @@
+#ifndef __MACH_REVISION_H__
+#define __MACH_REVISION_H__
+
+/* silicon revisions  */
+#define IMX_CHIP_REV_1_0	0x10
+#define IMX_CHIP_REV_1_1	0x11
+#define IMX_CHIP_REV_1_2	0x12
+#define IMX_CHIP_REV_1_3	0x13
+#define IMX_CHIP_REV_2_0	0x20
+#define IMX_CHIP_REV_2_1	0x21
+#define IMX_CHIP_REV_2_2	0x22
+#define IMX_CHIP_REV_2_3	0x23
+#define IMX_CHIP_REV_3_0	0x30
+#define IMX_CHIP_REV_3_1	0x31
+#define IMX_CHIP_REV_3_2	0x32
+#define IMX_CHIP_REV_UNKNOWN	0xff
+
+int imx_silicon_revision(void);
+
+void imx_set_silicon_revision(int revision);
+
+#endif /* __MACH_REVISION_H__ */
-- 
1.7.10.4




More information about the barebox mailing list