diff options
Diffstat (limited to 'arch/arm/plat-s3c64xx/cpufreq.c')
-rw-r--r-- | arch/arm/plat-s3c64xx/cpufreq.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/arch/arm/plat-s3c64xx/cpufreq.c b/arch/arm/plat-s3c64xx/cpufreq.c index e6e0843215df..74c0e8347de5 100644 --- a/arch/arm/plat-s3c64xx/cpufreq.c +++ b/arch/arm/plat-s3c64xx/cpufreq.c | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | static struct clk *armclk; | 20 | static struct clk *armclk; |
21 | static struct regulator *vddarm; | 21 | static struct regulator *vddarm; |
22 | static unsigned long regulator_latency; | ||
22 | 23 | ||
23 | #ifdef CONFIG_CPU_S3C6410 | 24 | #ifdef CONFIG_CPU_S3C6410 |
24 | struct s3c64xx_dvfs { | 25 | struct s3c64xx_dvfs { |
@@ -27,11 +28,10 @@ struct s3c64xx_dvfs { | |||
27 | }; | 28 | }; |
28 | 29 | ||
29 | static struct s3c64xx_dvfs s3c64xx_dvfs_table[] = { | 30 | static struct s3c64xx_dvfs s3c64xx_dvfs_table[] = { |
30 | [0] = { 1000000, 1000000 }, | 31 | [0] = { 1000000, 1150000 }, |
31 | [1] = { 1000000, 1050000 }, | 32 | [1] = { 1050000, 1150000 }, |
32 | [2] = { 1050000, 1100000 }, | 33 | [2] = { 1100000, 1150000 }, |
33 | [3] = { 1050000, 1150000 }, | 34 | [3] = { 1200000, 1350000 }, |
34 | [4] = { 1250000, 1350000 }, | ||
35 | }; | 35 | }; |
36 | 36 | ||
37 | static struct cpufreq_frequency_table s3c64xx_freq_table[] = { | 37 | static struct cpufreq_frequency_table s3c64xx_freq_table[] = { |
@@ -41,9 +41,9 @@ static struct cpufreq_frequency_table s3c64xx_freq_table[] = { | |||
41 | { 1, 266000 }, | 41 | { 1, 266000 }, |
42 | { 2, 333000 }, | 42 | { 2, 333000 }, |
43 | { 2, 400000 }, | 43 | { 2, 400000 }, |
44 | { 3, 532000 }, | 44 | { 2, 532000 }, |
45 | { 3, 533000 }, | 45 | { 2, 533000 }, |
46 | { 4, 667000 }, | 46 | { 3, 667000 }, |
47 | { 0, CPUFREQ_TABLE_END }, | 47 | { 0, CPUFREQ_TABLE_END }, |
48 | }; | 48 | }; |
49 | #endif | 49 | #endif |
@@ -141,7 +141,7 @@ err: | |||
141 | } | 141 | } |
142 | 142 | ||
143 | #ifdef CONFIG_REGULATOR | 143 | #ifdef CONFIG_REGULATOR |
144 | static void __init s3c64xx_cpufreq_constrain_voltages(void) | 144 | static void __init s3c64xx_cpufreq_config_regulator(void) |
145 | { | 145 | { |
146 | int count, v, i, found; | 146 | int count, v, i, found; |
147 | struct cpufreq_frequency_table *freq; | 147 | struct cpufreq_frequency_table *freq; |
@@ -150,11 +150,10 @@ static void __init s3c64xx_cpufreq_constrain_voltages(void) | |||
150 | count = regulator_count_voltages(vddarm); | 150 | count = regulator_count_voltages(vddarm); |
151 | if (count < 0) { | 151 | if (count < 0) { |
152 | pr_err("cpufreq: Unable to check supported voltages\n"); | 152 | pr_err("cpufreq: Unable to check supported voltages\n"); |
153 | return; | ||
154 | } | 153 | } |
155 | 154 | ||
156 | freq = s3c64xx_freq_table; | 155 | freq = s3c64xx_freq_table; |
157 | while (freq->frequency != CPUFREQ_TABLE_END) { | 156 | while (count > 0 && freq->frequency != CPUFREQ_TABLE_END) { |
158 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) | 157 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) |
159 | continue; | 158 | continue; |
160 | 159 | ||
@@ -175,6 +174,10 @@ static void __init s3c64xx_cpufreq_constrain_voltages(void) | |||
175 | 174 | ||
176 | freq++; | 175 | freq++; |
177 | } | 176 | } |
177 | |||
178 | /* Guess based on having to do an I2C/SPI write; in future we | ||
179 | * will be able to query the regulator performance here. */ | ||
180 | regulator_latency = 1 * 1000 * 1000; | ||
178 | } | 181 | } |
179 | #endif | 182 | #endif |
180 | 183 | ||
@@ -206,7 +209,7 @@ static int __init s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
206 | pr_err("cpufreq: Only frequency scaling available\n"); | 209 | pr_err("cpufreq: Only frequency scaling available\n"); |
207 | vddarm = NULL; | 210 | vddarm = NULL; |
208 | } else { | 211 | } else { |
209 | s3c64xx_cpufreq_constrain_voltages(); | 212 | s3c64xx_cpufreq_config_regulator(); |
210 | } | 213 | } |
211 | #endif | 214 | #endif |
212 | 215 | ||
@@ -217,8 +220,11 @@ static int __init s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
217 | /* Check for frequencies we can generate */ | 220 | /* Check for frequencies we can generate */ |
218 | r = clk_round_rate(armclk, freq->frequency * 1000); | 221 | r = clk_round_rate(armclk, freq->frequency * 1000); |
219 | r /= 1000; | 222 | r /= 1000; |
220 | if (r != freq->frequency) | 223 | if (r != freq->frequency) { |
224 | pr_debug("cpufreq: %dkHz unsupported by clock\n", | ||
225 | freq->frequency); | ||
221 | freq->frequency = CPUFREQ_ENTRY_INVALID; | 226 | freq->frequency = CPUFREQ_ENTRY_INVALID; |
227 | } | ||
222 | 228 | ||
223 | /* If we have no regulator then assume startup | 229 | /* If we have no regulator then assume startup |
224 | * frequency is the maximum we can support. */ | 230 | * frequency is the maximum we can support. */ |
@@ -230,9 +236,11 @@ static int __init s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
230 | 236 | ||
231 | policy->cur = clk_get_rate(armclk) / 1000; | 237 | policy->cur = clk_get_rate(armclk) / 1000; |
232 | 238 | ||
233 | /* Pick a conservative guess in ns: we'll need ~1 I2C/SPI | 239 | /* Datasheet says PLL stabalisation time (if we were to use |
234 | * write plus clock reprogramming. */ | 240 | * the PLLs, which we don't currently) is ~300us worst case, |
235 | policy->cpuinfo.transition_latency = 2 * 1000 * 1000; | 241 | * but add some fudge. |
242 | */ | ||
243 | policy->cpuinfo.transition_latency = (500 * 1000) + regulator_latency; | ||
236 | 244 | ||
237 | ret = cpufreq_frequency_table_cpuinfo(policy, s3c64xx_freq_table); | 245 | ret = cpufreq_frequency_table_cpuinfo(policy, s3c64xx_freq_table); |
238 | if (ret != 0) { | 246 | if (ret != 0) { |