2016-07-22 15:26:33 +00:00
|
|
|
/*
|
|
|
|
* This is a part of mm/cache-v7.S with extracted entry flushing D-cache. We
|
|
|
|
* need it for Broadcom devices with broken bootloader leaving cache enabled.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Deep Blue Solutions Ltd.
|
|
|
|
* Copyright (C) 2005 ARM Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
|
|
|
__INIT
|
|
|
|
|
|
|
|
/*
|
|
|
|
* v7_flush_dcache_all()
|
|
|
|
*
|
|
|
|
* Flush the whole D-cache.
|
|
|
|
*
|
2016-08-19 10:44:44 +00:00
|
|
|
* Corrupted registers: r0-r7, r9-r11 (r6 only in Thumb mode)
|
2016-07-22 15:26:33 +00:00
|
|
|
*
|
|
|
|
* - mm - mm_struct describing address space
|
|
|
|
*/
|
|
|
|
ENTRY(v7_flush_dcache_all)
|
2016-08-19 10:44:44 +00:00
|
|
|
dmb @ ensure ordering with previous memory accesses
|
2016-07-22 15:26:33 +00:00
|
|
|
mrc p15, 1, r0, c0, c0, 1 @ read clidr
|
2016-08-19 10:44:44 +00:00
|
|
|
mov r3, r0, lsr #23 @ move LoC into position
|
|
|
|
ands r3, r3, #7 << 1 @ extract LoC*2 from clidr
|
2016-07-22 15:26:33 +00:00
|
|
|
beq finished @ if loc is 0, then no need to clean
|
2016-08-19 10:44:44 +00:00
|
|
|
start_flush_levels:
|
2016-07-22 15:26:33 +00:00
|
|
|
mov r10, #0 @ start clean at cache level 0
|
2016-08-19 10:44:44 +00:00
|
|
|
flush_levels:
|
2016-07-22 15:26:33 +00:00
|
|
|
add r2, r10, r10, lsr #1 @ work out 3x current cache level
|
|
|
|
mov r1, r0, lsr r2 @ extract cache type bits from clidr
|
|
|
|
and r1, r1, #7 @ mask of the bits for current cache only
|
|
|
|
cmp r1, #2 @ see what cache we have at this level
|
|
|
|
blt skip @ skip if no cache, or just i-cache
|
2016-08-19 10:44:44 +00:00
|
|
|
#ifdef CONFIG_PREEMPT
|
|
|
|
save_and_disable_irqs_notrace r9 @ make cssr&csidr read atomic
|
|
|
|
#endif
|
2016-07-22 15:26:33 +00:00
|
|
|
mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
|
|
|
|
isb @ isb to sych the new cssr&csidr
|
|
|
|
mrc p15, 1, r1, c0, c0, 0 @ read the new csidr
|
2016-08-19 10:44:44 +00:00
|
|
|
#ifdef CONFIG_PREEMPT
|
|
|
|
restore_irqs_notrace r9
|
|
|
|
#endif
|
2016-07-22 15:26:33 +00:00
|
|
|
and r2, r1, #7 @ extract the length of the cache lines
|
|
|
|
add r2, r2, #4 @ add 4 (line length offset)
|
2016-08-19 10:44:44 +00:00
|
|
|
movw r4, #0x3ff
|
2016-07-22 15:26:33 +00:00
|
|
|
ands r4, r4, r1, lsr #3 @ find maximum number on the way size
|
|
|
|
clz r5, r4 @ find bit position of way size increment
|
2016-08-19 10:44:44 +00:00
|
|
|
movw r7, #0x7fff
|
2016-07-22 15:26:33 +00:00
|
|
|
ands r7, r7, r1, lsr #13 @ extract max number of the index size
|
2016-08-19 10:44:44 +00:00
|
|
|
loop1:
|
|
|
|
mov r9, r7 @ create working copy of max index
|
2016-07-22 15:26:33 +00:00
|
|
|
loop2:
|
2016-08-19 10:44:44 +00:00
|
|
|
ARM( orr r11, r10, r4, lsl r5 ) @ factor way and cache number into r11
|
|
|
|
THUMB( lsl r6, r4, r5 )
|
|
|
|
THUMB( orr r11, r10, r6 ) @ factor way and cache number into r11
|
|
|
|
ARM( orr r11, r11, r9, lsl r2 ) @ factor index number into r11
|
|
|
|
THUMB( lsl r6, r9, r2 )
|
|
|
|
THUMB( orr r11, r11, r6 ) @ factor index number into r11
|
2016-07-22 15:26:33 +00:00
|
|
|
mcr p15, 0, r11, c7, c14, 2 @ clean & invalidate by set/way
|
2016-08-19 10:44:44 +00:00
|
|
|
subs r9, r9, #1 @ decrement the index
|
2016-07-22 15:26:33 +00:00
|
|
|
bge loop2
|
2016-08-19 10:44:44 +00:00
|
|
|
subs r4, r4, #1 @ decrement the way
|
|
|
|
bge loop1
|
2016-07-22 15:26:33 +00:00
|
|
|
skip:
|
|
|
|
add r10, r10, #2 @ increment cache number
|
|
|
|
cmp r3, r10
|
2016-08-19 10:44:44 +00:00
|
|
|
bgt flush_levels
|
2016-07-22 15:26:33 +00:00
|
|
|
finished:
|
|
|
|
mov r10, #0 @ swith back to cache level 0
|
|
|
|
mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
|
2016-08-19 10:44:44 +00:00
|
|
|
dsb st
|
2016-07-22 15:26:33 +00:00
|
|
|
isb
|
2016-08-19 10:44:44 +00:00
|
|
|
ret lr
|
|
|
|
ENDPROC(v7_flush_dcache_all)
|