m54xxacr.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Bit definitions for the MCF54xx ACR and CACR registers.
  3. */
  4. #ifndef m54xxacr_h
  5. #define m54xxacr_h
  6. /*
  7. * Define the Cache register flags.
  8. */
  9. #define CACR_DEC 0x80000000 /* Enable data cache */
  10. #define CACR_DWP 0x40000000 /* Data write protection */
  11. #define CACR_DESB 0x20000000 /* Enable data store buffer */
  12. #define CACR_DDPI 0x10000000 /* Disable invalidation by CPUSHL */
  13. #define CACR_DHCLK 0x08000000 /* Half data cache lock mode */
  14. #define CACR_DDCM_WT 0x00000000 /* Write through cache*/
  15. #define CACR_DDCM_CP 0x02000000 /* Copyback cache */
  16. #define CACR_DDCM_P 0x04000000 /* No cache, precise */
  17. #define CACR_DDCM_IMP 0x06000000 /* No cache, imprecise */
  18. #define CACR_DCINVA 0x01000000 /* Invalidate data cache */
  19. #define CACR_BEC 0x00080000 /* Enable branch cache */
  20. #define CACR_BCINVA 0x00040000 /* Invalidate branch cache */
  21. #define CACR_IEC 0x00008000 /* Enable instruction cache */
  22. #define CACR_DNFB 0x00002000 /* Inhibited fill buffer */
  23. #define CACR_IDPI 0x00001000 /* Disable CPUSHL */
  24. #define CACR_IHLCK 0x00000800 /* Intruction cache half lock */
  25. #define CACR_IDCM 0x00000400 /* Intruction cache inhibit */
  26. #define CACR_ICINVA 0x00000100 /* Invalidate instr cache */
  27. #define CACR_EUSP 0x00000020 /* Enable separate user a7 */
  28. #define ACR_BASE_POS 24 /* Address Base */
  29. #define ACR_MASK_POS 16 /* Address Mask */
  30. #define ACR_ENABLE 0x00008000 /* Enable address */
  31. #define ACR_USER 0x00000000 /* User mode access only */
  32. #define ACR_SUPER 0x00002000 /* Supervisor mode only */
  33. #define ACR_ANY 0x00004000 /* Match any access mode */
  34. #define ACR_CM_WT 0x00000000 /* Write through mode */
  35. #define ACR_CM_CP 0x00000020 /* Copyback mode */
  36. #define ACR_CM_OFF_PRE 0x00000040 /* No cache, precise */
  37. #define ACR_CM_OFF_IMP 0x00000060 /* No cache, imprecise */
  38. #define ACR_CM 0x00000060 /* Cache mode mask */
  39. #define ACR_SP 0x00000008 /* Supervisor protect */
  40. #define ACR_WPROTECT 0x00000004 /* Write protect */
  41. #define ACR_BA(x) ((x) & 0xff000000)
  42. #define ACR_ADMSK(x) ((((x) - 1) & 0xff000000) >> 8)
  43. #if defined(CONFIG_M5407)
  44. #define ICACHE_SIZE 0x4000 /* instruction - 16k */
  45. #define DCACHE_SIZE 0x2000 /* data - 8k */
  46. #elif defined(CONFIG_M54xx)
  47. #define ICACHE_SIZE 0x8000 /* instruction - 32k */
  48. #define DCACHE_SIZE 0x8000 /* data - 32k */
  49. #endif
  50. #define CACHE_LINE_SIZE 0x0010 /* 16 bytes */
  51. #define CACHE_WAYS 4 /* 4 ways */
  52. #define ICACHE_SET_MASK ((ICACHE_SIZE / 64 - 1) << CACHE_WAYS)
  53. #define DCACHE_SET_MASK ((DCACHE_SIZE / 64 - 1) << CACHE_WAYS)
  54. #define ICACHE_MAX_ADDR ICACHE_SET_MASK
  55. #define DCACHE_MAX_ADDR DCACHE_SET_MASK
  56. /*
  57. * Version 4 cores have a true harvard style separate instruction
  58. * and data cache. Enable data and instruction caches, also enable write
  59. * buffers and branch accelerator.
  60. */
  61. /* attention : enabling CACR_DESB requires a "nop" to flush the store buffer */
  62. /* use '+' instead of '|' for assembler's sake */
  63. /* Enable data cache */
  64. /* Enable data store buffer */
  65. /* outside ACRs : No cache, precise */
  66. /* Enable instruction+branch caches */
  67. #if defined(CONFIG_M5407)
  68. #define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC)
  69. #else
  70. #define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC+CACR_EUSP)
  71. #endif
  72. #define CACHE_INIT (CACR_DCINVA+CACR_BCINVA+CACR_ICINVA)
  73. #if defined(CONFIG_MMU)
  74. /*
  75. * If running with the MMU enabled then we need to map the internal
  76. * register region as non-cacheable. And then we map all our RAM as
  77. * cacheable and supervisor access only.
  78. */
  79. #define ACR0_MODE (ACR_BA(CONFIG_MBAR)+ACR_ADMSK(0x1000000)+ \
  80. ACR_ENABLE+ACR_SUPER+ACR_CM_OFF_PRE+ACR_SP)
  81. #define ACR1_MODE (ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
  82. ACR_ENABLE+ACR_SUPER+ACR_SP)
  83. #define ACR2_MODE 0
  84. #define ACR3_MODE (ACR_BA(CONFIG_RAMBASE)+ACR_ADMSK(CONFIG_RAMSIZE)+ \
  85. ACR_ENABLE+ACR_SUPER+ACR_SP)
  86. #else
  87. /*
  88. * For the non-MMU enabled case we map all of RAM as cacheable.
  89. */
  90. #if defined(CONFIG_CACHE_COPYBACK)
  91. #define DATA_CACHE_MODE (ACR_ENABLE+ACR_ANY+ACR_CM_CP)
  92. #else
  93. #define DATA_CACHE_MODE (ACR_ENABLE+ACR_ANY+ACR_CM_WT)
  94. #endif
  95. #define INSN_CACHE_MODE (ACR_ENABLE+ACR_ANY)
  96. #define CACHE_INVALIDATE (CACHE_MODE+CACR_DCINVA+CACR_BCINVA+CACR_ICINVA)
  97. #define CACHE_INVALIDATEI (CACHE_MODE+CACR_BCINVA+CACR_ICINVA)
  98. #define CACHE_INVALIDATED (CACHE_MODE+CACR_DCINVA)
  99. #define ACR0_MODE (0x000f0000+DATA_CACHE_MODE)
  100. #define ACR1_MODE 0
  101. #define ACR2_MODE (0x000f0000+INSN_CACHE_MODE)
  102. #define ACR3_MODE 0
  103. #if ((DATA_CACHE_MODE & ACR_CM) == ACR_CM_CP)
  104. /* Copyback cache mode must push dirty cache lines first */
  105. #define CACHE_PUSH
  106. #endif
  107. #endif /* CONFIG_MMU */
  108. #endif /* m54xxacr_h */