libpayload: expose dcache_line_bytes() in ARM 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=built and booted on nyan, nothing obvious broke Signed-off-by: David Hendricks <dhendrix@chromium.org> Change-Id: I9b0ddc36aa39084f0d621af064487d1b2ef3d023 Reviewed-on: https://chromium-review.googlesource.com/174099 Reviewed-by: Gabe Black <gabeblack@chromium.org> Commit-Queue: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org>
This commit is contained in:
parent
6727f65702
commit
9387b02dff
2 changed files with 12 additions and 6 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -304,6 +304,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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue