blob: 48d148dc7da927b996a73c2ea49bddc10bfb73bc [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 Deacon28d7f4e2010-04-29 17:11:45 +010017enum arm_pmu_type {
18 ARM_PMU_DEVICE_CPU = 0,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019 ARM_PMU_DEVICE_L2 = 1,
Will Deacon28d7f4e2010-04-29 17:11:45 +010020 ARM_NUM_PMU_DEVICES,
21};
22
Rabin Vincent0e25a5c2011-02-08 09:24:36 +053023/*
24 * struct arm_pmu_platdata - ARM PMU platform data
25 *
26 * @handle_irq: an optional handler which will be called from the interrupt and
27 * passed the address of the low level handler, and can be used to implement
28 * any platform specific handling before or after calling it.
29 */
30struct arm_pmu_platdata {
31 irqreturn_t (*handle_irq)(int irq, void *dev,
32 irq_handler_t pmu_handler);
33};
34
Jamie Iles0f4f0672010-02-02 20:23:15 +010035#ifdef CONFIG_CPU_HAS_PMU
36
Jamie Iles0f4f0672010-02-02 20:23:15 +010037/**
38 * reserve_pmu() - reserve the hardware performance counters
39 *
40 * Reserve the hardware performance counters in the system for exclusive use.
Will Deacon49c006b2010-04-29 17:13:24 +010041 * The platform_device for the system is returned on success, ERR_PTR()
Jamie Iles0f4f0672010-02-02 20:23:15 +010042 * encoded error on failure.
43 */
Will Deacon49c006b2010-04-29 17:13:24 +010044extern struct platform_device *
45reserve_pmu(enum arm_pmu_type device);
Jamie Iles0f4f0672010-02-02 20:23:15 +010046
47/**
48 * release_pmu() - Relinquish control of the performance counters
49 *
50 * Release the performance counters and allow someone else to use them.
51 * Callers must have disabled the counters and released IRQs before calling
Will Deacon49c006b2010-04-29 17:13:24 +010052 * this. The platform_device returned from reserve_pmu() must be passed as
Jamie Iles0f4f0672010-02-02 20:23:15 +010053 * a cookie.
54 */
55extern int
Will Deacon49c006b2010-04-29 17:13:24 +010056release_pmu(struct platform_device *pdev);
Jamie Iles0f4f0672010-02-02 20:23:15 +010057
58/**
59 * init_pmu() - Initialise the PMU.
60 *
61 * Initialise the system ready for PMU enabling. This should typically set the
62 * IRQ affinity and nothing else. The users (oprofile/perf events etc) will do
63 * the actual hardware initialisation.
64 */
65extern int
Will Deacon49c006b2010-04-29 17:13:24 +010066init_pmu(enum arm_pmu_type device);
Jamie Iles0f4f0672010-02-02 20:23:15 +010067
68#else /* CONFIG_CPU_HAS_PMU */
69
Will Deacon49c006b2010-04-29 17:13:24 +010070#include <linux/err.h>
71
72static inline struct platform_device *
73reserve_pmu(enum arm_pmu_type device)
Jamie Iles0f4f0672010-02-02 20:23:15 +010074{
75 return ERR_PTR(-ENODEV);
76}
77
78static inline int
Will Deacon49c006b2010-04-29 17:13:24 +010079release_pmu(struct platform_device *pdev)
Jamie Iles0f4f0672010-02-02 20:23:15 +010080{
81 return -ENODEV;
82}
83
84static inline int
Will Deacon49c006b2010-04-29 17:13:24 +010085init_pmu(enum arm_pmu_type device)
Jamie Iles0f4f0672010-02-02 20:23:15 +010086{
87 return -ENODEV;
88}
89
90#endif /* CONFIG_CPU_HAS_PMU */
91
92#endif /* __ARM_PMU_H__ */