arm-smmu-regs.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * IOMMU API for ARM architected SMMU implementations.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. *
  17. * Copyright (C) 2013 ARM Limited
  18. *
  19. * Author: Will Deacon <will.deacon@arm.com>
  20. */
  21. #ifndef _ARM_SMMU_REGS_H
  22. #define _ARM_SMMU_REGS_H
  23. /* Configuration registers */
  24. #define ARM_SMMU_GR0_sCR0 0x0
  25. #define sCR0_CLIENTPD (1 << 0)
  26. #define sCR0_GFRE (1 << 1)
  27. #define sCR0_GFIE (1 << 2)
  28. #define sCR0_EXIDENABLE (1 << 3)
  29. #define sCR0_GCFGFRE (1 << 4)
  30. #define sCR0_GCFGFIE (1 << 5)
  31. #define sCR0_USFCFG (1 << 10)
  32. #define sCR0_VMIDPNE (1 << 11)
  33. #define sCR0_PTM (1 << 12)
  34. #define sCR0_FB (1 << 13)
  35. #define sCR0_VMID16EN (1 << 31)
  36. #define sCR0_BSU_SHIFT 14
  37. #define sCR0_BSU_MASK 0x3
  38. /* Auxiliary Configuration register */
  39. #define ARM_SMMU_GR0_sACR 0x10
  40. /* Identification registers */
  41. #define ARM_SMMU_GR0_ID0 0x20
  42. #define ARM_SMMU_GR0_ID1 0x24
  43. #define ARM_SMMU_GR0_ID2 0x28
  44. #define ARM_SMMU_GR0_ID3 0x2c
  45. #define ARM_SMMU_GR0_ID4 0x30
  46. #define ARM_SMMU_GR0_ID5 0x34
  47. #define ARM_SMMU_GR0_ID6 0x38
  48. #define ARM_SMMU_GR0_ID7 0x3c
  49. #define ARM_SMMU_GR0_sGFSR 0x48
  50. #define ARM_SMMU_GR0_sGFSYNR0 0x50
  51. #define ARM_SMMU_GR0_sGFSYNR1 0x54
  52. #define ARM_SMMU_GR0_sGFSYNR2 0x58
  53. #define ID0_S1TS (1 << 30)
  54. #define ID0_S2TS (1 << 29)
  55. #define ID0_NTS (1 << 28)
  56. #define ID0_SMS (1 << 27)
  57. #define ID0_ATOSNS (1 << 26)
  58. #define ID0_PTFS_NO_AARCH32 (1 << 25)
  59. #define ID0_PTFS_NO_AARCH32S (1 << 24)
  60. #define ID0_CTTW (1 << 14)
  61. #define ID0_NUMIRPT_SHIFT 16
  62. #define ID0_NUMIRPT_MASK 0xff
  63. #define ID0_NUMSIDB_SHIFT 9
  64. #define ID0_NUMSIDB_MASK 0xf
  65. #define ID0_EXIDS (1 << 8)
  66. #define ID0_NUMSMRG_SHIFT 0
  67. #define ID0_NUMSMRG_MASK 0xff
  68. #define ID1_PAGESIZE (1 << 31)
  69. #define ID1_NUMPAGENDXB_SHIFT 28
  70. #define ID1_NUMPAGENDXB_MASK 7
  71. #define ID1_NUMS2CB_SHIFT 16
  72. #define ID1_NUMS2CB_MASK 0xff
  73. #define ID1_NUMCB_SHIFT 0
  74. #define ID1_NUMCB_MASK 0xff
  75. #define ID2_OAS_SHIFT 4
  76. #define ID2_OAS_MASK 0xf
  77. #define ID2_IAS_SHIFT 0
  78. #define ID2_IAS_MASK 0xf
  79. #define ID2_UBS_SHIFT 8
  80. #define ID2_UBS_MASK 0xf
  81. #define ID2_PTFS_4K (1 << 12)
  82. #define ID2_PTFS_16K (1 << 13)
  83. #define ID2_PTFS_64K (1 << 14)
  84. #define ID2_VMID16 (1 << 15)
  85. #define ID7_MAJOR_SHIFT 4
  86. #define ID7_MAJOR_MASK 0xf
  87. /* Global TLB invalidation */
  88. #define ARM_SMMU_GR0_TLBIVMID 0x64
  89. #define ARM_SMMU_GR0_TLBIALLNSNH 0x68
  90. #define ARM_SMMU_GR0_TLBIALLH 0x6c
  91. #define ARM_SMMU_GR0_sTLBGSYNC 0x70
  92. #define ARM_SMMU_GR0_sTLBGSTATUS 0x74
  93. #define sTLBGSTATUS_GSACTIVE (1 << 0)
  94. /* Stream mapping registers */
  95. #define ARM_SMMU_GR0_SMR(n) (0x800 + ((n) << 2))
  96. #define SMR_VALID (1 << 31)
  97. #define SMR_MASK_SHIFT 16
  98. #define SMR_ID_SHIFT 0
  99. #define ARM_SMMU_GR0_S2CR(n) (0xc00 + ((n) << 2))
  100. #define S2CR_CBNDX_SHIFT 0
  101. #define S2CR_CBNDX_MASK 0xff
  102. #define S2CR_EXIDVALID (1 << 10)
  103. #define S2CR_TYPE_SHIFT 16
  104. #define S2CR_TYPE_MASK 0x3
  105. enum arm_smmu_s2cr_type {
  106. S2CR_TYPE_TRANS,
  107. S2CR_TYPE_BYPASS,
  108. S2CR_TYPE_FAULT,
  109. };
  110. #define S2CR_PRIVCFG_SHIFT 24
  111. #define S2CR_PRIVCFG_MASK 0x3
  112. enum arm_smmu_s2cr_privcfg {
  113. S2CR_PRIVCFG_DEFAULT,
  114. S2CR_PRIVCFG_DIPAN,
  115. S2CR_PRIVCFG_UNPRIV,
  116. S2CR_PRIVCFG_PRIV,
  117. };
  118. /* Context bank attribute registers */
  119. #define ARM_SMMU_GR1_CBAR(n) (0x0 + ((n) << 2))
  120. #define CBAR_VMID_SHIFT 0
  121. #define CBAR_VMID_MASK 0xff
  122. #define CBAR_S1_BPSHCFG_SHIFT 8
  123. #define CBAR_S1_BPSHCFG_MASK 3
  124. #define CBAR_S1_BPSHCFG_NSH 3
  125. #define CBAR_S1_MEMATTR_SHIFT 12
  126. #define CBAR_S1_MEMATTR_MASK 0xf
  127. #define CBAR_S1_MEMATTR_WB 0xf
  128. #define CBAR_TYPE_SHIFT 16
  129. #define CBAR_TYPE_MASK 0x3
  130. #define CBAR_TYPE_S2_TRANS (0 << CBAR_TYPE_SHIFT)
  131. #define CBAR_TYPE_S1_TRANS_S2_BYPASS (1 << CBAR_TYPE_SHIFT)
  132. #define CBAR_TYPE_S1_TRANS_S2_FAULT (2 << CBAR_TYPE_SHIFT)
  133. #define CBAR_TYPE_S1_TRANS_S2_TRANS (3 << CBAR_TYPE_SHIFT)
  134. #define CBAR_IRPTNDX_SHIFT 24
  135. #define CBAR_IRPTNDX_MASK 0xff
  136. #define ARM_SMMU_GR1_CBA2R(n) (0x800 + ((n) << 2))
  137. #define CBA2R_RW64_32BIT (0 << 0)
  138. #define CBA2R_RW64_64BIT (1 << 0)
  139. #define CBA2R_VMID_SHIFT 16
  140. #define CBA2R_VMID_MASK 0xffff
  141. #define ARM_SMMU_CB_SCTLR 0x0
  142. #define ARM_SMMU_CB_ACTLR 0x4
  143. #define ARM_SMMU_CB_RESUME 0x8
  144. #define ARM_SMMU_CB_TTBCR2 0x10
  145. #define ARM_SMMU_CB_TTBR0 0x20
  146. #define ARM_SMMU_CB_TTBR1 0x28
  147. #define ARM_SMMU_CB_TTBCR 0x30
  148. #define ARM_SMMU_CB_CONTEXTIDR 0x34
  149. #define ARM_SMMU_CB_S1_MAIR0 0x38
  150. #define ARM_SMMU_CB_S1_MAIR1 0x3c
  151. #define ARM_SMMU_CB_PAR 0x50
  152. #define ARM_SMMU_CB_FSR 0x58
  153. #define ARM_SMMU_CB_FAR 0x60
  154. #define ARM_SMMU_CB_FSYNR0 0x68
  155. #define ARM_SMMU_CB_S1_TLBIVA 0x600
  156. #define ARM_SMMU_CB_S1_TLBIASID 0x610
  157. #define ARM_SMMU_CB_S1_TLBIVAL 0x620
  158. #define ARM_SMMU_CB_S2_TLBIIPAS2 0x630
  159. #define ARM_SMMU_CB_S2_TLBIIPAS2L 0x638
  160. #define ARM_SMMU_CB_TLBSYNC 0x7f0
  161. #define ARM_SMMU_CB_TLBSTATUS 0x7f4
  162. #define ARM_SMMU_CB_ATS1PR 0x800
  163. #define ARM_SMMU_CB_ATSR 0x8f0
  164. #define SCTLR_S1_ASIDPNE (1 << 12)
  165. #define SCTLR_CFCFG (1 << 7)
  166. #define SCTLR_CFIE (1 << 6)
  167. #define SCTLR_CFRE (1 << 5)
  168. #define SCTLR_E (1 << 4)
  169. #define SCTLR_AFE (1 << 2)
  170. #define SCTLR_TRE (1 << 1)
  171. #define SCTLR_M (1 << 0)
  172. #define CB_PAR_F (1 << 0)
  173. #define ATSR_ACTIVE (1 << 0)
  174. #define RESUME_RETRY (0 << 0)
  175. #define RESUME_TERMINATE (1 << 0)
  176. #define TTBCR2_SEP_SHIFT 15
  177. #define TTBCR2_SEP_UPSTREAM (0x7 << TTBCR2_SEP_SHIFT)
  178. #define TTBCR2_AS (1 << 4)
  179. #define TTBRn_ASID_SHIFT 48
  180. #define FSR_MULTI (1 << 31)
  181. #define FSR_SS (1 << 30)
  182. #define FSR_UUT (1 << 8)
  183. #define FSR_ASF (1 << 7)
  184. #define FSR_TLBLKF (1 << 6)
  185. #define FSR_TLBMCF (1 << 5)
  186. #define FSR_EF (1 << 4)
  187. #define FSR_PF (1 << 3)
  188. #define FSR_AFF (1 << 2)
  189. #define FSR_TF (1 << 1)
  190. #define FSR_IGN (FSR_AFF | FSR_ASF | \
  191. FSR_TLBMCF | FSR_TLBLKF)
  192. #define FSR_FAULT (FSR_MULTI | FSR_SS | FSR_UUT | \
  193. FSR_EF | FSR_PF | FSR_TF | FSR_IGN)
  194. #define FSYNR0_WNR (1 << 4)
  195. #endif /* _ARM_SMMU_REGS_H */