aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
authorPhilippe De Muyter <phdm@macqel.be>2010-10-27 08:57:49 -0400
committerGreg Ungerer <gerg@uclinux.org>2011-01-05 00:19:17 -0500
commit9c68015b149d45a35114b4a1ed44c21fa66bc430 (patch)
tree28a0cda93fb4bdd88a23333261c16d83ed8d96dc /arch/m68k
parentb3d75b09bf8998fd302ba339eebbc768a110741b (diff)
m68knommu: Use symbolic constants for cache operations on M54xx
Now that we have meaningfull symbolic constants for bit definitions of the cache registers of m5407 and m548x chips, use them to improve readability, portability and efficiency of the cache operations. This also fixes __flush_cache_all for m548x chips : implicit DCACHE_SIZE was exact for m5407, but wrong for m548x. Signed-off-by: Philippe De Muyter <phdm@macqel.be> Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/include/asm/cacheflush_no.h2
-rw-r--r--arch/m68k/include/asm/m54xxacr.h58
-rw-r--r--arch/m68k/include/asm/mcfcache.h22
3 files changed, 65 insertions, 17 deletions
diff --git a/arch/m68k/include/asm/cacheflush_no.h b/arch/m68k/include/asm/cacheflush_no.h
index 8fda331f8a8..29f76204ce1 100644
--- a/arch/m68k/include/asm/cacheflush_no.h
+++ b/arch/m68k/include/asm/cacheflush_no.h
@@ -14,7 +14,9 @@
14#define flush_cache_dup_mm(mm) do { } while (0) 14#define flush_cache_dup_mm(mm) do { } while (0)
15#define flush_cache_range(vma, start, end) __flush_cache_all() 15#define flush_cache_range(vma, start, end) __flush_cache_all()
16#define flush_cache_page(vma, vmaddr) do { } while (0) 16#define flush_cache_page(vma, vmaddr) do { } while (0)
17#ifndef flush_dcache_range
17#define flush_dcache_range(start,len) __flush_cache_all() 18#define flush_dcache_range(start,len) __flush_cache_all()
19#endif
18#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 20#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
19#define flush_dcache_page(page) do { } while (0) 21#define flush_dcache_page(page) do { } while (0)
20#define flush_dcache_mmap_lock(mapping) do { } while (0) 22#define flush_dcache_mmap_lock(mapping) do { } while (0)
diff --git a/arch/m68k/include/asm/m54xxacr.h b/arch/m68k/include/asm/m54xxacr.h
index da713d22dd0..7d28da4d622 100644
--- a/arch/m68k/include/asm/m54xxacr.h
+++ b/arch/m68k/include/asm/m54xxacr.h
@@ -40,31 +40,75 @@
40#define ACR_CM 0x00000060 /* Cache mode mask */ 40#define ACR_CM 0x00000060 /* Cache mode mask */
41#define ACR_WPROTECT 0x00000004 /* Write protect */ 41#define ACR_WPROTECT 0x00000004 /* Write protect */
42 42
43#if defined(CONFIG_M5407)
44
45#define ICACHE_SIZE 0x4000 /* instruction - 16k */
46#define DCACHE_SIZE 0x2000 /* data - 8k */
47
48#elif defined(CONFIG_M548x)
49
50#define ICACHE_SIZE 0x8000 /* instruction - 32k */
51#define DCACHE_SIZE 0x8000 /* data - 32k */
52
53#endif
54
55#define CACHE_LINE_SIZE 0x0010 /* 16 bytes */
56#define CACHE_WAYS 4 /* 4 ways */
57
58/*
59 * Version 4 cores have a true harvard style separate instruction
60 * and data cache. Enable data and instruction caches, also enable write
61 * buffers and branch accelerator.
62 */
63/* attention : enabling CACR_DESB requires a "nop" to flush the store buffer */
64/* use '+' instead of '|' for assembler's sake */
65
66 /* Enable data cache */
67 /* Enable data store buffer */
68 /* outside ACRs : No cache, precise */
69 /* Enable instruction+branch caches */
70#define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC)
71
72#define DATA_CACHE_MODE (ACR_ENABLE+ACR_ANY+ACR_CM_WT)
73
74#define INSN_CACHE_MODE (ACR_ENABLE+ACR_ANY)
75
43#ifndef __ASSEMBLY__ 76#ifndef __ASSEMBLY__
44 77
78#if ((DATA_CACHE_MODE & ACR_CM) == ACR_CM_WT)
79#define flush_dcache_range(a, l) do { asm("nop"); } while (0)
80#endif
81
45static inline void __m54xx_flush_cache_all(void) 82static inline void __m54xx_flush_cache_all(void)
46{ 83{
84 __asm__ __volatile__ (
85#if ((DATA_CACHE_MODE & ACR_CM) == ACR_CM_CP)
47 /* 86 /*
48 * Use cpushl to push and invalidate all cache lines. 87 * Use cpushl to push and invalidate all cache lines.
49 * Gas doesn't seem to know how to generate the ColdFire 88 * Gas doesn't seem to know how to generate the ColdFire
50 * cpushl instruction... Oh well, bit stuff it for now. 89 * cpushl instruction... Oh well, bit stuff it for now.
51 */ 90 */
52 __asm__ __volatile__ (
53 "nop\n\t"
54 "clrl %%d0\n\t" 91 "clrl %%d0\n\t"
55 "1:\n\t" 92 "1:\n\t"
56 "movel %%d0,%%a0\n\t" 93 "movel %%d0,%%a0\n\t"
57 "2:\n\t" 94 "2:\n\t"
58 ".word 0xf468\n\t" 95 ".word 0xf468\n\t"
59 "addl #0x10,%%a0\n\t" 96 "addl %0,%%a0\n\t"
60 "cmpl #0x00000800,%%a0\n\t" 97 "cmpl %1,%%a0\n\t"
61 "blt 2b\n\t" 98 "blt 2b\n\t"
62 "addql #1,%%d0\n\t" 99 "addql #1,%%d0\n\t"
63 "cmpil #4,%%d0\n\t" 100 "cmpil %2,%%d0\n\t"
64 "bne 1b\n\t" 101 "bne 1b\n\t"
65 "movel #0xb6088500,%%d0\n\t" 102#endif
103 "movel %3,%%d0\n\t"
66 "movec %%d0,%%CACR\n\t" 104 "movec %%d0,%%CACR\n\t"
67 : : : "d0", "a0" ); 105 "nop\n\t" /* forces flush of Store Buffer */
106 : /* No output */
107 : "i" (CACHE_LINE_SIZE),
108 "i" (DCACHE_SIZE / CACHE_WAYS),
109 "i" (CACHE_WAYS),
110 "i" (CACHE_MODE|CACR_DCINVA|CACR_BCINVA|CACR_ICINVA)
111 : "d0", "a0" );
68} 112}
69 113
70#define __flush_cache_all() __m54xx_flush_cache_all() 114#define __flush_cache_all() __m54xx_flush_cache_all()
diff --git a/arch/m68k/include/asm/mcfcache.h b/arch/m68k/include/asm/mcfcache.h
index f49dfc09f70..7acb406d601 100644
--- a/arch/m68k/include/asm/mcfcache.h
+++ b/arch/m68k/include/asm/mcfcache.h
@@ -108,28 +108,30 @@
108#endif /* CONFIG_M532x */ 108#endif /* CONFIG_M532x */
109 109
110#if defined(CONFIG_M5407) || defined(CONFIG_M548x) 110#if defined(CONFIG_M5407) || defined(CONFIG_M548x)
111/* 111
112 * Version 4 cores have a true harvard style separate instruction 112#include <asm/m54xxacr.h>
113 * and data cache. Invalidate and enable cache, also enable write 113
114 * buffers and branch accelerator.
115 */
116.macro CACHE_ENABLE 114.macro CACHE_ENABLE
117 movel #0x01040100,%d0 /* invalidate whole cache */ 115 /* invalidate whole cache */
116 movel #(CACR_DCINVA+CACR_BCINVA+CACR_ICINVA),%d0
118 movec %d0,%CACR 117 movec %d0,%CACR
119 nop 118 nop
120 movel #0x000fc000,%d0 /* set SDRAM cached only */ 119 /* addresses range for data cache : 0x00000000-0x0fffffff */
120 movel #(0x000f0000+DATA_CACHE_MODE),%d0 /* set SDRAM cached */
121 movec %d0, %ACR0 121 movec %d0, %ACR0
122 movel #0x00000000,%d0 /* no other regions cached */ 122 movel #0x00000000,%d0 /* no other regions cached */
123 movec %d0, %ACR1 123 movec %d0, %ACR1
124 movel #0x000fc000,%d0 /* set SDRAM cached only */ 124 /* addresses range for instruction cache : 0x00000000-0x0fffffff */
125 movel #(0x000f0000+INSN_CACHE_MODE),%d0 /* set SDRAM cached */
125 movec %d0, %ACR2 126 movec %d0, %ACR2
126 movel #0x00000000,%d0 /* no other regions cached */ 127 movel #0x00000000,%d0 /* no other regions cached */
127 movec %d0, %ACR3 128 movec %d0, %ACR3
128 movel #0xb6088400,%d0 /* enable caches */ 129 /* enable caches */
130 movel #(CACHE_MODE),%d0
129 movec %d0,%CACR 131 movec %d0,%CACR
130 nop 132 nop
131.endm 133.endm
132#endif /* CONFIG_M5407 */ 134#endif /* CONFIG_M5407 || CONFIG_M548x */
133 135
134#if defined(CONFIG_M520x) 136#if defined(CONFIG_M520x)
135.macro CACHE_ENABLE 137.macro CACHE_ENABLE