11 #define pr_fmt(fmt) "cpufreq: " fmt
13 #include <linux/kernel.h>
14 #include <linux/types.h>
20 #include <linux/module.h>
22 static struct clk *armclk;
24 static unsigned long regulator_latency;
26 #ifdef CONFIG_CPU_S3C6410
28 unsigned int vddarm_min;
29 unsigned int vddarm_max;
32 static struct s3c64xx_dvfs s3c64xx_dvfs_table[] = {
33 [0] = { 1000000, 1150000 },
34 [1] = { 1050000, 1150000 },
35 [2] = { 1100000, 1150000 },
36 [3] = { 1200000, 1350000 },
37 [4] = { 1300000, 1350000 },
57 static int s3c64xx_cpufreq_verify_speed(
struct cpufreq_policy *policy)
65 static unsigned int s3c64xx_cpufreq_get_speed(
unsigned int cpu)
73 static int s3c64xx_cpufreq_set_target(
struct cpufreq_policy *policy,
74 unsigned int target_freq,
75 unsigned int relation)
80 struct s3c64xx_dvfs *dvfs;
83 target_freq, relation, &i);
91 dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[
i].
index];
93 if (freqs.old == freqs.new)
96 pr_debug(
"Transition %d-%dkHz\n", freqs.old, freqs.new);
100 #ifdef CONFIG_REGULATOR
101 if (vddarm && freqs.new > freqs.old) {
106 pr_err(
"Failed to set VDDARM for %dkHz: %d\n",
115 pr_err(
"Failed to set rate %dkHz: %d\n",
122 #ifdef CONFIG_REGULATOR
123 if (vddarm && freqs.new < freqs.old) {
128 pr_err(
"Failed to set VDDARM for %dkHz: %d\n",
135 pr_debug(
"Set actual frequency %lukHz\n",
142 pr_err(
"Failed to restore original clock rate\n");
149 #ifdef CONFIG_REGULATOR
150 static void __init s3c64xx_cpufreq_config_regulator(
void)
154 struct s3c64xx_dvfs *dvfs;
158 pr_err(
"Unable to check supported voltages\n");
161 freq = s3c64xx_freq_table;
166 dvfs = &s3c64xx_dvfs_table[freq->
index];
169 for (i = 0; i <
count; i++) {
171 if (v >= dvfs->vddarm_min && v <= dvfs->vddarm_max)
176 pr_debug(
"%dkHz unsupported by regulator\n",
186 regulator_latency = 1 * 1000 * 1000;
190 static int s3c64xx_cpufreq_driver_init(
struct cpufreq_policy *policy)
195 if (policy->
cpu != 0)
198 if (s3c64xx_freq_table ==
NULL) {
199 pr_err(
"No frequency information for this CPU\n");
204 if (IS_ERR(armclk)) {
205 pr_err(
"Unable to obtain ARMCLK: %ld\n",
207 return PTR_ERR(armclk);
210 #ifdef CONFIG_REGULATOR
212 if (IS_ERR(vddarm)) {
213 ret = PTR_ERR(vddarm);
214 pr_err(
"Failed to obtain VDDARM: %d\n", ret);
215 pr_err(
"Only frequency scaling available\n");
218 s3c64xx_cpufreq_config_regulator();
222 freq = s3c64xx_freq_table;
230 pr_debug(
"%dkHz unsupported by clock\n",
237 if (!vddarm && freq->
frequency > s3c64xx_cpufreq_get_speed(0))
249 policy->
cpuinfo.transition_latency = (500 * 1000) + regulator_latency;
253 pr_err(
"Failed to configure frequency table: %d\n",
265 .verify = s3c64xx_cpufreq_verify_speed,
266 .target = s3c64xx_cpufreq_set_target,
267 .get = s3c64xx_cpufreq_get_speed,
268 .init = s3c64xx_cpufreq_driver_init,
272 static int __init s3c64xx_cpufreq_init(
void)