Russell King | 2d9e1ae | 2006-12-19 12:41:22 +0000 | [diff] [blame] | 1 | /** |
| 2 | * @file op_model_v6.c |
| 3 | * ARM11 Performance Monitor Driver |
| 4 | * |
| 5 | * Based on op_model_xscale.c |
| 6 | * |
| 7 | * @remark Copyright 2000-2004 Deepak Saxena <dsaxena@mvista.com> |
| 8 | * @remark Copyright 2000-2004 MontaVista Software Inc |
| 9 | * @remark Copyright 2004 Dave Jiang <dave.jiang@intel.com> |
| 10 | * @remark Copyright 2004 Intel Corporation |
| 11 | * @remark Copyright 2004 Zwane Mwaikambo <zwane@arm.linux.org.uk> |
| 12 | * @remark Copyright 2004 OProfile Authors |
| 13 | * |
| 14 | * @remark Read the file COPYING |
| 15 | * |
| 16 | * @author Tony Lindgren <tony@atomide.com> |
| 17 | */ |
| 18 | |
| 19 | /* #define DEBUG */ |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/errno.h> |
Jamie Iles | 1618fdd | 2010-02-02 20:24:07 +0100 | [diff] [blame] | 22 | #include <linux/err.h> |
Russell King | 2d9e1ae | 2006-12-19 12:41:22 +0000 | [diff] [blame] | 23 | #include <linux/sched.h> |
| 24 | #include <linux/oprofile.h> |
| 25 | #include <linux/interrupt.h> |
| 26 | #include <asm/irq.h> |
| 27 | #include <asm/system.h> |
Jamie Iles | 1618fdd | 2010-02-02 20:24:07 +0100 | [diff] [blame] | 28 | #include <asm/pmu.h> |
Russell King | 2d9e1ae | 2006-12-19 12:41:22 +0000 | [diff] [blame] | 29 | |
| 30 | #include "op_counter.h" |
| 31 | #include "op_arm_model.h" |
| 32 | #include "op_model_arm11_core.h" |
| 33 | |
Jamie Iles | 1618fdd | 2010-02-02 20:24:07 +0100 | [diff] [blame] | 34 | static const struct pmu_irqs *pmu_irqs; |
Russell King | 2d9e1ae | 2006-12-19 12:41:22 +0000 | [diff] [blame] | 35 | |
| 36 | static void armv6_pmu_stop(void) |
| 37 | { |
| 38 | arm11_stop_pmu(); |
Jamie Iles | 1618fdd | 2010-02-02 20:24:07 +0100 | [diff] [blame] | 39 | arm11_release_interrupts(pmu_irqs->irqs, pmu_irqs->num_irqs); |
| 40 | release_pmu(pmu_irqs); |
| 41 | pmu_irqs = NULL; |
Russell King | 2d9e1ae | 2006-12-19 12:41:22 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static int armv6_pmu_start(void) |
| 45 | { |
| 46 | int ret; |
| 47 | |
Jamie Iles | 1618fdd | 2010-02-02 20:24:07 +0100 | [diff] [blame] | 48 | pmu_irqs = reserve_pmu(); |
| 49 | if (IS_ERR(pmu_irqs)) { |
| 50 | ret = PTR_ERR(pmu_irqs); |
| 51 | goto out; |
| 52 | } |
Russell King | 2d9e1ae | 2006-12-19 12:41:22 +0000 | [diff] [blame] | 53 | |
Jamie Iles | 1618fdd | 2010-02-02 20:24:07 +0100 | [diff] [blame] | 54 | ret = arm11_request_interrupts(pmu_irqs->irqs, pmu_irqs->num_irqs); |
| 55 | if (ret >= 0) { |
| 56 | ret = arm11_start_pmu(); |
| 57 | } else { |
| 58 | release_pmu(pmu_irqs); |
| 59 | pmu_irqs = NULL; |
| 60 | } |
| 61 | |
| 62 | out: |
Russell King | 2d9e1ae | 2006-12-19 12:41:22 +0000 | [diff] [blame] | 63 | return ret; |
| 64 | } |
| 65 | |
| 66 | static int armv6_detect_pmu(void) |
| 67 | { |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | struct op_arm_model_spec op_armv6_spec = { |
| 72 | .init = armv6_detect_pmu, |
| 73 | .num_counters = 3, |
| 74 | .setup_ctrs = arm11_setup_pmu, |
| 75 | .start = armv6_pmu_start, |
| 76 | .stop = armv6_pmu_stop, |
| 77 | .name = "arm/armv6", |
| 78 | }; |