arm-smmu-debug.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifdef CONFIG_ARM_SMMU_TESTBUS_DUMP_GEN3AUTO
  7. #define ARM_SMMU_TESTBUS_SEL 0x2524
  8. #define ARM_SMMU_TESTBUS 0x2528
  9. #define ARM_SMMU_TCU_TESTBUS_HLOS1_NS ARM_SMMU_TESTBUS_SEL_HLOS1_NS
  10. #else
  11. #define ARM_SMMU_TESTBUS_SEL 0x25E4
  12. #define ARM_SMMU_TESTBUS 0x25E8
  13. #define ARM_SMMU_TCU_TESTBUS_HLOS1_NS 0x28
  14. #endif
  15. #define ARM_SMMU_TESTBUS_SEL_HLOS1_NS 0x8
  16. #define DEBUG_TESTBUS_SEL_TBU 0x50
  17. #define DEBUG_TESTBUS_TBU 0x58
  18. #define DebugChainQTB_debug_Load 0x8
  19. #define DebugChainQTB_debug_Dump_Low 0x10
  20. #define DebugChainQTB_debug_Dump_High 0x14
  21. #define DebugChainQTB_debug_ShiftRegLen 0x18
  22. #define Qtb500_QtbNsDbgQsmStatus 0xc00
  23. #define Qtb500_QtbNsDbgIdleStatus 0xc08
  24. #define TCU_PTW_TESTBUS BIT(8)
  25. #define TCU_CACHE_TESTBUS ~TCU_PTW_TESTBUS
  26. #define TCU_PTW_TESTBUS_SEL BIT(1)
  27. #define TCU_PTW_INTERNAL_STATES 3
  28. #define TCU_PTW_INTERNAL_STATES_MASK GENMASK(7, 2)
  29. #define TCU_PTW_TESTBUS_SEL2 3
  30. #define TCU_PTW_TESTBUS_SEL2_MASK GENMASK(1, 0)
  31. #define TCU_PTW_QUEUE_START 32
  32. #define TCU_PTW_QUEUE_SIZE 32
  33. #define TCU_PTW_QUEUE_MASK GENMASK(7, 0)
  34. #define TCU_CACHE_TESTBUS_SEL 0x1
  35. #define TCU_CACHE_LOOKUP_QUEUE_SIZE 32
  36. #define TCU_CLK_TESTBUS_SEL 0x300
  37. #define TCU_CD_TESTBUS_SEL BIT(2)
  38. #define TCU_CD_TESTBUS BIT(8)
  39. #define TCU_CD_TESTBUS_SHIFT 3
  40. #define TBU_CLK_GATE_CONTROLLER_TESTBUS_SEL 0x1
  41. #define TBU_QNS4_A2Q_TESTBUS_SEL BIT(1)
  42. #define TBU_QNS4_Q2A_TESTBUS_SEL BIT(2)
  43. #define TBU_MULTIMASTER_QCHANNEL_TESTBUS_SEL BIT(3)
  44. #define TBU_CLK_GATE_CONTROLLER_EXT_TESTBUS_SEL BIT(4)
  45. #define TBU_LOW_POWER_STATUS_TESTBUS_SEL BIT(5)
  46. #define TBU_QNS4_VLD_RDY_SEL BIT(6)
  47. #define TBU_CLK_GATE_CONTROLLER_TESTBUS BIT(6)
  48. #define TBU_QNS4_A2Q_TESTBUS BIT(7)
  49. #define TBU_QNS4_Q2A_TESTBUS (BIT(5) | BIT(7))
  50. #define TBU_MULTIMASTER_QCHANNEL_TESTBUS GENMASK(7, 6)
  51. #define TBU_CLK_GATE_CONTROLLER_EXT_TESTBUS BIT(8)
  52. #define TBU_LOW_POWER_STATUS_TESTBUS (BIT(8) | BIT(6))
  53. #define TBU_QNS4_VLD_RDY (BIT(8) | BIT(7))
  54. #define TBU_MASK GENMASK(8, 0)
  55. #define TBU_QNS4_BRIDGE_SIZE 32
  56. #define TBU_QNS4_BRIDGE_MASK GENMASK(4, 0)
  57. extern int tbu_testbus_sel;
  58. extern int tcu_testbus_sel;
  59. #define TNX_TCR_CNTL 0x130
  60. #define TNX_TCR_CNTL_TBU_OT_CAPTURE_EN BIT(18)
  61. #define TNX_TCR_CNTL_ALWAYS_CAPTURE BIT(15)
  62. #define TNX_TCR_CNTL_MATCH_MASK_UPD BIT(7)
  63. #define TNX_TCR_CNTL_MATCH_MASK_VALID BIT(6)
  64. #define CAPTURE1_SNAPSHOT_1 0x138
  65. #define TNX_TCR_CNTL_2 0x178
  66. #define TNX_TCR_CNTL_2_CAP1_VALID BIT(0)
  67. #define ARM_SMMU_CAPTURE1_MASK(i) (0x100 + (0x8 * (i-1)))
  68. #define ARM_SMMU_CAPTURE1_MATCH(i) (0x118 + (0x8 * (i-1)))
  69. #define ARM_SMMU_CAPTURE_SNAPSHOT(i, j) (CAPTURE1_SNAPSHOT_1 + \
  70. (0x10 * (i)) + ((j) * 0x8))
  71. #define NO_OF_MASK_AND_MATCH 0x3
  72. #define NO_OF_CAPTURE_POINTS 0x4
  73. #define REGS_PER_CAPTURE_POINT 0x2
  74. #define INTR_CLR BIT(0)
  75. #define RESET_VALID BIT(7)
  76. #define TTQTB_SET 0x1
  77. #define TTQTB_RESET_VAL 0x0
  78. #define TTQTB_LogAsstEn BIT(8)
  79. #define TTQTB_LogAll BIT(7)
  80. #define TTQTB_GlbEn BIT(0)
  81. #define TTQTB_IgnoreCtiTrigIn0 BIT(5)
  82. #define TransTrackerQTB_MainCtl 0x8
  83. #define TransTrackerQTB_AlarmEn 0x10
  84. #define TransTrackerQTB_AlarmStatus 0x18
  85. #define TransTrackerQTB_AlarmClr 0x20
  86. #define TransTrackerQTB_LogClr 0x30
  87. #define TransTrackerQTB_LogInVld_Low 0x38
  88. #define TransTrackerQTB_LogOutVld_Low 0x40
  89. #define TransTrackerQTB_LogOutErr_Low 0x48
  90. #define TTQTB_Capture_Points 0x8
  91. #define TTQTB_Regs_Per_Capture_Points 0x4
  92. #define TTQTB_TimeStamp 0xa0
  93. #define TransTrackerQTB_TimeStamp(i) (TTQTB_TimeStamp + \
  94. (0x8 * (i)))
  95. #define TTQTB_Latency 0x50
  96. #define TransTrackerQTB_Latency(i) (TTQTB_Latency + \
  97. (0x8 * (i)))
  98. #define TTQTB_LogIn_Low 0x200
  99. #define TTQTB_LogIn_High 0x204
  100. #define TransTrackerQTB_LogIn_Low(i, j) (TTQTB_LogIn_Low + \
  101. (0x20 * (i)) + (0x8 * (j)))
  102. #define TransTrackerQTB_LogIn_High(i, j) (TTQTB_LogIn_High + \
  103. (0x20 * (i)) + (0x8 * (j)))
  104. #define TTQTB_LogOut_Low 0x300
  105. #define TTQTB_LogOut_High 0x304
  106. #define TransTrackerQTB_LogOut_Low(i, j) (TTQTB_LogIn_Low + \
  107. (0x20 * (i)) + (0x8 * (j)))
  108. #define TransTrackerQTB_LogOut_High(i, j) (TTQTB_LogIn_High + \
  109. (0x20 * (i)) + (0x8 * (j)))
  110. #define TTQTB_Filter_DevNeEn BIT(0)
  111. #define TTQTB_Filter_DevEEn BIT(1)
  112. #define TTQTB_Filter_NormalEn BIT(2)
  113. #define TTQTB_Filter_CachedEn BIT(3)
  114. #define TTQTB_Filter_SharedEn BIT(4)
  115. #define TTQTB_Filter_PostedEn BIT(5)
  116. #define TTQTB_Filter_OpCode_Set_Val 0x1f
  117. #define TTQTB_Filter_Alloc_Set_Val 0xe3ef
  118. #define TTQTB_Filter_Length_Set_Val 0x1ff
  119. #define TransTrackerQTB_Filter_TrType 0x168
  120. #define TransTrackerQTB_Filter_Addr_Min_Low 0x120
  121. #define TransTrackerQTB_Filter_Addr_Min_High 0x124
  122. #define TransTrackerQTB_Filter_Addr_Max_Low 0x128
  123. #define TransTrackerQTB_Filter_Addr_Max_High 0x12C
  124. #define TransTrackerQTB_gfx_Filter_Addr_Min 0x120
  125. #define TransTrackerQTB_gfx_Filter_Addr_Max 0x128
  126. #define TransTrackerQTB_Filter_OpCode 0x138
  127. #define TransTrackerQTB_Filter_ReqUser_Base 0x148
  128. #define TransTrackerQTB_Filter_ReqUser_Mask 0x150
  129. #define TransTrackerQTB_Filter_LogUser_Base 0x158
  130. #define TransTrackerQTB_Filter_LogUser_Mask 0x160
  131. #define TransTrackerQTB_Filter_Alloc 0x170
  132. #define TransTrackerQTB_Filter_ExtId_Base 0x178
  133. #define TransTrackerQTB_Filter_ExtId_Mask 0x180
  134. #define TransTrackerQTB_Filter_Length 0x188
  135. #define TransTrackerQTB_Filter_Urgency 0x190
  136. #define TransTrackerQTB_Filter_CacheIndex_Base 0x198
  137. #define TransTrackerQTB_Filter_CacheIndex_Mask 0x1A0
  138. enum tcu_testbus {
  139. PTW_AND_CACHE_TESTBUS,
  140. CLK_TESTBUS,
  141. };
  142. enum testbus_sel {
  143. SEL_TCU,
  144. SEL_TBU,
  145. };
  146. enum testbus_ops {
  147. TESTBUS_SELECT,
  148. TESTBUS_OUTPUT,
  149. };
  150. #if IS_ENABLED(CONFIG_ARM_SMMU)
  151. u32 arm_smmu_debug_qtb_debugchain_load(void __iomem *debugchain_base);
  152. u64 arm_smmu_debug_qtb_debugchain_dump(void __iomem *debugchain_base);
  153. void arm_smmu_debug_dump_debugchain(struct device *dev, void __iomem *debugchain_base);
  154. void arm_smmu_debug_dump_qtb_regs(struct device *dev, void __iomem *tbu_base);
  155. void arm_smmu_debug_qtb_transtracker_set_config(void __iomem *transactiontracker_base, u64 sel);
  156. u64 arm_smmu_debug_qtb_transtracker_get_config(void __iomem *transactiontracker_base);
  157. void arm_smmu_debug_qtb_transtracker_setfilter(void __iomem *transactiontracker_base,
  158. u64 sel, u64 filter, int qtb_type);
  159. void arm_smmu_debug_qtb_transtracker_getfilter(void __iomem *transactiontracker_base,
  160. u64 filter[3], int qtb_type);
  161. void arm_smmu_debug_qtb_transtrac_reset(void __iomem *transactiontracker_base);
  162. void arm_smmu_debug_qtb_transtrac_collect(void __iomem *transactiontracker_base,
  163. u64 gfxttlogs[TTQTB_Capture_Points][2*TTQTB_Regs_Per_Capture_Points],
  164. u64 ttlogs[TTQTB_Capture_Points][4*TTQTB_Regs_Per_Capture_Points],
  165. u64 ttlogs_time[2*TTQTB_Capture_Points], int qtb_type);
  166. u32 arm_smmu_debug_tbu_testbus_select(void __iomem *tbu_base,
  167. bool write, u32 val);
  168. u32 arm_smmu_debug_tbu_testbus_output(void __iomem *tbu_base);
  169. u32 arm_smmu_debug_tcu_testbus_select(phys_addr_t phys_addr,
  170. void __iomem *tcu_base, enum tcu_testbus testbus,
  171. bool write, u32 val);
  172. u32 arm_smmu_debug_tcu_testbus_output(phys_addr_t phys_addr);
  173. void arm_smmu_debug_dump_tbu_testbus(struct device *dev, void __iomem *tbu_base,
  174. int tbu_testbus_sel);
  175. void arm_smmu_debug_dump_tcu_testbus(struct device *dev, phys_addr_t phys_addr,
  176. void __iomem *tcu_base, int tcu_testbus_sel);
  177. void arm_smmu_debug_set_tnx_tcr_cntl(void __iomem *tbu_base, u64 val);
  178. u64 arm_smmu_debug_get_tnx_tcr_cntl(void __iomem *tbu_base);
  179. void arm_smmu_debug_set_mask_and_match(void __iomem *tbu_base, u64 sel,
  180. u64 mask, u64 match);
  181. void arm_smmu_debug_get_mask_and_match(void __iomem *tbu_base,
  182. u64 *mask, u64 *match);
  183. void arm_smmu_debug_get_capture_snapshot(void __iomem *tbu_base,
  184. u64 snapshot[NO_OF_CAPTURE_POINTS][REGS_PER_CAPTURE_POINT]);
  185. void arm_smmu_debug_clear_intr_and_validbits(void __iomem *tbu_base);
  186. #else
  187. u32 arm_smmu_debug_qtb_debugchain_load(void __iomem *debugchain_base);
  188. {
  189. return 0;
  190. }
  191. u64 arm_smmu_debug_qtb_debugchain_dump(void __iomem *debugchain_base);
  192. {
  193. return 0;
  194. }
  195. void arm_smmu_debug_dump_debugchain(struct device *dev, void __iomem *debugchain_base);
  196. {
  197. }
  198. void arm_smmu_debug_dump_qtb_regs(struct device *dev, void __iomem *tbu_base)
  199. {
  200. }
  201. u64 arm_smmu_debug_transtracker_get_config(void __iomem *transactiontracker_base)
  202. {
  203. return 0;
  204. }
  205. void arm_smmu_debug_transtracker_setfilter(void __iomem *transactiontracker_base,
  206. u64 sel, u64 filter, int qtb_type)
  207. {
  208. }
  209. void arm_smmu_debug_transtracker_getfilter(void __iomem *transactiontracker_base,
  210. u64 filter[3], int qtb_type)
  211. {
  212. }
  213. void arm_smmu_debug_qtb_transtrac_reset(void __iomem *transactiontracker_base)
  214. {
  215. }
  216. void arm_smmu_debug_configure_transtracker_custom(void __iomem *transactiontracker_base,
  217. u64 trtype, u64 addrmax)
  218. {
  219. }
  220. void arm_smmu_debug_qtb_transtrac_collect(void __iomem *transactiontracker_base,
  221. u64 gfxttlogs[TTQTB_Capture_Points][2*TTQTB_Regs_Per_Capture_Points],
  222. u64 ttlogs[TTQTB_Capture_Points][4*TTQTB_Regs_Per_Capture_Points],
  223. u64 ttlogs_time[2*TTQTB_Capture_Points], int qtb_type)
  224. {
  225. }
  226. static inline u32 arm_smmu_debug_tbu_testbus_select(void __iomem *tbu_base,
  227. bool write, u32 val)
  228. {
  229. return 0;
  230. }
  231. static inline u32 arm_smmu_debug_tbu_testbus_output(void __iomem *tbu_base)
  232. {
  233. return 0;
  234. }
  235. u32 arm_smmu_debug_tcu_testbus_select(phys_addr_t phys_addr,
  236. void __iomem *tcu_base, enum tcu_testbus testbus,
  237. bool write, u32 val)
  238. {
  239. }
  240. static inline u32 arm_smmu_debug_tcu_testbus_output(phys_addr_t phys_addr)
  241. {
  242. return 0;
  243. }
  244. static inline void arm_smmu_debug_dump_tbu_testbus(struct device *dev,
  245. void __iomem *tbu_base, int tbu_testbus_sel)
  246. {
  247. }
  248. static inline void arm_smmu_debug_dump_tcu_testbus(struct device *dev,
  249. phys_addr_t phys_addr, void __iomem *tcu_base,
  250. int tcu_testbus_sel)
  251. {
  252. }
  253. static inline void arm_smmu_debug_set_tnx_tcr_cntl(void __iomem *tbu_base,
  254. u64 val)
  255. {
  256. }
  257. static inline u64 arm_smmu_debug_get_tnx_tcr_cntl(void __iomem *tbu_base)
  258. {
  259. return 0;
  260. }
  261. static inline void arm_smmu_debug_set_mask_and_match(void __iomem *tbu_base, u64
  262. sel, u64 mask, u64 match)
  263. {
  264. }
  265. static inline void arm_smmu_debug_get_mask_and_match(void __iomem *tbu_base,
  266. u64 *mask, u64 *match)
  267. {
  268. }
  269. static inline void arm_smmu_debug_get_capture_snapshot(void __iomem *tbu_base,
  270. u64 snapshot[NO_OF_CAPTURE_POINTS][REGS_PER_CAPTURE_POINT])
  271. {
  272. }
  273. static inline void arm_smmu_debug_clear_intr_and_validbits(void __iomem
  274. *tbu_base)
  275. {
  276. }
  277. #endif