From 6727f65702c7668fcb33848b4113bc3d3cc04e12 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Mon, 21 Oct 2013 17:56:40 -0700 Subject: [PATCH] armv7: expose dcache_line_bytes() in cache API This exposes the function that obtains cache line size so that it can be used by drivers in DMA-related functions. BUG=none BRANCH=none TEST=tested on nyan Signed-off-by: David Hendricks Change-Id: I1664be98a91d2f776e27274b19838c1782371a81 Reviewed-on: https://chromium-review.googlesource.com/173975 Reviewed-by: Gabe Black Commit-Queue: David Hendricks Tested-by: David Hendricks --- src/arch/arm/armv7/cache.c | 15 +++++++++------ src/arch/arm/include/armv7/arch/cache.h | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/arch/arm/armv7/cache.c b/src/arch/arm/armv7/cache.c index acd1f9aefa..4ee2687d38 100644 --- a/src/arch/arm/armv7/cache.c +++ b/src/arch/arm/armv7/cache.c @@ -194,17 +194,20 @@ void dcache_invalidate_all(void) dcache_foreach(OP_DCISW); } -static unsigned int line_bytes(void) +unsigned int dcache_line_bytes(void) { uint32_t ccsidr; - unsigned int size; + static unsigned int line_bytes = 0; + + if (line_bytes) + return line_bytes; ccsidr = read_ccsidr(); /* [2:0] - Indicates (Log2(number of words in cache line)) - 2 */ - size = 1 << ((ccsidr & 0x7) + 2); /* words per line */ - size *= sizeof(unsigned int); /* bytes per line */ + line_bytes = 1 << ((ccsidr & 0x7) + 2); /* words per line */ + line_bytes *= sizeof(unsigned int); /* bytes per line */ - return size; + return line_bytes; } /* @@ -217,7 +220,7 @@ static void dcache_op_mva(void const *addr, size_t len, enum dcache_op op) { unsigned long line, linesize; - linesize = line_bytes(); + linesize = dcache_line_bytes(); line = (uint32_t)addr & ~(linesize - 1); dsb(); diff --git a/src/arch/arm/include/armv7/arch/cache.h b/src/arch/arm/include/armv7/arch/cache.h index db745b842e..69d319566d 100644 --- a/src/arch/arm/include/armv7/arch/cache.h +++ b/src/arch/arm/include/armv7/arch/cache.h @@ -305,6 +305,9 @@ void dcache_clean_all(void); /* dcache invalidate all (on current level given by CCSELR) */ void dcache_invalidate_all(void); +/* returns number of bytes per cache line */ +unsigned int dcache_line_bytes(void); + /* dcache and MMU disable */ void dcache_mmu_disable(void);