28 #include <asm/processor.h>
29 #include <asm/cputable.h>
33 static unsigned char oprofile_running;
42 static inline u64 ctr_read(
unsigned int i)
46 return mfspr(SPRN_PA6T_PMC0);
48 return mfspr(SPRN_PA6T_PMC1);
50 return mfspr(SPRN_PA6T_PMC2);
52 return mfspr(SPRN_PA6T_PMC3);
54 return mfspr(SPRN_PA6T_PMC4);
56 return mfspr(SPRN_PA6T_PMC5);
63 static inline void ctr_write(
unsigned int i,
u64 val)
67 mtspr(SPRN_PA6T_PMC0, val);
70 mtspr(SPRN_PA6T_PMC1, val);
73 mtspr(SPRN_PA6T_PMC2, val);
76 mtspr(SPRN_PA6T_PMC3, val);
79 mtspr(SPRN_PA6T_PMC4, val);
82 mtspr(SPRN_PA6T_PMC5, val);
107 sys->mmcr0 &= ~(0x1
UL << pmc);
108 sys->mmcr0 &= ~(0x1
UL << (pmc+12));
109 pr_debug(
"turned off counter %u\n", pmc);
113 sys->mmcr0 |= PA6T_MMCR0_SUPEN | PA6T_MMCR0_HYPEN;
115 sys->mmcr0 &= ~(PA6T_MMCR0_SUPEN | PA6T_MMCR0_HYPEN);
118 sys->mmcr0 |= PA6T_MMCR0_PREN;
120 sys->mmcr0 &= ~PA6T_MMCR0_PREN;
127 mmcr0_val = sys->mmcr0;
128 mmcr1_val = sys->mmcr1;
129 pr_debug(
"mmcr0_val inited to %016lx\n", sys->mmcr0);
130 pr_debug(
"mmcr1_val inited to %016lx\n", sys->mmcr1);
134 reset_value[pmc] = (0x1
UL << 39) - ctr[pmc].
count;
135 pr_debug(
"reset_value for pmc%u inited to 0x%llx\n",
136 pmc, reset_value[pmc]);
145 u64 mmcr0 = mmcr0_val;
146 u64 mmcr1 = mmcr1_val;
150 mtspr(SPRN_PA6T_MMCR0, mmcr0);
153 mtspr(SPRN_PA6T_MMCR1, mmcr1);
156 mfspr(SPRN_PA6T_MMCR0));
158 mfspr(SPRN_PA6T_MMCR1));
168 u64 mmcr0 = mmcr0_val | PA6T_MMCR0_HANDDIS;
172 ctr_write(i, reset_value[i]);
176 mtspr(SPRN_PA6T_MMCR0, mmcr0);
178 oprofile_running = 1;
185 static void pa6t_stop(
void)
190 mmcr0 =
mfspr(SPRN_PA6T_MMCR0);
191 mmcr0 |= PA6T_MMCR0_FCM0;
192 mtspr(SPRN_PA6T_MMCR0, mmcr0);
194 oprofile_running = 0;
200 static void pa6t_handle_interrupt(
struct pt_regs *
regs,
203 unsigned long pc =
mfspr(SPRN_PA6T_SIAR);
210 mmcr0 =
mfspr(SPRN_PA6T_MMCR0);
211 mtspr(SPRN_PA6T_MMCR0, mmcr0 | PA6T_MMCR0_HANDDIS);
218 if (val & (0x1UL << 39)) {
219 if (oprofile_running && ctr[i].enabled) {
220 if (mmcr0 & PA6T_MMCR0_SIARLOG)
222 ctr_write(i, reset_value[i]);
230 mmcr0 = mmcr0_val | PA6T_MMCR0_HANDDIS;
231 mtspr(SPRN_PA6T_MMCR0, mmcr0);
235 .reg_setup = pa6t_reg_setup,
236 .cpu_setup = pa6t_cpu_setup,
239 .handle_interrupt = pa6t_handle_interrupt,