12 #include <linux/kernel.h>
16 #include <linux/slab.h>
21 #include <mach/cpufreq.h>
30 static unsigned int locking_frequency;
31 static bool frequency_locked;
46 unsigned int target_freq,
47 unsigned int relation)
49 unsigned int index, old_index;
50 unsigned int arm_volt, safe_arm_volt = 0;
53 unsigned int *volt_table = exynos_info->
volt_table;
58 freqs.old = policy->
cur;
60 if (frequency_locked && target_freq != locking_frequency) {
73 if (freq_table[old_index].
frequency == freqs.old)
82 target_freq, relation, &index)) {
88 freqs.cpu = policy->
cpu;
98 (freq_table[old_index].
frequency < mpll_freq_khz))
101 arm_volt = volt_table[
index];
106 if ((freqs.new > freqs.old) && !safe_arm_volt) {
115 if (freqs.new != freqs.old)
116 exynos_info->
set_freq(old_index, index);
121 if ((freqs.new < freqs.old) ||
122 ((freqs.new > freqs.old) && safe_arm_volt)) {
161 static int exynos_cpufreq_pm_notifier(
struct notifier_block *notifier,
162 unsigned long pm_event,
void *
v)
165 static unsigned int saved_frequency;
171 if (frequency_locked)
174 frequency_locked =
true;
176 if (locking_frequency) {
180 exynos_target(policy, locking_frequency,
187 if (saved_frequency) {
194 temp = locking_frequency;
195 locking_frequency = saved_frequency;
198 exynos_target(policy, locking_frequency,
202 locking_frequency =
temp;
204 frequency_locked =
false;
214 .notifier_call = exynos_cpufreq_pm_notifier,
226 policy->
cpuinfo.transition_latency = 100000;
236 cpumask_copy(policy->
cpus, cpu_online_mask);
238 cpumask_setall(policy->
cpus);
247 .target = exynos_target,
249 .init = exynos_cpufreq_cpu_init,
250 .name =
"exynos_cpufreq",
252 .suspend = exynos_cpufreq_suspend,
253 .resume = exynos_cpufreq_resume,
257 static int __init exynos_cpufreq_init(
void)
272 pr_err(
"%s: CPU type not found\n", __func__);
278 pr_err(
"%s: No set_freq function (ERR)\n", __func__);
283 if (IS_ERR(arm_regulator)) {
284 pr_err(
"%s: failed to get resource vdd_arm\n", __func__);
288 register_pm_notifier(&exynos_cpufreq_nb);
291 pr_err(
"%s: failed to register cpufreq driver\n", __func__);
297 unregister_pm_notifier(&exynos_cpufreq_nb);
299 if (!IS_ERR(arm_regulator))
303 pr_debug(
"%s: failed initialization\n", __func__);