[U-Boot] [PATCH 4/4] microblaze: Add cache flush
monstr at monstr.eu
monstr at monstr.eu
Mon Jan 5 13:18:57 CET 2009
From: Michal Simek <monstr at monstr.eu>
Signed-off-by: Michal Simek <monstr at monstr.eu>
---
include/configs/microblaze-generic.h | 19 ++++++++++++++++++-
lib_microblaze/cache.c | 16 ++++++++++++++--
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index 867f885..4c6cc9f 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -194,6 +194,18 @@
#define CONFIG_DOS_PARTITION
#endif
+#if defined(XILINX_USE_ICACHE)
+ #define CONFIG_ICACHE
+#else
+ #undef CONFIG_ICACHE
+#endif
+
+#if defined(XILINX_USE_DCACHE)
+ #define CONFIG_DCACHE
+#else
+ #undef CONFIG_DCACHE
+#endif
+
/*
* BOOTP options
*/
@@ -208,11 +220,16 @@
#include <config_cmd_default.h>
#define CONFIG_CMD_ASKENV
-#define CONFIG_CMD_CACHE
#define CONFIG_CMD_IRQ
#define CONFIG_CMD_MFSL
#define CONFIG_CMD_ECHO
+#if defined(CONFIG_DCACHE) || defined(CONFIG_ICACHE)
+ #define CONFIG_CMD_CACHE
+#else
+ #undef CONFIG_CMD_CACHE
+#endif
+
#ifndef CONFIG_SYS_ENET
#undef CONFIG_CMD_NET
#else
diff --git a/lib_microblaze/cache.c b/lib_microblaze/cache.c
index a2f7493..4b2e8e3 100644
--- a/lib_microblaze/cache.c
+++ b/lib_microblaze/cache.c
@@ -26,6 +26,18 @@
void flush_cache (ulong addr, ulong size)
{
- /* MicroBlaze have write thruough cache. nothing to do. */
- return;
+ int i;
+ for (i = 0; i < size; i += 4)
+ asm volatile (
+#ifdef CONFIG_ICACHE
+ "wic %0, r0;"
+#endif
+ "nop;"
+#ifdef CONFIG_DCACHE
+ "wdc %0, r0;"
+#endif
+ "nop;"
+ :
+ : "r" (addr + i)
+ : "memory");
}
--
1.5.5.1
More information about the U-Boot
mailing list