]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/asm-arm/cache-cp15.h
applied patches from Freescale and Ka-Ro
[karo-tx-uboot.git] / include / asm-arm / cache-cp15.h
1 /*
2  * (C) Copyright 2008-2010 Freescale Semiconductor, Inc.
3  *
4  * (C) Copyright 2002
5  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6  *
7  * See file CREDITS for list of people who contributed to this
8  * project.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License as
12  * published by the Free Software Foundation; either version 2 of
13  * the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23  * MA 02111-1307 USA
24  */
25
26 #include <common.h>
27 #include <asm/system.h>
28
29 #if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE))
30 #define cp_delay()      \
31 {       \
32         volatile int i; \
33         /* copro seems to need some delay between reading and writing */        \
34         for (i = 0; i < 100; i++)       \
35                 nop();  \
36 }
37
38 /* cache_bit must be either CR_I or CR_C */
39 #define cache_enable(cache_bit) \
40 {       \
41         uint32_t reg;   \
42         reg = get_cr(); /* get control reg. */  \
43         set_cr(reg | cache_bit);        \
44         cp_delay();     \
45 }
46
47 /* cache_bit must be either CR_I or CR_C */
48 #define cache_disable(cache_bit)        \
49 {       \
50         uint32_t reg;   \
51         reg = get_cr(); \
52         set_cr(reg & ~cache_bit);       \
53         cp_delay();     \
54 }
55
56 #endif
57
58 #ifdef CONFIG_SYS_NO_ICACHE
59 #define icache_enable()
60
61 #define icache_disable()
62
63 #define icache_status()
64 #else
65 #define icache_enable()         (cache_enable(CR_I))
66
67 #define icache_disable()        (cache_disable(CR_I))
68
69 #define icache_status()         ((get_cr() & CR_I) != 0)
70 #endif
71
72 #ifdef CONFIG_SYS_NO_DCACHE
73 #define dcache_enable()
74
75 #define dcache_disable()
76
77 #define dcache_status()
78 #else
79 #define dcache_enable()         (cache_enable(CR_C))
80
81 #define dcache_disable()        \
82 {       \
83         cache_disable(CR_C);    \
84 }
85
86 #define dcache_status() ((get_cr() & CR_C) != 0)
87
88 #endif