blob: a06ba8773cd7b8d6ba314e7ccd1dbbb69adf762f [file] [log] [blame]
Jamie Iles0f4f0672010-02-02 20:23:15 +01001/*
2 * linux/arch/arm/include/asm/pmu.h
3 *
4 * Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#ifndef __ARM_PMU_H__
13#define __ARM_PMU_H__
14
Rabin Vincent0e25a5c2011-02-08 09:24:36 +053015#include <linux/interrupt.h>
16
Will Deaconb0e89592011-07-26 22:10:28 +010017/*
18 * Types of PMUs that can be accessed directly and require mutual
19 * exclusion between profiling tools.
20 */
Will Deacon28d7f4e2010-04-29 17:11:45 +010021enum arm_pmu_type {
22 ARM_PMU_DEVICE_CPU = 0,
23 ARM_NUM_PMU_DEVICES,
24};
25
Rabin Vincent0e25a5c2011-02-08 09:24:36 +053026/*
27 * struct arm_pmu_platdata - ARM PMU platform data
28 *
29 * @handle_irq: an optional handler which will be called from the interrupt and
30 * passed the address of the low level handler, and can be used to implement
31 * any platform specific handling before or after calling it.
32 */
33struct arm_pmu_platdata {
34 irqreturn_t (*handle_irq)(int irq, void *dev,
35 irq_handler_t pmu_handler);
36};
37
Jamie Iles0f4f0672010-02-02 20:23:15 +010038#ifdef CONFIG_CPU_HAS_PMU
39
Jamie Iles0f4f0672010-02-02 20:23:15 +010040/**
41 * reserve_pmu() - reserve the hardware performance counters
42 *
43 * Reserve the hardware performance counters in the system for exclusive use.
Will Deaconb0e89592011-07-26 22:10:28 +010044 * Returns 0 on success or -EBUSY if the lock is already held.
Jamie Iles0f4f0672010-02-02 20:23:15 +010045 */
Will Deaconb0e89592011-07-26 22:10:28 +010046extern int
Mark Rutland7fdd3c42011-08-12 10:42:48 +010047reserve_pmu(enum arm_pmu_type type);
Jamie Iles0f4f0672010-02-02 20:23:15 +010048
49/**
50 * release_pmu() - Relinquish control of the performance counters
51 *
52 * Release the performance counters and allow someone else to use them.
Jamie Iles0f4f0672010-02-02 20:23:15 +010053 */
Will Deaconb0e89592011-07-26 22:10:28 +010054extern void
Mark Rutlandf12482c2011-06-22 15:30:51 +010055release_pmu(enum arm_pmu_type type);
Jamie Iles0f4f0672010-02-02 20:23:15 +010056
57/**
58 * init_pmu() - Initialise the PMU.
59 *
60 * Initialise the system ready for PMU enabling. This should typically set the
61 * IRQ affinity and nothing else. The users (oprofile/perf events etc) will do
62 * the actual hardware initialisation.
63 */
64extern int
Mark Rutland7fdd3c42011-08-12 10:42:48 +010065init_pmu(enum arm_pmu_type type);
Jamie Iles0f4f0672010-02-02 20:23:15 +010066
67#else /* CONFIG_CPU_HAS_PMU */
68
Will Deacon49c006b2010-04-29 17:13:24 +010069#include <linux/err.h>
70
Will Deaconb0e89592011-07-26 22:10:28 +010071static inline int
Mark Rutland7fdd3c42011-08-12 10:42:48 +010072reserve_pmu(enum arm_pmu_type type)
Jamie Iles0f4f0672010-02-02 20:23:15 +010073{
Jamie Iles0f4f0672010-02-02 20:23:15 +010074 return -ENODEV;
75}
76
Will Deaconb0e89592011-07-26 22:10:28 +010077static inline void
78release_pmu(enum arm_pmu_type type) { }
Jamie Iles0f4f0672010-02-02 20:23:15 +010079
80#endif /* CONFIG_CPU_HAS_PMU */
81
82#endif /* __ARM_PMU_H__ */