cache.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * ColdFire cache
  3. *
  4. * Copyright 2004-2012 Freescale Semiconductor, Inc.
  5. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __CACHE_H
  10. #define __CACHE_H
  11. #if defined(CONFIG_MCF520x) || defined(CONFIG_MCF523x) || \
  12. defined(CONFIG_MCF52x2) || defined(CONFIG_MCF5227x)
  13. #define CONFIG_CF_V2
  14. #endif
  15. #if defined(CONFIG_MCF530x) || defined(CONFIG_MCF532x) || \
  16. defined(CONFIG_MCF5301x)
  17. #define CONFIG_CF_V3
  18. #endif
  19. #if defined(CONFIG_MCF547x_8x) || defined(CONFIG_MCF5445x)
  20. #define CONFIG_CF_V4
  21. #elif defined(CONFIG_MCF5441x)
  22. #define CONFIG_CF_V4E /* Four Extra ACRn */
  23. #endif
  24. /* ***** CACR ***** */
  25. /* V2 Core */
  26. #ifdef CONFIG_CF_V2
  27. #define CF_CACR_CENB (1 << 31)
  28. #define CF_CACR_CPD (1 << 28)
  29. #define CF_CACR_CFRZ (1 << 27)
  30. #define CF_CACR_CEIB (1 << 10)
  31. #define CF_CACR_DCM (1 << 9)
  32. #define CF_CACR_DBWE (1 << 8)
  33. #if defined(CONFIG_MCF5249) || defined(CONFIG_MCF5253)
  34. #define CF_CACR_DWP (1 << 6)
  35. #else
  36. #define CF_CACR_CINV (1 << 24)
  37. #define CF_CACR_DISI (1 << 23)
  38. #define CF_CACR_DISD (1 << 22)
  39. #define CF_CACR_INVI (1 << 21)
  40. #define CF_CACR_INVD (1 << 20)
  41. #define CF_CACR_DWP (1 << 5)
  42. #define CF_CACR_EUSP (1 << 4)
  43. #endif /* CONFIG_MCF5249 || CONFIG_MCF5253 */
  44. #endif /* CONFIG_CF_V2 */
  45. /* V3 Core */
  46. #ifdef CONFIG_CF_V3
  47. #define CF_CACR_EC (1 << 31)
  48. #define CF_CACR_ESB (1 << 29)
  49. #define CF_CACR_DPI (1 << 28)
  50. #define CF_CACR_HLCK (1 << 27)
  51. #define CF_CACR_CINVA (1 << 24)
  52. #define CF_CACR_DNFB (1 << 10)
  53. #define CF_CACR_DCM_UNMASK 0xFFFFFCFF
  54. #define CF_CACR_DCM_WT (0 << 8)
  55. #define CF_CACR_DCM_CB (1 << 8)
  56. #define CF_CACR_DCM_P (2 << 8)
  57. #define CF_CACR_DCM_IP (3 << 8)
  58. #define CF_CACR_DW (1 << 5)
  59. #define CF_CACR_EUSP (1 << 4)
  60. #endif /* CONFIG_CF_V3 */
  61. /* V4 Core */
  62. #if defined(CONFIG_CF_V4) || defined(CONFIG_CF_V4E)
  63. #define CF_CACR_DEC (1 << 31)
  64. #define CF_CACR_DW (1 << 30)
  65. #define CF_CACR_DESB (1 << 29)
  66. #define CF_CACR_DDPI (1 << 28)
  67. #define CF_CACR_DHLCK (1 << 27)
  68. #define CF_CACR_DDCM_UNMASK (0xF9FFFFFF)
  69. #define CF_CACR_DDCM_WT (0 << 25)
  70. #define CF_CACR_DDCM_CB (1 << 25)
  71. #define CF_CACR_DDCM_P (2 << 25)
  72. #define CF_CACR_DDCM_IP (3 << 25)
  73. #define CF_CACR_DCINVA (1 << 24)
  74. #define CF_CACR_DDSP (1 << 23)
  75. #define CF_CACR_BEC (1 << 19)
  76. #define CF_CACR_BCINVA (1 << 18)
  77. #define CF_CACR_IEC (1 << 15)
  78. #define CF_CACR_DNFB (1 << 13)
  79. #define CF_CACR_IDPI (1 << 12)
  80. #define CF_CACR_IHLCK (1 << 11)
  81. #define CF_CACR_IDCM (1 << 10)
  82. #define CF_CACR_ICINVA (1 << 8)
  83. #define CF_CACR_IDSP (1 << 7)
  84. #define CF_CACR_EUSP (1 << 5)
  85. #if defined(CONFIG_MCF5445x) || defined(CONFIG_MCF5441x)
  86. #define CF_CACR_IVO (1 << 20)
  87. #define CF_CACR_SPA (1 << 14)
  88. #else
  89. #define CF_CACR_DF (1 << 4)
  90. #endif
  91. #endif /* CONFIG_CF_V4 */
  92. /* ***** ACR ***** */
  93. #define CF_ACR_ADR_UNMASK (0x00FFFFFF)
  94. #define CF_ACR_ADR(x) ((x & 0xFF) << 24)
  95. #define CF_ACR_ADRMSK_UNMASK (0xFF00FFFF)
  96. #define CF_ACR_ADRMSK(x) ((x & 0xFF) << 16)
  97. #define CF_ACR_EN (1 << 15)
  98. #define CF_ACR_SM_UNMASK (0xFFFF9FFF)
  99. #define CF_ACR_SM_UM (0 << 13)
  100. #define CF_ACR_SM_SM (1 << 13)
  101. #define CF_ACR_SM_ALL (3 << 13)
  102. #define CF_ACR_WP (1 << 2)
  103. /* V2 Core */
  104. #ifdef CONFIG_CF_V2
  105. #define CF_ACR_CM (1 << 6)
  106. #define CF_ACR_BWE (1 << 5)
  107. #else
  108. /* V3 & V4 */
  109. #define CF_ACR_CM_UNMASK (0xFFFFFF9F)
  110. #define CF_ACR_CM_WT (0 << 5)
  111. #define CF_ACR_CM_CB (1 << 5)
  112. #define CF_ACR_CM_P (2 << 5)
  113. #define CF_ACR_CM_IP (3 << 5)
  114. #endif /* CONFIG_CF_V2 */
  115. /* V4 Core */
  116. #if defined(CONFIG_CF_V4) || defined(CONFIG_CF_V4E)
  117. #define CF_ACR_AMM (1 << 10)
  118. #define CF_ACR_SP (1 << 3)
  119. #endif /* CONFIG_CF_V4 */
  120. #ifndef CONFIG_SYS_CACHE_ICACR
  121. #define CONFIG_SYS_CACHE_ICACR 0
  122. #endif
  123. #ifndef CONFIG_SYS_CACHE_DCACR
  124. #ifdef CONFIG_SYS_CACHE_ICACR
  125. #define CONFIG_SYS_CACHE_DCACR CONFIG_SYS_CACHE_ICACR
  126. #else
  127. #define CONFIG_SYS_CACHE_DCACR 0
  128. #endif
  129. #endif
  130. #ifndef CONFIG_SYS_CACHE_ACR0
  131. #define CONFIG_SYS_CACHE_ACR0 0
  132. #endif
  133. #ifndef CONFIG_SYS_CACHE_ACR1
  134. #define CONFIG_SYS_CACHE_ACR1 0
  135. #endif
  136. #ifndef CONFIG_SYS_CACHE_ACR2
  137. #define CONFIG_SYS_CACHE_ACR2 0
  138. #endif
  139. #ifndef CONFIG_SYS_CACHE_ACR3
  140. #define CONFIG_SYS_CACHE_ACR3 0
  141. #endif
  142. #ifndef CONFIG_SYS_CACHE_ACR4
  143. #define CONFIG_SYS_CACHE_ACR4 0
  144. #endif
  145. #ifndef CONFIG_SYS_CACHE_ACR5
  146. #define CONFIG_SYS_CACHE_ACR5 0
  147. #endif
  148. #ifndef CONFIG_SYS_CACHE_ACR6
  149. #define CONFIG_SYS_CACHE_ACR6 0
  150. #endif
  151. #ifndef CONFIG_SYS_CACHE_ACR7
  152. #define CONFIG_SYS_CACHE_ACR7 0
  153. #endif
  154. #define CF_ADDRMASK(x) (((x > 0x10) ? ((x >> 4) - 1) : (x)) << 16)
  155. #ifndef __ASSEMBLY__ /* put C only stuff in this section */
  156. void icache_invalid(void);
  157. void dcache_invalid(void);
  158. #endif
  159. /*
  160. * m68k uses 16 byte L1 data cache line sizes. Use this for DMA buffer
  161. * alignment unless the board configuration has specified a new value.
  162. */
  163. #ifdef CONFIG_SYS_CACHELINE_SIZE
  164. #define ARCH_DMA_MINALIGN CONFIG_SYS_CACHELINE_SIZE
  165. #else
  166. #define ARCH_DMA_MINALIGN 16
  167. #endif
  168. #endif /* __CACHE_H */