ckmmu.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
  3. #ifndef __ASM_CSKY_CKMMUV2_H
  4. #define __ASM_CSKY_CKMMUV2_H
  5. #include <abi/reg_ops.h>
  6. #include <asm/barrier.h>
  7. static inline int read_mmu_index(void)
  8. {
  9. return mfcr("cr<0, 15>");
  10. }
  11. static inline void write_mmu_index(int value)
  12. {
  13. mtcr("cr<0, 15>", value);
  14. }
  15. static inline int read_mmu_entrylo0(void)
  16. {
  17. return mfcr("cr<2, 15>");
  18. }
  19. static inline int read_mmu_entrylo1(void)
  20. {
  21. return mfcr("cr<3, 15>");
  22. }
  23. static inline void write_mmu_pagemask(int value)
  24. {
  25. mtcr("cr<6, 15>", value);
  26. }
  27. static inline int read_mmu_entryhi(void)
  28. {
  29. return mfcr("cr<4, 15>");
  30. }
  31. static inline void write_mmu_entryhi(int value)
  32. {
  33. mtcr("cr<4, 15>", value);
  34. }
  35. /*
  36. * TLB operations.
  37. */
  38. static inline void tlb_probe(void)
  39. {
  40. mtcr("cr<8, 15>", 0x80000000);
  41. }
  42. static inline void tlb_read(void)
  43. {
  44. mtcr("cr<8, 15>", 0x40000000);
  45. }
  46. static inline void tlb_invalid_all(void)
  47. {
  48. #ifdef CONFIG_CPU_HAS_TLBI
  49. asm volatile("tlbi.alls\n":::"memory");
  50. sync_is();
  51. #else
  52. mtcr("cr<8, 15>", 0x04000000);
  53. #endif
  54. }
  55. static inline void tlb_invalid_indexed(void)
  56. {
  57. mtcr("cr<8, 15>", 0x02000000);
  58. }
  59. /* setup hardrefil pgd */
  60. static inline unsigned long get_pgd(void)
  61. {
  62. return mfcr("cr<29, 15>");
  63. }
  64. static inline void setup_pgd(unsigned long pgd, bool kernel)
  65. {
  66. if (kernel)
  67. mtcr("cr<28, 15>", pgd);
  68. else
  69. mtcr("cr<29, 15>", pgd);
  70. }
  71. #endif /* __ASM_CSKY_CKMMUV2_H */