3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #include <asm/immap.h>
26 #include <asm/cache.h>
28 volatile int *cf_icache_status = (int *)ICACHE_STATUS;
29 volatile int *cf_dcache_status = (int *)DCACHE_STATUS;
31 void flush_cache(ulong start_addr, ulong size)
33 /* Must be implemented for all M68k processors with copy-back data cache */
36 int icache_status(void)
38 return *cf_icache_status;
41 int dcache_status(void)
43 return *cf_dcache_status;
46 void icache_enable(void)
50 *cf_icache_status = 1;
53 __asm__ __volatile__("movec %0, %%acr2"::"r"(CONFIG_SYS_CACHE_ACR2));
54 __asm__ __volatile__("movec %0, %%acr3"::"r"(CONFIG_SYS_CACHE_ACR3));
55 #elif defined(CONFIG_CF_V4e)
56 __asm__ __volatile__("movec %0, %%acr6"::"r"(CONFIG_SYS_CACHE_ACR6));
57 __asm__ __volatile__("movec %0, %%acr7"::"r"(CONFIG_SYS_CACHE_ACR7));
59 __asm__ __volatile__("movec %0, %%acr0"::"r"(CONFIG_SYS_CACHE_ACR0));
60 __asm__ __volatile__("movec %0, %%acr1"::"r"(CONFIG_SYS_CACHE_ACR1));
63 __asm__ __volatile__("movec %0, %%cacr"::"r"(CONFIG_SYS_CACHE_ICACR));
66 void icache_disable(void)
70 *cf_icache_status = 0;
74 __asm__ __volatile__("movec %0, %%acr2"::"r"(temp));
75 __asm__ __volatile__("movec %0, %%acr3"::"r"(temp));
76 #elif defined(CONFIG_CF_V4e)
77 __asm__ __volatile__("movec %0, %%acr6"::"r"(temp));
78 __asm__ __volatile__("movec %0, %%acr7"::"r"(temp));
80 __asm__ __volatile__("movec %0, %%acr0"::"r"(temp));
81 __asm__ __volatile__("movec %0, %%acr1"::"r"(temp));
86 void icache_invalid(void)
90 temp = CONFIG_SYS_ICACHE_INV;
91 if (*cf_icache_status)
92 temp |= CONFIG_SYS_CACHE_ICACR;
94 __asm__ __volatile__("movec %0, %%cacr"::"r"(temp));
98 * data cache only for ColdFire V4 such as MCF547x_8x, MCF5445x
99 * the dcache will be dummy in ColdFire V2 and V3
101 void dcache_enable(void)
104 *cf_dcache_status = 1;
107 __asm__ __volatile__("movec %0, %%acr0"::"r"(CONFIG_SYS_CACHE_ACR0));
108 __asm__ __volatile__("movec %0, %%acr1"::"r"(CONFIG_SYS_CACHE_ACR1));
109 #elif defined(CONFIG_CF_V4e)
110 __asm__ __volatile__("movec %0, %%acr4"::"r"(CONFIG_SYS_CACHE_ACR4));
111 __asm__ __volatile__("movec %0, %%acr5"::"r"(CONFIG_SYS_CACHE_ACR5));
115 __asm__ __volatile__("movec %0, %%cacr"::"r"(CONFIG_SYS_CACHE_DCACR));
118 void dcache_disable(void)
122 *cf_dcache_status = 0;
125 __asm__ __volatile__("movec %0, %%cacr"::"r"(temp));
128 __asm__ __volatile__("movec %0, %%acr0"::"r"(temp));
129 __asm__ __volatile__("movec %0, %%acr1"::"r"(temp));
130 #elif defined(CONFIG_CF_V4e)
131 __asm__ __volatile__("movec %0, %%acr4"::"r"(temp));
132 __asm__ __volatile__("movec %0, %%acr5"::"r"(temp));
137 void dcache_invalid(void)
142 temp = CONFIG_SYS_DCACHE_INV;
143 if (*cf_dcache_status)
144 temp |= CONFIG_SYS_CACHE_DCACR;
145 if (*cf_icache_status)
146 temp |= CONFIG_SYS_CACHE_ICACR;
148 __asm__ __volatile__("movec %0, %%cacr"::"r"(temp));