cp15.h 3.2 KB

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