public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] armv7:cache: D cache line size read method
@ 2011-08-12  8:24 Lukasz Majewski
  2011-08-12  8:58 ` Albert ARIBAUD
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Lukasz Majewski @ 2011-08-12  8:24 UTC (permalink / raw)
  To: u-boot

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@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Aneesh V <aneesh@ti.com>
CC: Albert ARIBAUD <albert.u.boot@aribaud.net>
---
 arch/arm/cpu/armv7/cache_v7.c |   25 +++++++++++++++++++++++++
 include/common.h              |    1 +
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c
index 3e1e1bf..bd0b1a8 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 (bytes) */
+static int v7_dcache_line_size(void)
+{
+	u32 ccsidr, log2_line_len;
+
+	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);
@@ -303,6 +318,11 @@ void  flush_cache(unsigned long start, unsigned long size)
 {
 	flush_dcache_range(start, start + size);
 }
+
+int get_dcache_line_size(void)
+{
+	return v7_dcache_line_size();
+}
 #else /* #ifndef CONFIG_SYS_DCACHE_OFF */
 void invalidate_dcache_all(void)
 {
@@ -327,6 +347,11 @@ void arm_init_before_mmu(void)
 void  flush_cache(unsigned long start, unsigned long size)
 {
 }
+
+int get_dcache_line_size(void)
+{
+	return 0;
+}
 #endif /* #ifndef CONFIG_SYS_DCACHE_OFF */
 
 #ifndef CONFIG_SYS_ICACHE_OFF
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

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

end of thread, other threads:[~2011-08-23  6:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-12  8:24 [U-Boot] [PATCH] armv7:cache: D cache line size read method Lukasz Majewski
2011-08-12  8:58 ` Albert ARIBAUD
2011-08-12  9:16   ` Aneesh V
2011-08-12  9:48     ` Albert ARIBAUD
2011-08-16 18:32     ` Anton Staaf
2011-08-12  9:02 ` Aneesh V
2011-08-12  9:46   ` Lukasz Majewski
2011-08-16 10:31 ` [U-Boot] [PATCH v2] " Lukasz Majewski
2011-08-16 11:24   ` Sergei Shtylyov
2011-08-16 12:01 ` [U-Boot] [RESEND PATCH " Lukasz Majewski
2011-08-17  8:51 ` [U-Boot] [PATCH v3] " Lukasz Majewski
2011-08-17 16:28   ` Albert ARIBAUD
2011-08-18  6:46 ` [U-Boot] [RESEND PATCH " Lukasz Majewski
2011-08-23  6:13 ` [U-Boot] [PATCH v4] dcache: " Lukasz Majewski

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