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 | |
Will Deacon | 28d7f4e | 2010-04-29 17:11:45 +0100 | [diff] [blame] | 15 | enum arm_pmu_type { |
| 16 | ARM_PMU_DEVICE_CPU = 0, |
| 17 | ARM_NUM_PMU_DEVICES, |
| 18 | }; |
| 19 | |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 20 | #ifdef CONFIG_CPU_HAS_PMU |
| 21 | |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 22 | /** |
| 23 | * reserve_pmu() - reserve the hardware performance counters |
| 24 | * |
| 25 | * Reserve the hardware performance counters in the system for exclusive use. |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 26 | * The platform_device for the system is returned on success, ERR_PTR() |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 27 | * encoded error on failure. |
| 28 | */ |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 29 | extern struct platform_device * |
| 30 | reserve_pmu(enum arm_pmu_type device); |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * release_pmu() - Relinquish control of the performance counters |
| 34 | * |
| 35 | * Release the performance counters and allow someone else to use them. |
| 36 | * Callers must have disabled the counters and released IRQs before calling |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 37 | * this. The platform_device returned from reserve_pmu() must be passed as |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 38 | * a cookie. |
| 39 | */ |
| 40 | extern int |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 41 | release_pmu(struct platform_device *pdev); |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * init_pmu() - Initialise the PMU. |
| 45 | * |
| 46 | * Initialise the system ready for PMU enabling. This should typically set the |
| 47 | * IRQ affinity and nothing else. The users (oprofile/perf events etc) will do |
| 48 | * the actual hardware initialisation. |
| 49 | */ |
| 50 | extern int |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 51 | init_pmu(enum arm_pmu_type device); |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 52 | |
| 53 | #else /* CONFIG_CPU_HAS_PMU */ |
| 54 | |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 55 | #include <linux/err.h> |
| 56 | |
| 57 | static inline struct platform_device * |
| 58 | reserve_pmu(enum arm_pmu_type device) |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 59 | { |
| 60 | return ERR_PTR(-ENODEV); |
| 61 | } |
| 62 | |
| 63 | static inline int |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 64 | release_pmu(struct platform_device *pdev) |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 65 | { |
| 66 | return -ENODEV; |
| 67 | } |
| 68 | |
| 69 | static inline int |
Will Deacon | 49c006b | 2010-04-29 17:13:24 +0100 | [diff] [blame] | 70 | init_pmu(enum arm_pmu_type device) |
Jamie Iles | 0f4f067 | 2010-02-02 20:23:15 +0100 | [diff] [blame] | 71 | { |
| 72 | return -ENODEV; |
| 73 | } |
| 74 | |
| 75 | #endif /* CONFIG_CPU_HAS_PMU */ |
| 76 | |
| 77 | #endif /* __ARM_PMU_H__ */ |