2 * linux/arch/arm/kernel/pmu.c
4 * Copyright (C) 2009 picoChip Designs Ltd, Jamie Iles
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.
12 #include <linux/cpumask.h>
13 #include <linux/err.h>
14 #include <linux/interrupt.h>
15 #include <linux/kernel.h>
16 #include <linux/module.h>
21 * Define the IRQs for the system. We could use something like a platform
22 * device but that seems fairly heavyweight for this. Also, the performance
23 * counters can't be removed or hotplugged.
25 * Ordering is important: init_pmu() will use the ordering to set the affinity
26 * to the corresponding core. e.g. the first interrupt will go to cpu 0, the
27 * second goes to cpu 1 etc.
29 static const int irqs[] = {
30 #if defined(CONFIG_ARCH_OMAP2)
32 #elif defined(CONFIG_ARCH_BCMRING)
34 #elif defined(CONFIG_MACH_REALVIEW_EB)
39 #elif defined(CONFIG_ARCH_OMAP3)
40 INT_34XX_BENCH_MPU_EMUL,
41 #elif defined(CONFIG_ARCH_IOP32X)
43 #elif defined(CONFIG_ARCH_IOP33X)
45 #elif defined(CONFIG_ARCH_PXA)
50 static const struct pmu_irqs pmu_irqs = {
52 .num_irqs = ARRAY_SIZE(irqs),
55 static volatile long pmu_lock;
57 const struct pmu_irqs *
60 return test_and_set_bit_lock(0, &pmu_lock) ? ERR_PTR(-EBUSY) :
63 EXPORT_SYMBOL_GPL(reserve_pmu);
66 release_pmu(const struct pmu_irqs *irqs)
68 if (WARN_ON(irqs != &pmu_irqs))
70 clear_bit_unlock(0, &pmu_lock);
73 EXPORT_SYMBOL_GPL(release_pmu);
76 set_irq_affinity(int irq,
80 int err = irq_set_affinity(irq, cpumask_of(cpu));
82 pr_warning("unable to set irq affinity (irq=%d, cpu=%u)\n",
95 for (i = 0; i < pmu_irqs.num_irqs; ++i) {
96 err = set_irq_affinity(pmu_irqs.irqs[i], i);
103 EXPORT_SYMBOL_GPL(init_pmu);