coresight-etm.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _CORESIGHT_CORESIGHT_ETM_H
  13. #define _CORESIGHT_CORESIGHT_ETM_H
  14. #include <linux/spinlock.h>
  15. #include "coresight-priv.h"
  16. /*
  17. * Device registers:
  18. * 0x000 - 0x2FC: Trace registers
  19. * 0x300 - 0x314: Management registers
  20. * 0x318 - 0xEFC: Trace registers
  21. *
  22. * Coresight registers
  23. * 0xF00 - 0xF9C: Management registers
  24. * 0xFA0 - 0xFA4: Management registers in PFTv1.0
  25. * Trace registers in PFTv1.1
  26. * 0xFA8 - 0xFFC: Management registers
  27. */
  28. /* Trace registers (0x000-0x2FC) */
  29. #define ETMCR 0x000
  30. #define ETMCCR 0x004
  31. #define ETMTRIGGER 0x008
  32. #define ETMSR 0x010
  33. #define ETMSCR 0x014
  34. #define ETMTSSCR 0x018
  35. #define ETMTECR2 0x01c
  36. #define ETMTEEVR 0x020
  37. #define ETMTECR1 0x024
  38. #define ETMFFLR 0x02c
  39. #define ETMACVRn(n) (0x040 + (n * 4))
  40. #define ETMACTRn(n) (0x080 + (n * 4))
  41. #define ETMCNTRLDVRn(n) (0x140 + (n * 4))
  42. #define ETMCNTENRn(n) (0x150 + (n * 4))
  43. #define ETMCNTRLDEVRn(n) (0x160 + (n * 4))
  44. #define ETMCNTVRn(n) (0x170 + (n * 4))
  45. #define ETMSQ12EVR 0x180
  46. #define ETMSQ21EVR 0x184
  47. #define ETMSQ23EVR 0x188
  48. #define ETMSQ31EVR 0x18c
  49. #define ETMSQ32EVR 0x190
  50. #define ETMSQ13EVR 0x194
  51. #define ETMSQR 0x19c
  52. #define ETMEXTOUTEVRn(n) (0x1a0 + (n * 4))
  53. #define ETMCIDCVRn(n) (0x1b0 + (n * 4))
  54. #define ETMCIDCMR 0x1bc
  55. #define ETMIMPSPEC0 0x1c0
  56. #define ETMIMPSPEC1 0x1c4
  57. #define ETMIMPSPEC2 0x1c8
  58. #define ETMIMPSPEC3 0x1cc
  59. #define ETMIMPSPEC4 0x1d0
  60. #define ETMIMPSPEC5 0x1d4
  61. #define ETMIMPSPEC6 0x1d8
  62. #define ETMIMPSPEC7 0x1dc
  63. #define ETMSYNCFR 0x1e0
  64. #define ETMIDR 0x1e4
  65. #define ETMCCER 0x1e8
  66. #define ETMEXTINSELR 0x1ec
  67. #define ETMTESSEICR 0x1f0
  68. #define ETMEIBCR 0x1f4
  69. #define ETMTSEVR 0x1f8
  70. #define ETMAUXCR 0x1fc
  71. #define ETMTRACEIDR 0x200
  72. #define ETMVMIDCVR 0x240
  73. /* Management registers (0x300-0x314) */
  74. #define ETMOSLAR 0x300
  75. #define ETMOSLSR 0x304
  76. #define ETMOSSRR 0x308
  77. #define ETMPDCR 0x310
  78. #define ETMPDSR 0x314
  79. #define ETM_MAX_ADDR_CMP 16
  80. #define ETM_MAX_CNTR 4
  81. #define ETM_MAX_CTXID_CMP 3
  82. /* Register definition */
  83. /* ETMCR - 0x00 */
  84. #define ETMCR_PWD_DWN BIT(0)
  85. #define ETMCR_STALL_MODE BIT(7)
  86. #define ETMCR_ETM_PRG BIT(10)
  87. #define ETMCR_ETM_EN BIT(11)
  88. #define ETMCR_CYC_ACC BIT(12)
  89. #define ETMCR_CTXID_SIZE (BIT(14)|BIT(15))
  90. #define ETMCR_TIMESTAMP_EN BIT(28)
  91. /* ETMCCR - 0x04 */
  92. #define ETMCCR_FIFOFULL BIT(23)
  93. /* ETMPDCR - 0x310 */
  94. #define ETMPDCR_PWD_UP BIT(3)
  95. /* ETMTECR1 - 0x024 */
  96. #define ETMTECR1_ADDR_COMP_1 BIT(0)
  97. #define ETMTECR1_INC_EXC BIT(24)
  98. #define ETMTECR1_START_STOP BIT(25)
  99. /* ETMCCER - 0x1E8 */
  100. #define ETMCCER_TIMESTAMP BIT(22)
  101. #define ETM_MODE_EXCLUDE BIT(0)
  102. #define ETM_MODE_CYCACC BIT(1)
  103. #define ETM_MODE_STALL BIT(2)
  104. #define ETM_MODE_TIMESTAMP BIT(3)
  105. #define ETM_MODE_CTXID BIT(4)
  106. #define ETM_MODE_ALL 0x1f
  107. #define ETM_SQR_MASK 0x3
  108. #define ETM_TRACEID_MASK 0x3f
  109. #define ETM_EVENT_MASK 0x1ffff
  110. #define ETM_SYNC_MASK 0xfff
  111. #define ETM_ALL_MASK 0xffffffff
  112. #define ETMSR_PROG_BIT 1
  113. #define ETM_SEQ_STATE_MAX_VAL (0x2)
  114. #define PORT_SIZE_MASK (GENMASK(21, 21) | GENMASK(6, 4))
  115. #define ETM_HARD_WIRE_RES_A /* Hard wired, always true */ \
  116. ((0x0f << 0) | \
  117. /* Resource index A */ \
  118. (0x06 << 4))
  119. #define ETM_ADD_COMP_0 /* Single addr comparator 1 */ \
  120. ((0x00 << 7) | \
  121. /* Resource index B */ \
  122. (0x00 << 11))
  123. #define ETM_EVENT_NOT_A BIT(14) /* NOT(A) */
  124. #define ETM_DEFAULT_EVENT_VAL (ETM_HARD_WIRE_RES_A | \
  125. ETM_ADD_COMP_0 | \
  126. ETM_EVENT_NOT_A)
  127. /**
  128. * struct etm_drvdata - specifics associated to an ETM component
  129. * @base: memory mapped base address for this component.
  130. * @dev: the device entity associated to this component.
  131. * @atclk: optional clock for the core parts of the ETM.
  132. * @csdev: component vitals needed by the framework.
  133. * @spinlock: only one at a time pls.
  134. * @cpu: the cpu this component is affined to.
  135. * @port_size: port size as reported by ETMCR bit 4-6 and 21.
  136. * @arch: ETM/PTM version number.
  137. * @use_cpu14: true if management registers need to be accessed via CP14.
  138. * @enable: is this ETM/PTM currently tracing.
  139. * @sticky_enable: true if ETM base configuration has been done.
  140. * @boot_enable:true if we should start tracing at boot time.
  141. * @os_unlock: true if access to management registers is allowed.
  142. * @nr_addr_cmp:Number of pairs of address comparators as found in ETMCCR.
  143. * @nr_cntr: Number of counters as found in ETMCCR bit 13-15.
  144. * @nr_ext_inp: Number of external input as found in ETMCCR bit 17-19.
  145. * @nr_ext_out: Number of external output as found in ETMCCR bit 20-22.
  146. * @nr_ctxid_cmp: Number of contextID comparators as found in ETMCCR bit 24-25.
  147. * @etmccr: value of register ETMCCR.
  148. * @etmccer: value of register ETMCCER.
  149. * @traceid: value of the current ID for this component.
  150. * @mode: controls various modes supported by this ETM/PTM.
  151. * @ctrl: used in conjunction with @mode.
  152. * @trigger_event: setting for register ETMTRIGGER.
  153. * @startstop_ctrl: setting for register ETMTSSCR.
  154. * @enable_event: setting for register ETMTEEVR.
  155. * @enable_ctrl1: setting for register ETMTECR1.
  156. * @fifofull_level: setting for register ETMFFLR.
  157. * @addr_idx: index for the address comparator selection.
  158. * @addr_val: value for address comparator register.
  159. * @addr_acctype: access type for address comparator register.
  160. * @addr_type: current status of the comparator register.
  161. * @cntr_idx: index for the counter register selection.
  162. * @cntr_rld_val: reload value of a counter register.
  163. * @cntr_event: control for counter enable register.
  164. * @cntr_rld_event: value for counter reload event register.
  165. * @cntr_val: counter value register.
  166. * @seq_12_event: event causing the transition from 1 to 2.
  167. * @seq_21_event: event causing the transition from 2 to 1.
  168. * @seq_23_event: event causing the transition from 2 to 3.
  169. * @seq_31_event: event causing the transition from 3 to 1.
  170. * @seq_32_event: event causing the transition from 3 to 2.
  171. * @seq_13_event: event causing the transition from 1 to 3.
  172. * @seq_curr_state: current value of the sequencer register.
  173. * @ctxid_idx: index for the context ID registers.
  174. * @ctxid_pid: value for the context ID to trigger on.
  175. * @ctxid_vpid: Virtual PID seen by users if PID namespace is enabled, otherwise
  176. * the same value of ctxid_pid.
  177. * @ctxid_mask: mask applicable to all the context IDs.
  178. * @sync_freq: Synchronisation frequency.
  179. * @timestamp_event: Defines an event that requests the insertion
  180. of a timestamp into the trace stream.
  181. */
  182. struct etm_drvdata {
  183. void __iomem *base;
  184. struct device *dev;
  185. struct clk *atclk;
  186. struct coresight_device *csdev;
  187. spinlock_t spinlock;
  188. int cpu;
  189. int port_size;
  190. u8 arch;
  191. bool use_cp14;
  192. bool enable;
  193. bool sticky_enable;
  194. bool boot_enable;
  195. bool os_unlock;
  196. u8 nr_addr_cmp;
  197. u8 nr_cntr;
  198. u8 nr_ext_inp;
  199. u8 nr_ext_out;
  200. u8 nr_ctxid_cmp;
  201. u32 etmccr;
  202. u32 etmccer;
  203. u32 traceid;
  204. u32 mode;
  205. u32 ctrl;
  206. u32 trigger_event;
  207. u32 startstop_ctrl;
  208. u32 enable_event;
  209. u32 enable_ctrl1;
  210. u32 fifofull_level;
  211. u8 addr_idx;
  212. u32 addr_val[ETM_MAX_ADDR_CMP];
  213. u32 addr_acctype[ETM_MAX_ADDR_CMP];
  214. u32 addr_type[ETM_MAX_ADDR_CMP];
  215. u8 cntr_idx;
  216. u32 cntr_rld_val[ETM_MAX_CNTR];
  217. u32 cntr_event[ETM_MAX_CNTR];
  218. u32 cntr_rld_event[ETM_MAX_CNTR];
  219. u32 cntr_val[ETM_MAX_CNTR];
  220. u32 seq_12_event;
  221. u32 seq_21_event;
  222. u32 seq_23_event;
  223. u32 seq_31_event;
  224. u32 seq_32_event;
  225. u32 seq_13_event;
  226. u32 seq_curr_state;
  227. u8 ctxid_idx;
  228. u32 ctxid_pid[ETM_MAX_CTXID_CMP];
  229. u32 ctxid_vpid[ETM_MAX_CTXID_CMP];
  230. u32 ctxid_mask;
  231. u32 sync_freq;
  232. u32 timestamp_event;
  233. };
  234. enum etm_addr_type {
  235. ETM_ADDR_TYPE_NONE,
  236. ETM_ADDR_TYPE_SINGLE,
  237. ETM_ADDR_TYPE_RANGE,
  238. ETM_ADDR_TYPE_START,
  239. ETM_ADDR_TYPE_STOP,
  240. };
  241. #endif