1 /*****************************************************************************
2 * Copyright 2003 - 2008 Broadcom Corporation. All rights reserved.
4 * Unless you and Broadcom execute a separate written software license
5 * agreement governing use of this software, this software is licensed to you
6 * under the terms of the GNU General Public License version 2, available at
7 * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
9 * Notwithstanding the above, under no circumstances may you combine this
10 * software in any way with any other Broadcom software provided under a
11 * license other than the GPL, without Broadcom's express prior written
13 *****************************************************************************/
15 #include <linux/linkage.h>
16 #include <linux/init.h>
21 * v7_l1_cache_invalidate
23 * Invalidate contents of L1 cache without flushing its contents
24 * into outer cache and memory. This is needed when the contents
25 * of the cache are unpredictable after power-up.
30 ENTRY(v7_l1_cache_invalidate)
32 mcr p15, 2, r0, c0, c0, 0 @ set cache level to 1
33 mrc p15, 1, r0, c0, c0, 0 @ read CLIDR
36 and r2, r1, r0, lsr #13 @ get max # of index size
39 and r3, r1, r0, lsr #3 @ NumWays - 1
40 add r2, r2, #1 @ NumSets
43 add r0, r0, #4 @ SetShift
46 add r4, r3, #1 @ NumWays
47 1: sub r2, r2, #1 @ NumSets--
48 mov r3, r4 @ Temp = NumWays
49 2: subs r3, r3, #1 @ Temp--
52 orr r5, r5, r6 @ Reg = (Temp<<WayShift)|(NumSets<<SetShift)
53 mcr p15, 0, r5, c7, c6, 2 @ Invalidate line
59 mcr p15,0,r0,c7,c5,0 /* Invalidate icache */
62 ENDPROC(v7_l1_cache_invalidate)
65 * v7_all_dcache_invalidate
67 * Invalidate without flushing the contents of all cache levels
68 * accesible by the current processor core.
69 * This is useful when the contents of cache memory are undetermined
71 * Corrupted registers: r0-r7, r9-r11
73 * Based on cache-v7.S: v7_flush_dcache_all()
76 ENTRY(v7_all_dcache_invalidate)
77 mrc p15, 1, r0, c0, c0, 1 @ read clidr
78 ands r3, r0, #0x7000000 @ extract loc from clidr
79 mov r3, r3, lsr #23 @ left align loc bit field
80 beq finished @ if loc is 0, then no need to clean
81 mov r10, #0 @ start clean at cache level 0
83 add r2, r10, r10, lsr #1 @ work out 3x current cache level
84 mov r1, r0, lsr r2 @ extract cache type bits from clidr
85 and r1, r1, #7 @ mask of bits for current cache only
86 cmp r1, #2 @ see what cache we have at this level
87 blt skip @ skip if no cache, or just i-cache
88 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
89 isb @ isb to sych the new cssr&csidr
90 mrc p15, 1, r1, c0, c0, 0 @ read the new csidr
91 and r2, r1, #7 @ extract the length of the cache lines
92 add r2, r2, #4 @ add 4 (line length offset)
94 ands r4, r4, r1, lsr #3 @ find maximum number on the way size
95 clz r5, r4 @ find bit pos of way size increment
97 ands r7, r7, r1, lsr #13 @ extract max number of the index size
99 mov r9, r4 @ create working copy of max way size
101 orr r11, r10, r9, lsl r5 @ factor way and cache number into r11
102 orr r11, r11, r7, lsl r2 @ factor index number into r11
103 mcr p15, 0, r11, c7, c6, 2 @ Invalidate line
104 subs r9, r9, #1 @ decrement the way
106 subs r7, r7, #1 @ decrement the index
109 add r10, r10, #2 @ increment cache number
113 mov r10, #0 @ swith back to cache level 0
114 mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
118 ENDPROC(v7_all_dcache_invalidate)