nfsd: link returns nfserr_delay when breaking lease
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / unicore32 / kernel / cpu-ucv2.c
blob4a99f62584c73ba5079cf9c435fc882848bf9317
1 /*
2 * linux/arch/unicore32/kernel/cpu-ucv2.c: clock scaling for the UniCore-II
4 * Code specific to PKUnity SoC and UniCore ISA
6 * Maintained by GUAN Xue-tao <gxt@mprc.pku.edu.cn>
7 * Copyright (C) 2001-2010 Guan Xuetao
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/init.h>
17 #include <linux/clk.h>
18 #include <linux/cpufreq.h>
20 #include <mach/hardware.h>
22 static struct cpufreq_driver ucv2_driver;
24 /* make sure that only the "userspace" governor is run
25 * -- anything else wouldn't make sense on this platform, anyway.
27 int ucv2_verify_speed(struct cpufreq_policy *policy)
29 if (policy->cpu)
30 return -EINVAL;
32 cpufreq_verify_within_limits(policy,
33 policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
35 return 0;
38 static unsigned int ucv2_getspeed(unsigned int cpu)
40 struct clk *mclk = clk_get(NULL, "MAIN_CLK");
42 if (cpu)
43 return 0;
44 return clk_get_rate(mclk)/1000;
47 static int ucv2_target(struct cpufreq_policy *policy,
48 unsigned int target_freq,
49 unsigned int relation)
51 unsigned int cur = ucv2_getspeed(0);
52 struct cpufreq_freqs freqs;
53 struct clk *mclk = clk_get(NULL, "MAIN_CLK");
55 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
57 if (!clk_set_rate(mclk, target_freq * 1000)) {
58 freqs.old = cur;
59 freqs.new = target_freq;
60 freqs.cpu = 0;
63 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
65 return 0;
68 static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
70 if (policy->cpu != 0)
71 return -EINVAL;
72 policy->cur = ucv2_getspeed(0);
73 policy->min = policy->cpuinfo.min_freq = 250000;
74 policy->max = policy->cpuinfo.max_freq = 1000000;
75 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
76 return 0;
79 static struct cpufreq_driver ucv2_driver = {
80 .flags = CPUFREQ_STICKY,
81 .verify = ucv2_verify_speed,
82 .target = ucv2_target,
83 .get = ucv2_getspeed,
84 .init = ucv2_cpu_init,
85 .name = "UniCore-II",
88 static int __init ucv2_cpufreq_init(void)
90 return cpufreq_register_driver(&ucv2_driver);
93 arch_initcall(ucv2_cpufreq_init);