m53xxacr.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /****************************************************************************/
  3. /*
  4. * m53xxacr.h -- ColdFire version 3 core cache support
  5. *
  6. * (C) Copyright 2010, Greg Ungerer <[email protected]>
  7. */
  8. /****************************************************************************/
  9. #ifndef m53xxacr_h
  10. #define m53xxacr_h
  11. /****************************************************************************/
  12. /*
  13. * All varients of the ColdFire using version 3 cores have a similar
  14. * cache setup. They have a unified instruction and data cache, with
  15. * configurable write-through or copy-back operation.
  16. */
  17. /*
  18. * Define the Cache Control register flags.
  19. */
  20. #define CACR_EC 0x80000000 /* Enable cache */
  21. #define CACR_ESB 0x20000000 /* Enable store buffer */
  22. #define CACR_DPI 0x10000000 /* Disable invalidation by CPUSHL */
  23. #define CACR_HLCK 0x08000000 /* Half cache lock mode */
  24. #define CACR_CINVA 0x01000000 /* Invalidate cache */
  25. #define CACR_DNFB 0x00000400 /* Inhibited fill buffer */
  26. #define CACR_DCM_WT 0x00000000 /* Cacheable write-through */
  27. #define CACR_DCM_CB 0x00000100 /* Cacheable copy-back */
  28. #define CACR_DCM_PRE 0x00000200 /* Cache inhibited, precise */
  29. #define CACR_DCM_IMPRE 0x00000300 /* Cache inhibited, imprecise */
  30. #define CACR_WPROTECT 0x00000020 /* Write protect*/
  31. #define CACR_EUSP 0x00000010 /* Eanble separate user a7 */
  32. /*
  33. * Define the Access Control register flags.
  34. */
  35. #define ACR_BASE_POS 24 /* Address Base (upper 8 bits) */
  36. #define ACR_MASK_POS 16 /* Address Mask (next 8 bits) */
  37. #define ACR_ENABLE 0x00008000 /* Enable this ACR */
  38. #define ACR_USER 0x00000000 /* Allow only user accesses */
  39. #define ACR_SUPER 0x00002000 /* Allow supervisor access only */
  40. #define ACR_ANY 0x00004000 /* Allow any access type */
  41. #define ACR_CM_WT 0x00000000 /* Cacheable, write-through */
  42. #define ACR_CM_CB 0x00000020 /* Cacheable, copy-back */
  43. #define ACR_CM_PRE 0x00000040 /* Cache inhibited, precise */
  44. #define ACR_CM_IMPRE 0x00000060 /* Cache inhibited, imprecise */
  45. #define ACR_WPROTECT 0x00000004 /* Write protect region */
  46. /*
  47. * Define the cache type and arrangement (needed for pushes).
  48. */
  49. #if defined(CONFIG_M5307)
  50. #define CACHE_SIZE 0x2000 /* 8k of unified cache */
  51. #define ICACHE_SIZE CACHE_SIZE
  52. #define DCACHE_SIZE CACHE_SIZE
  53. #elif defined(CONFIG_M53xx)
  54. #define CACHE_SIZE 0x4000 /* 16k of unified cache */
  55. #define ICACHE_SIZE CACHE_SIZE
  56. #define DCACHE_SIZE CACHE_SIZE
  57. #endif
  58. #define CACHE_LINE_SIZE 16 /* 16 byte line size */
  59. #define CACHE_WAYS 4 /* 4 ways - set associative */
  60. /*
  61. * Set the cache controller settings we will use. This default in the
  62. * CACR is cache inhibited, we use the ACR register to set cacheing
  63. * enabled on the regions we want (eg RAM).
  64. */
  65. #if defined(CONFIG_CACHE_COPYBACK)
  66. #define CACHE_TYPE ACR_CM_CB
  67. #define CACHE_PUSH
  68. #else
  69. #define CACHE_TYPE ACR_CM_WT
  70. #endif
  71. #ifdef CONFIG_COLDFIRE_SW_A7
  72. #define CACHE_MODE (CACR_EC + CACR_ESB + CACR_DCM_PRE)
  73. #else
  74. #define CACHE_MODE (CACR_EC + CACR_ESB + CACR_DCM_PRE + CACR_EUSP)
  75. #endif
  76. /*
  77. * Unified cache means we will never need to flush for coherency of
  78. * instruction fetch. We will need to flush to maintain memory/DMA
  79. * coherency though in all cases. And for copyback caches we will need
  80. * to push cached data as well.
  81. */
  82. #define CACHE_INIT (CACHE_MODE + CACR_CINVA - CACR_EC)
  83. #define CACHE_INVALIDATE (CACHE_MODE + CACR_CINVA)
  84. #define CACHE_INVALIDATED (CACHE_MODE + CACR_CINVA)
  85. #define ACR0_MODE ((CONFIG_RAMBASE & 0xff000000) + \
  86. (0x000f0000) + \
  87. (ACR_ENABLE + ACR_ANY + CACHE_TYPE))
  88. #define ACR1_MODE 0
  89. /****************************************************************************/
  90. #endif /* m53xxsim_h */