[U-Boot] [PATCH v2] armv7:cache: D cache line size read method
Lukasz Majewski
l.majewski at samsung.com
Tue Aug 16 12:31:49 CEST 2011
This commit adds support for reading the D cache line size for armv7
architecture.
The get_dcache_line_size() function is supposed to work in conjunction
with memalign call to provide D cache aligned DMA buffers.
Signed-off-by: Lukasz Majewski <l.majewski at samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
CC: Aneesh V <aneesh at ti.com>
CC: Albert ARIBAUD <albert.u.boot at aribaud.net>
---
Changes for v2:
- Weak function get_dcache_line_size added to lib/cache.c for non armv7
architectures
---
arch/arm/cpu/armv7/cache_v7.c | 15 +++++++++++++++
arch/arm/lib/cache.c | 11 +++++++++++
include/common.h | 1 +
3 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c
index 3e1e1bf..0ff9a97 100644
--- a/arch/arm/cpu/armv7/cache_v7.c
+++ b/arch/arm/cpu/armv7/cache_v7.c
@@ -246,6 +246,21 @@ static void v7_inval_tlb(void)
CP15ISB;
}
+/* Read the cache line size (in bytes) */
+int get_dcache_line_size(void)
+{
+ u32 ccsidr, log2_line_len;
+ puts("222\n");
+ ccsidr = get_ccsidr();
+
+ log2_line_len = ((ccsidr & CCSIDR_LINE_SIZE_MASK) >>
+ CCSIDR_LINE_SIZE_OFFSET) + 2;
+ /* Converting from words to bytes */
+ log2_line_len += 2;
+
+ return 1 << log2_line_len;
+}
+
void invalidate_dcache_all(void)
{
v7_maint_dcache_all(ARMV7_DCACHE_INVAL_ALL);
diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index 92b61a2..5ebf551 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -53,3 +53,14 @@ void __flush_dcache_all(void)
}
void flush_dcache_all(void)
__attribute__((weak, alias("__flush_dcache_all")));
+
+/* Default implementation: */
+/* Read the default D CACHE LINE size */
+int __attribute__((weak)) get_dcache_line_size(void)
+{
+#if defined(CONFIG_SYS_CACHE_LINE_SIZE) && !defined(CONFIG_SYS_DCACHE_OFF)
+ return CONFIG_SYS_CACHE_LINE_SIZE;
+#else
+ return 8; /* Default alignment for memalign() */
+#endif
+}
diff --git a/include/common.h b/include/common.h
index 12a1074..b535300 100644
--- a/include/common.h
+++ b/include/common.h
@@ -622,6 +622,7 @@ void flush_dcache_range(unsigned long start, unsigned long stop);
void invalidate_dcache_range(unsigned long start, unsigned long stop);
void invalidate_dcache_all(void);
void invalidate_icache_all(void);
+int get_dcache_line_size(void);
/* arch/$(ARCH)/lib/ticks.S */
unsigned long long get_ticks(void);
--
1.7.2.3
More information about the U-Boot
mailing list