* @remark Copyright 2004 Dave Jiang <dave.jiang@intel.com>
* @remark Copyright 2004 Intel Corporation
* @remark Copyright 2004 Zwane Mwaikambo <zwane@arm.linux.org.uk>
- * @remark Copyright 2004 Oprofile Authors
+ * @remark Copyright 2004 OProfile Authors
*
* @remark Read the file COPYING
*
#define PMN_RESET 0x002 /* Reset event counters */
#define CCNT_RESET 0x004 /* Reset clock counter */
#define PMU_RESET (CCNT_RESET | PMN_RESET)
+#define PMU_CNT64 0x008 /* Make CCNT count every 64th cycle */
/* TODO do runtime detection */
#ifdef CONFIG_ARCH_IOP310
static void write_pmnc(u32 val)
{
- /* upper 4bits and 7, 11 are write-as-0 */
- val &= 0xffff77f;
- if (pmu->id == PMU_XSC1)
+ if (pmu->id == PMU_XSC1) {
+ /* upper 4bits and 7, 11 are write-as-0 */
+ val &= 0xffff77f;
__asm__ __volatile__ ("mcr p14, 0, %0, c0, c0, 0" : : "r" (val));
- else
+ } else {
+ /* bits 4-23 are write-as-0, 24-31 are write ignored */
+ val &= 0xf;
__asm__ __volatile__ ("mcr p14, 0, %0, c0, c1, 0" : : "r" (val));
+ }
}
static u32 read_pmnc(void)
if (pmu->id == PMU_XSC1)
__asm__ __volatile__ ("mrc p14, 0, %0, c0, c0, 0" : "=r" (val));
- else
+ else {
__asm__ __volatile__ ("mrc p14, 0, %0, c0, c1, 0" : "=r" (val));
+ /* bits 1-2 and 4-23 are read-unpredictable */
+ val &= 0xff000009;
+ }
return val;
}
int i;
for (i = CCNT; i < MAX_COUNTERS; i++) {
- if (counter_config[i].event)
+ if (counter_config[i].enabled)
continue;
counter_config[i].event = EVT_UNUSED;
static irqreturn_t xscale_pmu_interrupt(int irq, void *arg, struct pt_regs *regs)
{
- unsigned long eip = instruction_pointer(regs);
+ unsigned long pc = profile_pc(regs);
int i, is_kernel = !user_mode(regs);
u32 pmnc;
continue;
write_counter(i, -(u32)results[i].reset_counter);
- oprofile_add_sample(eip, is_kernel, i, smp_processor_id());
+ oprofile_add_sample(pc, is_kernel, i, smp_processor_id());
results[i].ovf--;
}
if (pmu->id == PMU_XSC1)
pmnc |= pmu->int_enable;
- else
+ else {
__asm__ __volatile__ ("mcr p14, 0, %0, c4, c1, 0" : : "r" (pmu->int_enable));
+ pmnc &= ~PMU_CNT64;
+ }
pmnc |= PMU_ENABLE;
write_pmnc(pmnc);