Пример #1
0
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;
}
Пример #2
0
/*
 * Free PMU resources and unhook the PMU ISR
 */
void free_pmu(void)
{
#ifdef PX_CPU_PJ1
	return;
#else
#ifdef PRM_SUPPORT
	if (prm_client_id != -1)
	{
		prm_free_resources(prm_client_id, 0);
		prm_close_session(prm_client_id);
		prm_client_id = -1;
		return;
	}
#else
//	free_irq(g_pmu_irq_num/*IRQ_PMU*/, dev_id);

#endif
#endif // PX_CPU_PJ1
}