blob: 6d13cae44af530240b99b83e4248288ee939ae69 [file] [log] [blame]
Philippe De Muyter5291fa92010-10-27 14:57:47 +02001/*
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 Ungerer1c83af52010-11-04 13:53:26 +100029#define CACR_EUSP 0x00000020 /* Enable separate user a7 */
Philippe De Muyter5291fa92010-10-27 14:57:47 +020030
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 */
Greg Ungerer0b0b8082011-10-17 14:56:45 +100042#define ACR_SP 0x00000008 /* Supervisor protect */
Philippe De Muyter5291fa92010-10-27 14:57:47 +020043#define ACR_WPROTECT 0x00000004 /* Write protect */
44
Greg Ungerer0b0b8082011-10-17 14:56:45 +100045#define ACR_BA(x) ((x) & 0xff000000)
46#define ACR_ADMSK(x) ((((x) - 1) & 0xff000000) >> 8)
47
Philippe De Muyter9c680152010-10-27 14:57:49 +020048#if defined(CONFIG_M5407)
49
50#define ICACHE_SIZE 0x4000 /* instruction - 16k */
51#define DCACHE_SIZE 0x2000 /* data - 8k */
52
Greg Ungerer5b2e6552010-11-02 12:05:29 +100053#elif defined(CONFIG_M54xx)
Philippe De Muyter9c680152010-10-27 14:57:49 +020054
55#define ICACHE_SIZE 0x8000 /* instruction - 32k */
56#define DCACHE_SIZE 0x8000 /* data - 32k */
57
Steven Kingbea8bcb2012-06-06 14:28:31 -070058#elif defined(CONFIG_M5441x)
59
60#define ICACHE_SIZE 0x2000 /* instruction - 8k */
61#define DCACHE_SIZE 0x2000 /* data - 8k */
Philippe De Muyter9c680152010-10-27 14:57:49 +020062#endif
63
64#define CACHE_LINE_SIZE 0x0010 /* 16 bytes */
65#define CACHE_WAYS 4 /* 4 ways */
66
Greg Ungerer0b0b8082011-10-17 14:56:45 +100067#define ICACHE_SET_MASK ((ICACHE_SIZE / 64 - 1) << CACHE_WAYS)
68#define DCACHE_SET_MASK ((DCACHE_SIZE / 64 - 1) << CACHE_WAYS)
69#define ICACHE_MAX_ADDR ICACHE_SET_MASK
70#define DCACHE_MAX_ADDR DCACHE_SET_MASK
71
Philippe De Muyter9c680152010-10-27 14:57:49 +020072/*
73 * Version 4 cores have a true harvard style separate instruction
74 * and data cache. Enable data and instruction caches, also enable write
75 * buffers and branch accelerator.
76 */
77/* attention : enabling CACR_DESB requires a "nop" to flush the store buffer */
78/* use '+' instead of '|' for assembler's sake */
79
80 /* Enable data cache */
81 /* Enable data store buffer */
82 /* outside ACRs : No cache, precise */
83 /* Enable instruction+branch caches */
Greg Ungerer1c83af52010-11-04 13:53:26 +100084#if defined(CONFIG_M5407)
Philippe De Muyter9c680152010-10-27 14:57:49 +020085#define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC)
Greg Ungerer1c83af52010-11-04 13:53:26 +100086#else
87#define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC+CACR_EUSP)
88#endif
Greg Ungerer0b0b8082011-10-17 14:56:45 +100089#define CACHE_INIT (CACR_DCINVA+CACR_BCINVA+CACR_ICINVA)
90
91#if defined(CONFIG_MMU)
92/*
93 * If running with the MMU enabled then we need to map the internal
94 * register region as non-cacheable. And then we map all our RAM as
95 * cacheable and supervisor access only.
96 */
97#define ACR0_MODE (ACR_BA(CONFIG_MBAR)+ACR_ADMSK(0x1000000)+ \
98 ACR_ENABLE+ACR_SUPER+ACR_CM_OFF_PRE+ACR_SP)
Stany MARCELa4eff482012-10-16 15:26:11 +100099#if defined(CONFIG_CACHE_COPYBACK)
Greg Ungerer0b0b8082011-10-17 14:56:45 +1000100#define ACR1_MODE (ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
Stany MARCELa4eff482012-10-16 15:26:11 +1000101 ACR_ENABLE+ACR_SUPER+ACR_SP+ACR_CM_CP)
102#else
103#define ACR1_MODE (ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
104 ACR_ENABLE+ACR_SUPER+ACR_SP+ACR_CM_WT)
105#endif
Greg Ungerer0b0b8082011-10-17 14:56:45 +1000106#define ACR2_MODE 0
107#define ACR3_MODE (ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
108 ACR_ENABLE+ACR_SUPER+ACR_SP)
109
110#else
111
112/*
113 * For the non-MMU enabled case we map all of RAM as cacheable.
114 */
Greg Ungerer4a5bae42010-11-09 16:00:17 +1000115#if defined(CONFIG_CACHE_COPYBACK)
116#define DATA_CACHE_MODE (ACR_ENABLE+ACR_ANY+ACR_CM_CP)
117#else
Philippe De Muyter9c680152010-10-27 14:57:49 +0200118#define DATA_CACHE_MODE (ACR_ENABLE+ACR_ANY+ACR_CM_WT)
Greg Ungerer4a5bae42010-11-09 16:00:17 +1000119#endif
Philippe De Muyter9c680152010-10-27 14:57:49 +0200120#define INSN_CACHE_MODE (ACR_ENABLE+ACR_ANY)
121
Greg Ungerer07ffee52010-11-10 15:22:19 +1000122#define CACHE_INVALIDATE (CACHE_MODE+CACR_DCINVA+CACR_BCINVA+CACR_ICINVA)
123#define CACHE_INVALIDATEI (CACHE_MODE+CACR_BCINVA+CACR_ICINVA)
124#define CACHE_INVALIDATED (CACHE_MODE+CACR_DCINVA)
Greg Ungerer8ce877a2010-11-09 13:35:55 +1000125#define ACR0_MODE (0x000f0000+DATA_CACHE_MODE)
126#define ACR1_MODE 0
127#define ACR2_MODE (0x000f0000+INSN_CACHE_MODE)
128#define ACR3_MODE 0
129
Philippe De Muyter9c680152010-10-27 14:57:49 +0200130#if ((DATA_CACHE_MODE & ACR_CM) == ACR_CM_CP)
Greg Ungererd475e3e42010-11-09 14:27:50 +1000131/* Copyback cache mode must push dirty cache lines first */
132#define CACHE_PUSH
Philippe De Muyter9c680152010-10-27 14:57:49 +0200133#endif
Philippe De Muyterb3d75b02010-10-27 14:57:48 +0200134
Greg Ungerer0b0b8082011-10-17 14:56:45 +1000135#endif /* CONFIG_MMU */
Philippe De Muyter5291fa92010-10-27 14:57:47 +0200136#endif /* m54xxacr_h */