Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 1 | /* |
| 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 Vincent | 0e25a5c | 2011-02-08 09:24:36 +0530 | [diff] [blame] | 15 | #include <linux/interrupt.h> |
| 16 | |
Will Deacon | 28d7f4e | 2010-04-29 17:11:45 +0100 | [diff] [blame] | 17 | enum arm_pmu_type { |
| 18 | ARM_PMU_DEVICE_CPU = 0, |
| 19 | ARM_NUM_PMU_DEVICES, |
| 20 | }; |
| 21 | |
Rabin Vincent | 0e25a5c | 2011-02-08 09:24:36 +0530 | [diff] [blame] | 22 | /* |
| 23 | * struct arm_pmu_platdata - ARM PMU platform data |
| 24 | * |
| 25 | * @handle_irq: an optional handler which will be called from the interrupt and |
| 26 | * passed the address of the low level handler, and can be used to implement |
| 27 | * any platform specific handling before or after calling it. |
| 28 | */ |
| 29 | struct arm_pmu_platdata { |
| 30 | irqreturn_t (*handle_irq)(int irq, void *dev, |
| 31 | irq_handler_t pmu_handler); |
| 32 | }; |
| 33 | |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 34 | #ifdef CONFIG_CPU_HAS_PMU |
| 35 | |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 36 | /** |
| 37 | * reserve_pmu() - reserve the hardware performance counters |
| 38 | * |
| 39 | * Reserve the hardware performance counters in the system for exclusive use. |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 40 | * The platform_device for the system is returned on success, ERR_PTR() |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 41 | * encoded error on failure. |
| 42 | */ |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 43 | extern struct platform_device * |
Mark Rutland | 7fdd3c4 | 2011-08-12 10:42:48 +0100 | [diff] [blame^] | 44 | reserve_pmu(enum arm_pmu_type type); |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * release_pmu() - Relinquish control of the performance counters |
| 48 | * |
| 49 | * Release the performance counters and allow someone else to use them. |
| 50 | * Callers must have disabled the counters and released IRQs before calling |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 51 | * this. The platform_device returned from reserve_pmu() must be passed as |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 52 | * a cookie. |
| 53 | */ |
| 54 | extern int |
Mark Rutland | f12482c | 2011-06-22 15:30:51 +0100 | [diff] [blame] | 55 | release_pmu(enum arm_pmu_type type); |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 56 | |
| 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 | */ |
| 64 | extern int |
Mark Rutland | 7fdd3c4 | 2011-08-12 10:42:48 +0100 | [diff] [blame^] | 65 | init_pmu(enum arm_pmu_type type); |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 66 | |
| 67 | #else /* CONFIG_CPU_HAS_PMU */ |
| 68 | |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 69 | #include <linux/err.h> |
| 70 | |
| 71 | static inline struct platform_device * |
Mark Rutland | 7fdd3c4 | 2011-08-12 10:42:48 +0100 | [diff] [blame^] | 72 | reserve_pmu(enum arm_pmu_type type) |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 73 | { |
| 74 | return ERR_PTR(-ENODEV); |
| 75 | } |
| 76 | |
| 77 | static inline int |
Mark Rutland | 7fdd3c4 | 2011-08-12 10:42:48 +0100 | [diff] [blame^] | 78 | release_pmu(enum arm_pmu_type type) |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 79 | { |
| 80 | return -ENODEV; |
| 81 | } |
| 82 | |
| 83 | static inline int |
Mark Rutland | 7fdd3c4 | 2011-08-12 10:42:48 +0100 | [diff] [blame^] | 84 | init_pmu(enum arm_pmu_type type) |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 85 | { |
| 86 | return -ENODEV; |
| 87 | } |
| 88 | |
| 89 | #endif /* CONFIG_CPU_HAS_PMU */ |
| 90 | |
| 91 | #endif /* __ARM_PMU_H__ */ |