Commit 657b1437 authored by Dave Jones's avatar Dave Jones Committed by Dave Jones

[CPUFREQ] Move cpufreq_get() from the userspace governor to the core.

Contrary to the previous implementation, it now calls the cpufreq driver,
and reads out the _actual_ current frequency, and not the frequency the
CPUfreq core _thinks_ the CPU is running at. Most cpufreq drivers do provide
such a "hw get" function (only ACPI-io can definitely not be supported,
I'm not sure about sh, sparc64 and powermac) anyway, and it is useful for
other issues.
parent f962f4e7
...@@ -478,6 +478,38 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) ...@@ -478,6 +478,38 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
return 0; return 0;
} }
/**
* cpufreq_get - get the current CPU frequency (in kHz)
* @cpu: CPU number
*
* Get the CPU current (static) CPU frequency
*/
unsigned int cpufreq_get(unsigned int cpu)
{
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
unsigned int ret = 0;
if (!policy)
return 0;
if (!cpufreq_driver->get)
goto out;
down(&policy->lock);
ret = cpufreq_driver->get(cpu);
up(&policy->lock);
out:
cpufreq_cpu_put(policy);
return (ret);
}
EXPORT_SYMBOL(cpufreq_get);
/** /**
* cpufreq_resume - restore the CPU clock frequency after resume * cpufreq_resume - restore the CPU clock frequency after resume
* *
......
...@@ -145,19 +145,6 @@ int cpufreq_setmax(unsigned int cpu) ...@@ -145,19 +145,6 @@ int cpufreq_setmax(unsigned int cpu)
EXPORT_SYMBOL_GPL(cpufreq_setmax); EXPORT_SYMBOL_GPL(cpufreq_setmax);
/**
* cpufreq_get - get the current CPU frequency (in kHz)
* @cpu: CPU number
*
* Get the CPU current (static) CPU frequency
*/
unsigned int cpufreq_get(unsigned int cpu)
{
return cpu_cur_freq[cpu];
}
EXPORT_SYMBOL(cpufreq_get);
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
...@@ -542,20 +529,6 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, ...@@ -542,20 +529,6 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
return 0; return 0;
} }
/* on ARM SA1100 we need to rely on the values of cpufreq_get() - because
* of this, cpu_cur_freq[] needs to be set early.
*/
#if defined(CONFIG_ARM) && defined(CONFIG_ARCH_SA1100)
extern unsigned int sa11x0_getspeed(void);
static void cpufreq_sa11x0_compat(void)
{
cpu_cur_freq[0] = sa11x0_getspeed();
}
#else
#define cpufreq_sa11x0_compat() do {} while(0)
#endif
struct cpufreq_governor cpufreq_gov_userspace = { struct cpufreq_governor cpufreq_gov_userspace = {
.name = "userspace", .name = "userspace",
...@@ -564,21 +537,12 @@ struct cpufreq_governor cpufreq_gov_userspace = { ...@@ -564,21 +537,12 @@ struct cpufreq_governor cpufreq_gov_userspace = {
}; };
EXPORT_SYMBOL(cpufreq_gov_userspace); EXPORT_SYMBOL(cpufreq_gov_userspace);
static int already_init = 0; static int __init cpufreq_gov_userspace_init(void)
int cpufreq_gov_userspace_init(void)
{ {
if (!already_init) { cpufreq_sysctl_init();
down(&userspace_sem); cpufreq_register_notifier(&userspace_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
cpufreq_sa11x0_compat();
cpufreq_sysctl_init();
cpufreq_register_notifier(&userspace_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
already_init = 1;
up(&userspace_sem);
}
return cpufreq_register_governor(&cpufreq_gov_userspace); return cpufreq_register_governor(&cpufreq_gov_userspace);
} }
EXPORT_SYMBOL(cpufreq_gov_userspace_init);
static void __exit cpufreq_gov_userspace_exit(void) static void __exit cpufreq_gov_userspace_exit(void)
......
...@@ -187,6 +187,9 @@ struct cpufreq_driver { ...@@ -187,6 +187,9 @@ struct cpufreq_driver {
unsigned int target_freq, unsigned int target_freq,
unsigned int relation); unsigned int relation);
/* should be defined, if possible */
unsigned int (*get) (unsigned int cpu);
/* optional */ /* optional */
int (*exit) (struct cpufreq_policy *policy); int (*exit) (struct cpufreq_policy *policy);
int (*resume) (struct cpufreq_policy *policy); int (*resume) (struct cpufreq_policy *policy);
...@@ -234,6 +237,9 @@ int cpufreq_set_policy(struct cpufreq_policy *policy); ...@@ -234,6 +237,9 @@ int cpufreq_set_policy(struct cpufreq_policy *policy);
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
int cpufreq_update_policy(unsigned int cpu); int cpufreq_update_policy(unsigned int cpu);
/* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */
unsigned int cpufreq_get(unsigned int cpu);
/* the proc_intf.c needs this */ /* the proc_intf.c needs this */
int cpufreq_parse_governor (char *str_governor, unsigned int *policy, struct cpufreq_governor **governor); int cpufreq_parse_governor (char *str_governor, unsigned int *policy, struct cpufreq_governor **governor);
...@@ -241,13 +247,10 @@ int cpufreq_parse_governor (char *str_governor, unsigned int *policy, struct cpu ...@@ -241,13 +247,10 @@ int cpufreq_parse_governor (char *str_governor, unsigned int *policy, struct cpu
/********************************************************************* /*********************************************************************
* CPUFREQ USERSPACE GOVERNOR * * CPUFREQ USERSPACE GOVERNOR *
*********************************************************************/ *********************************************************************/
int cpufreq_gov_userspace_init(void);
#ifdef CONFIG_CPU_FREQ_24_API #ifdef CONFIG_CPU_FREQ_24_API
int cpufreq_setmax(unsigned int cpu); int cpufreq_setmax(unsigned int cpu);
int cpufreq_set(unsigned int kHz, unsigned int cpu); int cpufreq_set(unsigned int kHz, unsigned int cpu);
unsigned int cpufreq_get(unsigned int cpu);
/* /proc/sys/cpu */ /* /proc/sys/cpu */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment