mmu-44x.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_POWERPC_MMU_44X_H_
  3. #define _ASM_POWERPC_MMU_44X_H_
  4. /*
  5. * PPC440 support
  6. */
  7. #include <asm/page.h>
  8. #include <asm/asm-const.h>
  9. #define PPC44x_MMUCR_TID 0x000000ff
  10. #define PPC44x_MMUCR_STS 0x00010000
  11. #define PPC44x_TLB_PAGEID 0
  12. #define PPC44x_TLB_XLAT 1
  13. #define PPC44x_TLB_ATTRIB 2
  14. /* Page identification fields */
  15. #define PPC44x_TLB_EPN_MASK 0xfffffc00 /* Effective Page Number */
  16. #define PPC44x_TLB_VALID 0x00000200 /* Valid flag */
  17. #define PPC44x_TLB_TS 0x00000100 /* Translation address space */
  18. #define PPC44x_TLB_1K 0x00000000 /* Page sizes */
  19. #define PPC44x_TLB_4K 0x00000010
  20. #define PPC44x_TLB_16K 0x00000020
  21. #define PPC44x_TLB_64K 0x00000030
  22. #define PPC44x_TLB_256K 0x00000040
  23. #define PPC44x_TLB_1M 0x00000050
  24. #define PPC44x_TLB_16M 0x00000070
  25. #define PPC44x_TLB_256M 0x00000090
  26. /* Translation fields */
  27. #define PPC44x_TLB_RPN_MASK 0xfffffc00 /* Real Page Number */
  28. #define PPC44x_TLB_ERPN_MASK 0x0000000f
  29. /* Storage attribute and access control fields */
  30. #define PPC44x_TLB_ATTR_MASK 0x0000ff80
  31. #define PPC44x_TLB_U0 0x00008000 /* User 0 */
  32. #define PPC44x_TLB_U1 0x00004000 /* User 1 */
  33. #define PPC44x_TLB_U2 0x00002000 /* User 2 */
  34. #define PPC44x_TLB_U3 0x00001000 /* User 3 */
  35. #define PPC44x_TLB_W 0x00000800 /* Caching is write-through */
  36. #define PPC44x_TLB_I 0x00000400 /* Caching is inhibited */
  37. #define PPC44x_TLB_M 0x00000200 /* Memory is coherent */
  38. #define PPC44x_TLB_G 0x00000100 /* Memory is guarded */
  39. #define PPC44x_TLB_E 0x00000080 /* Memory is little endian */
  40. #define PPC44x_TLB_PERM_MASK 0x0000003f
  41. #define PPC44x_TLB_UX 0x00000020 /* User execution */
  42. #define PPC44x_TLB_UW 0x00000010 /* User write */
  43. #define PPC44x_TLB_UR 0x00000008 /* User read */
  44. #define PPC44x_TLB_SX 0x00000004 /* Super execution */
  45. #define PPC44x_TLB_SW 0x00000002 /* Super write */
  46. #define PPC44x_TLB_SR 0x00000001 /* Super read */
  47. /* Number of TLB entries */
  48. #define PPC44x_TLB_SIZE 64
  49. /* 47x bits */
  50. #define PPC47x_MMUCR_TID 0x0000ffff
  51. #define PPC47x_MMUCR_STS 0x00010000
  52. /* Page identification fields */
  53. #define PPC47x_TLB0_EPN_MASK 0xfffff000 /* Effective Page Number */
  54. #define PPC47x_TLB0_VALID 0x00000800 /* Valid flag */
  55. #define PPC47x_TLB0_TS 0x00000400 /* Translation address space */
  56. #define PPC47x_TLB0_4K 0x00000000
  57. #define PPC47x_TLB0_16K 0x00000010
  58. #define PPC47x_TLB0_64K 0x00000030
  59. #define PPC47x_TLB0_1M 0x00000070
  60. #define PPC47x_TLB0_16M 0x000000f0
  61. #define PPC47x_TLB0_256M 0x000001f0
  62. #define PPC47x_TLB0_1G 0x000003f0
  63. #define PPC47x_TLB0_BOLTED_R 0x00000008 /* tlbre only */
  64. /* Translation fields */
  65. #define PPC47x_TLB1_RPN_MASK 0xfffff000 /* Real Page Number */
  66. #define PPC47x_TLB1_ERPN_MASK 0x000003ff
  67. /* Storage attribute and access control fields */
  68. #define PPC47x_TLB2_ATTR_MASK 0x0003ff80
  69. #define PPC47x_TLB2_IL1I 0x00020000 /* Memory is guarded */
  70. #define PPC47x_TLB2_IL1D 0x00010000 /* Memory is guarded */
  71. #define PPC47x_TLB2_U0 0x00008000 /* User 0 */
  72. #define PPC47x_TLB2_U1 0x00004000 /* User 1 */
  73. #define PPC47x_TLB2_U2 0x00002000 /* User 2 */
  74. #define PPC47x_TLB2_U3 0x00001000 /* User 3 */
  75. #define PPC47x_TLB2_W 0x00000800 /* Caching is write-through */
  76. #define PPC47x_TLB2_I 0x00000400 /* Caching is inhibited */
  77. #define PPC47x_TLB2_M 0x00000200 /* Memory is coherent */
  78. #define PPC47x_TLB2_G 0x00000100 /* Memory is guarded */
  79. #define PPC47x_TLB2_E 0x00000080 /* Memory is little endian */
  80. #define PPC47x_TLB2_PERM_MASK 0x0000003f
  81. #define PPC47x_TLB2_UX 0x00000020 /* User execution */
  82. #define PPC47x_TLB2_UW 0x00000010 /* User write */
  83. #define PPC47x_TLB2_UR 0x00000008 /* User read */
  84. #define PPC47x_TLB2_SX 0x00000004 /* Super execution */
  85. #define PPC47x_TLB2_SW 0x00000002 /* Super write */
  86. #define PPC47x_TLB2_SR 0x00000001 /* Super read */
  87. #define PPC47x_TLB2_U_RWX (PPC47x_TLB2_UX|PPC47x_TLB2_UW|PPC47x_TLB2_UR)
  88. #define PPC47x_TLB2_S_RWX (PPC47x_TLB2_SX|PPC47x_TLB2_SW|PPC47x_TLB2_SR)
  89. #define PPC47x_TLB2_S_RW (PPC47x_TLB2_SW | PPC47x_TLB2_SR)
  90. #define PPC47x_TLB2_IMG (PPC47x_TLB2_I | PPC47x_TLB2_M | PPC47x_TLB2_G)
  91. #ifndef __ASSEMBLY__
  92. extern unsigned int tlb_44x_hwater;
  93. extern unsigned int tlb_44x_index;
  94. typedef struct {
  95. unsigned int id;
  96. unsigned int active;
  97. unsigned long vdso_base;
  98. } mm_context_t;
  99. #endif /* !__ASSEMBLY__ */
  100. #ifndef CONFIG_PPC_EARLY_DEBUG_44x
  101. #define PPC44x_EARLY_TLBS 1
  102. #else
  103. #define PPC44x_EARLY_TLBS 2
  104. #define PPC44x_EARLY_DEBUG_VIRTADDR (ASM_CONST(0xf0000000) \
  105. | (ASM_CONST(CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW) & 0xffff))
  106. #endif
  107. /* Size of the TLBs used for pinning in lowmem */
  108. #define PPC_PIN_SIZE (1 << 28) /* 256M */
  109. #if (PAGE_SHIFT == 12)
  110. #define PPC44x_TLBE_SIZE PPC44x_TLB_4K
  111. #define PPC47x_TLBE_SIZE PPC47x_TLB0_4K
  112. #define mmu_virtual_psize MMU_PAGE_4K
  113. #elif (PAGE_SHIFT == 14)
  114. #define PPC44x_TLBE_SIZE PPC44x_TLB_16K
  115. #define PPC47x_TLBE_SIZE PPC47x_TLB0_16K
  116. #define mmu_virtual_psize MMU_PAGE_16K
  117. #elif (PAGE_SHIFT == 16)
  118. #define PPC44x_TLBE_SIZE PPC44x_TLB_64K
  119. #define PPC47x_TLBE_SIZE PPC47x_TLB0_64K
  120. #define mmu_virtual_psize MMU_PAGE_64K
  121. #elif (PAGE_SHIFT == 18)
  122. #define PPC44x_TLBE_SIZE PPC44x_TLB_256K
  123. #define mmu_virtual_psize MMU_PAGE_256K
  124. #else
  125. #error "Unsupported PAGE_SIZE"
  126. #endif
  127. #define mmu_linear_psize MMU_PAGE_256M
  128. #define PPC44x_PGD_OFF_SHIFT (32 - PGDIR_SHIFT + PGD_T_LOG2)
  129. #define PPC44x_PGD_OFF_MASK_BIT (PGDIR_SHIFT - PGD_T_LOG2)
  130. #define PPC44x_PTE_ADD_SHIFT (32 - PGDIR_SHIFT + PTE_SHIFT + PTE_T_LOG2)
  131. #define PPC44x_PTE_ADD_MASK_BIT (32 - PTE_T_LOG2 - PTE_SHIFT)
  132. #endif /* _ASM_POWERPC_MMU_44X_H_ */