ckmmu.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_CSKY_CKMMUV2_H
  3. #define __ASM_CSKY_CKMMUV2_H
  4. #include <abi/reg_ops.h>
  5. #include <asm/barrier.h>
  6. static inline int read_mmu_index(void)
  7. {
  8. return mfcr("cr<0, 15>");
  9. }
  10. static inline void write_mmu_index(int value)
  11. {
  12. mtcr("cr<0, 15>", value);
  13. }
  14. static inline int read_mmu_entrylo0(void)
  15. {
  16. return mfcr("cr<2, 15>");
  17. }
  18. static inline int read_mmu_entrylo1(void)
  19. {
  20. return mfcr("cr<3, 15>");
  21. }
  22. static inline void write_mmu_pagemask(int value)
  23. {
  24. mtcr("cr<6, 15>", value);
  25. }
  26. static inline int read_mmu_entryhi(void)
  27. {
  28. return mfcr("cr<4, 15>");
  29. }
  30. static inline void write_mmu_entryhi(int value)
  31. {
  32. mtcr("cr<4, 15>", value);
  33. }
  34. static inline unsigned long read_mmu_msa0(void)
  35. {
  36. return mfcr("cr<30, 15>");
  37. }
  38. static inline void write_mmu_msa0(unsigned long value)
  39. {
  40. mtcr("cr<30, 15>", value);
  41. }
  42. static inline unsigned long read_mmu_msa1(void)
  43. {
  44. return mfcr("cr<31, 15>");
  45. }
  46. static inline void write_mmu_msa1(unsigned long value)
  47. {
  48. mtcr("cr<31, 15>", value);
  49. }
  50. /*
  51. * TLB operations.
  52. */
  53. static inline void tlb_probe(void)
  54. {
  55. mtcr("cr<8, 15>", 0x80000000);
  56. }
  57. static inline void tlb_read(void)
  58. {
  59. mtcr("cr<8, 15>", 0x40000000);
  60. }
  61. static inline void tlb_invalid_all(void)
  62. {
  63. #ifdef CONFIG_CPU_HAS_TLBI
  64. sync_is();
  65. asm volatile(
  66. "tlbi.alls \n"
  67. "sync.i \n"
  68. :
  69. :
  70. : "memory");
  71. #else
  72. mtcr("cr<8, 15>", 0x04000000);
  73. #endif
  74. }
  75. static inline void local_tlb_invalid_all(void)
  76. {
  77. #ifdef CONFIG_CPU_HAS_TLBI
  78. sync_is();
  79. asm volatile(
  80. "tlbi.all \n"
  81. "sync.i \n"
  82. :
  83. :
  84. : "memory");
  85. #else
  86. tlb_invalid_all();
  87. #endif
  88. }
  89. static inline void tlb_invalid_indexed(void)
  90. {
  91. mtcr("cr<8, 15>", 0x02000000);
  92. }
  93. #define NOP32 ".long 0x4820c400\n"
  94. static inline void setup_pgd(pgd_t *pgd, int asid)
  95. {
  96. #ifdef CONFIG_CPU_HAS_TLBI
  97. sync_is();
  98. #else
  99. mb();
  100. #endif
  101. asm volatile(
  102. #ifdef CONFIG_CPU_HAS_TLBI
  103. "mtcr %1, cr<28, 15> \n"
  104. #endif
  105. "mtcr %1, cr<29, 15> \n"
  106. "mtcr %0, cr< 4, 15> \n"
  107. ".rept 64 \n"
  108. NOP32
  109. ".endr \n"
  110. :
  111. :"r"(asid), "r"(__pa(pgd) | BIT(0))
  112. :"memory");
  113. }
  114. static inline pgd_t *get_pgd(void)
  115. {
  116. return __va(mfcr("cr<29, 15>") & ~BIT(0));
  117. }
  118. #endif /* __ASM_CSKY_CKMMUV2_H */