10 #include <linux/kernel.h>
14 #include <linux/perf_event.h>
15 #include <asm/processor.h>
17 #define PM_CR_BASE 0xff000084
18 #define PM_CTR_BASE 0xff100004
20 #define PMCR(n) (PM_CR_BASE + ((n) * 0x04))
21 #define PMCTRH(n) (PM_CTR_BASE + 0x00 + ((n) * 0x08))
22 #define PMCTRL(n) (PM_CTR_BASE + 0x04 + ((n) * 0x08))
24 #define PMCR_PMM_MASK 0x0000003f
26 #define PMCR_CLKF 0x00000100
27 #define PMCR_PMCLR 0x00002000
28 #define PMCR_PMST 0x00004000
29 #define PMCR_PMEN 0x00008000
31 static struct sh_pmu sh7750_pmu;
77 static const int sh7750_general_events[] = {
87 #define C(x) PERF_COUNT_HW_CACHE_##x
89 static const int sh7750_cache_events
96 [
C(RESULT_ACCESS) ] = 0x0001,
97 [
C(RESULT_MISS) ] = 0x0004,
100 [
C(RESULT_ACCESS) ] = 0x0002,
101 [
C(RESULT_MISS) ] = 0x0005,
103 [
C(OP_PREFETCH) ] = {
104 [
C(RESULT_ACCESS) ] = 0,
105 [
C(RESULT_MISS) ] = 0,
111 [
C(RESULT_ACCESS) ] = 0x0006,
112 [
C(RESULT_MISS) ] = 0x0008,
115 [
C(RESULT_ACCESS) ] = -1,
116 [
C(RESULT_MISS) ] = -1,
118 [
C(OP_PREFETCH) ] = {
119 [
C(RESULT_ACCESS) ] = 0,
120 [
C(RESULT_MISS) ] = 0,
126 [
C(RESULT_ACCESS) ] = 0,
127 [
C(RESULT_MISS) ] = 0,
130 [
C(RESULT_ACCESS) ] = 0,
131 [
C(RESULT_MISS) ] = 0,
133 [
C(OP_PREFETCH) ] = {
134 [
C(RESULT_ACCESS) ] = 0,
135 [
C(RESULT_MISS) ] = 0,
141 [
C(RESULT_ACCESS) ] = 0,
142 [
C(RESULT_MISS) ] = 0x0003,
145 [
C(RESULT_ACCESS) ] = 0,
146 [
C(RESULT_MISS) ] = 0,
148 [
C(OP_PREFETCH) ] = {
149 [
C(RESULT_ACCESS) ] = 0,
150 [
C(RESULT_MISS) ] = 0,
156 [
C(RESULT_ACCESS) ] = 0,
157 [
C(RESULT_MISS) ] = 0x0007,
160 [
C(RESULT_ACCESS) ] = -1,
161 [
C(RESULT_MISS) ] = -1,
163 [
C(OP_PREFETCH) ] = {
164 [
C(RESULT_ACCESS) ] = -1,
165 [
C(RESULT_MISS) ] = -1,
171 [
C(RESULT_ACCESS) ] = -1,
172 [
C(RESULT_MISS) ] = -1,
175 [
C(RESULT_ACCESS) ] = -1,
176 [
C(RESULT_MISS) ] = -1,
178 [
C(OP_PREFETCH) ] = {
179 [
C(RESULT_ACCESS) ] = -1,
180 [
C(RESULT_MISS) ] = -1,
186 [
C(RESULT_ACCESS) ] = -1,
187 [
C(RESULT_MISS) ] = -1,
190 [
C(RESULT_ACCESS) ] = -1,
191 [
C(RESULT_MISS) ] = -1,
193 [
C(OP_PREFETCH) ] = {
194 [
C(RESULT_ACCESS) ] = -1,
195 [
C(RESULT_MISS) ] = -1,
200 static int sh7750_event_map(
int event)
202 return sh7750_general_events[
event];
205 static u64 sh7750_pmu_read(
int idx)
211 static void sh7750_pmu_disable(
struct hw_perf_event *hwc,
int idx)
220 static void sh7750_pmu_enable(
struct hw_perf_event *hwc,
int idx)
226 static void sh7750_pmu_disable_all(
void)
230 for (i = 0; i < sh7750_pmu.num_events; i++)
234 static void sh7750_pmu_enable_all(
void)
238 for (i = 0; i < sh7750_pmu.num_events; i++)
242 static struct sh_pmu sh7750_pmu = {
245 .event_map = sh7750_event_map,
246 .max_events =
ARRAY_SIZE(sh7750_general_events),
248 .cache_events = &sh7750_cache_events,
249 .read = sh7750_pmu_read,
250 .disable = sh7750_pmu_disable,
251 .enable = sh7750_pmu_enable,
252 .disable_all = sh7750_pmu_disable_all,
253 .enable_all = sh7750_pmu_enable_all,
256 static int __init sh7750_pmu_init(
void)
262 pr_notice(
"HW perf events unsupported, software events only.\n");