12 #include <linux/types.h>
13 #include <linux/kernel.h>
19 #include <linux/reboot.h>
24 #include <mach/regs-clock.h>
26 static struct clk *cpu_clk;
27 static struct clk *dmc0_clk;
28 static struct clk *dmc1_clk;
33 #define APLL_VAL_1000 ((1 << 31) | (125 << 16) | (3 << 8) | 1)
34 #define APLL_VAL_800 ((1 << 31) | (100 << 16) | (3 << 8) | 1)
37 #define SLEEP_FREQ (800 * 1000)
49 static bool no_cpufreq_access;
61 static struct dram_conf s5pv210_dram_conf[2];
95 static const int arm_volt_max = 1350000;
96 static const int int_volt_max = 1250000;
121 static u32 clkdiv_val[5][11] = {
130 {0, 4, 4, 1, 3, 1, 4, 1, 3, 0, 0},
133 {0, 3, 3, 1, 3, 1, 4, 1, 3, 0, 0},
136 {1, 3, 1, 1, 3, 1, 4, 1, 3, 0, 0},
139 {3, 3, 1, 1, 3, 1, 4, 1, 3, 0, 0},
142 {7, 7, 0, 0, 7, 0, 9, 0, 7, 0, 0},
158 }
else if (ch ==
DMC1) {
166 tmp = s5pv210_dram_conf[ch].freq;
170 tmp1 = s5pv210_dram_conf[ch].refresh;
185 static unsigned int s5pv210_getspeed(
unsigned int cpu)
194 unsigned int target_freq,
195 unsigned int relation)
198 unsigned int index, priv_index;
199 unsigned int pll_changing = 0;
200 unsigned int bus_speed_changing = 0;
207 no_cpufreq_access =
false;
209 if (no_cpufreq_access) {
210 #ifdef CONFIG_PM_VERBOSE
211 pr_err(
"%s:%d denied access to %s as it is disabled"
212 "temporarily\n", __FILE__, __LINE__, __func__);
219 no_cpufreq_access =
true;
223 freqs.old = s5pv210_getspeed(0);
226 target_freq, relation, &index)) {
234 if (freqs.new == freqs.old)
239 freqs.old, relation, &priv_index)) {
247 if (freqs.new > freqs.old) {
249 arm_volt, arm_volt_max);
254 int_volt, int_volt_max);
262 if ((index ==
L0) || (priv_index ==
L0))
266 if ((index ==
L4) || (priv_index ==
L4))
267 bus_speed_changing = 1;
269 if (bus_speed_changing) {
276 s5pv210_set_refresh(
DMC1, 83000);
278 s5pv210_set_refresh(
DMC1, 100000);
280 s5pv210_set_refresh(
DMC0, 83000);
303 }
while (reg & ((1 << 16) | (1 << 17)));
317 }
while (reg & ((1 << 7) | (1 << 3)));
324 if (!bus_speed_changing)
325 s5pv210_set_refresh(
DMC1, 133000);
335 }
while (reg & (0x1 << 18));
360 }
while (reg & 0xff);
388 }
while (!(reg & (0x1 << 29)));
403 }
while (reg & ((1 << 7) | (1 << 3)));
418 }
while (reg & ((1 << 16) | (1 << 17)));
428 }
while (reg & (0x1 << 18));
435 if (!bus_speed_changing)
436 s5pv210_set_refresh(
DMC1, 200000);
443 if (bus_speed_changing) {
451 }
while (reg & (1 << 15));
459 s5pv210_set_refresh(
DMC0, 166000);
460 s5pv210_set_refresh(
DMC1, 200000);
466 s5pv210_set_refresh(
DMC0, 83000);
467 s5pv210_set_refresh(
DMC1, 100000);
473 if (freqs.new < freqs.old) {
475 int_volt, int_volt_max);
478 arm_volt, arm_volt_max);
500 static int check_mem_type(
void __iomem *dmc_reg)
505 val = (val & (0xf << 8));
517 return PTR_ERR(cpu_clk);
520 if (IS_ERR(dmc0_clk)) {
521 ret = PTR_ERR(dmc0_clk);
526 if (IS_ERR(dmc1_clk)) {
527 ret = PTR_ERR(dmc1_clk);
531 if (policy->
cpu != 0) {
555 policy->
cur = policy->
min = policy->
max = s5pv210_getspeed(0);
559 policy->
cpuinfo.transition_latency = 40000;
570 static int s5pv210_cpufreq_notifier_event(
struct notifier_block *
this,
578 DISABLE_FURTHER_CPUFREQ);
586 ENABLE_FURTHER_CPUFREQ);
594 static int s5pv210_cpufreq_reboot_notifier_event(
struct notifier_block *
this,
595 unsigned long event,
void *ptr)
600 DISABLE_FURTHER_CPUFREQ);
609 .verify = s5pv210_verify_speed,
610 .target = s5pv210_target,
611 .get = s5pv210_getspeed,
612 .init = s5pv210_cpu_init,
615 .suspend = s5pv210_cpufreq_suspend,
616 .resume = s5pv210_cpufreq_resume,
621 .notifier_call = s5pv210_cpufreq_notifier_event,
625 .notifier_call = s5pv210_cpufreq_reboot_notifier_event,
628 static int __init s5pv210_cpufreq_init(
void)
631 if (IS_ERR(arm_regulator)) {
632 pr_err(
"failed to get regulator vddarm");
633 return PTR_ERR(arm_regulator);
637 if (IS_ERR(int_regulator)) {
638 pr_err(
"failed to get regulator vddint");
640 return PTR_ERR(int_regulator);
643 register_pm_notifier(&s5pv210_cpufreq_notifier);