This source file includes following definitions.
- etm4_set_mode_exclude
- nr_pe_cmp_show
- nr_addr_cmp_show
- nr_cntr_show
- nr_ext_inp_show
- numcidc_show
- numvmidc_show
- nrseqstate_show
- nr_resource_show
- nr_ss_cmp_show
- reset_store
- mode_show
- mode_store
- pe_show
- pe_store
- event_show
- event_store
- event_instren_show
- event_instren_store
- event_ts_show
- event_ts_store
- syncfreq_show
- syncfreq_store
- cyc_threshold_show
- cyc_threshold_store
- bb_ctrl_show
- bb_ctrl_store
- event_vinst_show
- event_vinst_store
- s_exlevel_vinst_show
- s_exlevel_vinst_store
- ns_exlevel_vinst_show
- ns_exlevel_vinst_store
- addr_idx_show
- addr_idx_store
- addr_instdatatype_show
- addr_instdatatype_store
- addr_single_show
- addr_single_store
- addr_range_show
- addr_range_store
- addr_start_show
- addr_start_store
- addr_stop_show
- addr_stop_store
- addr_ctxtype_show
- addr_ctxtype_store
- addr_context_show
- addr_context_store
- seq_idx_show
- seq_idx_store
- seq_state_show
- seq_state_store
- seq_event_show
- seq_event_store
- seq_reset_event_show
- seq_reset_event_store
- cntr_idx_show
- cntr_idx_store
- cntrldvr_show
- cntrldvr_store
- cntr_val_show
- cntr_val_store
- cntr_ctrl_show
- cntr_ctrl_store
- res_idx_show
- res_idx_store
- res_ctrl_show
- res_ctrl_store
- ctxid_idx_show
- ctxid_idx_store
- ctxid_pid_show
- ctxid_pid_store
- ctxid_masks_show
- ctxid_masks_store
- vmid_idx_show
- vmid_idx_store
- vmid_val_show
- vmid_val_store
- vmid_masks_show
- vmid_masks_store
- cpu_show
- do_smp_cross_read
- etmv4_cross_read
1
2
3
4
5
6
7 #include <linux/pid_namespace.h>
8 #include <linux/pm_runtime.h>
9 #include <linux/sysfs.h>
10 #include "coresight-etm4x.h"
11 #include "coresight-priv.h"
12
13 static int etm4_set_mode_exclude(struct etmv4_drvdata *drvdata, bool exclude)
14 {
15 u8 idx;
16 struct etmv4_config *config = &drvdata->config;
17
18 idx = config->addr_idx;
19
20
21
22
23
24 if (BMVAL(config->addr_acc[idx], 0, 1) == ETM_INSTR_ADDR) {
25 if (idx % 2 != 0)
26 return -EINVAL;
27
28
29
30
31
32
33 if (config->addr_type[idx] != ETM_ADDR_TYPE_RANGE ||
34 config->addr_type[idx + 1] != ETM_ADDR_TYPE_RANGE)
35 return -EINVAL;
36
37 if (exclude == true) {
38
39
40
41
42 config->viiectlr |= BIT(idx / 2 + 16);
43 config->viiectlr &= ~BIT(idx / 2);
44 } else {
45
46
47
48
49 config->viiectlr |= BIT(idx / 2);
50 config->viiectlr &= ~BIT(idx / 2 + 16);
51 }
52 }
53 return 0;
54 }
55
56 static ssize_t nr_pe_cmp_show(struct device *dev,
57 struct device_attribute *attr,
58 char *buf)
59 {
60 unsigned long val;
61 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
62
63 val = drvdata->nr_pe_cmp;
64 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
65 }
66 static DEVICE_ATTR_RO(nr_pe_cmp);
67
68 static ssize_t nr_addr_cmp_show(struct device *dev,
69 struct device_attribute *attr,
70 char *buf)
71 {
72 unsigned long val;
73 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
74
75 val = drvdata->nr_addr_cmp;
76 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
77 }
78 static DEVICE_ATTR_RO(nr_addr_cmp);
79
80 static ssize_t nr_cntr_show(struct device *dev,
81 struct device_attribute *attr,
82 char *buf)
83 {
84 unsigned long val;
85 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
86
87 val = drvdata->nr_cntr;
88 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
89 }
90 static DEVICE_ATTR_RO(nr_cntr);
91
92 static ssize_t nr_ext_inp_show(struct device *dev,
93 struct device_attribute *attr,
94 char *buf)
95 {
96 unsigned long val;
97 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
98
99 val = drvdata->nr_ext_inp;
100 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
101 }
102 static DEVICE_ATTR_RO(nr_ext_inp);
103
104 static ssize_t numcidc_show(struct device *dev,
105 struct device_attribute *attr,
106 char *buf)
107 {
108 unsigned long val;
109 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
110
111 val = drvdata->numcidc;
112 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
113 }
114 static DEVICE_ATTR_RO(numcidc);
115
116 static ssize_t numvmidc_show(struct device *dev,
117 struct device_attribute *attr,
118 char *buf)
119 {
120 unsigned long val;
121 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
122
123 val = drvdata->numvmidc;
124 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
125 }
126 static DEVICE_ATTR_RO(numvmidc);
127
128 static ssize_t nrseqstate_show(struct device *dev,
129 struct device_attribute *attr,
130 char *buf)
131 {
132 unsigned long val;
133 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
134
135 val = drvdata->nrseqstate;
136 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
137 }
138 static DEVICE_ATTR_RO(nrseqstate);
139
140 static ssize_t nr_resource_show(struct device *dev,
141 struct device_attribute *attr,
142 char *buf)
143 {
144 unsigned long val;
145 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
146
147 val = drvdata->nr_resource;
148 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
149 }
150 static DEVICE_ATTR_RO(nr_resource);
151
152 static ssize_t nr_ss_cmp_show(struct device *dev,
153 struct device_attribute *attr,
154 char *buf)
155 {
156 unsigned long val;
157 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
158
159 val = drvdata->nr_ss_cmp;
160 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
161 }
162 static DEVICE_ATTR_RO(nr_ss_cmp);
163
164 static ssize_t reset_store(struct device *dev,
165 struct device_attribute *attr,
166 const char *buf, size_t size)
167 {
168 int i;
169 unsigned long val;
170 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
171 struct etmv4_config *config = &drvdata->config;
172
173 if (kstrtoul(buf, 16, &val))
174 return -EINVAL;
175
176 spin_lock(&drvdata->spinlock);
177 if (val)
178 config->mode = 0x0;
179
180
181 config->mode &= ~(ETM_MODE_LOAD | ETM_MODE_STORE);
182 config->cfg &= ~(BIT(1) | BIT(2));
183
184
185 config->mode &= ~(ETM_MODE_DATA_TRACE_ADDR |
186 ETM_MODE_DATA_TRACE_VAL);
187 config->cfg &= ~(BIT(16) | BIT(17));
188
189
190 config->eventctrl0 = 0x0;
191 config->eventctrl1 = 0x0;
192
193
194 config->ts_ctrl = 0x0;
195
196
197 config->stall_ctrl = 0x0;
198
199
200 if (drvdata->syncpr == false)
201 config->syncfreq = 0x8;
202
203
204
205
206
207
208 config->vinst_ctrl |= BIT(0);
209 if (drvdata->nr_addr_cmp == true) {
210 config->mode |= ETM_MODE_VIEWINST_STARTSTOP;
211
212 config->vinst_ctrl |= BIT(9);
213 }
214
215
216 config->viiectlr = 0x0;
217
218
219 config->vissctlr = 0x0;
220
221
222 for (i = 0; i < drvdata->nrseqstate-1; i++)
223 config->seq_ctrl[i] = 0x0;
224 config->seq_rst = 0x0;
225 config->seq_state = 0x0;
226
227
228 config->ext_inp = 0x0;
229
230 config->cntr_idx = 0x0;
231 for (i = 0; i < drvdata->nr_cntr; i++) {
232 config->cntrldvr[i] = 0x0;
233 config->cntr_ctrl[i] = 0x0;
234 config->cntr_val[i] = 0x0;
235 }
236
237 config->res_idx = 0x0;
238 for (i = 0; i < drvdata->nr_resource; i++)
239 config->res_ctrl[i] = 0x0;
240
241 for (i = 0; i < drvdata->nr_ss_cmp; i++) {
242 config->ss_ctrl[i] = 0x0;
243 config->ss_pe_cmp[i] = 0x0;
244 }
245
246 config->addr_idx = 0x0;
247 for (i = 0; i < drvdata->nr_addr_cmp * 2; i++) {
248 config->addr_val[i] = 0x0;
249 config->addr_acc[i] = 0x0;
250 config->addr_type[i] = ETM_ADDR_TYPE_NONE;
251 }
252
253 config->ctxid_idx = 0x0;
254 for (i = 0; i < drvdata->numcidc; i++)
255 config->ctxid_pid[i] = 0x0;
256
257 config->ctxid_mask0 = 0x0;
258 config->ctxid_mask1 = 0x0;
259
260 config->vmid_idx = 0x0;
261 for (i = 0; i < drvdata->numvmidc; i++)
262 config->vmid_val[i] = 0x0;
263 config->vmid_mask0 = 0x0;
264 config->vmid_mask1 = 0x0;
265
266 drvdata->trcid = drvdata->cpu + 1;
267
268 spin_unlock(&drvdata->spinlock);
269
270 return size;
271 }
272 static DEVICE_ATTR_WO(reset);
273
274 static ssize_t mode_show(struct device *dev,
275 struct device_attribute *attr,
276 char *buf)
277 {
278 unsigned long val;
279 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
280 struct etmv4_config *config = &drvdata->config;
281
282 val = config->mode;
283 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
284 }
285
286 static ssize_t mode_store(struct device *dev,
287 struct device_attribute *attr,
288 const char *buf, size_t size)
289 {
290 unsigned long val, mode;
291 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
292 struct etmv4_config *config = &drvdata->config;
293
294 if (kstrtoul(buf, 16, &val))
295 return -EINVAL;
296
297 spin_lock(&drvdata->spinlock);
298 config->mode = val & ETMv4_MODE_ALL;
299 etm4_set_mode_exclude(drvdata,
300 config->mode & ETM_MODE_EXCLUDE ? true : false);
301
302 if (drvdata->instrp0 == true) {
303
304 config->cfg &= ~(BIT(1) | BIT(2));
305 if (config->mode & ETM_MODE_LOAD)
306
307 config->cfg |= BIT(1);
308 if (config->mode & ETM_MODE_STORE)
309
310 config->cfg |= BIT(2);
311 if (config->mode & ETM_MODE_LOAD_STORE)
312
313
314
315
316 config->cfg |= BIT(1) | BIT(2);
317 }
318
319
320 if ((config->mode & ETM_MODE_BB) && (drvdata->trcbb == true))
321 config->cfg |= BIT(3);
322 else
323 config->cfg &= ~BIT(3);
324
325
326 if ((config->mode & ETMv4_MODE_CYCACC) &&
327 (drvdata->trccci == true))
328 config->cfg |= BIT(4);
329 else
330 config->cfg &= ~BIT(4);
331
332
333 if ((config->mode & ETMv4_MODE_CTXID) && (drvdata->ctxid_size))
334 config->cfg |= BIT(6);
335 else
336 config->cfg &= ~BIT(6);
337
338 if ((config->mode & ETM_MODE_VMID) && (drvdata->vmid_size))
339 config->cfg |= BIT(7);
340 else
341 config->cfg &= ~BIT(7);
342
343
344 mode = ETM_MODE_COND(config->mode);
345 if (drvdata->trccond == true) {
346 config->cfg &= ~(BIT(8) | BIT(9) | BIT(10));
347 config->cfg |= mode << 8;
348 }
349
350
351 if ((config->mode & ETMv4_MODE_TIMESTAMP) && (drvdata->ts_size))
352 config->cfg |= BIT(11);
353 else
354 config->cfg &= ~BIT(11);
355
356
357 if ((config->mode & ETM_MODE_RETURNSTACK) &&
358 (drvdata->retstack == true))
359 config->cfg |= BIT(12);
360 else
361 config->cfg &= ~BIT(12);
362
363
364 mode = ETM_MODE_QELEM(config->mode);
365
366 config->cfg &= ~(BIT(13) | BIT(14));
367
368 if ((mode & BIT(0)) && (drvdata->q_support & BIT(0)))
369 config->cfg |= BIT(13);
370
371
372
373
374 if ((mode & BIT(1)) && (drvdata->q_support & BIT(1)))
375 config->cfg |= BIT(14);
376
377
378 if ((config->mode & ETM_MODE_ATB_TRIGGER) &&
379 (drvdata->atbtrig == true))
380 config->eventctrl1 |= BIT(11);
381 else
382 config->eventctrl1 &= ~BIT(11);
383
384
385 if ((config->mode & ETM_MODE_LPOVERRIDE) &&
386 (drvdata->lpoverride == true))
387 config->eventctrl1 |= BIT(12);
388 else
389 config->eventctrl1 &= ~BIT(12);
390
391
392 if (config->mode & ETM_MODE_ISTALL_EN)
393 config->stall_ctrl |= BIT(8);
394 else
395 config->stall_ctrl &= ~BIT(8);
396
397
398 if (config->mode & ETM_MODE_INSTPRIO)
399 config->stall_ctrl |= BIT(10);
400 else
401 config->stall_ctrl &= ~BIT(10);
402
403
404 if ((config->mode & ETM_MODE_NOOVERFLOW) &&
405 (drvdata->nooverflow == true))
406 config->stall_ctrl |= BIT(13);
407 else
408 config->stall_ctrl &= ~BIT(13);
409
410
411 if (config->mode & ETM_MODE_VIEWINST_STARTSTOP)
412 config->vinst_ctrl |= BIT(9);
413 else
414 config->vinst_ctrl &= ~BIT(9);
415
416
417 if (config->mode & ETM_MODE_TRACE_RESET)
418 config->vinst_ctrl |= BIT(10);
419 else
420 config->vinst_ctrl &= ~BIT(10);
421
422
423 if ((config->mode & ETM_MODE_TRACE_ERR) &&
424 (drvdata->trc_error == true))
425 config->vinst_ctrl |= BIT(11);
426 else
427 config->vinst_ctrl &= ~BIT(11);
428
429 if (config->mode & (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER))
430 etm4_config_trace_mode(config);
431
432 spin_unlock(&drvdata->spinlock);
433
434 return size;
435 }
436 static DEVICE_ATTR_RW(mode);
437
438 static ssize_t pe_show(struct device *dev,
439 struct device_attribute *attr,
440 char *buf)
441 {
442 unsigned long val;
443 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
444 struct etmv4_config *config = &drvdata->config;
445
446 val = config->pe_sel;
447 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
448 }
449
450 static ssize_t pe_store(struct device *dev,
451 struct device_attribute *attr,
452 const char *buf, size_t size)
453 {
454 unsigned long val;
455 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
456 struct etmv4_config *config = &drvdata->config;
457
458 if (kstrtoul(buf, 16, &val))
459 return -EINVAL;
460
461 spin_lock(&drvdata->spinlock);
462 if (val > drvdata->nr_pe) {
463 spin_unlock(&drvdata->spinlock);
464 return -EINVAL;
465 }
466
467 config->pe_sel = val;
468 spin_unlock(&drvdata->spinlock);
469 return size;
470 }
471 static DEVICE_ATTR_RW(pe);
472
473 static ssize_t event_show(struct device *dev,
474 struct device_attribute *attr,
475 char *buf)
476 {
477 unsigned long val;
478 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
479 struct etmv4_config *config = &drvdata->config;
480
481 val = config->eventctrl0;
482 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
483 }
484
485 static ssize_t event_store(struct device *dev,
486 struct device_attribute *attr,
487 const char *buf, size_t size)
488 {
489 unsigned long val;
490 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
491 struct etmv4_config *config = &drvdata->config;
492
493 if (kstrtoul(buf, 16, &val))
494 return -EINVAL;
495
496 spin_lock(&drvdata->spinlock);
497 switch (drvdata->nr_event) {
498 case 0x0:
499
500 config->eventctrl0 = val & 0xFF;
501 break;
502 case 0x1:
503
504 config->eventctrl0 = val & 0xFFFF;
505 break;
506 case 0x2:
507
508 config->eventctrl0 = val & 0xFFFFFF;
509 break;
510 case 0x3:
511
512 config->eventctrl0 = val;
513 break;
514 default:
515 break;
516 }
517 spin_unlock(&drvdata->spinlock);
518 return size;
519 }
520 static DEVICE_ATTR_RW(event);
521
522 static ssize_t event_instren_show(struct device *dev,
523 struct device_attribute *attr,
524 char *buf)
525 {
526 unsigned long val;
527 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
528 struct etmv4_config *config = &drvdata->config;
529
530 val = BMVAL(config->eventctrl1, 0, 3);
531 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
532 }
533
534 static ssize_t event_instren_store(struct device *dev,
535 struct device_attribute *attr,
536 const char *buf, size_t size)
537 {
538 unsigned long val;
539 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
540 struct etmv4_config *config = &drvdata->config;
541
542 if (kstrtoul(buf, 16, &val))
543 return -EINVAL;
544
545 spin_lock(&drvdata->spinlock);
546
547 config->eventctrl1 &= ~(BIT(0) | BIT(1) | BIT(2) | BIT(3));
548 switch (drvdata->nr_event) {
549 case 0x0:
550
551 config->eventctrl1 |= val & BIT(1);
552 break;
553 case 0x1:
554
555 config->eventctrl1 |= val & (BIT(0) | BIT(1));
556 break;
557 case 0x2:
558
559 config->eventctrl1 |= val & (BIT(0) | BIT(1) | BIT(2));
560 break;
561 case 0x3:
562
563 config->eventctrl1 |= val & 0xF;
564 break;
565 default:
566 break;
567 }
568 spin_unlock(&drvdata->spinlock);
569 return size;
570 }
571 static DEVICE_ATTR_RW(event_instren);
572
573 static ssize_t event_ts_show(struct device *dev,
574 struct device_attribute *attr,
575 char *buf)
576 {
577 unsigned long val;
578 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
579 struct etmv4_config *config = &drvdata->config;
580
581 val = config->ts_ctrl;
582 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
583 }
584
585 static ssize_t event_ts_store(struct device *dev,
586 struct device_attribute *attr,
587 const char *buf, size_t size)
588 {
589 unsigned long val;
590 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
591 struct etmv4_config *config = &drvdata->config;
592
593 if (kstrtoul(buf, 16, &val))
594 return -EINVAL;
595 if (!drvdata->ts_size)
596 return -EINVAL;
597
598 config->ts_ctrl = val & ETMv4_EVENT_MASK;
599 return size;
600 }
601 static DEVICE_ATTR_RW(event_ts);
602
603 static ssize_t syncfreq_show(struct device *dev,
604 struct device_attribute *attr,
605 char *buf)
606 {
607 unsigned long val;
608 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
609 struct etmv4_config *config = &drvdata->config;
610
611 val = config->syncfreq;
612 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
613 }
614
615 static ssize_t syncfreq_store(struct device *dev,
616 struct device_attribute *attr,
617 const char *buf, size_t size)
618 {
619 unsigned long val;
620 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
621 struct etmv4_config *config = &drvdata->config;
622
623 if (kstrtoul(buf, 16, &val))
624 return -EINVAL;
625 if (drvdata->syncpr == true)
626 return -EINVAL;
627
628 config->syncfreq = val & ETMv4_SYNC_MASK;
629 return size;
630 }
631 static DEVICE_ATTR_RW(syncfreq);
632
633 static ssize_t cyc_threshold_show(struct device *dev,
634 struct device_attribute *attr,
635 char *buf)
636 {
637 unsigned long val;
638 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
639 struct etmv4_config *config = &drvdata->config;
640
641 val = config->ccctlr;
642 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
643 }
644
645 static ssize_t cyc_threshold_store(struct device *dev,
646 struct device_attribute *attr,
647 const char *buf, size_t size)
648 {
649 unsigned long val;
650 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
651 struct etmv4_config *config = &drvdata->config;
652
653 if (kstrtoul(buf, 16, &val))
654 return -EINVAL;
655
656
657 val &= ETM_CYC_THRESHOLD_MASK;
658 if (val < drvdata->ccitmin)
659 return -EINVAL;
660
661 config->ccctlr = val;
662 return size;
663 }
664 static DEVICE_ATTR_RW(cyc_threshold);
665
666 static ssize_t bb_ctrl_show(struct device *dev,
667 struct device_attribute *attr,
668 char *buf)
669 {
670 unsigned long val;
671 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
672 struct etmv4_config *config = &drvdata->config;
673
674 val = config->bb_ctrl;
675 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
676 }
677
678 static ssize_t bb_ctrl_store(struct device *dev,
679 struct device_attribute *attr,
680 const char *buf, size_t size)
681 {
682 unsigned long val;
683 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
684 struct etmv4_config *config = &drvdata->config;
685
686 if (kstrtoul(buf, 16, &val))
687 return -EINVAL;
688 if (drvdata->trcbb == false)
689 return -EINVAL;
690 if (!drvdata->nr_addr_cmp)
691 return -EINVAL;
692
693
694
695
696
697
698 if ((val & BIT(8)) && (BMVAL(val, 0, 7) == 0))
699 return -EINVAL;
700
701 config->bb_ctrl = val & GENMASK(8, 0);
702 return size;
703 }
704 static DEVICE_ATTR_RW(bb_ctrl);
705
706 static ssize_t event_vinst_show(struct device *dev,
707 struct device_attribute *attr,
708 char *buf)
709 {
710 unsigned long val;
711 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
712 struct etmv4_config *config = &drvdata->config;
713
714 val = config->vinst_ctrl & ETMv4_EVENT_MASK;
715 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
716 }
717
718 static ssize_t event_vinst_store(struct device *dev,
719 struct device_attribute *attr,
720 const char *buf, size_t size)
721 {
722 unsigned long val;
723 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
724 struct etmv4_config *config = &drvdata->config;
725
726 if (kstrtoul(buf, 16, &val))
727 return -EINVAL;
728
729 spin_lock(&drvdata->spinlock);
730 val &= ETMv4_EVENT_MASK;
731 config->vinst_ctrl &= ~ETMv4_EVENT_MASK;
732 config->vinst_ctrl |= val;
733 spin_unlock(&drvdata->spinlock);
734 return size;
735 }
736 static DEVICE_ATTR_RW(event_vinst);
737
738 static ssize_t s_exlevel_vinst_show(struct device *dev,
739 struct device_attribute *attr,
740 char *buf)
741 {
742 unsigned long val;
743 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
744 struct etmv4_config *config = &drvdata->config;
745
746 val = BMVAL(config->vinst_ctrl, 16, 19);
747 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
748 }
749
750 static ssize_t s_exlevel_vinst_store(struct device *dev,
751 struct device_attribute *attr,
752 const char *buf, size_t size)
753 {
754 unsigned long val;
755 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
756 struct etmv4_config *config = &drvdata->config;
757
758 if (kstrtoul(buf, 16, &val))
759 return -EINVAL;
760
761 spin_lock(&drvdata->spinlock);
762
763 config->vinst_ctrl &= ~(BIT(16) | BIT(17) | BIT(19));
764
765 val &= drvdata->s_ex_level;
766 config->vinst_ctrl |= (val << 16);
767 spin_unlock(&drvdata->spinlock);
768 return size;
769 }
770 static DEVICE_ATTR_RW(s_exlevel_vinst);
771
772 static ssize_t ns_exlevel_vinst_show(struct device *dev,
773 struct device_attribute *attr,
774 char *buf)
775 {
776 unsigned long val;
777 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
778 struct etmv4_config *config = &drvdata->config;
779
780
781 val = BMVAL(config->vinst_ctrl, 20, 23);
782 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
783 }
784
785 static ssize_t ns_exlevel_vinst_store(struct device *dev,
786 struct device_attribute *attr,
787 const char *buf, size_t size)
788 {
789 unsigned long val;
790 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
791 struct etmv4_config *config = &drvdata->config;
792
793 if (kstrtoul(buf, 16, &val))
794 return -EINVAL;
795
796 spin_lock(&drvdata->spinlock);
797
798 config->vinst_ctrl &= ~(BIT(20) | BIT(21) | BIT(22));
799
800 val &= drvdata->ns_ex_level;
801 config->vinst_ctrl |= (val << 20);
802 spin_unlock(&drvdata->spinlock);
803 return size;
804 }
805 static DEVICE_ATTR_RW(ns_exlevel_vinst);
806
807 static ssize_t addr_idx_show(struct device *dev,
808 struct device_attribute *attr,
809 char *buf)
810 {
811 unsigned long val;
812 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
813 struct etmv4_config *config = &drvdata->config;
814
815 val = config->addr_idx;
816 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
817 }
818
819 static ssize_t addr_idx_store(struct device *dev,
820 struct device_attribute *attr,
821 const char *buf, size_t size)
822 {
823 unsigned long val;
824 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
825 struct etmv4_config *config = &drvdata->config;
826
827 if (kstrtoul(buf, 16, &val))
828 return -EINVAL;
829 if (val >= drvdata->nr_addr_cmp * 2)
830 return -EINVAL;
831
832
833
834
835
836 spin_lock(&drvdata->spinlock);
837 config->addr_idx = val;
838 spin_unlock(&drvdata->spinlock);
839 return size;
840 }
841 static DEVICE_ATTR_RW(addr_idx);
842
843 static ssize_t addr_instdatatype_show(struct device *dev,
844 struct device_attribute *attr,
845 char *buf)
846 {
847 ssize_t len;
848 u8 val, idx;
849 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
850 struct etmv4_config *config = &drvdata->config;
851
852 spin_lock(&drvdata->spinlock);
853 idx = config->addr_idx;
854 val = BMVAL(config->addr_acc[idx], 0, 1);
855 len = scnprintf(buf, PAGE_SIZE, "%s\n",
856 val == ETM_INSTR_ADDR ? "instr" :
857 (val == ETM_DATA_LOAD_ADDR ? "data_load" :
858 (val == ETM_DATA_STORE_ADDR ? "data_store" :
859 "data_load_store")));
860 spin_unlock(&drvdata->spinlock);
861 return len;
862 }
863
864 static ssize_t addr_instdatatype_store(struct device *dev,
865 struct device_attribute *attr,
866 const char *buf, size_t size)
867 {
868 u8 idx;
869 char str[20] = "";
870 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
871 struct etmv4_config *config = &drvdata->config;
872
873 if (strlen(buf) >= 20)
874 return -EINVAL;
875 if (sscanf(buf, "%s", str) != 1)
876 return -EINVAL;
877
878 spin_lock(&drvdata->spinlock);
879 idx = config->addr_idx;
880 if (!strcmp(str, "instr"))
881
882 config->addr_acc[idx] &= ~(BIT(0) | BIT(1));
883
884 spin_unlock(&drvdata->spinlock);
885 return size;
886 }
887 static DEVICE_ATTR_RW(addr_instdatatype);
888
889 static ssize_t addr_single_show(struct device *dev,
890 struct device_attribute *attr,
891 char *buf)
892 {
893 u8 idx;
894 unsigned long val;
895 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
896 struct etmv4_config *config = &drvdata->config;
897
898 idx = config->addr_idx;
899 spin_lock(&drvdata->spinlock);
900 if (!(config->addr_type[idx] == ETM_ADDR_TYPE_NONE ||
901 config->addr_type[idx] == ETM_ADDR_TYPE_SINGLE)) {
902 spin_unlock(&drvdata->spinlock);
903 return -EPERM;
904 }
905 val = (unsigned long)config->addr_val[idx];
906 spin_unlock(&drvdata->spinlock);
907 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
908 }
909
910 static ssize_t addr_single_store(struct device *dev,
911 struct device_attribute *attr,
912 const char *buf, size_t size)
913 {
914 u8 idx;
915 unsigned long val;
916 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
917 struct etmv4_config *config = &drvdata->config;
918
919 if (kstrtoul(buf, 16, &val))
920 return -EINVAL;
921
922 spin_lock(&drvdata->spinlock);
923 idx = config->addr_idx;
924 if (!(config->addr_type[idx] == ETM_ADDR_TYPE_NONE ||
925 config->addr_type[idx] == ETM_ADDR_TYPE_SINGLE)) {
926 spin_unlock(&drvdata->spinlock);
927 return -EPERM;
928 }
929
930 config->addr_val[idx] = (u64)val;
931 config->addr_type[idx] = ETM_ADDR_TYPE_SINGLE;
932 spin_unlock(&drvdata->spinlock);
933 return size;
934 }
935 static DEVICE_ATTR_RW(addr_single);
936
937 static ssize_t addr_range_show(struct device *dev,
938 struct device_attribute *attr,
939 char *buf)
940 {
941 u8 idx;
942 unsigned long val1, val2;
943 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
944 struct etmv4_config *config = &drvdata->config;
945
946 spin_lock(&drvdata->spinlock);
947 idx = config->addr_idx;
948 if (idx % 2 != 0) {
949 spin_unlock(&drvdata->spinlock);
950 return -EPERM;
951 }
952 if (!((config->addr_type[idx] == ETM_ADDR_TYPE_NONE &&
953 config->addr_type[idx + 1] == ETM_ADDR_TYPE_NONE) ||
954 (config->addr_type[idx] == ETM_ADDR_TYPE_RANGE &&
955 config->addr_type[idx + 1] == ETM_ADDR_TYPE_RANGE))) {
956 spin_unlock(&drvdata->spinlock);
957 return -EPERM;
958 }
959
960 val1 = (unsigned long)config->addr_val[idx];
961 val2 = (unsigned long)config->addr_val[idx + 1];
962 spin_unlock(&drvdata->spinlock);
963 return scnprintf(buf, PAGE_SIZE, "%#lx %#lx\n", val1, val2);
964 }
965
966 static ssize_t addr_range_store(struct device *dev,
967 struct device_attribute *attr,
968 const char *buf, size_t size)
969 {
970 u8 idx;
971 unsigned long val1, val2;
972 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
973 struct etmv4_config *config = &drvdata->config;
974
975 if (sscanf(buf, "%lx %lx", &val1, &val2) != 2)
976 return -EINVAL;
977
978 if (val1 > val2)
979 return -EINVAL;
980
981 spin_lock(&drvdata->spinlock);
982 idx = config->addr_idx;
983 if (idx % 2 != 0) {
984 spin_unlock(&drvdata->spinlock);
985 return -EPERM;
986 }
987
988 if (!((config->addr_type[idx] == ETM_ADDR_TYPE_NONE &&
989 config->addr_type[idx + 1] == ETM_ADDR_TYPE_NONE) ||
990 (config->addr_type[idx] == ETM_ADDR_TYPE_RANGE &&
991 config->addr_type[idx + 1] == ETM_ADDR_TYPE_RANGE))) {
992 spin_unlock(&drvdata->spinlock);
993 return -EPERM;
994 }
995
996 config->addr_val[idx] = (u64)val1;
997 config->addr_type[idx] = ETM_ADDR_TYPE_RANGE;
998 config->addr_val[idx + 1] = (u64)val2;
999 config->addr_type[idx + 1] = ETM_ADDR_TYPE_RANGE;
1000
1001
1002
1003
1004 etm4_set_mode_exclude(drvdata,
1005 config->mode & ETM_MODE_EXCLUDE ? true : false);
1006
1007 spin_unlock(&drvdata->spinlock);
1008 return size;
1009 }
1010 static DEVICE_ATTR_RW(addr_range);
1011
1012 static ssize_t addr_start_show(struct device *dev,
1013 struct device_attribute *attr,
1014 char *buf)
1015 {
1016 u8 idx;
1017 unsigned long val;
1018 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1019 struct etmv4_config *config = &drvdata->config;
1020
1021 spin_lock(&drvdata->spinlock);
1022 idx = config->addr_idx;
1023
1024 if (!(config->addr_type[idx] == ETM_ADDR_TYPE_NONE ||
1025 config->addr_type[idx] == ETM_ADDR_TYPE_START)) {
1026 spin_unlock(&drvdata->spinlock);
1027 return -EPERM;
1028 }
1029
1030 val = (unsigned long)config->addr_val[idx];
1031 spin_unlock(&drvdata->spinlock);
1032 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1033 }
1034
1035 static ssize_t addr_start_store(struct device *dev,
1036 struct device_attribute *attr,
1037 const char *buf, size_t size)
1038 {
1039 u8 idx;
1040 unsigned long val;
1041 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1042 struct etmv4_config *config = &drvdata->config;
1043
1044 if (kstrtoul(buf, 16, &val))
1045 return -EINVAL;
1046
1047 spin_lock(&drvdata->spinlock);
1048 idx = config->addr_idx;
1049 if (!drvdata->nr_addr_cmp) {
1050 spin_unlock(&drvdata->spinlock);
1051 return -EINVAL;
1052 }
1053 if (!(config->addr_type[idx] == ETM_ADDR_TYPE_NONE ||
1054 config->addr_type[idx] == ETM_ADDR_TYPE_START)) {
1055 spin_unlock(&drvdata->spinlock);
1056 return -EPERM;
1057 }
1058
1059 config->addr_val[idx] = (u64)val;
1060 config->addr_type[idx] = ETM_ADDR_TYPE_START;
1061 config->vissctlr |= BIT(idx);
1062
1063 config->vinst_ctrl |= BIT(9);
1064 spin_unlock(&drvdata->spinlock);
1065 return size;
1066 }
1067 static DEVICE_ATTR_RW(addr_start);
1068
1069 static ssize_t addr_stop_show(struct device *dev,
1070 struct device_attribute *attr,
1071 char *buf)
1072 {
1073 u8 idx;
1074 unsigned long val;
1075 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1076 struct etmv4_config *config = &drvdata->config;
1077
1078 spin_lock(&drvdata->spinlock);
1079 idx = config->addr_idx;
1080
1081 if (!(config->addr_type[idx] == ETM_ADDR_TYPE_NONE ||
1082 config->addr_type[idx] == ETM_ADDR_TYPE_STOP)) {
1083 spin_unlock(&drvdata->spinlock);
1084 return -EPERM;
1085 }
1086
1087 val = (unsigned long)config->addr_val[idx];
1088 spin_unlock(&drvdata->spinlock);
1089 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1090 }
1091
1092 static ssize_t addr_stop_store(struct device *dev,
1093 struct device_attribute *attr,
1094 const char *buf, size_t size)
1095 {
1096 u8 idx;
1097 unsigned long val;
1098 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1099 struct etmv4_config *config = &drvdata->config;
1100
1101 if (kstrtoul(buf, 16, &val))
1102 return -EINVAL;
1103
1104 spin_lock(&drvdata->spinlock);
1105 idx = config->addr_idx;
1106 if (!drvdata->nr_addr_cmp) {
1107 spin_unlock(&drvdata->spinlock);
1108 return -EINVAL;
1109 }
1110 if (!(config->addr_type[idx] == ETM_ADDR_TYPE_NONE ||
1111 config->addr_type[idx] == ETM_ADDR_TYPE_STOP)) {
1112 spin_unlock(&drvdata->spinlock);
1113 return -EPERM;
1114 }
1115
1116 config->addr_val[idx] = (u64)val;
1117 config->addr_type[idx] = ETM_ADDR_TYPE_STOP;
1118 config->vissctlr |= BIT(idx + 16);
1119
1120 config->vinst_ctrl |= BIT(9);
1121 spin_unlock(&drvdata->spinlock);
1122 return size;
1123 }
1124 static DEVICE_ATTR_RW(addr_stop);
1125
1126 static ssize_t addr_ctxtype_show(struct device *dev,
1127 struct device_attribute *attr,
1128 char *buf)
1129 {
1130 ssize_t len;
1131 u8 idx, val;
1132 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1133 struct etmv4_config *config = &drvdata->config;
1134
1135 spin_lock(&drvdata->spinlock);
1136 idx = config->addr_idx;
1137
1138 val = BMVAL(config->addr_acc[idx], 2, 3);
1139 len = scnprintf(buf, PAGE_SIZE, "%s\n", val == ETM_CTX_NONE ? "none" :
1140 (val == ETM_CTX_CTXID ? "ctxid" :
1141 (val == ETM_CTX_VMID ? "vmid" : "all")));
1142 spin_unlock(&drvdata->spinlock);
1143 return len;
1144 }
1145
1146 static ssize_t addr_ctxtype_store(struct device *dev,
1147 struct device_attribute *attr,
1148 const char *buf, size_t size)
1149 {
1150 u8 idx;
1151 char str[10] = "";
1152 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1153 struct etmv4_config *config = &drvdata->config;
1154
1155 if (strlen(buf) >= 10)
1156 return -EINVAL;
1157 if (sscanf(buf, "%s", str) != 1)
1158 return -EINVAL;
1159
1160 spin_lock(&drvdata->spinlock);
1161 idx = config->addr_idx;
1162 if (!strcmp(str, "none"))
1163
1164 config->addr_acc[idx] &= ~(BIT(2) | BIT(3));
1165 else if (!strcmp(str, "ctxid")) {
1166
1167 if (drvdata->numcidc) {
1168 config->addr_acc[idx] |= BIT(2);
1169 config->addr_acc[idx] &= ~BIT(3);
1170 }
1171 } else if (!strcmp(str, "vmid")) {
1172
1173 if (drvdata->numvmidc) {
1174 config->addr_acc[idx] &= ~BIT(2);
1175 config->addr_acc[idx] |= BIT(3);
1176 }
1177 } else if (!strcmp(str, "all")) {
1178
1179
1180
1181
1182 if (drvdata->numcidc)
1183 config->addr_acc[idx] |= BIT(2);
1184 if (drvdata->numvmidc)
1185 config->addr_acc[idx] |= BIT(3);
1186 }
1187 spin_unlock(&drvdata->spinlock);
1188 return size;
1189 }
1190 static DEVICE_ATTR_RW(addr_ctxtype);
1191
1192 static ssize_t addr_context_show(struct device *dev,
1193 struct device_attribute *attr,
1194 char *buf)
1195 {
1196 u8 idx;
1197 unsigned long val;
1198 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1199 struct etmv4_config *config = &drvdata->config;
1200
1201 spin_lock(&drvdata->spinlock);
1202 idx = config->addr_idx;
1203
1204 val = BMVAL(config->addr_acc[idx], 4, 6);
1205 spin_unlock(&drvdata->spinlock);
1206 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1207 }
1208
1209 static ssize_t addr_context_store(struct device *dev,
1210 struct device_attribute *attr,
1211 const char *buf, size_t size)
1212 {
1213 u8 idx;
1214 unsigned long val;
1215 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1216 struct etmv4_config *config = &drvdata->config;
1217
1218 if (kstrtoul(buf, 16, &val))
1219 return -EINVAL;
1220 if ((drvdata->numcidc <= 1) && (drvdata->numvmidc <= 1))
1221 return -EINVAL;
1222 if (val >= (drvdata->numcidc >= drvdata->numvmidc ?
1223 drvdata->numcidc : drvdata->numvmidc))
1224 return -EINVAL;
1225
1226 spin_lock(&drvdata->spinlock);
1227 idx = config->addr_idx;
1228
1229 config->addr_acc[idx] &= ~(BIT(4) | BIT(5) | BIT(6));
1230 config->addr_acc[idx] |= (val << 4);
1231 spin_unlock(&drvdata->spinlock);
1232 return size;
1233 }
1234 static DEVICE_ATTR_RW(addr_context);
1235
1236 static ssize_t seq_idx_show(struct device *dev,
1237 struct device_attribute *attr,
1238 char *buf)
1239 {
1240 unsigned long val;
1241 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1242 struct etmv4_config *config = &drvdata->config;
1243
1244 val = config->seq_idx;
1245 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1246 }
1247
1248 static ssize_t seq_idx_store(struct device *dev,
1249 struct device_attribute *attr,
1250 const char *buf, size_t size)
1251 {
1252 unsigned long val;
1253 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1254 struct etmv4_config *config = &drvdata->config;
1255
1256 if (kstrtoul(buf, 16, &val))
1257 return -EINVAL;
1258 if (val >= drvdata->nrseqstate - 1)
1259 return -EINVAL;
1260
1261
1262
1263
1264
1265 spin_lock(&drvdata->spinlock);
1266 config->seq_idx = val;
1267 spin_unlock(&drvdata->spinlock);
1268 return size;
1269 }
1270 static DEVICE_ATTR_RW(seq_idx);
1271
1272 static ssize_t seq_state_show(struct device *dev,
1273 struct device_attribute *attr,
1274 char *buf)
1275 {
1276 unsigned long val;
1277 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1278 struct etmv4_config *config = &drvdata->config;
1279
1280 val = config->seq_state;
1281 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1282 }
1283
1284 static ssize_t seq_state_store(struct device *dev,
1285 struct device_attribute *attr,
1286 const char *buf, size_t size)
1287 {
1288 unsigned long val;
1289 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1290 struct etmv4_config *config = &drvdata->config;
1291
1292 if (kstrtoul(buf, 16, &val))
1293 return -EINVAL;
1294 if (val >= drvdata->nrseqstate)
1295 return -EINVAL;
1296
1297 config->seq_state = val;
1298 return size;
1299 }
1300 static DEVICE_ATTR_RW(seq_state);
1301
1302 static ssize_t seq_event_show(struct device *dev,
1303 struct device_attribute *attr,
1304 char *buf)
1305 {
1306 u8 idx;
1307 unsigned long val;
1308 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1309 struct etmv4_config *config = &drvdata->config;
1310
1311 spin_lock(&drvdata->spinlock);
1312 idx = config->seq_idx;
1313 val = config->seq_ctrl[idx];
1314 spin_unlock(&drvdata->spinlock);
1315 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1316 }
1317
1318 static ssize_t seq_event_store(struct device *dev,
1319 struct device_attribute *attr,
1320 const char *buf, size_t size)
1321 {
1322 u8 idx;
1323 unsigned long val;
1324 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1325 struct etmv4_config *config = &drvdata->config;
1326
1327 if (kstrtoul(buf, 16, &val))
1328 return -EINVAL;
1329
1330 spin_lock(&drvdata->spinlock);
1331 idx = config->seq_idx;
1332
1333 config->seq_ctrl[idx] = val & 0xFFFF;
1334 spin_unlock(&drvdata->spinlock);
1335 return size;
1336 }
1337 static DEVICE_ATTR_RW(seq_event);
1338
1339 static ssize_t seq_reset_event_show(struct device *dev,
1340 struct device_attribute *attr,
1341 char *buf)
1342 {
1343 unsigned long val;
1344 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1345 struct etmv4_config *config = &drvdata->config;
1346
1347 val = config->seq_rst;
1348 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1349 }
1350
1351 static ssize_t seq_reset_event_store(struct device *dev,
1352 struct device_attribute *attr,
1353 const char *buf, size_t size)
1354 {
1355 unsigned long val;
1356 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1357 struct etmv4_config *config = &drvdata->config;
1358
1359 if (kstrtoul(buf, 16, &val))
1360 return -EINVAL;
1361 if (!(drvdata->nrseqstate))
1362 return -EINVAL;
1363
1364 config->seq_rst = val & ETMv4_EVENT_MASK;
1365 return size;
1366 }
1367 static DEVICE_ATTR_RW(seq_reset_event);
1368
1369 static ssize_t cntr_idx_show(struct device *dev,
1370 struct device_attribute *attr,
1371 char *buf)
1372 {
1373 unsigned long val;
1374 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1375 struct etmv4_config *config = &drvdata->config;
1376
1377 val = config->cntr_idx;
1378 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1379 }
1380
1381 static ssize_t cntr_idx_store(struct device *dev,
1382 struct device_attribute *attr,
1383 const char *buf, size_t size)
1384 {
1385 unsigned long val;
1386 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1387 struct etmv4_config *config = &drvdata->config;
1388
1389 if (kstrtoul(buf, 16, &val))
1390 return -EINVAL;
1391 if (val >= drvdata->nr_cntr)
1392 return -EINVAL;
1393
1394
1395
1396
1397
1398 spin_lock(&drvdata->spinlock);
1399 config->cntr_idx = val;
1400 spin_unlock(&drvdata->spinlock);
1401 return size;
1402 }
1403 static DEVICE_ATTR_RW(cntr_idx);
1404
1405 static ssize_t cntrldvr_show(struct device *dev,
1406 struct device_attribute *attr,
1407 char *buf)
1408 {
1409 u8 idx;
1410 unsigned long val;
1411 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1412 struct etmv4_config *config = &drvdata->config;
1413
1414 spin_lock(&drvdata->spinlock);
1415 idx = config->cntr_idx;
1416 val = config->cntrldvr[idx];
1417 spin_unlock(&drvdata->spinlock);
1418 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1419 }
1420
1421 static ssize_t cntrldvr_store(struct device *dev,
1422 struct device_attribute *attr,
1423 const char *buf, size_t size)
1424 {
1425 u8 idx;
1426 unsigned long val;
1427 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1428 struct etmv4_config *config = &drvdata->config;
1429
1430 if (kstrtoul(buf, 16, &val))
1431 return -EINVAL;
1432 if (val > ETM_CNTR_MAX_VAL)
1433 return -EINVAL;
1434
1435 spin_lock(&drvdata->spinlock);
1436 idx = config->cntr_idx;
1437 config->cntrldvr[idx] = val;
1438 spin_unlock(&drvdata->spinlock);
1439 return size;
1440 }
1441 static DEVICE_ATTR_RW(cntrldvr);
1442
1443 static ssize_t cntr_val_show(struct device *dev,
1444 struct device_attribute *attr,
1445 char *buf)
1446 {
1447 u8 idx;
1448 unsigned long val;
1449 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1450 struct etmv4_config *config = &drvdata->config;
1451
1452 spin_lock(&drvdata->spinlock);
1453 idx = config->cntr_idx;
1454 val = config->cntr_val[idx];
1455 spin_unlock(&drvdata->spinlock);
1456 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1457 }
1458
1459 static ssize_t cntr_val_store(struct device *dev,
1460 struct device_attribute *attr,
1461 const char *buf, size_t size)
1462 {
1463 u8 idx;
1464 unsigned long val;
1465 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1466 struct etmv4_config *config = &drvdata->config;
1467
1468 if (kstrtoul(buf, 16, &val))
1469 return -EINVAL;
1470 if (val > ETM_CNTR_MAX_VAL)
1471 return -EINVAL;
1472
1473 spin_lock(&drvdata->spinlock);
1474 idx = config->cntr_idx;
1475 config->cntr_val[idx] = val;
1476 spin_unlock(&drvdata->spinlock);
1477 return size;
1478 }
1479 static DEVICE_ATTR_RW(cntr_val);
1480
1481 static ssize_t cntr_ctrl_show(struct device *dev,
1482 struct device_attribute *attr,
1483 char *buf)
1484 {
1485 u8 idx;
1486 unsigned long val;
1487 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1488 struct etmv4_config *config = &drvdata->config;
1489
1490 spin_lock(&drvdata->spinlock);
1491 idx = config->cntr_idx;
1492 val = config->cntr_ctrl[idx];
1493 spin_unlock(&drvdata->spinlock);
1494 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1495 }
1496
1497 static ssize_t cntr_ctrl_store(struct device *dev,
1498 struct device_attribute *attr,
1499 const char *buf, size_t size)
1500 {
1501 u8 idx;
1502 unsigned long val;
1503 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1504 struct etmv4_config *config = &drvdata->config;
1505
1506 if (kstrtoul(buf, 16, &val))
1507 return -EINVAL;
1508
1509 spin_lock(&drvdata->spinlock);
1510 idx = config->cntr_idx;
1511 config->cntr_ctrl[idx] = val;
1512 spin_unlock(&drvdata->spinlock);
1513 return size;
1514 }
1515 static DEVICE_ATTR_RW(cntr_ctrl);
1516
1517 static ssize_t res_idx_show(struct device *dev,
1518 struct device_attribute *attr,
1519 char *buf)
1520 {
1521 unsigned long val;
1522 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1523 struct etmv4_config *config = &drvdata->config;
1524
1525 val = config->res_idx;
1526 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1527 }
1528
1529 static ssize_t res_idx_store(struct device *dev,
1530 struct device_attribute *attr,
1531 const char *buf, size_t size)
1532 {
1533 unsigned long val;
1534 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1535 struct etmv4_config *config = &drvdata->config;
1536
1537 if (kstrtoul(buf, 16, &val))
1538 return -EINVAL;
1539
1540 if ((val == 0) || (val >= drvdata->nr_resource))
1541 return -EINVAL;
1542
1543
1544
1545
1546
1547 spin_lock(&drvdata->spinlock);
1548 config->res_idx = val;
1549 spin_unlock(&drvdata->spinlock);
1550 return size;
1551 }
1552 static DEVICE_ATTR_RW(res_idx);
1553
1554 static ssize_t res_ctrl_show(struct device *dev,
1555 struct device_attribute *attr,
1556 char *buf)
1557 {
1558 u8 idx;
1559 unsigned long val;
1560 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1561 struct etmv4_config *config = &drvdata->config;
1562
1563 spin_lock(&drvdata->spinlock);
1564 idx = config->res_idx;
1565 val = config->res_ctrl[idx];
1566 spin_unlock(&drvdata->spinlock);
1567 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1568 }
1569
1570 static ssize_t res_ctrl_store(struct device *dev,
1571 struct device_attribute *attr,
1572 const char *buf, size_t size)
1573 {
1574 u8 idx;
1575 unsigned long val;
1576 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1577 struct etmv4_config *config = &drvdata->config;
1578
1579 if (kstrtoul(buf, 16, &val))
1580 return -EINVAL;
1581
1582 spin_lock(&drvdata->spinlock);
1583 idx = config->res_idx;
1584
1585 if (idx % 2 != 0)
1586
1587 val &= ~BIT(21);
1588 config->res_ctrl[idx] = val & GENMASK(21, 0);
1589 spin_unlock(&drvdata->spinlock);
1590 return size;
1591 }
1592 static DEVICE_ATTR_RW(res_ctrl);
1593
1594 static ssize_t ctxid_idx_show(struct device *dev,
1595 struct device_attribute *attr,
1596 char *buf)
1597 {
1598 unsigned long val;
1599 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1600 struct etmv4_config *config = &drvdata->config;
1601
1602 val = config->ctxid_idx;
1603 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1604 }
1605
1606 static ssize_t ctxid_idx_store(struct device *dev,
1607 struct device_attribute *attr,
1608 const char *buf, size_t size)
1609 {
1610 unsigned long val;
1611 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1612 struct etmv4_config *config = &drvdata->config;
1613
1614 if (kstrtoul(buf, 16, &val))
1615 return -EINVAL;
1616 if (val >= drvdata->numcidc)
1617 return -EINVAL;
1618
1619
1620
1621
1622
1623 spin_lock(&drvdata->spinlock);
1624 config->ctxid_idx = val;
1625 spin_unlock(&drvdata->spinlock);
1626 return size;
1627 }
1628 static DEVICE_ATTR_RW(ctxid_idx);
1629
1630 static ssize_t ctxid_pid_show(struct device *dev,
1631 struct device_attribute *attr,
1632 char *buf)
1633 {
1634 u8 idx;
1635 unsigned long val;
1636 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1637 struct etmv4_config *config = &drvdata->config;
1638
1639
1640
1641
1642
1643 if (task_active_pid_ns(current) != &init_pid_ns)
1644 return -EINVAL;
1645
1646 spin_lock(&drvdata->spinlock);
1647 idx = config->ctxid_idx;
1648 val = (unsigned long)config->ctxid_pid[idx];
1649 spin_unlock(&drvdata->spinlock);
1650 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1651 }
1652
1653 static ssize_t ctxid_pid_store(struct device *dev,
1654 struct device_attribute *attr,
1655 const char *buf, size_t size)
1656 {
1657 u8 idx;
1658 unsigned long pid;
1659 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1660 struct etmv4_config *config = &drvdata->config;
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671 if (task_active_pid_ns(current) != &init_pid_ns)
1672 return -EINVAL;
1673
1674
1675
1676
1677
1678
1679 if (!drvdata->ctxid_size || !drvdata->numcidc)
1680 return -EINVAL;
1681 if (kstrtoul(buf, 16, &pid))
1682 return -EINVAL;
1683
1684 spin_lock(&drvdata->spinlock);
1685 idx = config->ctxid_idx;
1686 config->ctxid_pid[idx] = (u64)pid;
1687 spin_unlock(&drvdata->spinlock);
1688 return size;
1689 }
1690 static DEVICE_ATTR_RW(ctxid_pid);
1691
1692 static ssize_t ctxid_masks_show(struct device *dev,
1693 struct device_attribute *attr,
1694 char *buf)
1695 {
1696 unsigned long val1, val2;
1697 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1698 struct etmv4_config *config = &drvdata->config;
1699
1700
1701
1702
1703
1704 if (task_active_pid_ns(current) != &init_pid_ns)
1705 return -EINVAL;
1706
1707 spin_lock(&drvdata->spinlock);
1708 val1 = config->ctxid_mask0;
1709 val2 = config->ctxid_mask1;
1710 spin_unlock(&drvdata->spinlock);
1711 return scnprintf(buf, PAGE_SIZE, "%#lx %#lx\n", val1, val2);
1712 }
1713
1714 static ssize_t ctxid_masks_store(struct device *dev,
1715 struct device_attribute *attr,
1716 const char *buf, size_t size)
1717 {
1718 u8 i, j, maskbyte;
1719 unsigned long val1, val2, mask;
1720 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1721 struct etmv4_config *config = &drvdata->config;
1722
1723
1724
1725
1726
1727 if (task_active_pid_ns(current) != &init_pid_ns)
1728 return -EINVAL;
1729
1730
1731
1732
1733
1734
1735 if (!drvdata->ctxid_size || !drvdata->numcidc)
1736 return -EINVAL;
1737 if (sscanf(buf, "%lx %lx", &val1, &val2) != 2)
1738 return -EINVAL;
1739
1740 spin_lock(&drvdata->spinlock);
1741
1742
1743
1744
1745 switch (drvdata->numcidc) {
1746 case 0x1:
1747
1748 config->ctxid_mask0 = val1 & 0xFF;
1749 break;
1750 case 0x2:
1751
1752 config->ctxid_mask0 = val1 & 0xFFFF;
1753 break;
1754 case 0x3:
1755
1756 config->ctxid_mask0 = val1 & 0xFFFFFF;
1757 break;
1758 case 0x4:
1759
1760 config->ctxid_mask0 = val1;
1761 break;
1762 case 0x5:
1763
1764 config->ctxid_mask0 = val1;
1765 config->ctxid_mask1 = val2 & 0xFF;
1766 break;
1767 case 0x6:
1768
1769 config->ctxid_mask0 = val1;
1770 config->ctxid_mask1 = val2 & 0xFFFF;
1771 break;
1772 case 0x7:
1773
1774 config->ctxid_mask0 = val1;
1775 config->ctxid_mask1 = val2 & 0xFFFFFF;
1776 break;
1777 case 0x8:
1778
1779 config->ctxid_mask0 = val1;
1780 config->ctxid_mask1 = val2;
1781 break;
1782 default:
1783 break;
1784 }
1785
1786
1787
1788
1789
1790
1791 mask = config->ctxid_mask0;
1792 for (i = 0; i < drvdata->numcidc; i++) {
1793
1794 maskbyte = mask & ETMv4_EVENT_MASK;
1795
1796
1797
1798
1799 for (j = 0; j < 8; j++) {
1800 if (maskbyte & 1)
1801 config->ctxid_pid[i] &= ~(0xFFUL << (j * 8));
1802 maskbyte >>= 1;
1803 }
1804
1805 if (i == 3)
1806
1807 mask = config->ctxid_mask1;
1808 else
1809 mask >>= 0x8;
1810 }
1811
1812 spin_unlock(&drvdata->spinlock);
1813 return size;
1814 }
1815 static DEVICE_ATTR_RW(ctxid_masks);
1816
1817 static ssize_t vmid_idx_show(struct device *dev,
1818 struct device_attribute *attr,
1819 char *buf)
1820 {
1821 unsigned long val;
1822 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1823 struct etmv4_config *config = &drvdata->config;
1824
1825 val = config->vmid_idx;
1826 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1827 }
1828
1829 static ssize_t vmid_idx_store(struct device *dev,
1830 struct device_attribute *attr,
1831 const char *buf, size_t size)
1832 {
1833 unsigned long val;
1834 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1835 struct etmv4_config *config = &drvdata->config;
1836
1837 if (kstrtoul(buf, 16, &val))
1838 return -EINVAL;
1839 if (val >= drvdata->numvmidc)
1840 return -EINVAL;
1841
1842
1843
1844
1845
1846 spin_lock(&drvdata->spinlock);
1847 config->vmid_idx = val;
1848 spin_unlock(&drvdata->spinlock);
1849 return size;
1850 }
1851 static DEVICE_ATTR_RW(vmid_idx);
1852
1853 static ssize_t vmid_val_show(struct device *dev,
1854 struct device_attribute *attr,
1855 char *buf)
1856 {
1857 unsigned long val;
1858 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1859 struct etmv4_config *config = &drvdata->config;
1860
1861 val = (unsigned long)config->vmid_val[config->vmid_idx];
1862 return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
1863 }
1864
1865 static ssize_t vmid_val_store(struct device *dev,
1866 struct device_attribute *attr,
1867 const char *buf, size_t size)
1868 {
1869 unsigned long val;
1870 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1871 struct etmv4_config *config = &drvdata->config;
1872
1873
1874
1875
1876
1877 if (!drvdata->vmid_size || !drvdata->numvmidc)
1878 return -EINVAL;
1879 if (kstrtoul(buf, 16, &val))
1880 return -EINVAL;
1881
1882 spin_lock(&drvdata->spinlock);
1883 config->vmid_val[config->vmid_idx] = (u64)val;
1884 spin_unlock(&drvdata->spinlock);
1885 return size;
1886 }
1887 static DEVICE_ATTR_RW(vmid_val);
1888
1889 static ssize_t vmid_masks_show(struct device *dev,
1890 struct device_attribute *attr, char *buf)
1891 {
1892 unsigned long val1, val2;
1893 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1894 struct etmv4_config *config = &drvdata->config;
1895
1896 spin_lock(&drvdata->spinlock);
1897 val1 = config->vmid_mask0;
1898 val2 = config->vmid_mask1;
1899 spin_unlock(&drvdata->spinlock);
1900 return scnprintf(buf, PAGE_SIZE, "%#lx %#lx\n", val1, val2);
1901 }
1902
1903 static ssize_t vmid_masks_store(struct device *dev,
1904 struct device_attribute *attr,
1905 const char *buf, size_t size)
1906 {
1907 u8 i, j, maskbyte;
1908 unsigned long val1, val2, mask;
1909 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
1910 struct etmv4_config *config = &drvdata->config;
1911
1912
1913
1914
1915
1916 if (!drvdata->vmid_size || !drvdata->numvmidc)
1917 return -EINVAL;
1918 if (sscanf(buf, "%lx %lx", &val1, &val2) != 2)
1919 return -EINVAL;
1920
1921 spin_lock(&drvdata->spinlock);
1922
1923
1924
1925
1926
1927 switch (drvdata->numvmidc) {
1928 case 0x1:
1929
1930 config->vmid_mask0 = val1 & 0xFF;
1931 break;
1932 case 0x2:
1933
1934 config->vmid_mask0 = val1 & 0xFFFF;
1935 break;
1936 case 0x3:
1937
1938 config->vmid_mask0 = val1 & 0xFFFFFF;
1939 break;
1940 case 0x4:
1941
1942 config->vmid_mask0 = val1;
1943 break;
1944 case 0x5:
1945
1946 config->vmid_mask0 = val1;
1947 config->vmid_mask1 = val2 & 0xFF;
1948 break;
1949 case 0x6:
1950
1951 config->vmid_mask0 = val1;
1952 config->vmid_mask1 = val2 & 0xFFFF;
1953 break;
1954 case 0x7:
1955
1956 config->vmid_mask0 = val1;
1957 config->vmid_mask1 = val2 & 0xFFFFFF;
1958 break;
1959 case 0x8:
1960
1961 config->vmid_mask0 = val1;
1962 config->vmid_mask1 = val2;
1963 break;
1964 default:
1965 break;
1966 }
1967
1968
1969
1970
1971
1972
1973
1974 mask = config->vmid_mask0;
1975 for (i = 0; i < drvdata->numvmidc; i++) {
1976
1977 maskbyte = mask & ETMv4_EVENT_MASK;
1978
1979
1980
1981
1982 for (j = 0; j < 8; j++) {
1983 if (maskbyte & 1)
1984 config->vmid_val[i] &= ~(0xFFUL << (j * 8));
1985 maskbyte >>= 1;
1986 }
1987
1988 if (i == 3)
1989
1990 mask = config->vmid_mask1;
1991 else
1992 mask >>= 0x8;
1993 }
1994 spin_unlock(&drvdata->spinlock);
1995 return size;
1996 }
1997 static DEVICE_ATTR_RW(vmid_masks);
1998
1999 static ssize_t cpu_show(struct device *dev,
2000 struct device_attribute *attr, char *buf)
2001 {
2002 int val;
2003 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
2004
2005 val = drvdata->cpu;
2006 return scnprintf(buf, PAGE_SIZE, "%d\n", val);
2007
2008 }
2009 static DEVICE_ATTR_RO(cpu);
2010
2011 static struct attribute *coresight_etmv4_attrs[] = {
2012 &dev_attr_nr_pe_cmp.attr,
2013 &dev_attr_nr_addr_cmp.attr,
2014 &dev_attr_nr_cntr.attr,
2015 &dev_attr_nr_ext_inp.attr,
2016 &dev_attr_numcidc.attr,
2017 &dev_attr_numvmidc.attr,
2018 &dev_attr_nrseqstate.attr,
2019 &dev_attr_nr_resource.attr,
2020 &dev_attr_nr_ss_cmp.attr,
2021 &dev_attr_reset.attr,
2022 &dev_attr_mode.attr,
2023 &dev_attr_pe.attr,
2024 &dev_attr_event.attr,
2025 &dev_attr_event_instren.attr,
2026 &dev_attr_event_ts.attr,
2027 &dev_attr_syncfreq.attr,
2028 &dev_attr_cyc_threshold.attr,
2029 &dev_attr_bb_ctrl.attr,
2030 &dev_attr_event_vinst.attr,
2031 &dev_attr_s_exlevel_vinst.attr,
2032 &dev_attr_ns_exlevel_vinst.attr,
2033 &dev_attr_addr_idx.attr,
2034 &dev_attr_addr_instdatatype.attr,
2035 &dev_attr_addr_single.attr,
2036 &dev_attr_addr_range.attr,
2037 &dev_attr_addr_start.attr,
2038 &dev_attr_addr_stop.attr,
2039 &dev_attr_addr_ctxtype.attr,
2040 &dev_attr_addr_context.attr,
2041 &dev_attr_seq_idx.attr,
2042 &dev_attr_seq_state.attr,
2043 &dev_attr_seq_event.attr,
2044 &dev_attr_seq_reset_event.attr,
2045 &dev_attr_cntr_idx.attr,
2046 &dev_attr_cntrldvr.attr,
2047 &dev_attr_cntr_val.attr,
2048 &dev_attr_cntr_ctrl.attr,
2049 &dev_attr_res_idx.attr,
2050 &dev_attr_res_ctrl.attr,
2051 &dev_attr_ctxid_idx.attr,
2052 &dev_attr_ctxid_pid.attr,
2053 &dev_attr_ctxid_masks.attr,
2054 &dev_attr_vmid_idx.attr,
2055 &dev_attr_vmid_val.attr,
2056 &dev_attr_vmid_masks.attr,
2057 &dev_attr_cpu.attr,
2058 NULL,
2059 };
2060
2061 struct etmv4_reg {
2062 void __iomem *addr;
2063 u32 data;
2064 };
2065
2066 static void do_smp_cross_read(void *data)
2067 {
2068 struct etmv4_reg *reg = data;
2069
2070 reg->data = readl_relaxed(reg->addr);
2071 }
2072
2073 static u32 etmv4_cross_read(const struct device *dev, u32 offset)
2074 {
2075 struct etmv4_drvdata *drvdata = dev_get_drvdata(dev);
2076 struct etmv4_reg reg;
2077
2078 reg.addr = drvdata->base + offset;
2079
2080
2081
2082
2083 smp_call_function_single(drvdata->cpu, do_smp_cross_read, ®, 1);
2084 return reg.data;
2085 }
2086
2087 #define coresight_etm4x_reg(name, offset) \
2088 coresight_simple_reg32(struct etmv4_drvdata, name, offset)
2089
2090 #define coresight_etm4x_cross_read(name, offset) \
2091 coresight_simple_func(struct etmv4_drvdata, etmv4_cross_read, \
2092 name, offset)
2093
2094 coresight_etm4x_reg(trcpdcr, TRCPDCR);
2095 coresight_etm4x_reg(trcpdsr, TRCPDSR);
2096 coresight_etm4x_reg(trclsr, TRCLSR);
2097 coresight_etm4x_reg(trcauthstatus, TRCAUTHSTATUS);
2098 coresight_etm4x_reg(trcdevid, TRCDEVID);
2099 coresight_etm4x_reg(trcdevtype, TRCDEVTYPE);
2100 coresight_etm4x_reg(trcpidr0, TRCPIDR0);
2101 coresight_etm4x_reg(trcpidr1, TRCPIDR1);
2102 coresight_etm4x_reg(trcpidr2, TRCPIDR2);
2103 coresight_etm4x_reg(trcpidr3, TRCPIDR3);
2104 coresight_etm4x_cross_read(trcoslsr, TRCOSLSR);
2105 coresight_etm4x_cross_read(trcconfig, TRCCONFIGR);
2106 coresight_etm4x_cross_read(trctraceid, TRCTRACEIDR);
2107
2108 static struct attribute *coresight_etmv4_mgmt_attrs[] = {
2109 &dev_attr_trcoslsr.attr,
2110 &dev_attr_trcpdcr.attr,
2111 &dev_attr_trcpdsr.attr,
2112 &dev_attr_trclsr.attr,
2113 &dev_attr_trcconfig.attr,
2114 &dev_attr_trctraceid.attr,
2115 &dev_attr_trcauthstatus.attr,
2116 &dev_attr_trcdevid.attr,
2117 &dev_attr_trcdevtype.attr,
2118 &dev_attr_trcpidr0.attr,
2119 &dev_attr_trcpidr1.attr,
2120 &dev_attr_trcpidr2.attr,
2121 &dev_attr_trcpidr3.attr,
2122 NULL,
2123 };
2124
2125 coresight_etm4x_cross_read(trcidr0, TRCIDR0);
2126 coresight_etm4x_cross_read(trcidr1, TRCIDR1);
2127 coresight_etm4x_cross_read(trcidr2, TRCIDR2);
2128 coresight_etm4x_cross_read(trcidr3, TRCIDR3);
2129 coresight_etm4x_cross_read(trcidr4, TRCIDR4);
2130 coresight_etm4x_cross_read(trcidr5, TRCIDR5);
2131
2132 coresight_etm4x_cross_read(trcidr8, TRCIDR8);
2133 coresight_etm4x_cross_read(trcidr9, TRCIDR9);
2134 coresight_etm4x_cross_read(trcidr10, TRCIDR10);
2135 coresight_etm4x_cross_read(trcidr11, TRCIDR11);
2136 coresight_etm4x_cross_read(trcidr12, TRCIDR12);
2137 coresight_etm4x_cross_read(trcidr13, TRCIDR13);
2138
2139 static struct attribute *coresight_etmv4_trcidr_attrs[] = {
2140 &dev_attr_trcidr0.attr,
2141 &dev_attr_trcidr1.attr,
2142 &dev_attr_trcidr2.attr,
2143 &dev_attr_trcidr3.attr,
2144 &dev_attr_trcidr4.attr,
2145 &dev_attr_trcidr5.attr,
2146
2147 &dev_attr_trcidr8.attr,
2148 &dev_attr_trcidr9.attr,
2149 &dev_attr_trcidr10.attr,
2150 &dev_attr_trcidr11.attr,
2151 &dev_attr_trcidr12.attr,
2152 &dev_attr_trcidr13.attr,
2153 NULL,
2154 };
2155
2156 static const struct attribute_group coresight_etmv4_group = {
2157 .attrs = coresight_etmv4_attrs,
2158 };
2159
2160 static const struct attribute_group coresight_etmv4_mgmt_group = {
2161 .attrs = coresight_etmv4_mgmt_attrs,
2162 .name = "mgmt",
2163 };
2164
2165 static const struct attribute_group coresight_etmv4_trcidr_group = {
2166 .attrs = coresight_etmv4_trcidr_attrs,
2167 .name = "trcidr",
2168 };
2169
2170 const struct attribute_group *coresight_etmv4_groups[] = {
2171 &coresight_etmv4_group,
2172 &coresight_etmv4_mgmt_group,
2173 &coresight_etmv4_trcidr_group,
2174 NULL,
2175 };