]> rtime.felk.cvut.cz Git - mcf548x/linux.git/blob - arch/m68k/include/asm/mcfcache.h
Headers cleanup
[mcf548x/linux.git] / arch / m68k / include / asm / mcfcache.h
1 /****************************************************************************/
2
3 /*
4  *      mcfcache.h -- ColdFire CPU cache support code
5  *
6  *      (C) Copyright 2004, Greg Ungerer <gerg@snapgear.com>
7  */
8
9 /****************************************************************************/
10 #ifndef __M68K_MCFCACHE_H
11 #define __M68K_MCFCACHE_H
12 /****************************************************************************/
13
14 /*
15  *      The different ColdFire families have different cache arrangments.
16  *      Everything from a small instruction only cache, to configurable
17  *      data and/or instruction cache, to unified instruction/data, to 
18  *      harvard style separate instruction and data caches.
19  */
20
21 /* ========================================================================= */
22 /* NoMMU Coldfire                                                            */
23 /* ========================================================================= */
24
25 #if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || defined(CONFIG_M5272)
26 /*
27  *      Simple version 2 core cache. These have instruction cache only,
28  *      we just need to invalidate it and enable it.
29  */
30 .macro CACHE_ENABLE
31         movel   #0x01000000,%d0         /* invalidate cache cmd */
32         movec   %d0,%CACR               /* do invalidate cache */
33         movel   #0x80000100,%d0         /* setup cache mask */
34         movec   %d0,%CACR               /* enable cache */
35 .endm
36 #endif /* CONFIG_M5206 || CONFIG_M5206e || CONFIG_M5272 */
37
38 #if defined(CONFIG_M523x) || defined(CONFIG_M527x)
39 /*
40  *      New version 2 cores have a configurable split cache arrangement.
41  *      For now I am just enabling instruction cache - but ultimately I
42  *      think a split instruction/data cache would be better.
43  */
44 .macro CACHE_ENABLE
45         movel   #0x01400000,%d0
46         movec   %d0,%CACR               /* invalidate cache */
47         nop
48         movel   #0x0000c000,%d0         /* set SDRAM cached only */
49         movec   %d0,%ACR0
50         movel   #0x00000000,%d0         /* no other regions cached */
51         movec   %d0,%ACR1
52         movel   #0x80400100,%d0         /* configure cache */
53         movec   %d0,%CACR               /* enable cache */
54         nop
55 .endm
56 #endif /* CONFIG_M523x || CONFIG_M527x */
57
58 #if defined(CONFIG_M528x)
59 .macro CACHE_ENABLE
60         nop
61         movel   #0x01000000, %d0
62         movec   %d0, %CACR              /* Invalidate cache */
63         nop
64         movel   #0x0000c020, %d0        /* Set SDRAM cached only */
65         movec   %d0, %ACR0
66         movel   #0x00000000, %d0        /* No other regions cached */
67         movec   %d0, %ACR1
68         movel   #0x80000200, %d0        /* Setup cache mask */
69         movec   %d0, %CACR              /* Enable cache */
70         nop
71 .endm
72 #endif /* CONFIG_M528x */
73
74 #if defined(CONFIG_M5249) || defined(CONFIG_M5307)
75 /*
76  *      The version 3 core cache. Oddly enough the version 2 core 5249
77  *      has the same SDRAM and cache setup as the version 3 cores.
78  *      This is a single unified instruction/data cache.
79  */
80 .macro CACHE_ENABLE
81         movel   #0x01000000,%d0         /* invalidate whole cache */
82         movec   %d0,%CACR
83         nop
84 #if defined(DEBUGGER_COMPATIBLE_CACHE) || defined(CONFIG_SECUREEDGEMP3)
85         movel   #0x0000c000,%d0         /* set SDRAM cached (write-thru) */
86 #else
87         movel   #0x0000c020,%d0         /* set SDRAM cached (copyback) */
88 #endif
89         movec   %d0,%ACR0
90         movel   #0x00000000,%d0         /* no other regions cached */
91         movec   %d0,%ACR1
92         movel   #0xa0000200,%d0         /* enable cache */
93         movec   %d0,%CACR
94         nop
95 .endm
96 #endif /* CONFIG_M5249 || CONFIG_M5307 */
97
98 #if defined(CONFIG_M532x)
99 .macro CACHE_ENABLE
100         movel   #0x01000000,%d0         /* invalidate cache cmd */
101         movec   %d0,%CACR               /* do invalidate cache */
102         nop
103         movel   #0x4001C000,%d0         /* set SDRAM cached (write-thru) */
104         movec   %d0,%ACR0
105         movel   #0x00000000,%d0         /* no other regions cached */
106         movec   %d0,%ACR1
107         movel   #0x80000200,%d0         /* setup cache mask */
108         movec   %d0,%CACR               /* enable cache */
109         nop
110 .endm
111 #endif /* CONFIG_M532x */
112
113 #if defined(CONFIG_M5407) || defined(CONFIG_M548x)
114 /*
115  *      Version 4 cores have a true harvard style separate instruction
116  *      and data cache. Invalidate and enable cache, also enable write
117  *      buffers and branch accelerator.
118  */
119 .macro CACHE_ENABLE
120         movel   #0x01040100,%d0         /* invalidate whole cache */
121         movec   %d0,%CACR
122         nop
123         movel   #0x000fc000,%d0         /* set SDRAM cached only */
124         movec   %d0, %ACR0
125         movel   #0x00000000,%d0         /* no other regions cached */
126         movec   %d0, %ACR1
127         movel   #0x000fc000,%d0         /* set SDRAM cached only */
128         movec   %d0, %ACR2
129         movel   #0x00000000,%d0         /* no other regions cached */
130         movec   %d0, %ACR3
131         movel   #0xb6088400,%d0         /* enable caches */
132         movec   %d0,%CACR
133         nop
134 .endm
135 #endif /* CONFIG_M5407 */
136
137 #if defined(CONFIG_M520x)
138 .macro CACHE_ENABLE
139         move.l  #0x01000000,%d0         /* invalidate whole cache */
140         movec   %d0,%CACR
141         nop
142         move.l  #0x0000c000,%d0         /* set SDRAM cached (write-thru) */
143         movec   %d0,%ACR0
144         move.l  #0x00000000,%d0         /* no other regions cached */
145         movec   %d0,%ACR1
146         move.l  #0x80400000,%d0         /* enable 8K instruction cache */
147         movec   %d0,%CACR
148         nop
149 .endm
150 #endif /* CONFIG_M520x */
151
152 /* ========================================================================= */
153 /* MMU Coldfire                                                              */
154 /* ========================================================================= */
155
156 #if defined(CONFIG_M5445X) || defined(CONFIG_M547X_8X)
157
158 /*
159  * CACR Cache Control Register
160  */
161 #define CF_CACR_DEC         (0x80000000) /* Data Cache Enable                */
162 #define CF_CACR_DW          (0x40000000) /* Data default Write-protect       */
163 #define CF_CACR_DESB        (0x20000000) /* Data Enable Store Buffer         */
164 #define CF_CACR_DPI         (0x10000000) /* Data Disable CPUSHL Invalidate   */
165 #define CF_CACR_DHLCK       (0x08000000) /* 1/2 Data Cache Lock Mode         */
166 #define CF_CACR_DDCM_00     (0x00000000) /* Cacheable writethrough imprecise */
167 #define CF_CACR_DDCM_01     (0x02000000) /* Cacheable copyback               */
168 #define CF_CACR_DDCM_10     (0x04000000) /* Noncacheable precise             */
169 #define CF_CACR_DDCM_11     (0x06000000) /* Noncacheable imprecise           */
170 #define CF_CACR_DCINVA      (0x01000000) /* Data Cache Invalidate All        */
171 #define CF_CACR_DDSP        (0x00800000) /* Data default supervisor-protect  */
172 #define CF_CACR_IVO         (0x00100000) /* Invalidate only                  */
173 #define CF_CACR_BEC         (0x00080000) /* Branch Cache Enable              */
174 #define CF_CACR_BCINVA      (0x00040000) /* Branch Cache Invalidate All      */
175 #define CF_CACR_IEC         (0x00008000) /* Instruction Cache Enable         */
176 #define CF_CACR_SPA         (0x00004000) /* Search by Physical Address       */
177 #define CF_CACR_DNFB        (0x00002000) /* Default cache-inhibited fill buf */
178 #define CF_CACR_IDPI        (0x00001000) /* Instr Disable CPUSHL Invalidate  */
179 #define CF_CACR_IHLCK       (0x00000800) /* 1/2 Instruction Cache Lock Mode  */
180 #define CF_CACR_IDCM        (0x00000400) /* Noncacheable Instr default mode  */
181 #define CF_CACR_ICINVA      (0x00000100) /* Instr Cache Invalidate All       */
182 #define CF_CACR_IDSP        (0x00000080) /* Ins default supervisor-protect   */
183 #define CF_CACR_EUSP        (0x00000020) /* Switch stacks in user mode       */
184
185 #ifdef CONFIG_M5445X
186 /*
187  * M5445x Cache Configuration
188  *      - cache line size is 16 bytes
189  *      - cache is 4-way set associative
190  *      - each cache has 256 sets (64k / 16bytes / 4way)
191  *      - I-Cache size is 16KB
192  *      - D-Cache size is 16KB
193  */
194 #define ICACHE_SIZE 0x4000              /* instruction - 16k */
195 #define DCACHE_SIZE 0x4000              /* data - 16k */
196
197 #define CACHE_LINE_SIZE 0x0010          /* 16 bytes */
198 #define CACHE_SETS 0x0100               /* 256 sets */
199 #define CACHE_WAYS 0x0004               /* 4 way */
200
201 #define CACHE_DISABLE_MODE      (CF_CACR_DCINVA+        \
202                                  CF_CACR_BCINVA+        \
203                                  CF_CACR_ICINVA)
204
205 #ifndef CONFIG_M5445X_DISABLE_CACHE
206 #define CACHE_INITIAL_MODE      (CF_CACR_DEC+           \
207                                  CF_CACR_BEC+           \
208                                  CF_CACR_IEC+           \
209                                  CF_CACR_DESB+          \
210                                  CF_CACR_EUSP)
211 #else
212 /* cache disabled for testing */
213 #define CACHE_INITIAL_MODE      (CF_CACR_EUSP)
214 #endif /* CONFIG_M5445X_DISABLE_CACHE */
215
216 #elif defined(CONFIG_M547X_8X)
217 /*
218  * M547x/M548x Cache Configuration
219  *      - cache line size is 16 bytes
220  *      - cache is 4-way set associative
221  *      - each cache has 512 sets (128k / 16bytes / 4way)
222  *      - I-Cache size is 32KB
223  *      - D-Cache size is 32KB
224  */
225 #define ICACHE_SIZE 0x8000              /* instruction - 32k */
226 #define DCACHE_SIZE 0x8000              /* data - 32k */
227
228 #define CACHE_LINE_SIZE 0x0010          /* 16 bytes */
229 #define CACHE_SETS 0x0200               /* 512 sets */
230 #define CACHE_WAYS 0x0004               /* 4 way */
231
232 /* in for the old cpushl caching code */
233 #define _DCACHE_SET_MASK ((DCACHE_SIZE/64-1)<<CACHE_WAYS)
234 #define _ICACHE_SET_MASK ((ICACHE_SIZE/64-1)<<CACHE_WAYS)
235 #define LAST_DCACHE_ADDR _DCACHE_SET_MASK
236 #define LAST_ICACHE_ADDR _ICACHE_SET_MASK
237
238 #define CACHE_DISABLE_MODE      (CF_CACR_DCINVA+        \
239                                  CF_CACR_BCINVA+        \
240                                  CF_CACR_ICINVA)
241
242 #define CACHE_INITIAL_MODE      (CF_CACR_DEC+           \
243                                  CF_CACR_BEC+           \
244                                  CF_CACR_IEC+           \
245                                  CF_CACR_DESB+          \
246                                  CF_CACR_EUSP)
247 #endif /* CONFIG_M547X_8X */
248
249 #ifndef __ASSEMBLY__
250
251 extern unsigned long shadow_cacr;
252 extern void cacr_set(unsigned long x);
253
254 #endif /* !__ASSEMBLY__ */
255
256 #endif /* CONFIG_M5445X || CONFIG_M547X_8X */
257
258 /****************************************************************************/
259 #endif  /* __M68K_MCFCACHE_H */