aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2012-10-10 07:42:25 -0400
committerMike Turquette <mturquette@ti.com>2012-11-09 19:47:05 -0500
commitfdb44464ce844dc72e194a6671996fa8cfdbc532 (patch)
tree13a89d52fcf57fbef4959902a36a830cc8019993 /drivers/cpufreq
parentb46894447170963d7a29050b79fe532deab0966f (diff)
cpufreq: db8500: Fetch cpufreq table from platform data
By fetching the table as platform data we do not need the internally hardcoded cpufreq table anymore. Moreover the corresponding arm_opp idx2opp table, used for mapping frequency to correct opp bits is also removed. This due to that the opp bits is put directly in the index field of the cpufreq table. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Acked-by: Jonas Aaberg <jonas.aberg@stericsson.com> Acked-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/db8500-cpufreq.c67
1 files changed, 25 insertions, 42 deletions
diff --git a/drivers/cpufreq/db8500-cpufreq.c b/drivers/cpufreq/db8500-cpufreq.c
index 7d61a6c3e707..dea9a49023d7 100644
--- a/drivers/cpufreq/db8500-cpufreq.c
+++ b/drivers/cpufreq/db8500-cpufreq.c
@@ -17,36 +17,7 @@
17#include <linux/mfd/dbx500-prcmu.h> 17#include <linux/mfd/dbx500-prcmu.h>
18#include <mach/id.h> 18#include <mach/id.h>
19 19
20static struct cpufreq_frequency_table freq_table[] = { 20static struct cpufreq_frequency_table *freq_table;
21 [0] = {
22 .index = 0,
23 .frequency = 200000,
24 },
25 [1] = {
26 .index = 1,
27 .frequency = 400000,
28 },
29 [2] = {
30 .index = 2,
31 .frequency = 800000,
32 },
33 [3] = {
34 /* Used for MAX_OPP, if available */
35 .index = 3,
36 .frequency = CPUFREQ_TABLE_END,
37 },
38 [4] = {
39 .index = 4,
40 .frequency = CPUFREQ_TABLE_END,
41 },
42};
43
44static enum arm_opp idx2opp[] = {
45 ARM_EXTCLK,
46 ARM_50_OPP,
47 ARM_100_OPP,
48 ARM_MAX_OPP
49};
50 21
51static struct freq_attr *db8500_cpufreq_attr[] = { 22static struct freq_attr *db8500_cpufreq_attr[] = {
52 &cpufreq_freq_attr_scaling_available_freqs, 23 &cpufreq_freq_attr_scaling_available_freqs,
@@ -88,7 +59,7 @@ static int db8500_cpufreq_target(struct cpufreq_policy *policy,
88 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 59 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
89 60
90 /* request the PRCM unit for opp change */ 61 /* request the PRCM unit for opp change */
91 if (prcmu_set_arm_opp(idx2opp[idx])) { 62 if (prcmu_set_arm_opp(freq_table[idx].index)) {
92 pr_err("db8500-cpufreq: Failed to set OPP level\n"); 63 pr_err("db8500-cpufreq: Failed to set OPP level\n");
93 return -EINVAL; 64 return -EINVAL;
94 } 65 }
@@ -102,25 +73,30 @@ static int db8500_cpufreq_target(struct cpufreq_policy *policy,
102 73
103static unsigned int db8500_cpufreq_getspeed(unsigned int cpu) 74static unsigned int db8500_cpufreq_getspeed(unsigned int cpu)
104{ 75{
105 int i; 76 int i = 0;
106 /* request the prcm to get the current ARM opp */ 77 /* request the prcm to get the current ARM opp */
107 for (i = 0; prcmu_get_arm_opp() != idx2opp[i]; i++) 78 int opp = prcmu_get_arm_opp();
108 ; 79
109 return freq_table[i].frequency; 80 while (freq_table[i].frequency != CPUFREQ_TABLE_END) {
81 if (opp == freq_table[i].index)
82 return freq_table[i].frequency;
83 i++;
84 }
85
86 /* We could not find a corresponding opp frequency. */
87 return 0;
110} 88}
111 89
112static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy) 90static int __cpuinit db8500_cpufreq_init(struct cpufreq_policy *policy)
113{ 91{
114 int i, res; 92 int i = 0;
115 93 int res;
116 BUILD_BUG_ON(ARRAY_SIZE(idx2opp) + 1 != ARRAY_SIZE(freq_table));
117
118 if (prcmu_has_arm_maxopp())
119 freq_table[3].frequency = 1000000;
120 94
121 pr_info("db8500-cpufreq : Available frequencies:\n"); 95 pr_info("db8500-cpufreq : Available frequencies:\n");
122 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) 96 while (freq_table[i].frequency != CPUFREQ_TABLE_END) {
123 pr_info(" %d Mhz\n", freq_table[i].frequency/1000); 97 pr_info(" %d Mhz\n", freq_table[i].frequency/1000);
98 i++;
99 }
124 100
125 /* get policy fields based on the table */ 101 /* get policy fields based on the table */
126 res = cpufreq_frequency_table_cpuinfo(policy, freq_table); 102 res = cpufreq_frequency_table_cpuinfo(policy, freq_table);
@@ -163,6 +139,13 @@ static struct cpufreq_driver db8500_cpufreq_driver = {
163 139
164static int db8500_cpufreq_probe(struct platform_device *pdev) 140static int db8500_cpufreq_probe(struct platform_device *pdev)
165{ 141{
142 freq_table = dev_get_platdata(&pdev->dev);
143
144 if (!freq_table) {
145 pr_err("db8500-cpufreq: Failed to fetch cpufreq table\n");
146 return -ENODEV;
147 }
148
166 return cpufreq_register_driver(&db8500_cpufreq_driver); 149 return cpufreq_register_driver(&db8500_cpufreq_driver);
167} 150}
168 151