2 * Copyright (c) 2010 Per Odlund <per.odlund@armagedon.se>
3 * Copyright (C) 2011 MARVELL INTERNATIONAL LTD.
6 * Developed by Semihalf.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of MARVELL nor the names of contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <machine/asm.h>
34 __FBSDID("$FreeBSD$");
36 #include <machine/sysreg.h>
41 .word _C_LABEL(arm_cache_loc)
43 .word _C_LABEL(arm_cache_type)
44 .Larmv7_dcache_line_size:
45 .word _C_LABEL(arm_dcache_min_line_size)
46 .Larmv7_icache_line_size:
47 .word _C_LABEL(arm_icache_min_line_size)
48 .Larmv7_idcache_line_size:
49 .word _C_LABEL(arm_idcache_min_line_size)
57 #define PT_NOS (1 << 5)
60 #define PT_INNER_WT (1 << 0)
61 #define PT_INNER_WB ((1 << 0) | (1 << 6))
62 #define PT_INNER_WBWA (1 << 6)
64 #define PT_OUTER_WT (2 << 3)
65 #define PT_OUTER_WB (3 << 3)
66 #define PT_OUTER_WBWA (1 << 3)
69 #define PT_ATTR (PT_S|PT_INNER_WBWA|PT_OUTER_WBWA|PT_NOS)
71 #define PT_ATTR (PT_INNER_WBWA|PT_OUTER_WBWA)
90 /* Based on algorithm from ARM Architecture Reference Manual */
91 ENTRY(armv7_dcache_wbinv_all)
92 stmdb sp!, {r4, r5, r6, r7, r8, r9}
95 ldr r0, .Lcoherency_level
99 /* For each cache level */
102 /* Get cache type for given level */
112 /* Get number of ways */
114 ands r4, r4, r1, lsr #3
119 ands r7, r7, r1, lsr #13
124 orr r6, r6, r9, lsl r5
125 orr r6, r6, r7, lsl r2
127 /* Clean and invalidate data cache by way/index */
139 ldmia sp!, {r4, r5, r6, r7, r8, r9}
141 END(armv7_dcache_wbinv_all)
143 ENTRY(armv7_idcache_wbinv_all)
145 bl armv7_dcache_wbinv_all
155 END(armv7_idcache_wbinv_all)
158 ENTRY(armv7_cpu_sleep)
159 dsb /* data synchronization barrier */
160 wfi /* wait for interrupt */
164 ENTRY(armv7_drain_writebuf)
167 END(armv7_drain_writebuf)