diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq-cpu0.c')
-rw-r--r-- | drivers/cpufreq/cpufreq-cpu0.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index 3ab8294eab04..ad1fde277661 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c | |||
@@ -45,7 +45,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
45 | struct cpufreq_freqs freqs; | 45 | struct cpufreq_freqs freqs; |
46 | struct opp *opp; | 46 | struct opp *opp; |
47 | unsigned long volt = 0, volt_old = 0, tol = 0; | 47 | unsigned long volt = 0, volt_old = 0, tol = 0; |
48 | long freq_Hz; | 48 | long freq_Hz, freq_exact; |
49 | unsigned int index; | 49 | unsigned int index; |
50 | int ret; | 50 | int ret; |
51 | 51 | ||
@@ -60,6 +60,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
60 | freq_Hz = clk_round_rate(cpu_clk, freq_table[index].frequency * 1000); | 60 | freq_Hz = clk_round_rate(cpu_clk, freq_table[index].frequency * 1000); |
61 | if (freq_Hz < 0) | 61 | if (freq_Hz < 0) |
62 | freq_Hz = freq_table[index].frequency * 1000; | 62 | freq_Hz = freq_table[index].frequency * 1000; |
63 | freq_exact = freq_Hz; | ||
63 | freqs.new = freq_Hz / 1000; | 64 | freqs.new = freq_Hz / 1000; |
64 | freqs.old = clk_get_rate(cpu_clk) / 1000; | 65 | freqs.old = clk_get_rate(cpu_clk) / 1000; |
65 | 66 | ||
@@ -98,7 +99,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, | |||
98 | } | 99 | } |
99 | } | 100 | } |
100 | 101 | ||
101 | ret = clk_set_rate(cpu_clk, freqs.new * 1000); | 102 | ret = clk_set_rate(cpu_clk, freq_exact); |
102 | if (ret) { | 103 | if (ret) { |
103 | pr_err("failed to set clock rate: %d\n", ret); | 104 | pr_err("failed to set clock rate: %d\n", ret); |
104 | if (cpu_reg) | 105 | if (cpu_reg) |
@@ -189,12 +190,29 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
189 | 190 | ||
190 | if (!np) { | 191 | if (!np) { |
191 | pr_err("failed to find cpu0 node\n"); | 192 | pr_err("failed to find cpu0 node\n"); |
192 | return -ENOENT; | 193 | ret = -ENOENT; |
194 | goto out_put_parent; | ||
193 | } | 195 | } |
194 | 196 | ||
195 | cpu_dev = &pdev->dev; | 197 | cpu_dev = &pdev->dev; |
196 | cpu_dev->of_node = np; | 198 | cpu_dev->of_node = np; |
197 | 199 | ||
200 | cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); | ||
201 | if (IS_ERR(cpu_reg)) { | ||
202 | /* | ||
203 | * If cpu0 regulator supply node is present, but regulator is | ||
204 | * not yet registered, we should try defering probe. | ||
205 | */ | ||
206 | if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) { | ||
207 | dev_err(cpu_dev, "cpu0 regulator not ready, retry\n"); | ||
208 | ret = -EPROBE_DEFER; | ||
209 | goto out_put_node; | ||
210 | } | ||
211 | pr_warn("failed to get cpu0 regulator: %ld\n", | ||
212 | PTR_ERR(cpu_reg)); | ||
213 | cpu_reg = NULL; | ||
214 | } | ||
215 | |||
198 | cpu_clk = devm_clk_get(cpu_dev, NULL); | 216 | cpu_clk = devm_clk_get(cpu_dev, NULL); |
199 | if (IS_ERR(cpu_clk)) { | 217 | if (IS_ERR(cpu_clk)) { |
200 | ret = PTR_ERR(cpu_clk); | 218 | ret = PTR_ERR(cpu_clk); |
@@ -202,12 +220,6 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
202 | goto out_put_node; | 220 | goto out_put_node; |
203 | } | 221 | } |
204 | 222 | ||
205 | cpu_reg = devm_regulator_get(cpu_dev, "cpu0"); | ||
206 | if (IS_ERR(cpu_reg)) { | ||
207 | pr_warn("failed to get cpu0 regulator\n"); | ||
208 | cpu_reg = NULL; | ||
209 | } | ||
210 | |||
211 | ret = of_init_opp_table(cpu_dev); | 223 | ret = of_init_opp_table(cpu_dev); |
212 | if (ret) { | 224 | if (ret) { |
213 | pr_err("failed to init OPP table: %d\n", ret); | 225 | pr_err("failed to init OPP table: %d\n", ret); |
@@ -264,6 +276,8 @@ out_free_table: | |||
264 | opp_free_cpufreq_table(cpu_dev, &freq_table); | 276 | opp_free_cpufreq_table(cpu_dev, &freq_table); |
265 | out_put_node: | 277 | out_put_node: |
266 | of_node_put(np); | 278 | of_node_put(np); |
279 | out_put_parent: | ||
280 | of_node_put(parent); | ||
267 | return ret; | 281 | return ret; |
268 | } | 282 | } |
269 | 283 | ||