From 758abdd75b22108b14427edc3704a84783759c27 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Tue, 19 Mar 2013 17:57:59 -0700 Subject: armv7: add a helper function for dcache ops by MVA This adds a helper function for dcache ops by MVA which will perform the specified operation on a given memory range. This will make it more trivial to add other data cache maintenance routines. Change-Id: I01d746d5fd2f4138257ca9cab9e9d738e73f8633 Signed-off-by: David Hendricks Reviewed-on: http://review.coreboot.org/2870 Reviewed-by: Stefan Reinauer Tested-by: build bot (Jenkins) --- src/arch/armv7/lib/cache.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/arch/armv7/lib/cache.c b/src/arch/armv7/lib/cache.c index d413bc4046..8fb238af9b 100644 --- a/src/arch/armv7/lib/cache.c +++ b/src/arch/armv7/lib/cache.c @@ -77,7 +77,8 @@ void icache_invalidate_all(void) enum dcache_op { OP_DCCISW, - OP_DCISW + OP_DCISW, + OP_DCCIMVAC, }; /* @@ -169,13 +170,32 @@ static unsigned int line_bytes(void) return size; } -void dcache_clean_invalidate_by_mva(unsigned long addr, unsigned long len) +/* + * Do a dcache operation by modified virtual address. This is useful for + * maintaining coherency in drivers which do DMA transfers and only need to + * perform cache maintenance on a particular memory range rather than the + * entire cache. + */ +static void dcache_op_mva(unsigned long addr, + unsigned long len, enum dcache_op op) { unsigned long line, i; line = line_bytes(); - for (i = addr & ~(line - 1); i < addr + len - 1; i += line) - dccimvac(addr); + for (i = addr & ~(line - 1); i < addr + len - 1; i += line) { + switch(op) { + case OP_DCCIMVAC: + dccimvac(addr); + break; + default: + break; + } + } +} + +void dcache_clean_invalidate_by_mva(unsigned long addr, unsigned long len) +{ + dcache_op_mva(addr, len, OP_DCCIMVAC); } void armv7_invalidate_caches(void) -- cgit v1.2.3