[U-Boot] [PATCH 1/2] imx-common: Enable ACTLR.SMP bit for i.MX cortex-a7 platforms

Peng Fan peng.fan at nxp.com
Wed Apr 5 02:36:57 UTC 2017


According to the Cortex-A7 TRM, for ACTLR.SMP bit "You must ensure
this bit is set to 1 before the caches and MMU are enabled, or any
cache and TLB maintenance operations are performed".

ROM sets this bit in normal boot flow, but when in serial download
mode, it is not set. Here we add it in u-boot as a common flow for
all i.MX cortex-a7 platforms, including mx7d, mx6ul/ull and mx7ulp.

When cache not enabled in U-Boot, we also need enable the SMP bit.
because kernel does not set this bit, if this bit not enabled, kernel
works as cache disabled.

Signed-off-by: Peng Fan <peng.fan at nxp.com>
Signed-off-by: Ye Li <ye.li at nxp.com>
Cc: Stefano Babic <sbabic at denx.de>
---
 arch/arm/cpu/armv7/mx7/soc.c |  7 -------
 arch/arm/imx-common/cache.c  | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx7/soc.c b/arch/arm/cpu/armv7/mx7/soc.c
index 8422f24..b847cf8 100644
--- a/arch/arm/cpu/armv7/mx7/soc.c
+++ b/arch/arm/cpu/armv7/mx7/soc.c
@@ -446,13 +446,6 @@ int mmc_get_env_dev(void)
 
 void s_init(void)
 {
-#if !defined CONFIG_SPL_BUILD
-	/* Enable SMP mode for CPU0, by setting bit 6 of Auxiliary Ctl reg */
-	asm volatile(
-			"mrc p15, 0, r0, c1, c0, 1\n"
-			"orr r0, r0, #1 << 6\n"
-			"mcr p15, 0, r0, c1, c0, 1\n");
-#endif
 	/* clock configuration. */
 	clock_init();
 
diff --git a/arch/arm/imx-common/cache.c b/arch/arm/imx-common/cache.c
index 1c4a9a2..ed17f9e 100644
--- a/arch/arm/imx-common/cache.c
+++ b/arch/arm/imx-common/cache.c
@@ -10,6 +10,34 @@
 #include <asm/io.h>
 #include <asm/imx-common/sys_proto.h>
 
+static void enable_ca7_smp(void)
+{
+	uint32_t val;
+
+	/* Read MIDR */
+	asm volatile ("mrc p15, 0, %0, c0, c0, 0\r\n" : "=r"(val));
+	val = (val >> 4);
+	val &= 0xfff;
+
+	/* Only set the SMP for Cortex A7 */
+	if (val == 0xC07) {
+		/* Read auxiliary control register */
+		asm volatile ("mrc p15, 0, %0, c1, c0, 1\r\n" : "=r"(val));
+
+		if (val & (1 << 6))
+			return;
+
+		/* Enable SMP */
+		val |= (1 << 6);
+
+		/* Write auxiliary control register */
+		asm volatile ("mcr p15, 0, %0, c1, c0, 1\r\n" : : "r"(val));
+
+		DSB;
+		ISB;
+	}
+}
+
 #ifndef CONFIG_SYS_DCACHE_OFF
 void enable_caches(void)
 {
@@ -18,6 +46,9 @@ void enable_caches(void)
 #else
 	enum dcache_option option = DCACHE_WRITEBACK;
 #endif
+	/* Set ACTLR.SMP bit for Cortex-A7 */
+	enable_ca7_smp();
+
 	/* Avoid random hang when download by usb */
 	invalidate_dcache_all();
 
@@ -32,6 +63,17 @@ void enable_caches(void)
 					IRAM_SIZE,
 					option);
 }
+#else
+void enable_caches(void)
+{
+	/*
+	 * Set ACTLR.SMP bit for Cortex-A7, even the
+	 * caches not enabled.
+	 */
+	enable_ca7_smp();
+
+	puts("WARNING: Caches not enabled\n");
+}
 #endif
 
 #ifndef CONFIG_SYS_L2CACHE_OFF
-- 
2.6.2



More information about the U-Boot mailing list