public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ARM1136: add cache flush and invalidate operations
@ 2012-03-30 14:02 Anatolij Gustschin
  2012-03-30 14:20 ` Stefano Babic
  2012-04-01 13:22 ` [U-Boot] [PATCH 1/4] " Stefano Babic
  0 siblings, 2 replies; 34+ messages in thread
From: Anatolij Gustschin @ 2012-03-30 14:02 UTC (permalink / raw)
  To: u-boot

Since commit 5c1ad3e6f8ae578bbe30e09652f1531e9bc22031
(net: fec_mxc: allow use with cache enabled) the FEC_MXC
driver uses flush_dcache_range() and invalidate_dcache_range()
functions. This driver is also configured for ARM1136 based
'flea3' and 'mx35pdk' boards which currently do not build
as there are no ARM1136 specific flush_dcache_range() and
invalidate_dcache_range() functions. Add various ARM1136
cache functions to fix building for 'flea3' and 'mx35pdk'.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
This patch is completely untested, I have not the HW to test on.
Could someone test this patch? The mentioned commit to the
FEC_MXC driver is in u-boot-arm.git master.

Thanks,
Anatolij

 arch/arm/cpu/arm1136/cpu.c |   78 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/arm1136/cpu.c b/arch/arm/cpu/arm1136/cpu.c
index 2b91631..43b4f5f 100644
--- a/arch/arm/cpu/arm1136/cpu.c
+++ b/arch/arm/cpu/arm1136/cpu.c
@@ -75,3 +75,81 @@ static void cache_flush(void)
 	asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));  /* invalidate both caches and flush btb */
 	asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (i)); /* mem barrier to sync things */
 }
+
+#ifndef CONFIG_SYS_DCACHE_OFF
+
+#ifndef CONFIG_SYS_CACHELINE_SIZE
+#define CONFIG_SYS_CACHELINE_SIZE	32
+#endif
+
+void invalidate_dcache_all(void)
+{
+	asm ("mcr p15, 0, %0, c7, c6, 0" : : "r" (0));
+}
+
+void flush_dcache_all(void)
+{
+	asm ("mcr p15, 0, %0, c7, c10, 0" : : "r" (0));
+	asm ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0));
+}
+
+static inline int bad_cache_range(unsigned long start, unsigned long stop)
+{
+	if ((start | stop) & (CONFIG_SYS_CACHELINE_SIZE - 1)) {
+		printf("Misaligned cache operation [%08lx, %08lx]\n",
+			start, stop);
+		return 1;
+	}
+
+	return 0;
+}
+
+void invalidate_dcache_range(unsigned long start, unsigned long stop)
+{
+	if (bad_cache_range(start, stop))
+		return;
+
+	while (start < stop) {
+		asm ("mcr p15, 0, %0, c7, c6, 1" : : "r" (start));
+		start += CONFIG_SYS_CACHELINE_SIZE;
+	}
+}
+
+void flush_dcache_range(unsigned long start, unsigned long stop)
+{
+	if (bad_cache_range(start, stop))
+		return;
+
+	while (start < stop) {
+		asm ("mcr p15, 0, %0, c7, c14, 1" : : "r" (start));
+		start += CONFIG_SYS_CACHELINE_SIZE;
+	}
+
+	asm ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0));
+}
+
+void flush_cache(unsigned long start, unsigned long size)
+{
+	flush_dcache_range(start, start + size);
+}
+#else /* #ifndef CONFIG_SYS_DCACHE_OFF */
+void invalidate_dcache_all(void)
+{
+}
+
+void flush_dcache_all(void)
+{
+}
+
+void invalidate_dcache_range(unsigned long start, unsigned long stop)
+{
+}
+
+void flush_dcache_range(unsigned long start, unsigned long stop)
+{
+}
+
+void flush_cache(unsigned long start, unsigned long size)
+{
+}
+#endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2012-04-02 19:07 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-30 14:02 [U-Boot] [PATCH] ARM1136: add cache flush and invalidate operations Anatolij Gustschin
2012-03-30 14:20 ` Stefano Babic
2012-03-30 14:35   ` Anatolij Gustschin
2012-03-30 15:04     ` Stefano Babic
2012-03-30 15:28       ` Marek Vasut
2012-03-30 15:42         ` Anatolij Gustschin
2012-03-30 15:58         ` Stefano Babic
2012-03-30 16:05           ` Marek Vasut
2012-03-30 16:16             ` Stefano Babic
2012-04-01 13:22 ` [U-Boot] [PATCH 1/4] " Stefano Babic
2012-04-01 13:22   ` [U-Boot] [PATCH 2/4] net: round up before calling flush_cache Stefano Babic
2012-04-01 13:46     ` Marek Vasut
2012-04-01 14:56       ` Stefano Babic
2012-04-01 15:35         ` Marek Vasut
2012-04-01 19:23     ` Mike Frysinger
2012-04-01 21:00       ` Marek Vasut
2012-04-02  1:38         ` Mike Frysinger
2012-04-02  1:44           ` Marek Vasut
2012-04-02  3:06             ` Mike Frysinger
2012-04-02  3:34               ` Marek Vasut
2012-04-02  5:56                 ` Mike Frysinger
2012-04-02  7:13       ` Stefano Babic
2012-04-02 14:03         ` Marek Vasut
2012-04-02 14:38           ` Stefano Babic
2012-04-01 13:23   ` [U-Boot] [PATCH 3/4] mx35: flea3: fix when cache functions are linked Stefano Babic
2012-04-01 13:23   ` [U-Boot] [PATCH 4/4] mx35: mx35pdk: " Stefano Babic
2012-04-02 16:18   ` [U-Boot] [PATCH V3 1/4] ARM1136: add cache flush and invalidate operations Stefano Babic
2012-04-02 16:29     ` Marek Vasut
2012-04-02 16:51     ` Stefano Babic
2012-04-02 16:18   ` [U-Boot] [PATCH V2 2/4] ARM: 926ejs: use debug() for misaligned addresses Stefano Babic
2012-04-02 16:29     ` Marek Vasut
2012-04-02 18:23     ` Mike Frysinger
2012-04-02 18:42       ` Marek Vasut
2012-04-02 19:07         ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox