coresight: etm4x: splitting struct etmv4_drvdata
[deliverable/linux.git] / drivers / hwtracing / coresight / coresight-etm4x.h
CommitLineData
2e1cdfe1
PP
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
13#ifndef _CORESIGHT_CORESIGHT_ETM_H
14#define _CORESIGHT_CORESIGHT_ETM_H
15
16#include <linux/spinlock.h>
17#include "coresight-priv.h"
18
19/*
20 * Device registers:
21 * 0x000 - 0x2FC: Trace registers
22 * 0x300 - 0x314: Management registers
23 * 0x318 - 0xEFC: Trace registers
24 * 0xF00: Management registers
25 * 0xFA0 - 0xFA4: Trace registers
26 * 0xFA8 - 0xFFC: Management registers
27 */
28/* Trace registers (0x000-0x2FC) */
29/* Main control and configuration registers */
30#define TRCPRGCTLR 0x004
31#define TRCPROCSELR 0x008
32#define TRCSTATR 0x00C
33#define TRCCONFIGR 0x010
34#define TRCAUXCTLR 0x018
35#define TRCEVENTCTL0R 0x020
36#define TRCEVENTCTL1R 0x024
37#define TRCSTALLCTLR 0x02C
38#define TRCTSCTLR 0x030
39#define TRCSYNCPR 0x034
40#define TRCCCCTLR 0x038
41#define TRCBBCTLR 0x03C
42#define TRCTRACEIDR 0x040
43#define TRCQCTLR 0x044
44/* Filtering control registers */
45#define TRCVICTLR 0x080
46#define TRCVIIECTLR 0x084
47#define TRCVISSCTLR 0x088
48#define TRCVIPCSSCTLR 0x08C
49#define TRCVDCTLR 0x0A0
50#define TRCVDSACCTLR 0x0A4
51#define TRCVDARCCTLR 0x0A8
52/* Derived resources registers */
53#define TRCSEQEVRn(n) (0x100 + (n * 4))
54#define TRCSEQRSTEVR 0x118
55#define TRCSEQSTR 0x11C
56#define TRCEXTINSELR 0x120
57#define TRCCNTRLDVRn(n) (0x140 + (n * 4))
58#define TRCCNTCTLRn(n) (0x150 + (n * 4))
59#define TRCCNTVRn(n) (0x160 + (n * 4))
60/* ID registers */
61#define TRCIDR8 0x180
62#define TRCIDR9 0x184
63#define TRCIDR10 0x188
64#define TRCIDR11 0x18C
65#define TRCIDR12 0x190
66#define TRCIDR13 0x194
67#define TRCIMSPEC0 0x1C0
68#define TRCIMSPECn(n) (0x1C0 + (n * 4))
69#define TRCIDR0 0x1E0
70#define TRCIDR1 0x1E4
71#define TRCIDR2 0x1E8
72#define TRCIDR3 0x1EC
73#define TRCIDR4 0x1F0
74#define TRCIDR5 0x1F4
75#define TRCIDR6 0x1F8
76#define TRCIDR7 0x1FC
77/* Resource selection registers */
78#define TRCRSCTLRn(n) (0x200 + (n * 4))
79/* Single-shot comparator registers */
80#define TRCSSCCRn(n) (0x280 + (n * 4))
81#define TRCSSCSRn(n) (0x2A0 + (n * 4))
82#define TRCSSPCICRn(n) (0x2C0 + (n * 4))
83/* Management registers (0x300-0x314) */
84#define TRCOSLAR 0x300
85#define TRCOSLSR 0x304
86#define TRCPDCR 0x310
87#define TRCPDSR 0x314
88/* Trace registers (0x318-0xEFC) */
89/* Comparator registers */
90#define TRCACVRn(n) (0x400 + (n * 8))
91#define TRCACATRn(n) (0x480 + (n * 8))
92#define TRCDVCVRn(n) (0x500 + (n * 16))
93#define TRCDVCMRn(n) (0x580 + (n * 16))
94#define TRCCIDCVRn(n) (0x600 + (n * 8))
95#define TRCVMIDCVRn(n) (0x640 + (n * 8))
96#define TRCCIDCCTLR0 0x680
97#define TRCCIDCCTLR1 0x684
98#define TRCVMIDCCTLR0 0x688
99#define TRCVMIDCCTLR1 0x68C
100/* Management register (0xF00) */
101/* Integration control registers */
102#define TRCITCTRL 0xF00
103/* Trace registers (0xFA0-0xFA4) */
104/* Claim tag registers */
105#define TRCCLAIMSET 0xFA0
106#define TRCCLAIMCLR 0xFA4
107/* Management registers (0xFA8-0xFFC) */
108#define TRCDEVAFF0 0xFA8
109#define TRCDEVAFF1 0xFAC
110#define TRCLAR 0xFB0
111#define TRCLSR 0xFB4
112#define TRCAUTHSTATUS 0xFB8
113#define TRCDEVARCH 0xFBC
114#define TRCDEVID 0xFC8
115#define TRCDEVTYPE 0xFCC
116#define TRCPIDR4 0xFD0
117#define TRCPIDR5 0xFD4
118#define TRCPIDR6 0xFD8
119#define TRCPIDR7 0xFDC
120#define TRCPIDR0 0xFE0
121#define TRCPIDR1 0xFE4
122#define TRCPIDR2 0xFE8
123#define TRCPIDR3 0xFEC
124#define TRCCIDR0 0xFF0
125#define TRCCIDR1 0xFF4
126#define TRCCIDR2 0xFF8
127#define TRCCIDR3 0xFFC
128
129/* ETMv4 resources */
130#define ETM_MAX_NR_PE 8
131#define ETMv4_MAX_CNTR 4
132#define ETM_MAX_SEQ_STATES 4
133#define ETM_MAX_EXT_INP_SEL 4
134#define ETM_MAX_EXT_INP 256
135#define ETM_MAX_EXT_OUT 4
136#define ETM_MAX_SINGLE_ADDR_CMP 16
137#define ETM_MAX_ADDR_RANGE_CMP (ETM_MAX_SINGLE_ADDR_CMP / 2)
138#define ETM_MAX_DATA_VAL_CMP 8
139#define ETMv4_MAX_CTXID_CMP 8
140#define ETM_MAX_VMID_CMP 8
141#define ETM_MAX_PE_CMP 8
142#define ETM_MAX_RES_SEL 16
143#define ETM_MAX_SS_CMP 8
144
145#define ETM_ARCH_V4 0x40
146#define ETMv4_SYNC_MASK 0x1F
147#define ETM_CYC_THRESHOLD_MASK 0xFFF
148#define ETMv4_EVENT_MASK 0xFF
149#define ETM_CNTR_MAX_VAL 0xFFFF
150#define ETM_TRACEID_MASK 0x3f
151
152/* ETMv4 programming modes */
153#define ETM_MODE_EXCLUDE BIT(0)
154#define ETM_MODE_LOAD BIT(1)
155#define ETM_MODE_STORE BIT(2)
156#define ETM_MODE_LOAD_STORE BIT(3)
157#define ETM_MODE_BB BIT(4)
158#define ETMv4_MODE_CYCACC BIT(5)
159#define ETMv4_MODE_CTXID BIT(6)
160#define ETM_MODE_VMID BIT(7)
161#define ETM_MODE_COND(val) BMVAL(val, 8, 10)
162#define ETMv4_MODE_TIMESTAMP BIT(11)
163#define ETM_MODE_RETURNSTACK BIT(12)
164#define ETM_MODE_QELEM(val) BMVAL(val, 13, 14)
165#define ETM_MODE_DATA_TRACE_ADDR BIT(15)
166#define ETM_MODE_DATA_TRACE_VAL BIT(16)
167#define ETM_MODE_ISTALL BIT(17)
168#define ETM_MODE_DSTALL BIT(18)
169#define ETM_MODE_ATB_TRIGGER BIT(19)
170#define ETM_MODE_LPOVERRIDE BIT(20)
171#define ETM_MODE_ISTALL_EN BIT(21)
172#define ETM_MODE_DSTALL_EN BIT(22)
173#define ETM_MODE_INSTPRIO BIT(23)
174#define ETM_MODE_NOOVERFLOW BIT(24)
175#define ETM_MODE_TRACE_RESET BIT(25)
176#define ETM_MODE_TRACE_ERR BIT(26)
177#define ETM_MODE_VIEWINST_STARTSTOP BIT(27)
178#define ETMv4_MODE_ALL 0xFFFFFFF
179
180#define TRCSTATR_IDLE_BIT 0
181
182/**
54ff892b 183 * struct etmv4_config - configuration information related to an ETMv4
2e1cdfe1 184 * @mode: Controls various modes supported by this ETM.
2e1cdfe1
PP
185 * @pe_sel: Controls which PE to trace.
186 * @cfg: Controls the tracing options.
187 * @eventctrl0: Controls the tracing of arbitrary events.
188 * @eventctrl1: Controls the behavior of the events that @event_ctrl0 selects.
189 * @stallctl: If functionality that prevents trace unit buffer overflows
190 * is available.
2e1cdfe1
PP
191 * @ts_ctrl: Controls the insertion of global timestamps in the
192 * trace streams.
2e1cdfe1 193 * @syncfreq: Controls how often trace synchronization requests occur.
2e1cdfe1
PP
194 * the TRCCCCTLR register.
195 * @ccctlr: Sets the threshold value for cycle counting.
2e1cdfe1
PP
196 * @vinst_ctrl: Controls instruction trace filtering.
197 * @viiectlr: Set or read, the address range comparators.
198 * @vissctlr: Set, or read, the single address comparators that control the
199 * ViewInst start-stop logic.
200 * @vipcssctlr: Set, or read, which PE comparator inputs can control the
201 * ViewInst start-stop logic.
202 * @seq_idx: Sequencor index selector.
203 * @seq_ctrl: Control for the sequencer state transition control register.
204 * @seq_rst: Moves the sequencer to state 0 when a programmed event occurs.
205 * @seq_state: Set, or read the sequencer state.
206 * @cntr_idx: Counter index seletor.
207 * @cntrldvr: Sets or returns the reload count value for a counter.
208 * @cntr_ctrl: Controls the operation of a counter.
209 * @cntr_val: Sets or returns the value for a counter.
210 * @res_idx: Resource index selector.
211 * @res_ctrl: Controls the selection of the resources in the trace unit.
212 * @ss_ctrl: Controls the corresponding single-shot comparator resource.
213 * @ss_status: The status of the corresponding single-shot comparator.
214 * @ss_pe_cmp: Selects the PE comparator inputs for Single-shot control.
215 * @addr_idx: Address comparator index selector.
216 * @addr_val: Value for address comparator.
217 * @addr_acc: Address comparator access type.
218 * @addr_type: Current status of the comparator register.
219 * @ctxid_idx: Context ID index selector.
cd196ac3 220 * @ctxid_pid: Value of the context ID comparator.
f67b467a
CZ
221 * @ctxid_vpid: Virtual PID seen by users if PID namespace is enabled, otherwise
222 * the same value of ctxid_pid.
2e1cdfe1
PP
223 * @ctxid_mask0:Context ID comparator mask for comparator 0-3.
224 * @ctxid_mask1:Context ID comparator mask for comparator 4-7.
225 * @vmid_idx: VM ID index selector.
2e1cdfe1
PP
226 * @vmid_val: Value of the VM ID comparator.
227 * @vmid_mask0: VM ID comparator mask for comparator 0-3.
228 * @vmid_mask1: VM ID comparator mask for comparator 4-7.
2e1cdfe1
PP
229 * @ext_inp: External input selection.
230 */
54ff892b 231struct etmv4_config {
2e1cdfe1 232 u32 mode;
2e1cdfe1
PP
233 u32 pe_sel;
234 u32 cfg;
235 u32 eventctrl0;
236 u32 eventctrl1;
2e1cdfe1 237 u32 stall_ctrl;
2e1cdfe1 238 u32 ts_ctrl;
2e1cdfe1 239 u32 syncfreq;
2e1cdfe1 240 u32 ccctlr;
2e1cdfe1 241 u32 bb_ctrl;
2e1cdfe1
PP
242 u32 vinst_ctrl;
243 u32 viiectlr;
244 u32 vissctlr;
245 u32 vipcssctlr;
246 u8 seq_idx;
247 u32 seq_ctrl[ETM_MAX_SEQ_STATES];
248 u32 seq_rst;
249 u32 seq_state;
250 u8 cntr_idx;
251 u32 cntrldvr[ETMv4_MAX_CNTR];
252 u32 cntr_ctrl[ETMv4_MAX_CNTR];
253 u32 cntr_val[ETMv4_MAX_CNTR];
254 u8 res_idx;
255 u32 res_ctrl[ETM_MAX_RES_SEL];
256 u32 ss_ctrl[ETM_MAX_SS_CMP];
257 u32 ss_status[ETM_MAX_SS_CMP];
258 u32 ss_pe_cmp[ETM_MAX_SS_CMP];
259 u8 addr_idx;
260 u64 addr_val[ETM_MAX_SINGLE_ADDR_CMP];
261 u64 addr_acc[ETM_MAX_SINGLE_ADDR_CMP];
262 u8 addr_type[ETM_MAX_SINGLE_ADDR_CMP];
263 u8 ctxid_idx;
cd196ac3 264 u64 ctxid_pid[ETMv4_MAX_CTXID_CMP];
f67b467a 265 u64 ctxid_vpid[ETMv4_MAX_CTXID_CMP];
2e1cdfe1
PP
266 u32 ctxid_mask0;
267 u32 ctxid_mask1;
268 u8 vmid_idx;
2e1cdfe1
PP
269 u64 vmid_val[ETM_MAX_VMID_CMP];
270 u32 vmid_mask0;
271 u32 vmid_mask1;
54ff892b
MP
272 u32 ext_inp;
273};
274
275/**
276 * struct etm4_drvdata - specifics associated to an ETM component
277 * @base: Memory mapped base address for this component.
278 * @dev: The device entity associated to this component.
279 * @csdev: Component vitals needed by the framework.
280 * @spinlock: Only one at a time pls.
281 * @cpu: The cpu this component is affined to.
282 * @arch: ETM version number.
283 * @nr_pe: The number of processing entity available for tracing.
284 * @nr_pe_cmp: The number of processing entity comparator inputs that are
285 * available for tracing.
286 * @nr_addr_cmp:Number of pairs of address comparators available
287 * as found in ETMIDR4 0-3.
288 * @nr_cntr: Number of counters as found in ETMIDR5 bit 28-30.
289 * @nr_ext_inp: Number of external input.
290 * @numcidc: Number of contextID comparators.
291 * @numvmidc: Number of VMID comparators.
292 * @nrseqstate: The number of sequencer states that are implemented.
293 * @nr_event: Indicates how many events the trace unit support.
294 * @nr_resource:The number of resource selection pairs available for tracing.
295 * @nr_ss_cmp: Number of single-shot comparator controls that are available.
296 * @trcid: value of the current ID for this component.
297 * @trcid_size: Indicates the trace ID width.
298 * @ts_size: Global timestamp size field.
299 * @ctxid_size: Size of the context ID field to consider.
300 * @vmid_size: Size of the VM ID comparator to consider.
301 * @ccsize: Indicates the size of the cycle counter in bits.
302 * @ccitmin: minimum value that can be programmed in
303 * @s_ex_level: In secure state, indicates whether instruction tracing is
304 * supported for the corresponding Exception level.
305 * @ns_ex_level:In non-secure state, indicates whether instruction tracing is
306 * supported for the corresponding Exception level.
307 * @enable: Is this ETM currently tracing.
308 * @sticky_enable: true if ETM base configuration has been done.
309 * @boot_enable:True if we should start tracing at boot time.
310 * @os_unlock: True if access to management registers is allowed.
311 * @instrp0: Tracing of load and store instructions
312 * as P0 elements is supported.
313 * @trcbb: Indicates if the trace unit supports branch broadcast tracing.
314 * @trccond: If the trace unit supports conditional
315 * instruction tracing.
316 * @retstack: Indicates if the implementation supports a return stack.
317 * @trccci: Indicates if the trace unit supports cycle counting
318 * for instruction.
319 * @q_support: Q element support characteristics.
320 * @trc_error: Whether a trace unit can trace a system
321 * error exception.
322 * @syncpr: Indicates if an implementation has a fixed
323 * synchronization period.
324 * @stall_ctrl: Enables trace unit functionality that prevents trace
325 * unit buffer overflows.
326 * @sysstall: Does the system support stall control of the PE?
327 * @nooverflow: Indicate if overflow prevention is supported.
328 * @atbtrig: If the implementation can support ATB triggers
329 * @lpoverride: If the implementation can support low-power state over.
330 * @config: structure holding configuration parameters.
331 */
332struct etmv4_drvdata {
333 void __iomem *base;
334 struct device *dev;
335 struct coresight_device *csdev;
336 spinlock_t spinlock;
337 int cpu;
338 u8 arch;
339 u8 nr_pe;
340 u8 nr_pe_cmp;
341 u8 nr_addr_cmp;
342 u8 nr_cntr;
343 u8 nr_ext_inp;
344 u8 numcidc;
345 u8 numvmidc;
346 u8 nrseqstate;
347 u8 nr_event;
348 u8 nr_resource;
349 u8 nr_ss_cmp;
350 u8 trcid;
351 u8 trcid_size;
352 u8 ts_size;
353 u8 ctxid_size;
354 u8 vmid_size;
355 u8 ccsize;
356 u8 ccitmin;
2e1cdfe1
PP
357 u8 s_ex_level;
358 u8 ns_ex_level;
54ff892b
MP
359 bool enable;
360 bool sticky_enable;
361 bool boot_enable;
362 bool os_unlock;
363 bool instrp0;
364 bool trcbb;
365 bool trccond;
366 bool retstack;
367 bool trccci;
368 bool q_support;
369 bool trc_error;
370 bool syncpr;
371 bool stallctl;
372 bool sysstall;
373 bool nooverflow;
374 bool atbtrig;
375 bool lpoverride;
376 struct etmv4_config config;
2e1cdfe1
PP
377};
378
379/* Address comparator access types */
380enum etm_addr_acctype {
381 ETM_INSTR_ADDR,
382 ETM_DATA_LOAD_ADDR,
383 ETM_DATA_STORE_ADDR,
384 ETM_DATA_LOAD_STORE_ADDR,
385};
386
387/* Address comparator context types */
388enum etm_addr_ctxtype {
389 ETM_CTX_NONE,
390 ETM_CTX_CTXID,
391 ETM_CTX_VMID,
392 ETM_CTX_CTXID_VMID,
393};
394
395enum etm_addr_type {
396 ETM_ADDR_TYPE_NONE,
397 ETM_ADDR_TYPE_SINGLE,
398 ETM_ADDR_TYPE_RANGE,
399 ETM_ADDR_TYPE_START,
400 ETM_ADDR_TYPE_STOP,
401};
a77de263
MP
402
403extern const struct attribute_group *coresight_etmv4_groups[];
2e1cdfe1 404#endif
This page took 0.078591 seconds and 5 git commands to generate.