21 #include <asm/ptrace.h>
22 #include <asm/processor.h>
23 #include <asm/cputable.h>
30 static int oprofile_running;
31 static u32 mmcr0_val, mmcr1_val, mmcr2_val, num_pmcs;
33 #define MMCR0_PMC1_SHIFT 6
34 #define MMCR0_PMC2_SHIFT 0
35 #define MMCR1_PMC3_SHIFT 27
36 #define MMCR1_PMC4_SHIFT 22
37 #define MMCR1_PMC5_SHIFT 17
38 #define MMCR1_PMC6_SHIFT 11
40 #define mmcr0_event1(event) \
41 ((event << MMCR0_PMC1_SHIFT) & MMCR0_PMC1SEL)
42 #define mmcr0_event2(event) \
43 ((event << MMCR0_PMC2_SHIFT) & MMCR0_PMC2SEL)
45 #define mmcr1_event3(event) \
46 ((event << MMCR1_PMC3_SHIFT) & MMCR1_PMC3SEL)
47 #define mmcr1_event4(event) \
48 ((event << MMCR1_PMC4_SHIFT) & MMCR1_PMC4SEL)
49 #define mmcr1_event5(event) \
50 ((event << MMCR1_PMC5_SHIFT) & MMCR1_PMC5SEL)
51 #define mmcr1_event6(event) \
52 ((event << MMCR1_PMC6_SHIFT) & MMCR1_PMC6SEL)
54 #define MMCR0_INIT (MMCR0_FC | MMCR0_FCS | MMCR0_FCP | MMCR0_FCM1 | MMCR0_FCM0)
60 static void pmc_start_ctrs(
void)
64 mmcr0 &= ~(MMCR0_FC | MMCR0_FCM0);
65 mmcr0 |= (MMCR0_FCECE | MMCR0_PMC1CE | MMCR0_PMCnCE | MMCR0_PMXE);
67 mtspr(SPRN_MMCR0, mmcr0);
71 static void pmc_stop_ctrs(
void)
76 mmcr0 &= ~(MMCR0_FCECE | MMCR0_PMC1CE | MMCR0_PMCnCE | MMCR0_PMXE);
78 mtspr(SPRN_MMCR0, mmcr0);
88 mtspr(SPRN_MMCR0, mmcr0_val);
89 mtspr(SPRN_MMCR1, mmcr1_val);
91 mtspr(SPRN_MMCR2, mmcr2_val);
109 for (i = 0; i < num_ctrs; ++
i)
110 reset_value[i] = 0x80000000UL - ctr[i].
count;
118 mmcr0_val &= ~(MMCR0_FCS);
121 mmcr0_val &= ~(MMCR0_FCP);
140 mtmsr(mfmsr() | MSR_PMM);
142 for (i = 0; i < num_pmcs; ++
i) {
144 classic_ctr_write(i, reset_value[i]);
146 classic_ctr_write(i, 0);
154 oprofile_running = 1;
160 static void fsl7450_stop(
void)
165 oprofile_running = 0;
173 static void fsl7450_handle_interrupt(
struct pt_regs *
regs,
182 mtmsr(mfmsr() | MSR_PMM);
184 pc =
mfspr(SPRN_SIAR);
187 for (i = 0; i < num_pmcs; ++
i) {
188 val = classic_ctr_read(i);
190 if (oprofile_running && ctr[i].
enabled) {
192 classic_ctr_write(i, reset_value[i]);
194 classic_ctr_write(i, 0);
207 .reg_setup = fsl7450_reg_setup,
208 .cpu_setup = fsl7450_cpu_setup,
209 .start = fsl7450_start,
210 .stop = fsl7450_stop,
211 .handle_interrupt = fsl7450_handle_interrupt,