m54xxacr.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 ACR_BASE_POS 24 /* Address Base */
  28. #define ACR_MASK_POS 16 /* Address Mask */
  29. #define ACR_ENABLE 0x00008000 /* Enable address */
  30. #define ACR_USER 0x00000000 /* User mode access only */
  31. #define ACR_SUPER 0x00002000 /* Supervisor mode only */
  32. #define ACR_ANY 0x00004000 /* Match any access mode */
  33. #define ACR_CM_WT 0x00000000 /* Write through mode */
  34. #define ACR_CM_CP 0x00000020 /* Copyback mode */
  35. #define ACR_CM_OFF_PRE 0x00000040 /* No cache, precise */
  36. #define ACR_CM_OFF_IMP 0x00000060 /* No cache, imprecise */
  37. #define ACR_CM 0x00000060 /* Cache mode mask */
  38. #define ACR_WPROTECT 0x00000004 /* Write protect */
  39. #if defined(CONFIG_M5407)
  40. #define ICACHE_SIZE 0x4000 /* instruction - 16k */
  41. #define DCACHE_SIZE 0x2000 /* data - 8k */
  42. #elif defined(CONFIG_M548x)
  43. #define ICACHE_SIZE 0x8000 /* instruction - 32k */
  44. #define DCACHE_SIZE 0x8000 /* data - 32k */
  45. #endif
  46. #define CACHE_LINE_SIZE 0x0010 /* 16 bytes */
  47. #define CACHE_WAYS 4 /* 4 ways */
  48. /*
  49. * Version 4 cores have a true harvard style separate instruction
  50. * and data cache. Enable data and instruction caches, also enable write
  51. * buffers and branch accelerator.
  52. */
  53. /* attention : enabling CACR_DESB requires a "nop" to flush the store buffer */
  54. /* use '+' instead of '|' for assembler's sake */
  55. /* Enable data cache */
  56. /* Enable data store buffer */
  57. /* outside ACRs : No cache, precise */
  58. /* Enable instruction+branch caches */
  59. #define CACHE_MODE (CACR_DEC+CACR_DESB+CACR_DDCM_P+CACR_BEC+CACR_IEC)
  60. #define DATA_CACHE_MODE (ACR_ENABLE+ACR_ANY+ACR_CM_WT)
  61. #define INSN_CACHE_MODE (ACR_ENABLE+ACR_ANY)
  62. #ifndef __ASSEMBLY__
  63. #if ((DATA_CACHE_MODE & ACR_CM) == ACR_CM_WT)
  64. #define flush_dcache_range(a, l) do { asm("nop"); } while (0)
  65. #endif
  66. static inline void __m54xx_flush_cache_all(void)
  67. {
  68. __asm__ __volatile__ (
  69. #if ((DATA_CACHE_MODE & ACR_CM) == ACR_CM_CP)
  70. /*
  71. * Use cpushl to push and invalidate all cache lines.
  72. * Gas doesn't seem to know how to generate the ColdFire
  73. * cpushl instruction... Oh well, bit stuff it for now.
  74. */
  75. "clrl %%d0\n\t"
  76. "1:\n\t"
  77. "movel %%d0,%%a0\n\t"
  78. "2:\n\t"
  79. ".word 0xf468\n\t"
  80. "addl %0,%%a0\n\t"
  81. "cmpl %1,%%a0\n\t"
  82. "blt 2b\n\t"
  83. "addql #1,%%d0\n\t"
  84. "cmpil %2,%%d0\n\t"
  85. "bne 1b\n\t"
  86. #endif
  87. "movel %3,%%d0\n\t"
  88. "movec %%d0,%%CACR\n\t"
  89. "nop\n\t" /* forces flush of Store Buffer */
  90. : /* No output */
  91. : "i" (CACHE_LINE_SIZE),
  92. "i" (DCACHE_SIZE / CACHE_WAYS),
  93. "i" (CACHE_WAYS),
  94. "i" (CACHE_MODE|CACR_DCINVA|CACR_BCINVA|CACR_ICINVA)
  95. : "d0", "a0" );
  96. }
  97. #define __flush_cache_all() __m54xx_flush_cache_all()
  98. #endif /* __ASSEMBLY__ */
  99. #endif /* m54xxacr_h */