blob: 57378c7ac2dde5d94ae9a9410267037c7ca135e5 [file] [log] [blame]
Ashwin Chaugule50d59892013-03-12 12:58:51 -04001/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/platform_device.h>
14#include <asm/pmu.h>
15#include <mach/irqs.h>
Ashwin Chaugule39242ba2012-10-29 16:30:05 -040016#include <mach/socinfo.h>
17
Chintan Pandya9a429932012-02-13 19:14:16 +053018static struct resource cpu_pmu_resource[] = {
19 {
20 .start = INT_ARMQC_PERFMON,
21 .end = INT_ARMQC_PERFMON,
22 .flags = IORESOURCE_IRQ,
23 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024};
25
26#ifdef CONFIG_CPU_HAS_L2_PMU
Chintan Pandya9a429932012-02-13 19:14:16 +053027static struct resource l2_pmu_resource[] = {
28 {
29 .start = SC_SICL2PERFMONIRPTREQ,
30 .end = SC_SICL2PERFMONIRPTREQ,
31 .flags = IORESOURCE_IRQ,
32 },
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070033};
34
35static struct platform_device l2_pmu_device = {
Ashwin Chaugule50d59892013-03-12 12:58:51 -040036 .name = "l2-pmu",
Ashwin Chaugule4a81cb82012-06-07 13:40:54 -040037 .id = ARM_PMU_DEVICE_L2CC,
Chintan Pandya9a429932012-02-13 19:14:16 +053038 .resource = l2_pmu_resource,
39 .num_resources = ARRAY_SIZE(l2_pmu_resource),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070040};
41
42#endif
43
44static struct platform_device cpu_pmu_device = {
Ashwin Chaugule50d59892013-03-12 12:58:51 -040045 .name = "cpu-pmu",
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070046 .id = ARM_PMU_DEVICE_CPU,
Chintan Pandya9a429932012-02-13 19:14:16 +053047 .resource = cpu_pmu_resource,
48 .num_resources = ARRAY_SIZE(cpu_pmu_resource),
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070049};
50
Ashwin Chauguled82ed3a2012-11-05 10:35:30 -050051/*
52 * The 8625 is a special case. Due to the requirement of a single
53 * kernel image for the 7x27a and 8625 (which share IRQ headers),
54 * this target breaks the uniformity of IRQ names.
55 * See the file - arch/arm/mach-msm/include/mach/irqs-8625.h
56 */
57#ifdef CONFIG_ARCH_MSM8625
58static struct resource msm8625_cpu_pmu_resource[] = {
59 {
60 .start = MSM8625_INT_ARMQC_PERFMON,
61 .end = MSM8625_INT_ARMQC_PERFMON,
62 .flags = IORESOURCE_IRQ,
63 },
64};
65
66static struct platform_device msm8625_cpu_pmu_device = {
Ashwin Chaugule50d59892013-03-12 12:58:51 -040067 .name = "cpu-pmu",
Ashwin Chauguled82ed3a2012-11-05 10:35:30 -050068 .id = ARM_PMU_DEVICE_CPU,
69 .resource = msm8625_cpu_pmu_resource,
70 .num_resources = ARRAY_SIZE(msm8625_cpu_pmu_resource),
71};
Ashwin Chaugule3deb6b82012-12-21 13:09:48 -050072
73static struct resource msm8625_l2_pmu_resource[] = {
74 {
75 .start = MSM8625_INT_SC_SICL2PERFMONIRPTREQ,
76 .end = MSM8625_INT_SC_SICL2PERFMONIRPTREQ,
77 .flags = IORESOURCE_IRQ,
78 },
79};
80
81static struct platform_device msm8625_l2_pmu_device = {
Ashwin Chaugule50d59892013-03-12 12:58:51 -040082 .name = "l2-pmu",
Ashwin Chaugule3deb6b82012-12-21 13:09:48 -050083 .id = ARM_PMU_DEVICE_L2CC,
84 .resource = msm8625_l2_pmu_resource,
85 .num_resources = ARRAY_SIZE(msm8625_l2_pmu_resource),
86};
Ashwin Chauguled82ed3a2012-11-05 10:35:30 -050087#endif
Ashwin Chaugule39242ba2012-10-29 16:30:05 -040088
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070089static struct platform_device *pmu_devices[] = {
90 &cpu_pmu_device,
91#ifdef CONFIG_CPU_HAS_L2_PMU
92 &l2_pmu_device,
93#endif
94};
95
96static int __init msm_pmu_init(void)
97{
Ashwin Chaugule39242ba2012-10-29 16:30:05 -040098 /*
99 * For the targets we know are multicore's set the request/free IRQ
100 * handlers to call the percpu API.
101 * Defaults to unicore API {request,free}_irq().
102 * See arch/arm/kernel/perf_event.c
103 */
Ashwin Chaugulef213bb92012-11-17 11:32:48 -0500104#if defined(CONFIG_ARCH_MSM_KRAITMP) || defined(CONFIG_ARCH_MSM_SCORPIONMP) \
105 || (defined(CONFIG_ARCH_MSM_CORTEX_A5) && !defined(CONFIG_MSM_VIC))
Ashwin Chaugule39242ba2012-10-29 16:30:05 -0400106 cpu_pmu_device.dev.platform_data = &multicore_data;
107#endif
108
Ashwin Chauguled82ed3a2012-11-05 10:35:30 -0500109 /*
110 * The 7x27a and 8625 require a single kernel image.
111 * So we need to check if we're on an 8625 at runtime
112 * and point to the appropriate 'struct resource'.
113 */
114#ifdef CONFIG_ARCH_MSM8625
Gautam Akiwate83e7baa2012-12-18 16:55:02 +0530115 if (cpu_is_msm8625() || cpu_is_msm8625q()) {
Ashwin Chauguled82ed3a2012-11-05 10:35:30 -0500116 pmu_devices[0] = &msm8625_cpu_pmu_device;
Ashwin Chaugule3deb6b82012-12-21 13:09:48 -0500117 pmu_devices[1] = &msm8625_l2_pmu_device;
Ashwin Chauguled82ed3a2012-11-05 10:35:30 -0500118 msm8625_cpu_pmu_device.dev.platform_data = &multicore_data;
119 }
120#endif
121
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700122 return platform_add_devices(pmu_devices, ARRAY_SIZE(pmu_devices));
123}
124
125arch_initcall(msm_pmu_init);