1 /****************************************************************************/
4 * mcfcache.h -- ColdFire CPU cache support code
6 * (C) Copyright 2004, Greg Ungerer <gerg@snapgear.com>
9 /****************************************************************************/
10 #ifndef __M68K_MCFCACHE_H
11 #define __M68K_MCFCACHE_H
12 /****************************************************************************/
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.
21 /* ========================================================================= */
23 /* ========================================================================= */
25 #if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || defined(CONFIG_M5272)
27 * Simple version 2 core cache. These have instruction cache only,
28 * we just need to invalidate it and enable it.
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 */
36 #endif /* CONFIG_M5206 || CONFIG_M5206e || CONFIG_M5272 */
38 #if defined(CONFIG_M523x) || defined(CONFIG_M527x)
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.
46 movec %d0,%CACR /* invalidate cache */
48 movel #0x0000c000,%d0 /* set SDRAM cached only */
50 movel #0x00000000,%d0 /* no other regions cached */
52 movel #0x80400100,%d0 /* configure cache */
53 movec %d0,%CACR /* enable cache */
56 #endif /* CONFIG_M523x || CONFIG_M527x */
58 #if defined(CONFIG_M528x)
61 movel #0x01000000, %d0
62 movec %d0, %CACR /* Invalidate cache */
64 movel #0x0000c020, %d0 /* Set SDRAM cached only */
66 movel #0x00000000, %d0 /* No other regions cached */
68 movel #0x80000200, %d0 /* Setup cache mask */
69 movec %d0, %CACR /* Enable cache */
72 #endif /* CONFIG_M528x */
74 #if defined(CONFIG_M5249) || defined(CONFIG_M5307)
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.
81 movel #0x01000000,%d0 /* invalidate whole cache */
84 #if defined(DEBUGGER_COMPATIBLE_CACHE) || defined(CONFIG_SECUREEDGEMP3)
85 movel #0x0000c000,%d0 /* set SDRAM cached (write-thru) */
87 movel #0x0000c020,%d0 /* set SDRAM cached (copyback) */
90 movel #0x00000000,%d0 /* no other regions cached */
92 movel #0xa0000200,%d0 /* enable cache */
96 #endif /* CONFIG_M5249 || CONFIG_M5307 */
98 #if defined(CONFIG_M532x)
100 movel #0x01000000,%d0 /* invalidate cache cmd */
101 movec %d0,%CACR /* do invalidate cache */
103 movel #0x4001C000,%d0 /* set SDRAM cached (write-thru) */
105 movel #0x00000000,%d0 /* no other regions cached */
107 movel #0x80000200,%d0 /* setup cache mask */
108 movec %d0,%CACR /* enable cache */
111 #endif /* CONFIG_M532x */
113 #if defined(CONFIG_M5407) || defined(CONFIG_M548x)
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.
120 movel #0x01040100,%d0 /* invalidate whole cache */
123 movel #0x000fc000,%d0 /* set SDRAM cached only */
125 movel #0x00000000,%d0 /* no other regions cached */
127 movel #0x000fc000,%d0 /* set SDRAM cached only */
129 movel #0x00000000,%d0 /* no other regions cached */
131 movel #0xb6088400,%d0 /* enable caches */
135 #endif /* CONFIG_M5407 */
137 #if defined(CONFIG_M520x)
139 move.l #0x01000000,%d0 /* invalidate whole cache */
142 move.l #0x0000c000,%d0 /* set SDRAM cached (write-thru) */
144 move.l #0x00000000,%d0 /* no other regions cached */
146 move.l #0x80400000,%d0 /* enable 8K instruction cache */
150 #endif /* CONFIG_M520x */
152 /* ========================================================================= */
154 /* ========================================================================= */
156 #if defined(CONFIG_M5445X) || defined(CONFIG_M547X_8X)
159 * CACR Cache Control Register
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 */
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
194 #define ICACHE_SIZE 0x4000 /* instruction - 16k */
195 #define DCACHE_SIZE 0x4000 /* data - 16k */
197 #define CACHE_LINE_SIZE 0x0010 /* 16 bytes */
198 #define CACHE_SETS 0x0100 /* 256 sets */
199 #define CACHE_WAYS 0x0004 /* 4 way */
201 #define CACHE_DISABLE_MODE (CF_CACR_DCINVA+ \
205 #ifndef CONFIG_M5445X_DISABLE_CACHE
206 #define CACHE_INITIAL_MODE (CF_CACR_DEC+ \
212 /* cache disabled for testing */
213 #define CACHE_INITIAL_MODE (CF_CACR_EUSP)
214 #endif /* CONFIG_M5445X_DISABLE_CACHE */
216 #elif defined(CONFIG_M547X_8X)
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
225 #define ICACHE_SIZE 0x8000 /* instruction - 32k */
226 #define DCACHE_SIZE 0x8000 /* data - 32k */
228 #define CACHE_LINE_SIZE 0x0010 /* 16 bytes */
229 #define CACHE_SETS 0x0200 /* 512 sets */
230 #define CACHE_WAYS 0x0004 /* 4 way */
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
238 #define CACHE_DISABLE_MODE (CF_CACR_DCINVA+ \
242 #define CACHE_INITIAL_MODE (CF_CACR_DEC+ \
247 #endif /* CONFIG_M547X_8X */
251 extern unsigned long shadow_cacr;
252 extern void cacr_set(unsigned long x);
254 #endif /* !__ASSEMBLY__ */
256 #endif /* CONFIG_M5445X || CONFIG_M547X_8X */
258 /****************************************************************************/
259 #endif /* __M68K_MCFCACHE_H */