pmu.h 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 *  linux/arch/arm/include/asm/pmu.h
 *
 *  Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 */

#ifndef __ARM_PMU_H__
#define __ARM_PMU_H__

15 16
#include <linux/interrupt.h>

17 18 19 20 21
enum arm_pmu_type {
	ARM_PMU_DEVICE_CPU	= 0,
	ARM_NUM_PMU_DEVICES,
};

22 23 24 25 26 27 28 29 30 31 32 33
/*
 * struct arm_pmu_platdata - ARM PMU platform data
 *
 * @handle_irq: an optional handler which will be called from the interrupt and
 * passed the address of the low level handler, and can be used to implement
 * any platform specific handling before or after calling it.
 */
struct arm_pmu_platdata {
	irqreturn_t (*handle_irq)(int irq, void *dev,
				  irq_handler_t pmu_handler);
};

34 35 36 37 38 39
#ifdef CONFIG_CPU_HAS_PMU

/**
 * reserve_pmu() - reserve the hardware performance counters
 *
 * Reserve the hardware performance counters in the system for exclusive use.
40
 * The platform_device for the system is returned on success, ERR_PTR()
41 42
 * encoded error on failure.
 */
43 44
extern struct platform_device *
reserve_pmu(enum arm_pmu_type device);
45 46 47 48 49 50

/**
 * release_pmu() - Relinquish control of the performance counters
 *
 * Release the performance counters and allow someone else to use them.
 * Callers must have disabled the counters and released IRQs before calling
51
 * this. The platform_device returned from reserve_pmu() must be passed as
52 53 54
 * a cookie.
 */
extern int
55
release_pmu(enum arm_pmu_type type);
56 57 58 59 60 61 62 63 64

/**
 * init_pmu() - Initialise the PMU.
 *
 * Initialise the system ready for PMU enabling. This should typically set the
 * IRQ affinity and nothing else. The users (oprofile/perf events etc) will do
 * the actual hardware initialisation.
 */
extern int
65
init_pmu(enum arm_pmu_type device);
66 67 68

#else /* CONFIG_CPU_HAS_PMU */

69 70 71 72
#include <linux/err.h>

static inline struct platform_device *
reserve_pmu(enum arm_pmu_type device)
73 74 75 76 77
{
	return ERR_PTR(-ENODEV);
}

static inline int
78
release_pmu(enum arm_pmu_type device)
79 80 81 82 83
{
	return -ENODEV;
}

static inline int
84
init_pmu(enum arm_pmu_type device)
85 86 87 88 89 90 91
{
	return -ENODEV;
}

#endif /* CONFIG_CPU_HAS_PMU */

#endif /* __ARM_PMU_H__ */