blob: 5b94cebe053527730e8a7650cff37e2221f28095 [file] [log] [blame]
Mischa Jonker0dd450f2013-11-07 14:55:11 +01001/*
2 * Linux performance counter support for ARC700 series
3 *
Vineet Guptafb7c5722015-08-24 13:37:01 +03004 * Copyright (C) 2013-2015 Synopsys, Inc. (www.synopsys.com)
Mischa Jonker0dd450f2013-11-07 14:55:11 +01005 *
6 * This code is inspired by the perf support of various other architectures.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13#include <linux/errno.h>
Alexey Brodkin36481cf2015-08-24 13:48:06 +030014#include <linux/interrupt.h>
Mischa Jonker0dd450f2013-11-07 14:55:11 +010015#include <linux/module.h>
16#include <linux/of.h>
17#include <linux/perf_event.h>
18#include <linux/platform_device.h>
19#include <asm/arcregs.h>
Vineet Gupta389e3162013-11-12 11:00:03 +010020#include <asm/stacktrace.h>
Mischa Jonker0dd450f2013-11-07 14:55:11 +010021
22struct arc_pmu {
23 struct pmu pmu;
Mischa Jonker0dd450f2013-11-07 14:55:11 +010024 int n_counters;
Vineet Guptafb7c5722015-08-24 13:37:01 +030025 unsigned long used_mask[BITS_TO_LONGS(ARC_PERF_MAX_COUNTERS)];
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +030026 u64 max_period;
Mischa Jonker0dd450f2013-11-07 14:55:11 +010027 int ev_hw_idx[PERF_COUNT_ARC_HW_MAX];
Alexey Brodkin36481cf2015-08-24 13:48:06 +030028 struct perf_event *act_counter[ARC_PERF_MAX_COUNTERS];
Mischa Jonker0dd450f2013-11-07 14:55:11 +010029};
30
Vineet Gupta389e3162013-11-12 11:00:03 +010031struct arc_callchain_trace {
32 int depth;
33 void *perf_stuff;
34};
35
36static int callchain_trace(unsigned int addr, void *data)
37{
38 struct arc_callchain_trace *ctrl = data;
39 struct perf_callchain_entry *entry = ctrl->perf_stuff;
40 perf_callchain_store(entry, addr);
41
42 if (ctrl->depth++ < 3)
43 return 0;
44
45 return -1;
46}
47
48void
49perf_callchain_kernel(struct perf_callchain_entry *entry, struct pt_regs *regs)
50{
51 struct arc_callchain_trace ctrl = {
52 .depth = 0,
53 .perf_stuff = entry,
54 };
55
56 arc_unwind_core(NULL, regs, callchain_trace, &ctrl);
57}
58
Vineet Gupta22f6b892013-07-12 15:55:54 +020059void
60perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
61{
62 /*
63 * User stack can't be unwound trivially with kernel dwarf unwinder
64 * So for now just record the user PC
65 */
66 perf_callchain_store(entry, instruction_pointer(regs));
67}
68
Vineet Gupta03c94fc2014-11-17 17:13:03 +053069static struct arc_pmu *arc_pmu;
70
Mischa Jonker0dd450f2013-11-07 14:55:11 +010071/* read counter #idx; note that counter# != event# on ARC! */
72static uint64_t arc_pmu_read_counter(int idx)
73{
74 uint32_t tmp;
75 uint64_t result;
76
77 /*
78 * ARC supports making 'snapshots' of the counters, so we don't
79 * need to care about counters wrapping to 0 underneath our feet
80 */
81 write_aux_reg(ARC_REG_PCT_INDEX, idx);
82 tmp = read_aux_reg(ARC_REG_PCT_CONTROL);
83 write_aux_reg(ARC_REG_PCT_CONTROL, tmp | ARC_REG_PCT_CONTROL_SN);
84 result = (uint64_t) (read_aux_reg(ARC_REG_PCT_SNAPH)) << 32;
85 result |= read_aux_reg(ARC_REG_PCT_SNAPL);
86
87 return result;
88}
89
90static void arc_perf_event_update(struct perf_event *event,
91 struct hw_perf_event *hwc, int idx)
92{
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +030093 uint64_t prev_raw_count = local64_read(&hwc->prev_count);
94 uint64_t new_raw_count = arc_pmu_read_counter(idx);
95 int64_t delta = new_raw_count - prev_raw_count;
Mischa Jonker0dd450f2013-11-07 14:55:11 +010096
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +030097 /*
98 * We don't afaraid of hwc->prev_count changing beneath our feet
99 * because there's no way for us to re-enter this function anytime.
100 */
101 local64_set(&hwc->prev_count, new_raw_count);
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100102 local64_add(delta, &event->count);
103 local64_sub(delta, &hwc->period_left);
104}
105
106static void arc_pmu_read(struct perf_event *event)
107{
108 arc_perf_event_update(event, &event->hw, event->hw.idx);
109}
110
111static int arc_pmu_cache_event(u64 config)
112{
113 unsigned int cache_type, cache_op, cache_result;
114 int ret;
115
116 cache_type = (config >> 0) & 0xff;
117 cache_op = (config >> 8) & 0xff;
118 cache_result = (config >> 16) & 0xff;
119 if (cache_type >= PERF_COUNT_HW_CACHE_MAX)
120 return -EINVAL;
Vineet Guptada990a42013-11-28 15:49:59 +0530121 if (cache_op >= PERF_COUNT_HW_CACHE_OP_MAX)
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100122 return -EINVAL;
Vineet Guptada990a42013-11-28 15:49:59 +0530123 if (cache_result >= PERF_COUNT_HW_CACHE_RESULT_MAX)
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100124 return -EINVAL;
125
126 ret = arc_pmu_cache_map[cache_type][cache_op][cache_result];
127
128 if (ret == CACHE_OP_UNSUPPORTED)
129 return -ENOENT;
130
Vineet Guptabde80c22015-04-15 19:44:07 +0530131 pr_debug("init cache event: type/op/result %d/%d/%d with h/w %d \'%s\'\n",
132 cache_type, cache_op, cache_result, ret,
133 arc_pmu_ev_hw_map[ret]);
134
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100135 return ret;
136}
137
138/* initializes hw_perf_event structure if event is supported */
139static int arc_pmu_event_init(struct perf_event *event)
140{
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100141 struct hw_perf_event *hwc = &event->hw;
142 int ret;
143
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300144 if (!is_sampling_event(event)) {
145 hwc->sample_period = arc_pmu->max_period;
146 hwc->last_period = hwc->sample_period;
147 local64_set(&hwc->period_left, hwc->sample_period);
148 }
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +0300149
Alexey Brodkine6b1d122015-08-24 13:53:36 +0300150 hwc->config = 0;
151
152 if (is_isa_arcv2()) {
153 /* "exclude user" means "count only kernel" */
154 if (event->attr.exclude_user)
155 hwc->config |= ARC_REG_PCT_CONFIG_KERN;
156
157 /* "exclude kernel" means "count only user" */
158 if (event->attr.exclude_kernel)
159 hwc->config |= ARC_REG_PCT_CONFIG_USER;
160 }
161
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100162 switch (event->attr.type) {
163 case PERF_TYPE_HARDWARE:
164 if (event->attr.config >= PERF_COUNT_HW_MAX)
165 return -ENOENT;
166 if (arc_pmu->ev_hw_idx[event->attr.config] < 0)
167 return -ENOENT;
Alexey Brodkine6b1d122015-08-24 13:53:36 +0300168 hwc->config |= arc_pmu->ev_hw_idx[event->attr.config];
Vineet Guptabde80c22015-04-15 19:44:07 +0530169 pr_debug("init event %d with h/w %d \'%s\'\n",
170 (int) event->attr.config, (int) hwc->config,
171 arc_pmu_ev_hw_map[event->attr.config]);
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100172 return 0;
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +0300173
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100174 case PERF_TYPE_HW_CACHE:
175 ret = arc_pmu_cache_event(event->attr.config);
176 if (ret < 0)
177 return ret;
Alexey Brodkine6b1d122015-08-24 13:53:36 +0300178 hwc->config |= arc_pmu->ev_hw_idx[ret];
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100179 return 0;
180 default:
181 return -ENOENT;
182 }
183}
184
185/* starts all counters */
186static void arc_pmu_enable(struct pmu *pmu)
187{
188 uint32_t tmp;
189 tmp = read_aux_reg(ARC_REG_PCT_CONTROL);
190 write_aux_reg(ARC_REG_PCT_CONTROL, (tmp & 0xffff0000) | 0x1);
191}
192
193/* stops all counters */
194static void arc_pmu_disable(struct pmu *pmu)
195{
196 uint32_t tmp;
197 tmp = read_aux_reg(ARC_REG_PCT_CONTROL);
198 write_aux_reg(ARC_REG_PCT_CONTROL, (tmp & 0xffff0000) | 0x0);
199}
200
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +0300201static int arc_pmu_event_set_period(struct perf_event *event)
202{
203 struct hw_perf_event *hwc = &event->hw;
204 s64 left = local64_read(&hwc->period_left);
205 s64 period = hwc->sample_period;
206 int idx = hwc->idx;
207 int overflow = 0;
208 u64 value;
209
210 if (unlikely(left <= -period)) {
211 /* left underflowed by more than period. */
212 left = period;
213 local64_set(&hwc->period_left, left);
214 hwc->last_period = period;
215 overflow = 1;
216 } else if (unlikely(left <= 0)) {
217 /* left underflowed by less than period. */
218 left += period;
219 local64_set(&hwc->period_left, left);
220 hwc->last_period = period;
221 overflow = 1;
222 }
223
224 if (left > arc_pmu->max_period)
225 left = arc_pmu->max_period;
226
227 value = arc_pmu->max_period - left;
228 local64_set(&hwc->prev_count, value);
229
230 /* Select counter */
231 write_aux_reg(ARC_REG_PCT_INDEX, idx);
232
233 /* Write value */
234 write_aux_reg(ARC_REG_PCT_COUNTL, (u32)value);
235 write_aux_reg(ARC_REG_PCT_COUNTH, (value >> 32));
236
237 perf_event_update_userpage(event);
238
239 return overflow;
240}
241
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100242/*
243 * Assigns hardware counter to hardware condition.
244 * Note that there is no separate start/stop mechanism;
245 * stopping is achieved by assigning the 'never' condition
246 */
247static void arc_pmu_start(struct perf_event *event, int flags)
248{
249 struct hw_perf_event *hwc = &event->hw;
250 int idx = hwc->idx;
251
252 if (WARN_ON_ONCE(idx == -1))
253 return;
254
255 if (flags & PERF_EF_RELOAD)
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +0300256 WARN_ON_ONCE(!(hwc->state & PERF_HES_UPTODATE));
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100257
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +0300258 hwc->state = 0;
259
260 arc_pmu_event_set_period(event);
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100261
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300262 /* Enable interrupt for this counter */
263 if (is_sampling_event(event))
264 write_aux_reg(ARC_REG_PCT_INT_CTRL,
265 read_aux_reg(ARC_REG_PCT_INT_CTRL) | (1 << idx));
266
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100267 /* enable ARC pmu here */
Vineet Gupta09074952015-08-19 17:23:58 +0530268 write_aux_reg(ARC_REG_PCT_INDEX, idx); /* counter # */
269 write_aux_reg(ARC_REG_PCT_CONFIG, hwc->config); /* condition */
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100270}
271
272static void arc_pmu_stop(struct perf_event *event, int flags)
273{
274 struct hw_perf_event *hwc = &event->hw;
275 int idx = hwc->idx;
276
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300277 /* Disable interrupt for this counter */
278 if (is_sampling_event(event)) {
279 /*
280 * Reset interrupt flag by writing of 1. This is required
281 * to make sure pending interrupt was not left.
282 */
283 write_aux_reg(ARC_REG_PCT_INT_ACT, 1 << idx);
284 write_aux_reg(ARC_REG_PCT_INT_CTRL,
285 read_aux_reg(ARC_REG_PCT_INT_CTRL) & ~(1 << idx));
286 }
287
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100288 if (!(event->hw.state & PERF_HES_STOPPED)) {
289 /* stop ARC pmu here */
290 write_aux_reg(ARC_REG_PCT_INDEX, idx);
291
292 /* condition code #0 is always "never" */
293 write_aux_reg(ARC_REG_PCT_CONFIG, 0);
294
295 event->hw.state |= PERF_HES_STOPPED;
296 }
297
298 if ((flags & PERF_EF_UPDATE) &&
299 !(event->hw.state & PERF_HES_UPTODATE)) {
300 arc_perf_event_update(event, &event->hw, idx);
301 event->hw.state |= PERF_HES_UPTODATE;
302 }
303}
304
305static void arc_pmu_del(struct perf_event *event, int flags)
306{
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100307 arc_pmu_stop(event, PERF_EF_UPDATE);
308 __clear_bit(event->hw.idx, arc_pmu->used_mask);
309
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300310 arc_pmu->act_counter[event->hw.idx] = 0;
311
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100312 perf_event_update_userpage(event);
313}
314
315/* allocate hardware counter and optionally start counting */
316static int arc_pmu_add(struct perf_event *event, int flags)
317{
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100318 struct hw_perf_event *hwc = &event->hw;
319 int idx = hwc->idx;
320
321 if (__test_and_set_bit(idx, arc_pmu->used_mask)) {
322 idx = find_first_zero_bit(arc_pmu->used_mask,
323 arc_pmu->n_counters);
324 if (idx == arc_pmu->n_counters)
325 return -EAGAIN;
326
327 __set_bit(idx, arc_pmu->used_mask);
328 hwc->idx = idx;
329 }
330
331 write_aux_reg(ARC_REG_PCT_INDEX, idx);
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300332
333 arc_pmu->act_counter[idx] = event;
334
335 if (is_sampling_event(event)) {
336 /* Mimic full counter overflow as other arches do */
337 write_aux_reg(ARC_REG_PCT_INT_CNTL, (u32)arc_pmu->max_period);
338 write_aux_reg(ARC_REG_PCT_INT_CNTH,
339 (arc_pmu->max_period >> 32));
340 }
341
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100342 write_aux_reg(ARC_REG_PCT_CONFIG, 0);
343 write_aux_reg(ARC_REG_PCT_COUNTL, 0);
344 write_aux_reg(ARC_REG_PCT_COUNTH, 0);
345 local64_set(&hwc->prev_count, 0);
346
347 hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
348 if (flags & PERF_EF_START)
349 arc_pmu_start(event, PERF_EF_RELOAD);
350
351 perf_event_update_userpage(event);
352
353 return 0;
354}
355
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300356#ifdef CONFIG_ISA_ARCV2
357static irqreturn_t arc_pmu_intr(int irq, void *dev)
358{
359 struct perf_sample_data data;
360 struct arc_pmu *arc_pmu = (struct arc_pmu *)dev;
361 struct pt_regs *regs;
362 int active_ints;
363 int idx;
364
365 arc_pmu_disable(&arc_pmu->pmu);
366
367 active_ints = read_aux_reg(ARC_REG_PCT_INT_ACT);
368
369 regs = get_irq_regs();
370
371 for (idx = 0; idx < arc_pmu->n_counters; idx++) {
372 struct perf_event *event = arc_pmu->act_counter[idx];
373 struct hw_perf_event *hwc;
374
375 if (!(active_ints & (1 << idx)))
376 continue;
377
378 /* Reset interrupt flag by writing of 1 */
379 write_aux_reg(ARC_REG_PCT_INT_ACT, 1 << idx);
380
381 /*
382 * On reset of "interrupt active" bit corresponding
383 * "interrupt enable" bit gets automatically reset as well.
384 * Now we need to re-enable interrupt for the counter.
385 */
386 write_aux_reg(ARC_REG_PCT_INT_CTRL,
387 read_aux_reg(ARC_REG_PCT_INT_CTRL) | (1 << idx));
388
389 hwc = &event->hw;
390
391 WARN_ON_ONCE(hwc->idx != idx);
392
393 arc_perf_event_update(event, &event->hw, event->hw.idx);
394 perf_sample_data_init(&data, 0, hwc->last_period);
395 if (!arc_pmu_event_set_period(event))
396 continue;
397
398 if (perf_event_overflow(event, &data, regs))
399 arc_pmu_stop(event, 0);
400 }
401
402 arc_pmu_enable(&arc_pmu->pmu);
403
404 return IRQ_HANDLED;
405}
406#else
407
408static irqreturn_t arc_pmu_intr(int irq, void *dev)
409{
410 return IRQ_NONE;
411}
412
413#endif /* CONFIG_ISA_ARCV2 */
414
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100415static int arc_pmu_device_probe(struct platform_device *pdev)
416{
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100417 struct arc_reg_pct_build pct_bcr;
418 struct arc_reg_cc_build cc_bcr;
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300419 int i, j, has_interrupts;
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +0300420 int counter_size; /* in bits */
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100421
422 union cc_name {
423 struct {
424 uint32_t word0, word1;
425 char sentinel;
426 } indiv;
427 char str[9];
428 } cc_name;
429
430
431 READ_BCR(ARC_REG_PCT_BUILD, pct_bcr);
432 if (!pct_bcr.v) {
433 pr_err("This core does not have performance counters!\n");
434 return -ENODEV;
435 }
Vineet Guptafb7c5722015-08-24 13:37:01 +0300436 BUG_ON(pct_bcr.c > ARC_PERF_MAX_COUNTERS);
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100437
Vineet Gupta56372082014-09-25 16:54:43 +0530438 READ_BCR(ARC_REG_CC_BUILD, cc_bcr);
Vineet Guptad8f6ad82015-04-20 16:49:30 +0530439 BUG_ON(!cc_bcr.v); /* Counters exist but No countable conditions ? */
Vineet Gupta56372082014-09-25 16:54:43 +0530440
441 arc_pmu = devm_kzalloc(&pdev->dev, sizeof(struct arc_pmu), GFP_KERNEL);
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100442 if (!arc_pmu)
443 return -ENOMEM;
444
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300445 has_interrupts = is_isa_arcv2() ? pct_bcr.i : 0;
446
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100447 arc_pmu->n_counters = pct_bcr.c;
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +0300448 counter_size = 32 + (pct_bcr.s << 4);
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300449
Alexey Brodkin1fe8bfa2015-08-24 13:42:27 +0300450 arc_pmu->max_period = (1ULL << counter_size) / 2 - 1ULL;
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100451
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300452 pr_info("ARC perf\t: %d counters (%d bits), %d conditions%s\n",
453 arc_pmu->n_counters, counter_size, cc_bcr.c,
454 has_interrupts ? ", [overflow IRQ support]":"");
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100455
456 cc_name.str[8] = 0;
Vineet Guptabde80c22015-04-15 19:44:07 +0530457 for (i = 0; i < PERF_COUNT_ARC_HW_MAX; i++)
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100458 arc_pmu->ev_hw_idx[i] = -1;
459
Vineet Guptabde80c22015-04-15 19:44:07 +0530460 /* loop thru all available h/w condition indexes */
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100461 for (j = 0; j < cc_bcr.c; j++) {
462 write_aux_reg(ARC_REG_CC_INDEX, j);
463 cc_name.indiv.word0 = read_aux_reg(ARC_REG_CC_NAME0);
464 cc_name.indiv.word1 = read_aux_reg(ARC_REG_CC_NAME1);
Vineet Guptabde80c22015-04-15 19:44:07 +0530465
466 /* See if it has been mapped to a perf event_id */
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100467 for (i = 0; i < ARRAY_SIZE(arc_pmu_ev_hw_map); i++) {
468 if (arc_pmu_ev_hw_map[i] &&
469 !strcmp(arc_pmu_ev_hw_map[i], cc_name.str) &&
470 strlen(arc_pmu_ev_hw_map[i])) {
Vineet Guptabde80c22015-04-15 19:44:07 +0530471 pr_debug("mapping perf event %2d to h/w event \'%8s\' (idx %d)\n",
472 i, cc_name.str, j);
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100473 arc_pmu->ev_hw_idx[i] = j;
474 }
475 }
476 }
477
478 arc_pmu->pmu = (struct pmu) {
479 .pmu_enable = arc_pmu_enable,
480 .pmu_disable = arc_pmu_disable,
481 .event_init = arc_pmu_event_init,
482 .add = arc_pmu_add,
483 .del = arc_pmu_del,
484 .start = arc_pmu_start,
485 .stop = arc_pmu_stop,
486 .read = arc_pmu_read,
487 };
488
Alexey Brodkin36481cf2015-08-24 13:48:06 +0300489 if (has_interrupts) {
490 int irq = platform_get_irq(pdev, 0);
491
492 if (irq < 0) {
493 pr_err("Cannot get IRQ number for the platform\n");
494 return -ENODEV;
495 }
496
497 ret = devm_request_irq(&pdev->dev, irq, arc_pmu_intr, 0,
498 "arc-pmu", arc_pmu);
499 if (ret) {
500 pr_err("could not allocate PMU IRQ\n");
501 return ret;
502 }
503
504 /* Clean all pending interrupt flags */
505 write_aux_reg(ARC_REG_PCT_INT_ACT, 0xffffffff);
506 } else
507 arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
Vince Weaver2cc9e582014-06-15 02:00:18 -0400508
Tobias Klauser082ae1e2015-04-24 10:27:34 +0200509 return perf_pmu_register(&arc_pmu->pmu, pdev->name, PERF_TYPE_RAW);
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100510}
511
512#ifdef CONFIG_OF
513static const struct of_device_id arc_pmu_match[] = {
Vineet Gupta30fdd372015-04-15 16:35:38 +0530514 { .compatible = "snps,arc700-pct" },
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100515 {},
516};
517MODULE_DEVICE_TABLE(of, arc_pmu_match);
518#endif
519
520static struct platform_driver arc_pmu_driver = {
521 .driver = {
Vineet Gupta30fdd372015-04-15 16:35:38 +0530522 .name = "arc700-pct",
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100523 .of_match_table = of_match_ptr(arc_pmu_match),
524 },
525 .probe = arc_pmu_device_probe,
526};
527
528module_platform_driver(arc_pmu_driver);
529
530MODULE_LICENSE("GPL");
531MODULE_AUTHOR("Mischa Jonker <mjonker@synopsys.com>");
532MODULE_DESCRIPTION("ARC PMU driver");