diff options
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/db8500-cpufreq.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/cpufreq/db8500-cpufreq.c b/drivers/cpufreq/db8500-cpufreq.c index dea9a49023d7..4f154bc0ebe4 100644 --- a/drivers/cpufreq/db8500-cpufreq.c +++ b/drivers/cpufreq/db8500-cpufreq.c | |||
@@ -14,10 +14,11 @@ | |||
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/mfd/dbx500-prcmu.h> | 17 | #include <linux/clk.h> |
18 | #include <mach/id.h> | 18 | #include <mach/id.h> |
19 | 19 | ||
20 | static struct cpufreq_frequency_table *freq_table; | 20 | static struct cpufreq_frequency_table *freq_table; |
21 | static struct clk *armss_clk; | ||
21 | 22 | ||
22 | static struct freq_attr *db8500_cpufreq_attr[] = { | 23 | static struct freq_attr *db8500_cpufreq_attr[] = { |
23 | &cpufreq_freq_attr_scaling_available_freqs, | 24 | &cpufreq_freq_attr_scaling_available_freqs, |
@@ -58,9 +59,9 @@ static int db8500_cpufreq_target(struct cpufreq_policy *policy, | |||
58 | for_each_cpu(freqs.cpu, policy->cpus) | 59 | for_each_cpu(freqs.cpu, policy->cpus) |
59 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); | 60 | cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); |
60 | 61 | ||
61 | /* request the PRCM unit for opp change */ | 62 | /* update armss clk frequency */ |
62 | if (prcmu_set_arm_opp(freq_table[idx].index)) { | 63 | if (clk_set_rate(armss_clk, freq_table[idx].frequency * 1000)) { |
63 | pr_err("db8500-cpufreq: Failed to set OPP level\n"); | 64 | pr_err("db8500-cpufreq: Failed to update armss clk\n"); |
64 | return -EINVAL; | 65 | return -EINVAL; |
65 | } | 66 | } |
66 | 67 | ||
@@ -74,16 +75,16 @@ static int db8500_cpufreq_target(struct cpufreq_policy *policy, | |||
74 | static unsigned int db8500_cpufreq_getspeed(unsigned int cpu) | 75 | static unsigned int db8500_cpufreq_getspeed(unsigned int cpu) |
75 | { | 76 | { |
76 | int i = 0; | 77 | int i = 0; |
77 | /* request the prcm to get the current ARM opp */ | 78 | unsigned long freq = clk_get_rate(armss_clk) / 1000; |
78 | int opp = prcmu_get_arm_opp(); | ||
79 | 79 | ||
80 | while (freq_table[i].frequency != CPUFREQ_TABLE_END) { | 80 | while (freq_table[i].frequency != CPUFREQ_TABLE_END) { |
81 | if (opp == freq_table[i].index) | 81 | if (freq <= freq_table[i].frequency) |
82 | return freq_table[i].frequency; | 82 | return freq_table[i].frequency; |
83 | i++; | 83 | i++; |
84 | } | 84 | } |
85 | 85 | ||
86 | /* We could not find a corresponding opp frequency. */ | 86 | /* We could not find a corresponding frequency. */ |
87 | pr_err("db8500-cpufreq: Failed to find cpufreq speed\n"); | ||
87 | return 0; | 88 | return 0; |
88 | } | 89 | } |
89 | 90 | ||
@@ -92,6 +93,12 @@ static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy) | |||
92 | int i = 0; | 93 | int i = 0; |
93 | int res; | 94 | int res; |
94 | 95 | ||
96 | armss_clk = clk_get(NULL, "armss"); | ||
97 | if (IS_ERR(armss_clk)) { | ||
98 | pr_err("db8500-cpufreq : Failed to get armss clk\n"); | ||
99 | return PTR_ERR(armss_clk); | ||
100 | } | ||
101 | |||
95 | pr_info("db8500-cpufreq : Available frequencies:\n"); | 102 | pr_info("db8500-cpufreq : Available frequencies:\n"); |
96 | while (freq_table[i].frequency != CPUFREQ_TABLE_END) { | 103 | while (freq_table[i].frequency != CPUFREQ_TABLE_END) { |
97 | pr_info(" %d Mhz\n", freq_table[i].frequency/1000); | 104 | pr_info(" %d Mhz\n", freq_table[i].frequency/1000); |
@@ -104,6 +111,7 @@ static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy) | |||
104 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | 111 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); |
105 | else { | 112 | else { |
106 | pr_err("db8500-cpufreq : Failed to read policy table\n"); | 113 | pr_err("db8500-cpufreq : Failed to read policy table\n"); |
114 | clk_put(armss_clk); | ||
107 | return res; | 115 | return res; |
108 | } | 116 | } |
109 | 117 | ||