v3d_regs.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /* Copyright (C) 2017-2018 Broadcom */
  3. #ifndef V3D_REGS_H
  4. #define V3D_REGS_H
  5. #include <linux/bitops.h>
  6. #define V3D_MASK(high, low) ((u32)GENMASK(high, low))
  7. /* Using the GNU statement expression extension */
  8. #define V3D_SET_FIELD(value, field) \
  9. ({ \
  10. u32 fieldval = (value) << field##_SHIFT; \
  11. WARN_ON((fieldval & ~field##_MASK) != 0); \
  12. fieldval & field##_MASK; \
  13. })
  14. #define V3D_GET_FIELD(word, field) (((word) & field##_MASK) >> \
  15. field##_SHIFT)
  16. /* Hub registers for shared hardware between V3D cores. */
  17. #define V3D_HUB_AXICFG 0x00000
  18. # define V3D_HUB_AXICFG_MAX_LEN_MASK V3D_MASK(3, 0)
  19. # define V3D_HUB_AXICFG_MAX_LEN_SHIFT 0
  20. #define V3D_HUB_UIFCFG 0x00004
  21. #define V3D_HUB_IDENT0 0x00008
  22. #define V3D_HUB_IDENT1 0x0000c
  23. # define V3D_HUB_IDENT1_WITH_MSO BIT(19)
  24. # define V3D_HUB_IDENT1_WITH_TSY BIT(18)
  25. # define V3D_HUB_IDENT1_WITH_TFU BIT(17)
  26. # define V3D_HUB_IDENT1_WITH_L3C BIT(16)
  27. # define V3D_HUB_IDENT1_NHOSTS_MASK V3D_MASK(15, 12)
  28. # define V3D_HUB_IDENT1_NHOSTS_SHIFT 12
  29. # define V3D_HUB_IDENT1_NCORES_MASK V3D_MASK(11, 8)
  30. # define V3D_HUB_IDENT1_NCORES_SHIFT 8
  31. # define V3D_HUB_IDENT1_REV_MASK V3D_MASK(7, 4)
  32. # define V3D_HUB_IDENT1_REV_SHIFT 4
  33. # define V3D_HUB_IDENT1_TVER_MASK V3D_MASK(3, 0)
  34. # define V3D_HUB_IDENT1_TVER_SHIFT 0
  35. #define V3D_HUB_IDENT2 0x00010
  36. # define V3D_HUB_IDENT2_WITH_MMU BIT(8)
  37. # define V3D_HUB_IDENT2_L3C_NKB_MASK V3D_MASK(7, 0)
  38. # define V3D_HUB_IDENT2_L3C_NKB_SHIFT 0
  39. #define V3D_HUB_IDENT3 0x00014
  40. # define V3D_HUB_IDENT3_IPREV_MASK V3D_MASK(15, 8)
  41. # define V3D_HUB_IDENT3_IPREV_SHIFT 8
  42. # define V3D_HUB_IDENT3_IPIDX_MASK V3D_MASK(7, 0)
  43. # define V3D_HUB_IDENT3_IPIDX_SHIFT 0
  44. #define V3D_HUB_INT_STS 0x00050
  45. #define V3D_HUB_INT_SET 0x00054
  46. #define V3D_HUB_INT_CLR 0x00058
  47. #define V3D_HUB_INT_MSK_STS 0x0005c
  48. #define V3D_HUB_INT_MSK_SET 0x00060
  49. #define V3D_HUB_INT_MSK_CLR 0x00064
  50. # define V3D_HUB_INT_MMU_WRV BIT(5)
  51. # define V3D_HUB_INT_MMU_PTI BIT(4)
  52. # define V3D_HUB_INT_MMU_CAP BIT(3)
  53. # define V3D_HUB_INT_MSO BIT(2)
  54. # define V3D_HUB_INT_TFUC BIT(1)
  55. # define V3D_HUB_INT_TFUF BIT(0)
  56. #define V3D_GCA_CACHE_CTRL 0x0000c
  57. # define V3D_GCA_CACHE_CTRL_FLUSH BIT(0)
  58. #define V3D_GCA_SAFE_SHUTDOWN 0x000b0
  59. # define V3D_GCA_SAFE_SHUTDOWN_EN BIT(0)
  60. #define V3D_GCA_SAFE_SHUTDOWN_ACK 0x000b4
  61. # define V3D_GCA_SAFE_SHUTDOWN_ACK_ACKED 3
  62. # define V3D_TOP_GR_BRIDGE_REVISION 0x00000
  63. # define V3D_TOP_GR_BRIDGE_MAJOR_MASK V3D_MASK(15, 8)
  64. # define V3D_TOP_GR_BRIDGE_MAJOR_SHIFT 8
  65. # define V3D_TOP_GR_BRIDGE_MINOR_MASK V3D_MASK(7, 0)
  66. # define V3D_TOP_GR_BRIDGE_MINOR_SHIFT 0
  67. /* 7268 reset reg */
  68. # define V3D_TOP_GR_BRIDGE_SW_INIT_0 0x00008
  69. # define V3D_TOP_GR_BRIDGE_SW_INIT_0_V3D_CLK_108_SW_INIT BIT(0)
  70. /* 7278 reset reg */
  71. # define V3D_TOP_GR_BRIDGE_SW_INIT_1 0x0000c
  72. # define V3D_TOP_GR_BRIDGE_SW_INIT_1_V3D_CLK_108_SW_INIT BIT(0)
  73. /* Per-MMU registers. */
  74. #define V3D_MMUC_CONTROL 0x01000
  75. # define V3D_MMUC_CONTROL_CLEAR BIT(3)
  76. # define V3D_MMUC_CONTROL_FLUSHING BIT(2)
  77. # define V3D_MMUC_CONTROL_FLUSH BIT(1)
  78. # define V3D_MMUC_CONTROL_ENABLE BIT(0)
  79. #define V3D_MMU_CTL 0x01200
  80. # define V3D_MMU_CTL_CAP_EXCEEDED BIT(27)
  81. # define V3D_MMU_CTL_CAP_EXCEEDED_ABORT BIT(26)
  82. # define V3D_MMU_CTL_CAP_EXCEEDED_INT BIT(25)
  83. # define V3D_MMU_CTL_CAP_EXCEEDED_EXCEPTION BIT(24)
  84. # define V3D_MMU_CTL_PT_INVALID BIT(20)
  85. # define V3D_MMU_CTL_PT_INVALID_ABORT BIT(19)
  86. # define V3D_MMU_CTL_PT_INVALID_INT BIT(18)
  87. # define V3D_MMU_CTL_PT_INVALID_EXCEPTION BIT(17)
  88. # define V3D_MMU_CTL_WRITE_VIOLATION BIT(16)
  89. # define V3D_MMU_CTL_WRITE_VIOLATION_ABORT BIT(11)
  90. # define V3D_MMU_CTL_WRITE_VIOLATION_INT BIT(10)
  91. # define V3D_MMU_CTL_WRITE_VIOLATION_EXCEPTION BIT(9)
  92. # define V3D_MMU_CTL_TLB_CLEARING BIT(7)
  93. # define V3D_MMU_CTL_TLB_STATS_CLEAR BIT(3)
  94. # define V3D_MMU_CTL_TLB_CLEAR BIT(2)
  95. # define V3D_MMU_CTL_TLB_STATS_ENABLE BIT(1)
  96. # define V3D_MMU_CTL_ENABLE BIT(0)
  97. #define V3D_MMU_PT_PA_BASE 0x01204
  98. #define V3D_MMU_HIT 0x01208
  99. #define V3D_MMU_MISSES 0x0120c
  100. #define V3D_MMU_STALLS 0x01210
  101. #define V3D_MMU_ADDR_CAP 0x01214
  102. # define V3D_MMU_ADDR_CAP_ENABLE BIT(31)
  103. # define V3D_MMU_ADDR_CAP_MPAGE_MASK V3D_MASK(11, 0)
  104. # define V3D_MMU_ADDR_CAP_MPAGE_SHIFT 0
  105. #define V3D_MMU_SHOOT_DOWN 0x01218
  106. # define V3D_MMU_SHOOT_DOWN_SHOOTING BIT(29)
  107. # define V3D_MMU_SHOOT_DOWN_SHOOT BIT(28)
  108. # define V3D_MMU_SHOOT_DOWN_PAGE_MASK V3D_MASK(27, 0)
  109. # define V3D_MMU_SHOOT_DOWN_PAGE_SHIFT 0
  110. #define V3D_MMU_BYPASS_START 0x0121c
  111. #define V3D_MMU_BYPASS_END 0x01220
  112. /* AXI ID of the access that faulted */
  113. #define V3D_MMU_VIO_ID 0x0122c
  114. /* Address for illegal PTEs to return */
  115. #define V3D_MMU_ILLEGAL_ADDR 0x01230
  116. # define V3D_MMU_ILLEGAL_ADDR_ENABLE BIT(31)
  117. /* Address that faulted */
  118. #define V3D_MMU_VIO_ADDR 0x01234
  119. /* Per-V3D-core registers */
  120. #define V3D_CTL_IDENT0 0x00000
  121. # define V3D_IDENT0_VER_MASK V3D_MASK(31, 24)
  122. # define V3D_IDENT0_VER_SHIFT 24
  123. #define V3D_CTL_IDENT1 0x00004
  124. /* Multiples of 1kb */
  125. # define V3D_IDENT1_VPM_SIZE_MASK V3D_MASK(31, 28)
  126. # define V3D_IDENT1_VPM_SIZE_SHIFT 28
  127. # define V3D_IDENT1_NSEM_MASK V3D_MASK(23, 16)
  128. # define V3D_IDENT1_NSEM_SHIFT 16
  129. # define V3D_IDENT1_NTMU_MASK V3D_MASK(15, 12)
  130. # define V3D_IDENT1_NTMU_SHIFT 12
  131. # define V3D_IDENT1_QUPS_MASK V3D_MASK(11, 8)
  132. # define V3D_IDENT1_QUPS_SHIFT 8
  133. # define V3D_IDENT1_NSLC_MASK V3D_MASK(7, 4)
  134. # define V3D_IDENT1_NSLC_SHIFT 4
  135. # define V3D_IDENT1_REV_MASK V3D_MASK(3, 0)
  136. # define V3D_IDENT1_REV_SHIFT 0
  137. #define V3D_CTL_IDENT2 0x00008
  138. # define V3D_IDENT2_BCG_INT BIT(28)
  139. #define V3D_CTL_MISCCFG 0x00018
  140. # define V3D_MISCCFG_OVRTMUOUT BIT(0)
  141. #define V3D_CTL_L2CACTL 0x00020
  142. # define V3D_L2CACTL_L2CCLR BIT(2)
  143. # define V3D_L2CACTL_L2CDIS BIT(1)
  144. # define V3D_L2CACTL_L2CENA BIT(0)
  145. #define V3D_CTL_SLCACTL 0x00024
  146. # define V3D_SLCACTL_TVCCS_MASK V3D_MASK(27, 24)
  147. # define V3D_SLCACTL_TVCCS_SHIFT 24
  148. # define V3D_SLCACTL_TDCCS_MASK V3D_MASK(19, 16)
  149. # define V3D_SLCACTL_TDCCS_SHIFT 16
  150. # define V3D_SLCACTL_UCC_MASK V3D_MASK(11, 8)
  151. # define V3D_SLCACTL_UCC_SHIFT 8
  152. # define V3D_SLCACTL_ICC_MASK V3D_MASK(3, 0)
  153. # define V3D_SLCACTL_ICC_SHIFT 0
  154. #define V3D_CTL_L2TCACTL 0x00030
  155. # define V3D_L2TCACTL_TMUWCF BIT(8)
  156. # define V3D_L2TCACTL_L2T_NO_WM BIT(4)
  157. # define V3D_L2TCACTL_FLM_FLUSH 0
  158. # define V3D_L2TCACTL_FLM_CLEAR 1
  159. # define V3D_L2TCACTL_FLM_CLEAN 2
  160. # define V3D_L2TCACTL_FLM_MASK V3D_MASK(2, 1)
  161. # define V3D_L2TCACTL_FLM_SHIFT 1
  162. # define V3D_L2TCACTL_L2TFLS BIT(0)
  163. #define V3D_CTL_L2TFLSTA 0x00034
  164. #define V3D_CTL_L2TFLEND 0x00038
  165. #define V3D_CTL_INT_STS 0x00050
  166. #define V3D_CTL_INT_SET 0x00054
  167. #define V3D_CTL_INT_CLR 0x00058
  168. #define V3D_CTL_INT_MSK_STS 0x0005c
  169. #define V3D_CTL_INT_MSK_SET 0x00060
  170. #define V3D_CTL_INT_MSK_CLR 0x00064
  171. # define V3D_INT_QPU_MASK V3D_MASK(27, 16)
  172. # define V3D_INT_QPU_SHIFT 16
  173. # define V3D_INT_GMPV BIT(5)
  174. # define V3D_INT_TRFB BIT(4)
  175. # define V3D_INT_SPILLUSE BIT(3)
  176. # define V3D_INT_OUTOMEM BIT(2)
  177. # define V3D_INT_FLDONE BIT(1)
  178. # define V3D_INT_FRDONE BIT(0)
  179. #define V3D_CLE_CT0CS 0x00100
  180. #define V3D_CLE_CT1CS 0x00104
  181. #define V3D_CLE_CTNCS(n) (V3D_CLE_CT0CS + 4 * n)
  182. #define V3D_CLE_CT0EA 0x00108
  183. #define V3D_CLE_CT1EA 0x0010c
  184. #define V3D_CLE_CTNEA(n) (V3D_CLE_CT0EA + 4 * n)
  185. #define V3D_CLE_CT0CA 0x00110
  186. #define V3D_CLE_CT1CA 0x00114
  187. #define V3D_CLE_CTNCA(n) (V3D_CLE_CT0CA + 4 * n)
  188. #define V3D_CLE_CT0RA 0x00118
  189. #define V3D_CLE_CT1RA 0x0011c
  190. #define V3D_CLE_CTNRA(n) (V3D_CLE_CT0RA + 4 * n)
  191. #define V3D_CLE_CT0LC 0x00120
  192. #define V3D_CLE_CT1LC 0x00124
  193. #define V3D_CLE_CT0PC 0x00128
  194. #define V3D_CLE_CT1PC 0x0012c
  195. #define V3D_CLE_PCS 0x00130
  196. #define V3D_CLE_BFC 0x00134
  197. #define V3D_CLE_RFC 0x00138
  198. #define V3D_CLE_TFBC 0x0013c
  199. #define V3D_CLE_TFIT 0x00140
  200. #define V3D_CLE_CT1CFG 0x00144
  201. #define V3D_CLE_CT1TILECT 0x00148
  202. #define V3D_CLE_CT1TSKIP 0x0014c
  203. #define V3D_CLE_CT1PTCT 0x00150
  204. #define V3D_CLE_CT0SYNC 0x00154
  205. #define V3D_CLE_CT1SYNC 0x00158
  206. #define V3D_CLE_CT0QTS 0x0015c
  207. # define V3D_CLE_CT0QTS_ENABLE BIT(1)
  208. #define V3D_CLE_CT0QBA 0x00160
  209. #define V3D_CLE_CT1QBA 0x00164
  210. #define V3D_CLE_CTNQBA(n) (V3D_CLE_CT0QBA + 4 * n)
  211. #define V3D_CLE_CT0QEA 0x00168
  212. #define V3D_CLE_CT1QEA 0x0016c
  213. #define V3D_CLE_CTNQEA(n) (V3D_CLE_CT0QEA + 4 * n)
  214. #define V3D_CLE_CT0QMA 0x00170
  215. #define V3D_CLE_CT0QMS 0x00174
  216. #define V3D_CLE_CT1QCFG 0x00178
  217. /* If set without ETPROC, entirely skip tiles with no primitives. */
  218. # define V3D_CLE_QCFG_ETFILT BIT(7)
  219. /* If set with ETFILT, just write the clear color to tiles with no
  220. * primitives.
  221. */
  222. # define V3D_CLE_QCFG_ETPROC BIT(6)
  223. # define V3D_CLE_QCFG_ETSFLUSH BIT(1)
  224. # define V3D_CLE_QCFG_MCDIS BIT(0)
  225. #define V3D_PTB_BPCA 0x00300
  226. #define V3D_PTB_BPCS 0x00304
  227. #define V3D_PTB_BPOA 0x00308
  228. #define V3D_PTB_BPOS 0x0030c
  229. #define V3D_PTB_BXCF 0x00310
  230. # define V3D_PTB_BXCF_RWORDERDISA BIT(1)
  231. # define V3D_PTB_BXCF_CLIPDISA BIT(0)
  232. #define V3D_GMP_STATUS 0x00800
  233. # define V3D_GMP_STATUS_GMPRST BIT(31)
  234. # define V3D_GMP_STATUS_WR_COUNT_MASK V3D_MASK(30, 24)
  235. # define V3D_GMP_STATUS_WR_COUNT_SHIFT 24
  236. # define V3D_GMP_STATUS_RD_COUNT_MASK V3D_MASK(22, 16)
  237. # define V3D_GMP_STATUS_RD_COUNT_SHIFT 16
  238. # define V3D_GMP_STATUS_WR_ACTIVE BIT(5)
  239. # define V3D_GMP_STATUS_RD_ACTIVE BIT(4)
  240. # define V3D_GMP_STATUS_CFG_BUSY BIT(3)
  241. # define V3D_GMP_STATUS_CNTOVF BIT(2)
  242. # define V3D_GMP_STATUS_INVPROT BIT(1)
  243. # define V3D_GMP_STATUS_VIO BIT(0)
  244. #define V3D_GMP_CFG 0x00804
  245. # define V3D_GMP_CFG_LBURSTEN BIT(3)
  246. # define V3D_GMP_CFG_PGCRSEN BIT()
  247. # define V3D_GMP_CFG_STOP_REQ BIT(1)
  248. # define V3D_GMP_CFG_PROT_ENABLE BIT(0)
  249. #define V3D_GMP_VIO_ADDR 0x00808
  250. #define V3D_GMP_VIO_TYPE 0x0080c
  251. #define V3D_GMP_TABLE_ADDR 0x00810
  252. #define V3D_GMP_CLEAR_LOAD 0x00814
  253. #define V3D_GMP_PRESERVE_LOAD 0x00818
  254. #define V3D_GMP_VALID_LINES 0x00820
  255. #endif /* V3D_REGS_H */