Ashwin Chaugule | 50d5989 | 2013-03-12 12:58:51 -0400 | [diff] [blame] | 1 | /* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 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 Chaugule | 39242ba | 2012-10-29 16:30:05 -0400 | [diff] [blame] | 16 | #include <mach/socinfo.h> |
| 17 | |
Chintan Pandya | 9a42993 | 2012-02-13 19:14:16 +0530 | [diff] [blame] | 18 | static struct resource cpu_pmu_resource[] = { |
| 19 | { |
| 20 | .start = INT_ARMQC_PERFMON, |
| 21 | .end = INT_ARMQC_PERFMON, |
| 22 | .flags = IORESOURCE_IRQ, |
| 23 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | #ifdef CONFIG_CPU_HAS_L2_PMU |
Chintan Pandya | 9a42993 | 2012-02-13 19:14:16 +0530 | [diff] [blame] | 27 | static struct resource l2_pmu_resource[] = { |
| 28 | { |
| 29 | .start = SC_SICL2PERFMONIRPTREQ, |
| 30 | .end = SC_SICL2PERFMONIRPTREQ, |
| 31 | .flags = IORESOURCE_IRQ, |
| 32 | }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | static struct platform_device l2_pmu_device = { |
Ashwin Chaugule | 50d5989 | 2013-03-12 12:58:51 -0400 | [diff] [blame] | 36 | .name = "l2-pmu", |
Ashwin Chaugule | 4a81cb8 | 2012-06-07 13:40:54 -0400 | [diff] [blame] | 37 | .id = ARM_PMU_DEVICE_L2CC, |
Chintan Pandya | 9a42993 | 2012-02-13 19:14:16 +0530 | [diff] [blame] | 38 | .resource = l2_pmu_resource, |
| 39 | .num_resources = ARRAY_SIZE(l2_pmu_resource), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | #endif |
| 43 | |
| 44 | static struct platform_device cpu_pmu_device = { |
Ashwin Chaugule | 50d5989 | 2013-03-12 12:58:51 -0400 | [diff] [blame] | 45 | .name = "cpu-pmu", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 46 | .id = ARM_PMU_DEVICE_CPU, |
Chintan Pandya | 9a42993 | 2012-02-13 19:14:16 +0530 | [diff] [blame] | 47 | .resource = cpu_pmu_resource, |
| 48 | .num_resources = ARRAY_SIZE(cpu_pmu_resource), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Ashwin Chaugule | d82ed3a | 2012-11-05 10:35:30 -0500 | [diff] [blame] | 51 | /* |
| 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 |
| 58 | static 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 | |
| 66 | static struct platform_device msm8625_cpu_pmu_device = { |
Ashwin Chaugule | 50d5989 | 2013-03-12 12:58:51 -0400 | [diff] [blame] | 67 | .name = "cpu-pmu", |
Ashwin Chaugule | d82ed3a | 2012-11-05 10:35:30 -0500 | [diff] [blame] | 68 | .id = ARM_PMU_DEVICE_CPU, |
| 69 | .resource = msm8625_cpu_pmu_resource, |
| 70 | .num_resources = ARRAY_SIZE(msm8625_cpu_pmu_resource), |
| 71 | }; |
Ashwin Chaugule | 3deb6b8 | 2012-12-21 13:09:48 -0500 | [diff] [blame] | 72 | |
| 73 | static 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 | |
| 81 | static struct platform_device msm8625_l2_pmu_device = { |
Ashwin Chaugule | 50d5989 | 2013-03-12 12:58:51 -0400 | [diff] [blame] | 82 | .name = "l2-pmu", |
Ashwin Chaugule | 3deb6b8 | 2012-12-21 13:09:48 -0500 | [diff] [blame] | 83 | .id = ARM_PMU_DEVICE_L2CC, |
| 84 | .resource = msm8625_l2_pmu_resource, |
| 85 | .num_resources = ARRAY_SIZE(msm8625_l2_pmu_resource), |
| 86 | }; |
Ashwin Chaugule | d82ed3a | 2012-11-05 10:35:30 -0500 | [diff] [blame] | 87 | #endif |
Ashwin Chaugule | 39242ba | 2012-10-29 16:30:05 -0400 | [diff] [blame] | 88 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 89 | static struct platform_device *pmu_devices[] = { |
| 90 | &cpu_pmu_device, |
| 91 | #ifdef CONFIG_CPU_HAS_L2_PMU |
| 92 | &l2_pmu_device, |
| 93 | #endif |
| 94 | }; |
| 95 | |
| 96 | static int __init msm_pmu_init(void) |
| 97 | { |
Ashwin Chaugule | 39242ba | 2012-10-29 16:30:05 -0400 | [diff] [blame] | 98 | /* |
| 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 Chaugule | f213bb9 | 2012-11-17 11:32:48 -0500 | [diff] [blame] | 104 | #if defined(CONFIG_ARCH_MSM_KRAITMP) || defined(CONFIG_ARCH_MSM_SCORPIONMP) \ |
| 105 | || (defined(CONFIG_ARCH_MSM_CORTEX_A5) && !defined(CONFIG_MSM_VIC)) |
Ashwin Chaugule | 39242ba | 2012-10-29 16:30:05 -0400 | [diff] [blame] | 106 | cpu_pmu_device.dev.platform_data = &multicore_data; |
| 107 | #endif |
| 108 | |
Ashwin Chaugule | d82ed3a | 2012-11-05 10:35:30 -0500 | [diff] [blame] | 109 | /* |
| 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 Akiwate | 83e7baa | 2012-12-18 16:55:02 +0530 | [diff] [blame] | 115 | if (cpu_is_msm8625() || cpu_is_msm8625q()) { |
Ashwin Chaugule | d82ed3a | 2012-11-05 10:35:30 -0500 | [diff] [blame] | 116 | pmu_devices[0] = &msm8625_cpu_pmu_device; |
Ashwin Chaugule | 3deb6b8 | 2012-12-21 13:09:48 -0500 | [diff] [blame] | 117 | pmu_devices[1] = &msm8625_l2_pmu_device; |
Ashwin Chaugule | d82ed3a | 2012-11-05 10:35:30 -0500 | [diff] [blame] | 118 | msm8625_cpu_pmu_device.dev.platform_data = &multicore_data; |
| 119 | } |
| 120 | #endif |
| 121 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 122 | return platform_add_devices(pmu_devices, ARRAY_SIZE(pmu_devices)); |
| 123 | } |
| 124 | |
| 125 | arch_initcall(msm_pmu_init); |