Skip to contentSkip to conversation

microblaze: Consolidate cache code

PATCH New monstr at monstr.eu 1 participant 1 message Apr 16, 2010 Microblaze architecture

lore
Share & tools
lore

monstr at monstr.eu

author maintainer
#0 lore raw

PATCH 1/1 microblaze: Consolidate cache code

From: Michal Simek <[email protected]>

Merge cpu and lib cache code.
Flush cache before disabling.

---
 arch/microblaze/cpu/cache.c  |   28 +++++++++++++++++++++++++++
 arch/microblaze/lib/Makefile |    1 -
 arch/microblaze/lib/cache.c  |   43 ------------------------------------------
 3 files changed, 28 insertions(+), 44 deletions(-)
 delete mode 100644 arch/microblaze/lib/cache.c
arch/microblaze/cpu/cache.c +28 -0
index 3b7c4d4..d258a69 100644
@@ -50,6 +50,8 @@ void	icache_enable (void) {
 }
 
 void	icache_disable(void) {
+	/* we are not generate ICACHE size -> flush whole cache */
+	flush_cache(0, 32768);
 	MSRCLR(0x20);
 }
 
@@ -58,5 +60,31 @@ void	dcache_enable (void) {
 }
 
 void	dcache_disable(void) {
+#ifdef XILINX_USE_DCACHE
+#ifdef XILINX_DCACHE_BYTE_SIZE
+	flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
+#else
+#warning please rebuild BSPs and update configuration
+	flush_cache(0, 32768);
+#endif
+#endif
 	MSRCLR(0x80);
 }
+
+void flush_cache (ulong addr, ulong size)
+{
+	int i;
+	for (i = 0; i < size; i += 4)
+		asm volatile (
+#ifdef CONFIG_ICACHE
+				"wic	%0, r0;"
+#endif
+				"nop;"
+#ifdef CONFIG_DCACHE
+				"wdc.flush	%0, r0;"
+#endif
+				"nop;"
+				:
+				: "r" (addr + i)
+				: "memory");
+}
arch/microblaze/lib/Makefile +0 -1
index 9b0f296..8176437 100644
@@ -29,7 +29,6 @@ SOBJS-y	+=
 
 COBJS-y	+= board.o
 COBJS-y	+= bootm.o
-COBJS-y	+= cache.o
 COBJS-y	+= time.o
 
 SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
arch/microblaze/lib/cache.c deleted +0 -43

43 lines not on this page · raw message

Signature · 1 line
1.5.5.1