Philippe De Muyter | 5291fa9 | 2010-10-27 14:57:47 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Bit definitions for the MCF54xx ACR and CACR registers. |
| 3 | */ |
| 4 | |
| 5 | #ifndef m54xxacr_h |
| 6 | #define m54xxacr_h |
| 7 | |
| 8 | /* |
| 9 | * Define the Cache register flags. |
| 10 | */ |
| 11 | #define CACR_DEC 0x80000000 /* Enable data cache */ |
| 12 | #define CACR_DWP 0x40000000 /* Data write protection */ |
| 13 | #define CACR_DESB 0x20000000 /* Enable data store buffer */ |
| 14 | #define CACR_DDPI 0x10000000 /* Disable invalidation by CPUSHL */ |
| 15 | #define CACR_DHCLK 0x08000000 /* Half data cache lock mode */ |
| 16 | #define CACR_DDCM_WT 0x00000000 /* Write through cache*/ |
| 17 | #define CACR_DDCM_CP 0x02000000 /* Copyback cache */ |
| 18 | #define CACR_DDCM_P 0x04000000 /* No cache, precise */ |
| 19 | #define CACR_DDCM_IMP 0x06000000 /* No cache, imprecise */ |
| 20 | #define CACR_DCINVA 0x01000000 /* Invalidate data cache */ |
| 21 | #define CACR_BEC 0x00080000 /* Enable branch cache */ |
| 22 | #define CACR_BCINVA 0x00040000 /* Invalidate branch cache */ |
| 23 | #define CACR_IEC 0x00008000 /* Enable instruction cache */ |
| 24 | #define CACR_DNFB 0x00002000 /* Inhibited fill buffer */ |
| 25 | #define CACR_IDPI 0x00001000 /* Disable CPUSHL */ |
| 26 | #define CACR_IHLCK 0x00000800 /* Intruction cache half lock */ |
| 27 | #define CACR_IDCM 0x00000400 /* Intruction cache inhibit */ |
| 28 | #define CACR_ICINVA 0x00000100 /* Invalidate instr cache */ |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 29 | #define CACR_EUSP 0x00000020 /* Enable separate user a7 */ |
Philippe De Muyter | 5291fa9 | 2010-10-27 14:57:47 +0200 | [diff] [blame] | 30 | |
| 31 | #define ACR_BASE_POS 24 /* Address Base */ |
| 32 | #define ACR_MASK_POS 16 /* Address Mask */ |
| 33 | #define ACR_ENABLE 0x00008000 /* Enable address */ |
| 34 | #define ACR_USER 0x00000000 /* User mode access only */ |
| 35 | #define ACR_SUPER 0x00002000 /* Supervisor mode only */ |
| 36 | #define ACR_ANY 0x00004000 /* Match any access mode */ |
| 37 | #define ACR_CM_WT 0x00000000 /* Write through mode */ |
| 38 | #define ACR_CM_CP 0x00000020 /* Copyback mode */ |
| 39 | #define ACR_CM_OFF_PRE 0x00000040 /* No cache, precise */ |
| 40 | #define ACR_CM_OFF_IMP 0x00000060 /* No cache, imprecise */ |
| 41 | #define ACR_CM 0x00000060 /* Cache mode mask */ |
| 42 | #define ACR_WPROTECT 0x00000004 /* Write protect */ |
| 43 | |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 44 | #if defined(CONFIG_M5407) |
| 45 | |
| 46 | #define ICACHE_SIZE 0x4000 /* instruction - 16k */ |
| 47 | #define DCACHE_SIZE 0x2000 /* data - 8k */ |
| 48 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 49 | #elif defined(CONFIG_M54xx) |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 50 | |
| 51 | #define ICACHE_SIZE 0x8000 /* instruction - 32k */ |
| 52 | #define DCACHE_SIZE 0x8000 /* data - 32k */ |
| 53 | |
| 54 | #endif |
| 55 | |
| 56 | #define CACHE_LINE_SIZE 0x0010 /* 16 bytes */ |
| 57 | #define CACHE_WAYS 4 /* 4 ways */ |
| 58 | |
| 59 | /* |
| 60 | * Version 4 cores have a true harvard style separate instruction |
| 61 | * and data cache. Enable data and instruction caches, also enable write |
| 62 | * buffers and branch accelerator. |
| 63 | */ |
| 64 | /* attention : enabling CACR_DESB requires a "nop" to flush the store buffer */ |
| 65 | /* use '+' instead of '|' for assembler's sake */ |
| 66 | |
| 67 | /* Enable data cache */ |
| 68 | /* Enable data store buffer */ |
| 69 | /* outside ACRs : No cache, precise */ |
| 70 | /* Enable instruction+branch caches */ |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 71 | #if defined(CONFIG_M5407) |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 72 | #define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC) |
Greg Ungerer | 1c83af5 | 2010-11-04 13:53:26 +1000 | [diff] [blame] | 73 | #else |
| 74 | #define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC+CACR_EUSP) |
| 75 | #endif |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 76 | #define DATA_CACHE_MODE (ACR_ENABLE+ACR_ANY+ACR_CM_WT) |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 77 | #define INSN_CACHE_MODE (ACR_ENABLE+ACR_ANY) |
| 78 | |
Greg Ungerer | 8ce877a | 2010-11-09 13:35:55 +1000 | [diff] [blame^] | 79 | #define CACHE_INIT (CACR_DCINVA+CACR_BCINVA+CACR_ICINVA) |
| 80 | #define CACHE_INVALIDATE (CACHE_MODE+CACR_DCINVA+CACR_BCINVA+CACR_ICINVA) |
| 81 | #define ACR0_MODE (0x000f0000+DATA_CACHE_MODE) |
| 82 | #define ACR1_MODE 0 |
| 83 | #define ACR2_MODE (0x000f0000+INSN_CACHE_MODE) |
| 84 | #define ACR3_MODE 0 |
| 85 | |
Philippe De Muyter | b3d75b0 | 2010-10-27 14:57:48 +0200 | [diff] [blame] | 86 | #ifndef __ASSEMBLY__ |
| 87 | |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 88 | #if ((DATA_CACHE_MODE & ACR_CM) == ACR_CM_WT) |
| 89 | #define flush_dcache_range(a, l) do { asm("nop"); } while (0) |
| 90 | #endif |
| 91 | |
Philippe De Muyter | b3d75b0 | 2010-10-27 14:57:48 +0200 | [diff] [blame] | 92 | static inline void __m54xx_flush_cache_all(void) |
| 93 | { |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 94 | __asm__ __volatile__ ( |
| 95 | #if ((DATA_CACHE_MODE & ACR_CM) == ACR_CM_CP) |
Philippe De Muyter | b3d75b0 | 2010-10-27 14:57:48 +0200 | [diff] [blame] | 96 | /* |
| 97 | * Use cpushl to push and invalidate all cache lines. |
| 98 | * Gas doesn't seem to know how to generate the ColdFire |
| 99 | * cpushl instruction... Oh well, bit stuff it for now. |
| 100 | */ |
Philippe De Muyter | b3d75b0 | 2010-10-27 14:57:48 +0200 | [diff] [blame] | 101 | "clrl %%d0\n\t" |
| 102 | "1:\n\t" |
| 103 | "movel %%d0,%%a0\n\t" |
| 104 | "2:\n\t" |
| 105 | ".word 0xf468\n\t" |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 106 | "addl %0,%%a0\n\t" |
| 107 | "cmpl %1,%%a0\n\t" |
Philippe De Muyter | b3d75b0 | 2010-10-27 14:57:48 +0200 | [diff] [blame] | 108 | "blt 2b\n\t" |
| 109 | "addql #1,%%d0\n\t" |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 110 | "cmpil %2,%%d0\n\t" |
Philippe De Muyter | b3d75b0 | 2010-10-27 14:57:48 +0200 | [diff] [blame] | 111 | "bne 1b\n\t" |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 112 | #endif |
| 113 | "movel %3,%%d0\n\t" |
Philippe De Muyter | b3d75b0 | 2010-10-27 14:57:48 +0200 | [diff] [blame] | 114 | "movec %%d0,%%CACR\n\t" |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 115 | "nop\n\t" /* forces flush of Store Buffer */ |
| 116 | : /* No output */ |
| 117 | : "i" (CACHE_LINE_SIZE), |
| 118 | "i" (DCACHE_SIZE / CACHE_WAYS), |
| 119 | "i" (CACHE_WAYS), |
Greg Ungerer | 8ce877a | 2010-11-09 13:35:55 +1000 | [diff] [blame^] | 120 | "i" (CACHE_INVALIDATE) |
Philippe De Muyter | 9c68015 | 2010-10-27 14:57:49 +0200 | [diff] [blame] | 121 | : "d0", "a0" ); |
Philippe De Muyter | b3d75b0 | 2010-10-27 14:57:48 +0200 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | #define __flush_cache_all() __m54xx_flush_cache_all() |
| 125 | |
| 126 | #endif /* __ASSEMBLY__ */ |
| 127 | |
Philippe De Muyter | 5291fa9 | 2010-10-27 14:57:47 +0200 | [diff] [blame] | 128 | #endif /* m54xxacr_h */ |