1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef _CORESIGHT_CORESIGHT_ETM_H
14#define _CORESIGHT_CORESIGHT_ETM_H
15
16#include <asm/local.h>
17#include <linux/spinlock.h>
18#include "coresight-priv.h"
19
20
21
22
23
24
25
26
27
28
29
30
31#define TRCPRGCTLR 0x004
32#define TRCPROCSELR 0x008
33#define TRCSTATR 0x00C
34#define TRCCONFIGR 0x010
35#define TRCAUXCTLR 0x018
36#define TRCEVENTCTL0R 0x020
37#define TRCEVENTCTL1R 0x024
38#define TRCSTALLCTLR 0x02C
39#define TRCTSCTLR 0x030
40#define TRCSYNCPR 0x034
41#define TRCCCCTLR 0x038
42#define TRCBBCTLR 0x03C
43#define TRCTRACEIDR 0x040
44#define TRCQCTLR 0x044
45
46#define TRCVICTLR 0x080
47#define TRCVIIECTLR 0x084
48#define TRCVISSCTLR 0x088
49#define TRCVIPCSSCTLR 0x08C
50#define TRCVDCTLR 0x0A0
51#define TRCVDSACCTLR 0x0A4
52#define TRCVDARCCTLR 0x0A8
53
54#define TRCSEQEVRn(n) (0x100 + (n * 4))
55#define TRCSEQRSTEVR 0x118
56#define TRCSEQSTR 0x11C
57#define TRCEXTINSELR 0x120
58#define TRCCNTRLDVRn(n) (0x140 + (n * 4))
59#define TRCCNTCTLRn(n) (0x150 + (n * 4))
60#define TRCCNTVRn(n) (0x160 + (n * 4))
61
62#define TRCIDR8 0x180
63#define TRCIDR9 0x184
64#define TRCIDR10 0x188
65#define TRCIDR11 0x18C
66#define TRCIDR12 0x190
67#define TRCIDR13 0x194
68#define TRCIMSPEC0 0x1C0
69#define TRCIMSPECn(n) (0x1C0 + (n * 4))
70#define TRCIDR0 0x1E0
71#define TRCIDR1 0x1E4
72#define TRCIDR2 0x1E8
73#define TRCIDR3 0x1EC
74#define TRCIDR4 0x1F0
75#define TRCIDR5 0x1F4
76#define TRCIDR6 0x1F8
77#define TRCIDR7 0x1FC
78
79#define TRCRSCTLRn(n) (0x200 + (n * 4))
80
81#define TRCSSCCRn(n) (0x280 + (n * 4))
82#define TRCSSCSRn(n) (0x2A0 + (n * 4))
83#define TRCSSPCICRn(n) (0x2C0 + (n * 4))
84
85#define TRCOSLAR 0x300
86#define TRCOSLSR 0x304
87#define TRCPDCR 0x310
88#define TRCPDSR 0x314
89
90
91#define TRCACVRn(n) (0x400 + (n * 8))
92#define TRCACATRn(n) (0x480 + (n * 8))
93#define TRCDVCVRn(n) (0x500 + (n * 16))
94#define TRCDVCMRn(n) (0x580 + (n * 16))
95#define TRCCIDCVRn(n) (0x600 + (n * 8))
96#define TRCVMIDCVRn(n) (0x640 + (n * 8))
97#define TRCCIDCCTLR0 0x680
98#define TRCCIDCCTLR1 0x684
99#define TRCVMIDCCTLR0 0x688
100#define TRCVMIDCCTLR1 0x68C
101
102
103#define TRCITCTRL 0xF00
104
105
106#define TRCCLAIMSET 0xFA0
107#define TRCCLAIMCLR 0xFA4
108
109#define TRCDEVAFF0 0xFA8
110#define TRCDEVAFF1 0xFAC
111#define TRCLAR 0xFB0
112#define TRCLSR 0xFB4
113#define TRCAUTHSTATUS 0xFB8
114#define TRCDEVARCH 0xFBC
115#define TRCDEVID 0xFC8
116#define TRCDEVTYPE 0xFCC
117#define TRCPIDR4 0xFD0
118#define TRCPIDR5 0xFD4
119#define TRCPIDR6 0xFD8
120#define TRCPIDR7 0xFDC
121#define TRCPIDR0 0xFE0
122#define TRCPIDR1 0xFE4
123#define TRCPIDR2 0xFE8
124#define TRCPIDR3 0xFEC
125#define TRCCIDR0 0xFF0
126#define TRCCIDR1 0xFF4
127#define TRCCIDR2 0xFF8
128#define TRCCIDR3 0xFFC
129
130
131#define ETM_MAX_NR_PE 8
132#define ETMv4_MAX_CNTR 4
133#define ETM_MAX_SEQ_STATES 4
134#define ETM_MAX_EXT_INP_SEL 4
135#define ETM_MAX_EXT_INP 256
136#define ETM_MAX_EXT_OUT 4
137#define ETM_MAX_SINGLE_ADDR_CMP 16
138#define ETM_MAX_ADDR_RANGE_CMP (ETM_MAX_SINGLE_ADDR_CMP / 2)
139#define ETM_MAX_DATA_VAL_CMP 8
140#define ETMv4_MAX_CTXID_CMP 8
141#define ETM_MAX_VMID_CMP 8
142#define ETM_MAX_PE_CMP 8
143#define ETM_MAX_RES_SEL 16
144#define ETM_MAX_SS_CMP 8
145
146#define ETM_ARCH_V4 0x40
147#define ETMv4_SYNC_MASK 0x1F
148#define ETM_CYC_THRESHOLD_MASK 0xFFF
149#define ETM_CYC_THRESHOLD_DEFAULT 0x100
150#define ETMv4_EVENT_MASK 0xFF
151#define ETM_CNTR_MAX_VAL 0xFFFF
152#define ETM_TRACEID_MASK 0x3f
153
154
155#define ETM_MODE_EXCLUDE BIT(0)
156#define ETM_MODE_LOAD BIT(1)
157#define ETM_MODE_STORE BIT(2)
158#define ETM_MODE_LOAD_STORE BIT(3)
159#define ETM_MODE_BB BIT(4)
160#define ETMv4_MODE_CYCACC BIT(5)
161#define ETMv4_MODE_CTXID BIT(6)
162#define ETM_MODE_VMID BIT(7)
163#define ETM_MODE_COND(val) BMVAL(val, 8, 10)
164#define ETMv4_MODE_TIMESTAMP BIT(11)
165#define ETM_MODE_RETURNSTACK BIT(12)
166#define ETM_MODE_QELEM(val) BMVAL(val, 13, 14)
167#define ETM_MODE_DATA_TRACE_ADDR BIT(15)
168#define ETM_MODE_DATA_TRACE_VAL BIT(16)
169#define ETM_MODE_ISTALL BIT(17)
170#define ETM_MODE_DSTALL BIT(18)
171#define ETM_MODE_ATB_TRIGGER BIT(19)
172#define ETM_MODE_LPOVERRIDE BIT(20)
173#define ETM_MODE_ISTALL_EN BIT(21)
174#define ETM_MODE_DSTALL_EN BIT(22)
175#define ETM_MODE_INSTPRIO BIT(23)
176#define ETM_MODE_NOOVERFLOW BIT(24)
177#define ETM_MODE_TRACE_RESET BIT(25)
178#define ETM_MODE_TRACE_ERR BIT(26)
179#define ETM_MODE_VIEWINST_STARTSTOP BIT(27)
180#define ETMv4_MODE_ALL (GENMASK(27, 0) | \
181 ETM_MODE_EXCL_KERN | \
182 ETM_MODE_EXCL_USER)
183
184#define TRCSTATR_IDLE_BIT 0
185#define ETM_DEFAULT_ADDR_COMP 0
186
187
188#define TRCPDCR_PU BIT(3)
189
190
191#define ETM_EXLEVEL_S_APP BIT(8)
192#define ETM_EXLEVEL_S_OS BIT(9)
193#define ETM_EXLEVEL_S_NA BIT(10)
194#define ETM_EXLEVEL_S_HYP BIT(11)
195
196#define ETM_EXLEVEL_NS_APP BIT(12)
197#define ETM_EXLEVEL_NS_OS BIT(13)
198#define ETM_EXLEVEL_NS_HYP BIT(14)
199#define ETM_EXLEVEL_NS_NA BIT(15)
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250struct etmv4_config {
251 u32 mode;
252 u32 pe_sel;
253 u32 cfg;
254 u32 eventctrl0;
255 u32 eventctrl1;
256 u32 stall_ctrl;
257 u32 ts_ctrl;
258 u32 syncfreq;
259 u32 ccctlr;
260 u32 bb_ctrl;
261 u32 vinst_ctrl;
262 u32 viiectlr;
263 u32 vissctlr;
264 u32 vipcssctlr;
265 u8 seq_idx;
266 u32 seq_ctrl[ETM_MAX_SEQ_STATES];
267 u32 seq_rst;
268 u32 seq_state;
269 u8 cntr_idx;
270 u32 cntrldvr[ETMv4_MAX_CNTR];
271 u32 cntr_ctrl[ETMv4_MAX_CNTR];
272 u32 cntr_val[ETMv4_MAX_CNTR];
273 u8 res_idx;
274 u32 res_ctrl[ETM_MAX_RES_SEL];
275 u32 ss_ctrl[ETM_MAX_SS_CMP];
276 u32 ss_status[ETM_MAX_SS_CMP];
277 u32 ss_pe_cmp[ETM_MAX_SS_CMP];
278 u8 addr_idx;
279 u64 addr_val[ETM_MAX_SINGLE_ADDR_CMP];
280 u64 addr_acc[ETM_MAX_SINGLE_ADDR_CMP];
281 u8 addr_type[ETM_MAX_SINGLE_ADDR_CMP];
282 u8 ctxid_idx;
283 u64 ctxid_pid[ETMv4_MAX_CTXID_CMP];
284 u64 ctxid_vpid[ETMv4_MAX_CTXID_CMP];
285 u32 ctxid_mask0;
286 u32 ctxid_mask1;
287 u8 vmid_idx;
288 u64 vmid_val[ETM_MAX_VMID_CMP];
289 u32 vmid_mask0;
290 u32 vmid_mask1;
291 u32 ext_inp;
292};
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351struct etmv4_drvdata {
352 void __iomem *base;
353 struct device *dev;
354 struct coresight_device *csdev;
355 spinlock_t spinlock;
356 local_t mode;
357 int cpu;
358 u8 arch;
359 u8 nr_pe;
360 u8 nr_pe_cmp;
361 u8 nr_addr_cmp;
362 u8 nr_cntr;
363 u8 nr_ext_inp;
364 u8 numcidc;
365 u8 numvmidc;
366 u8 nrseqstate;
367 u8 nr_event;
368 u8 nr_resource;
369 u8 nr_ss_cmp;
370 u8 trcid;
371 u8 trcid_size;
372 u8 ts_size;
373 u8 ctxid_size;
374 u8 vmid_size;
375 u8 ccsize;
376 u8 ccitmin;
377 u8 s_ex_level;
378 u8 ns_ex_level;
379 u8 q_support;
380 bool sticky_enable;
381 bool boot_enable;
382 bool os_unlock;
383 bool instrp0;
384 bool trcbb;
385 bool trccond;
386 bool retstack;
387 bool trccci;
388 bool trc_error;
389 bool syncpr;
390 bool stallctl;
391 bool sysstall;
392 bool nooverflow;
393 bool atbtrig;
394 bool lpoverride;
395 struct etmv4_config config;
396};
397
398
399enum etm_addr_acctype {
400 ETM_INSTR_ADDR,
401 ETM_DATA_LOAD_ADDR,
402 ETM_DATA_STORE_ADDR,
403 ETM_DATA_LOAD_STORE_ADDR,
404};
405
406
407enum etm_addr_ctxtype {
408 ETM_CTX_NONE,
409 ETM_CTX_CTXID,
410 ETM_CTX_VMID,
411 ETM_CTX_CTXID_VMID,
412};
413
414extern const struct attribute_group *coresight_etmv4_groups[];
415void etm4_config_trace_mode(struct etmv4_config *config);
416#endif
417