static int get_cpu_freq(unsigned int *cpu_freq) { unsigned long freq = 0; #ifdef CONFIG_CPU_FREQ freq = cpufreq_quick_get(0); #else // CONFIG_CPU_FREQ //#if defined(PRM_SUPPORT) && !defined(PJ1) #if defined(PRM_SUPPORT) int client_id; char* client_name = "frequency queryer"; unsigned int cop; #if defined(LINUX_VERSION_CODE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 21)) struct pxa3xx_fv_info fv_info; #else struct mhn_fv_info fv_info; #endif /* open a PRM session to query current core frequency */ client_id = prm_open_session(PRI_LOWEST, client_name, NULL, NULL); if (client_id < 0) { printk (KERN_ALERT "[CPA] *STATUS* open prm session failed!\n"); return -1; } if (cop_get_cur_cop(client_id, &cop, &fv_info)) { printk(KERN_ERR "[CPA] Can't get core clock frequency\n"); return -1; } // check if in ring 0 mode, frequency is always 60MHz when in ring 0 mode // BSP releases older than alpha4 don't support ring 0 mode if (fv_info.d0cs) freq = 60 * 1000; else freq = fv_info.xl * fv_info.xn * 13000; prm_close_session(client_id); #else freq = 0; #endif #endif // CONFIG_CPU_FREQ if (copy_to_user(cpu_freq, &freq, sizeof(unsigned long)) != 0) { return -EFAULT; } return 0; }
/* * Allocate PMU resources and hook the PMU ISR */ int allocate_pmu(void) { #ifdef PX_CPU_PJ1 return 0; #else #ifdef PRM_SUPPORT int ret; int i; ret = prm_open_session(PRI_VTUNE, prm_client_name, NULL, NULL); if (ret < 0) { printk(KERN_ERR "failed to open prm open session\n"); return ret; } prm_client_id = ret; for (i=0; i<PRM_ALLOC_RES_COUNT; i++) { ret = prm_allocate_resource(prm_client_id, prm_resource[i], 0); if (ret != 0) { printk(KERN_ERR "failed to allocate prm resource %d\n", prm_resource[i]); printk(KERN_ERR "ret = %d\n", ret); goto alloc_pmu_err; } } /* if ((ret = pmu_register_isr(prm_client_id, cm_pmu_isr, 0)) != 0) { printk(KERN_ERR "failed to register ISR\n"); goto alloc_pmu_err; } */ if ((ret = prm_commit_resources(prm_client_id, 0)) != 0) { printk(KERN_ERR "failed to commit prm resource\n"); goto alloc_pmu_err; } return 0; alloc_pmu_err: free_pmu(); return ret; #else // PRM_SUPPORT #if 0 if ((ret = request_irq(g_pmu_irq_num/*IRQ_PMU*/, cm_pmu_isr, #if defined(LINUX_VERSION_CODE) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 21)) IRQF_DISABLED #else SA_INTERRUPT #endif , "CPA PMU", dev_id)) != 0) { printk(KERN_ERR "request_irq fails: ret = %d", ret); return -EACCES; } #endif return 0; #endif // PRM_SUPPORT #endif // PX_CPU_PJ1 }