]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/m68k/lib/cache.c
Move lib_$ARCH directories to arch/$ARCH/lib
[people/ms/u-boot.git] / arch / m68k / lib / cache.c
CommitLineData
4e5ca3eb 1/*
bf9e3b38 2 * (C) Copyright 2002
4e5ca3eb
WD
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
dd9f054e
TL
25#include <asm/immap.h>
26#include <asm/cache.h>
4e5ca3eb 27
dd9f054e
TL
28volatile int *cf_icache_status = (int *)ICACHE_STATUS;
29volatile int *cf_dcache_status = (int *)DCACHE_STATUS;
30
31void flush_cache(ulong start_addr, ulong size)
4e5ca3eb 32{
bf9e3b38 33 /* Must be implemented for all M68k processors with copy-back data cache */
4e5ca3eb 34}
dd9f054e
TL
35
36int icache_status(void)
37{
38 return *cf_icache_status;
39}
40
41int dcache_status(void)
42{
43 return *cf_dcache_status;
44}
45
46void icache_enable(void)
47{
48 icache_invalid();
49
50 *cf_icache_status = 1;
51
52#ifdef CONFIG_CF_V4
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));
58#else
59 __asm__ __volatile__("movec %0, %%acr0"::"r"(CONFIG_SYS_CACHE_ACR0));
60 __asm__ __volatile__("movec %0, %%acr1"::"r"(CONFIG_SYS_CACHE_ACR1));
61#endif
62
63 __asm__ __volatile__("movec %0, %%cacr"::"r"(CONFIG_SYS_CACHE_ICACR));
64}
65
66void icache_disable(void)
67{
68 u32 temp = 0;
69
70 *cf_icache_status = 0;
71 icache_invalid();
72
73#ifdef CONFIG_CF_V4
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));
79#else
80 __asm__ __volatile__("movec %0, %%acr0"::"r"(temp));
81 __asm__ __volatile__("movec %0, %%acr1"::"r"(temp));
82
83#endif
84}
85
86void icache_invalid(void)
87{
88 u32 temp;
89
90 temp = CONFIG_SYS_ICACHE_INV;
91 if (*cf_icache_status)
92 temp |= CONFIG_SYS_CACHE_ICACR;
93
94 __asm__ __volatile__("movec %0, %%cacr"::"r"(temp));
95}
96
97/*
98 * data cache only for ColdFire V4 such as MCF547x_8x, MCF5445x
99 * the dcache will be dummy in ColdFire V2 and V3
100 */
101void dcache_enable(void)
102{
103 dcache_invalid();
104 *cf_dcache_status = 1;
105
106#ifdef CONFIG_CF_V4
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));
112
113#endif
114
115 __asm__ __volatile__("movec %0, %%cacr"::"r"(CONFIG_SYS_CACHE_DCACR));
116}
117
118void dcache_disable(void)
119{
120 u32 temp = 0;
121
122 *cf_dcache_status = 0;
123 dcache_invalid();
124
125 __asm__ __volatile__("movec %0, %%cacr"::"r"(temp));
126
127#ifdef CONFIG_CF_V4
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));
133
134#endif
135}
136
137void dcache_invalid(void)
138{
139#ifdef CONFIG_CF_V4
140 u32 temp;
141
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;
147
148 __asm__ __volatile__("movec %0, %%cacr"::"r"(temp));
149#endif
150}