diff options
Diffstat (limited to 'drivers/cpufreq/dbx500-cpufreq.c')
-rw-r--r-- | drivers/cpufreq/dbx500-cpufreq.c | 78 |
1 files changed, 6 insertions, 72 deletions
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c index 26321cdc1946..0e67ab96321a 100644 --- a/drivers/cpufreq/dbx500-cpufreq.c +++ b/drivers/cpufreq/dbx500-cpufreq.c | |||
@@ -19,51 +19,11 @@ | |||
19 | static struct cpufreq_frequency_table *freq_table; | 19 | static struct cpufreq_frequency_table *freq_table; |
20 | static struct clk *armss_clk; | 20 | static struct clk *armss_clk; |
21 | 21 | ||
22 | static struct freq_attr *dbx500_cpufreq_attr[] = { | ||
23 | &cpufreq_freq_attr_scaling_available_freqs, | ||
24 | NULL, | ||
25 | }; | ||
26 | |||
27 | static int dbx500_cpufreq_verify_speed(struct cpufreq_policy *policy) | ||
28 | { | ||
29 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
30 | } | ||
31 | |||
32 | static int dbx500_cpufreq_target(struct cpufreq_policy *policy, | 22 | static int dbx500_cpufreq_target(struct cpufreq_policy *policy, |
33 | unsigned int target_freq, | 23 | unsigned int index) |
34 | unsigned int relation) | ||
35 | { | 24 | { |
36 | struct cpufreq_freqs freqs; | ||
37 | unsigned int idx; | ||
38 | int ret; | ||
39 | |||
40 | /* Lookup the next frequency */ | ||
41 | if (cpufreq_frequency_table_target(policy, freq_table, target_freq, | ||
42 | relation, &idx)) | ||
43 | return -EINVAL; | ||
44 | |||
45 | freqs.old = policy->cur; | ||
46 | freqs.new = freq_table[idx].frequency; | ||
47 | |||
48 | if (freqs.old == freqs.new) | ||
49 | return 0; | ||
50 | |||
51 | /* pre-change notification */ | ||
52 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
53 | |||
54 | /* update armss clk frequency */ | 25 | /* update armss clk frequency */ |
55 | ret = clk_set_rate(armss_clk, freqs.new * 1000); | 26 | return clk_set_rate(armss_clk, freq_table[index].frequency * 1000); |
56 | |||
57 | if (ret) { | ||
58 | pr_err("dbx500-cpufreq: Failed to set armss_clk to %d Hz: error %d\n", | ||
59 | freqs.new * 1000, ret); | ||
60 | freqs.new = freqs.old; | ||
61 | } | ||
62 | |||
63 | /* post change notification */ | ||
64 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
65 | |||
66 | return ret; | ||
67 | } | 27 | } |
68 | 28 | ||
69 | static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) | 29 | static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) |
@@ -84,43 +44,17 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) | |||
84 | 44 | ||
85 | static int dbx500_cpufreq_init(struct cpufreq_policy *policy) | 45 | static int dbx500_cpufreq_init(struct cpufreq_policy *policy) |
86 | { | 46 | { |
87 | int res; | 47 | return cpufreq_generic_init(policy, freq_table, 20 * 1000); |
88 | |||
89 | /* get policy fields based on the table */ | ||
90 | res = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
91 | if (!res) | ||
92 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
93 | else { | ||
94 | pr_err("dbx500-cpufreq: Failed to read policy table\n"); | ||
95 | return res; | ||
96 | } | ||
97 | |||
98 | policy->min = policy->cpuinfo.min_freq; | ||
99 | policy->max = policy->cpuinfo.max_freq; | ||
100 | policy->cur = dbx500_cpufreq_getspeed(policy->cpu); | ||
101 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; | ||
102 | |||
103 | /* | ||
104 | * FIXME : Need to take time measurement across the target() | ||
105 | * function with no/some/all drivers in the notification | ||
106 | * list. | ||
107 | */ | ||
108 | policy->cpuinfo.transition_latency = 20 * 1000; /* in ns */ | ||
109 | |||
110 | /* policy sharing between dual CPUs */ | ||
111 | cpumask_setall(policy->cpus); | ||
112 | |||
113 | return 0; | ||
114 | } | 48 | } |
115 | 49 | ||
116 | static struct cpufreq_driver dbx500_cpufreq_driver = { | 50 | static struct cpufreq_driver dbx500_cpufreq_driver = { |
117 | .flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS, | 51 | .flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS, |
118 | .verify = dbx500_cpufreq_verify_speed, | 52 | .verify = cpufreq_generic_frequency_table_verify, |
119 | .target = dbx500_cpufreq_target, | 53 | .target_index = dbx500_cpufreq_target, |
120 | .get = dbx500_cpufreq_getspeed, | 54 | .get = dbx500_cpufreq_getspeed, |
121 | .init = dbx500_cpufreq_init, | 55 | .init = dbx500_cpufreq_init, |
122 | .name = "DBX500", | 56 | .name = "DBX500", |
123 | .attr = dbx500_cpufreq_attr, | 57 | .attr = cpufreq_generic_attr, |
124 | }; | 58 | }; |
125 | 59 | ||
126 | static int dbx500_cpufreq_probe(struct platform_device *pdev) | 60 | static int dbx500_cpufreq_probe(struct platform_device *pdev) |