cp15.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifndef __ASM_ARM_CP15_H
  2. #define __ASM_ARM_CP15_H
  3. #include <asm/barrier.h>
  4. /*
  5. * CR1 bits (CP#15 CR1)
  6. */
  7. #define CR_M (1 << 0) /* MMU enable */
  8. #define CR_A (1 << 1) /* Alignment abort enable */
  9. #define CR_C (1 << 2) /* Dcache enable */
  10. #define CR_W (1 << 3) /* Write buffer enable */
  11. #define CR_P (1 << 4) /* 32-bit exception handler */
  12. #define CR_D (1 << 5) /* 32-bit data address range */
  13. #define CR_L (1 << 6) /* Implementation defined */
  14. #define CR_B (1 << 7) /* Big endian */
  15. #define CR_S (1 << 8) /* System MMU protection */
  16. #define CR_R (1 << 9) /* ROM MMU protection */
  17. #define CR_F (1 << 10) /* Implementation defined */
  18. #define CR_Z (1 << 11) /* Implementation defined */
  19. #define CR_I (1 << 12) /* Icache enable */
  20. #define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */
  21. #define CR_RR (1 << 14) /* Round Robin cache replacement */
  22. #define CR_L4 (1 << 15) /* LDR pc can set T bit */
  23. #define CR_DT (1 << 16)
  24. #ifdef CONFIG_MMU
  25. #define CR_HA (1 << 17) /* Hardware management of Access Flag */
  26. #else
  27. #define CR_BR (1 << 17) /* MPU Background region enable (PMSA) */
  28. #endif
  29. #define CR_IT (1 << 18)
  30. #define CR_ST (1 << 19)
  31. #define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */
  32. #define CR_U (1 << 22) /* Unaligned access operation */
  33. #define CR_XP (1 << 23) /* Extended page tables */
  34. #define CR_VE (1 << 24) /* Vectored interrupts */
  35. #define CR_EE (1 << 25) /* Exception (Big) Endian */
  36. #define CR_TRE (1 << 28) /* TEX remap enable */
  37. #define CR_AFE (1 << 29) /* Access flag enable */
  38. #define CR_TE (1 << 30) /* Thumb exception enable */
  39. #ifndef __ASSEMBLY__
  40. #if __LINUX_ARM_ARCH__ >= 4
  41. #define vectors_high() (get_cr() & CR_V)
  42. #else
  43. #define vectors_high() (0)
  44. #endif
  45. #ifdef CONFIG_CPU_CP15
  46. #define __ACCESS_CP15(CRn, Op1, CRm, Op2) \
  47. "mrc", "mcr", __stringify(p15, Op1, %0, CRn, CRm, Op2), u32
  48. #define __ACCESS_CP15_64(Op1, CRm) \
  49. "mrrc", "mcrr", __stringify(p15, Op1, %Q0, %R0, CRm), u64
  50. #define __read_sysreg(r, w, c, t) ({ \
  51. t __val; \
  52. asm volatile(r " " c : "=r" (__val)); \
  53. __val; \
  54. })
  55. #define read_sysreg(...) __read_sysreg(__VA_ARGS__)
  56. #define __write_sysreg(v, r, w, c, t) asm volatile(w " " c : : "r" ((t)(v)))
  57. #define write_sysreg(v, ...) __write_sysreg(v, __VA_ARGS__)
  58. extern unsigned long cr_alignment; /* defined in entry-armv.S */
  59. static inline unsigned long get_cr(void)
  60. {
  61. unsigned long val;
  62. asm("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val) : : "cc");
  63. return val;
  64. }
  65. static inline void set_cr(unsigned long val)
  66. {
  67. asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR"
  68. : : "r" (val) : "cc");
  69. isb();
  70. }
  71. static inline unsigned int get_auxcr(void)
  72. {
  73. unsigned int val;
  74. asm("mrc p15, 0, %0, c1, c0, 1 @ get AUXCR" : "=r" (val));
  75. return val;
  76. }
  77. static inline void set_auxcr(unsigned int val)
  78. {
  79. asm volatile("mcr p15, 0, %0, c1, c0, 1 @ set AUXCR"
  80. : : "r" (val));
  81. isb();
  82. }
  83. #define CPACC_FULL(n) (3 << (n * 2))
  84. #define CPACC_SVC(n) (1 << (n * 2))
  85. #define CPACC_DISABLE(n) (0 << (n * 2))
  86. static inline unsigned int get_copro_access(void)
  87. {
  88. unsigned int val;
  89. asm("mrc p15, 0, %0, c1, c0, 2 @ get copro access"
  90. : "=r" (val) : : "cc");
  91. return val;
  92. }
  93. static inline void set_copro_access(unsigned int val)
  94. {
  95. asm volatile("mcr p15, 0, %0, c1, c0, 2 @ set copro access"
  96. : : "r" (val) : "cc");
  97. isb();
  98. }
  99. #else /* ifdef CONFIG_CPU_CP15 */
  100. /*
  101. * cr_alignment is tightly coupled to cp15 (at least in the minds of the
  102. * developers). Yielding 0 for machines without a cp15 (and making it
  103. * read-only) is fine for most cases and saves quite some #ifdeffery.
  104. */
  105. #define cr_alignment UL(0)
  106. static inline unsigned long get_cr(void)
  107. {
  108. return 0;
  109. }
  110. #endif /* ifdef CONFIG_CPU_CP15 / else */
  111. #endif /* ifndef __ASSEMBLY__ */
  112. #endif