diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2013-10-25 10:15:48 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rjw@rjwysocki.net> | 2013-10-25 16:42:24 -0400 |
commit | 9c0ebcf78fde0ffa348a95a544c6d3f2dac5af65 (patch) | |
tree | 0aa1814b3cdbd6900a6494d8f0c56551d90cf693 /Documentation/cpu-freq | |
parent | 6ddee424fea2d269c2f402278d93165c7b92dc58 (diff) |
cpufreq: Implement light weight ->target_index() routine
Currently, the prototype of cpufreq_drivers target routines is:
int target(struct cpufreq_policy *policy, unsigned int target_freq,
unsigned int relation);
And most of the drivers call cpufreq_frequency_table_target() to get a valid
index of their frequency table which is closest to the target_freq. And they
don't use target_freq and relation after that.
So, it makes sense to just do this work in cpufreq core before calling
cpufreq_frequency_table_target() and simply pass index instead. But this can be
done only with drivers which expose their frequency table with cpufreq core. For
others we need to stick with the old prototype of target() until those drivers
are converted to expose frequency tables.
This patch implements the new light weight prototype for target_index() routine.
It looks like this:
int target_index(struct cpufreq_policy *policy, unsigned int index);
CPUFreq core will call cpufreq_frequency_table_target() before calling this
routine and pass index to it. Because CPUFreq core now requires to call routines
present in freq_table.c CONFIG_CPU_FREQ_TABLE must be enabled all the time.
This also marks target() interface as deprecated. So, that new drivers avoid
using it. And Documentation is updated accordingly.
It also converts existing .target() to newly defined light weight
.target_index() routine for many driver.
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Russell King <linux@arm.linux.org.uk>
Acked-by: David S. Miller <davem@davemloft.net>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rjw@rjwysocki.net>
Diffstat (limited to 'Documentation/cpu-freq')
-rw-r--r-- | Documentation/cpu-freq/cpu-drivers.txt | 27 | ||||
-rw-r--r-- | Documentation/cpu-freq/governors.txt | 4 |
2 files changed, 20 insertions, 11 deletions
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt index 40282e617913..8b1a4451422e 100644 --- a/Documentation/cpu-freq/cpu-drivers.txt +++ b/Documentation/cpu-freq/cpu-drivers.txt | |||
@@ -23,8 +23,8 @@ Contents: | |||
23 | 1.1 Initialization | 23 | 1.1 Initialization |
24 | 1.2 Per-CPU Initialization | 24 | 1.2 Per-CPU Initialization |
25 | 1.3 verify | 25 | 1.3 verify |
26 | 1.4 target or setpolicy? | 26 | 1.4 target/target_index or setpolicy? |
27 | 1.5 target | 27 | 1.5 target/target_index |
28 | 1.6 setpolicy | 28 | 1.6 setpolicy |
29 | 2. Frequency Table Helpers | 29 | 2. Frequency Table Helpers |
30 | 30 | ||
@@ -56,7 +56,8 @@ cpufreq_driver.init - A pointer to the per-CPU initialization | |||
56 | cpufreq_driver.verify - A pointer to a "verification" function. | 56 | cpufreq_driver.verify - A pointer to a "verification" function. |
57 | 57 | ||
58 | cpufreq_driver.setpolicy _or_ | 58 | cpufreq_driver.setpolicy _or_ |
59 | cpufreq_driver.target - See below on the differences. | 59 | cpufreq_driver.target/ |
60 | target_index - See below on the differences. | ||
60 | 61 | ||
61 | And optionally | 62 | And optionally |
62 | 63 | ||
@@ -66,7 +67,7 @@ cpufreq_driver.resume - A pointer to a per-CPU resume function | |||
66 | which is called with interrupts disabled | 67 | which is called with interrupts disabled |
67 | and _before_ the pre-suspend frequency | 68 | and _before_ the pre-suspend frequency |
68 | and/or policy is restored by a call to | 69 | and/or policy is restored by a call to |
69 | ->target or ->setpolicy. | 70 | ->target/target_index or ->setpolicy. |
70 | 71 | ||
71 | cpufreq_driver.attr - A pointer to a NULL-terminated list of | 72 | cpufreq_driver.attr - A pointer to a NULL-terminated list of |
72 | "struct freq_attr" which allow to | 73 | "struct freq_attr" which allow to |
@@ -103,8 +104,8 @@ policy->governor must contain the "default policy" for | |||
103 | this CPU. A few moments later, | 104 | this CPU. A few moments later, |
104 | cpufreq_driver.verify and either | 105 | cpufreq_driver.verify and either |
105 | cpufreq_driver.setpolicy or | 106 | cpufreq_driver.setpolicy or |
106 | cpufreq_driver.target is called with | 107 | cpufreq_driver.target/target_index is called |
107 | these values. | 108 | with these values. |
108 | 109 | ||
109 | For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the | 110 | For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the |
110 | frequency table helpers might be helpful. See the section 2 for more information | 111 | frequency table helpers might be helpful. See the section 2 for more information |
@@ -133,20 +134,28 @@ range) is within policy->min and policy->max. If necessary, increase | |||
133 | policy->max first, and only if this is no solution, decrease policy->min. | 134 | policy->max first, and only if this is no solution, decrease policy->min. |
134 | 135 | ||
135 | 136 | ||
136 | 1.4 target or setpolicy? | 137 | 1.4 target/target_index or setpolicy? |
137 | ---------------------------- | 138 | ---------------------------- |
138 | 139 | ||
139 | Most cpufreq drivers or even most cpu frequency scaling algorithms | 140 | Most cpufreq drivers or even most cpu frequency scaling algorithms |
140 | only allow the CPU to be set to one frequency. For these, you use the | 141 | only allow the CPU to be set to one frequency. For these, you use the |
141 | ->target call. | 142 | ->target/target_index call. |
142 | 143 | ||
143 | Some cpufreq-capable processors switch the frequency between certain | 144 | Some cpufreq-capable processors switch the frequency between certain |
144 | limits on their own. These shall use the ->setpolicy call | 145 | limits on their own. These shall use the ->setpolicy call |
145 | 146 | ||
146 | 147 | ||
147 | 1.4. target | 148 | 1.4. target/target_index |
148 | ------------- | 149 | ------------- |
149 | 150 | ||
151 | The target_index call has two arguments: struct cpufreq_policy *policy, | ||
152 | and unsigned int index (into the exposed frequency table). | ||
153 | |||
154 | The CPUfreq driver must set the new frequency when called here. The | ||
155 | actual frequency must be determined by freq_table[index].frequency. | ||
156 | |||
157 | Deprecated: | ||
158 | ---------- | ||
150 | The target call has three arguments: struct cpufreq_policy *policy, | 159 | The target call has three arguments: struct cpufreq_policy *policy, |
151 | unsigned int target_frequency, unsigned int relation. | 160 | unsigned int target_frequency, unsigned int relation. |
152 | 161 | ||
diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt index 219970ba54b7..77ec21574fb1 100644 --- a/Documentation/cpu-freq/governors.txt +++ b/Documentation/cpu-freq/governors.txt | |||
@@ -40,7 +40,7 @@ Most cpufreq drivers (in fact, all except one, longrun) or even most | |||
40 | cpu frequency scaling algorithms only offer the CPU to be set to one | 40 | cpu frequency scaling algorithms only offer the CPU to be set to one |
41 | frequency. In order to offer dynamic frequency scaling, the cpufreq | 41 | frequency. In order to offer dynamic frequency scaling, the cpufreq |
42 | core must be able to tell these drivers of a "target frequency". So | 42 | core must be able to tell these drivers of a "target frequency". So |
43 | these specific drivers will be transformed to offer a "->target" | 43 | these specific drivers will be transformed to offer a "->target/target_index" |
44 | call instead of the existing "->setpolicy" call. For "longrun", all | 44 | call instead of the existing "->setpolicy" call. For "longrun", all |
45 | stays the same, though. | 45 | stays the same, though. |
46 | 46 | ||
@@ -71,7 +71,7 @@ CPU can be set to switch independently | CPU can only be set | |||
71 | / the limits of policy->{min,max} | 71 | / the limits of policy->{min,max} |
72 | / \ | 72 | / \ |
73 | / \ | 73 | / \ |
74 | Using the ->setpolicy call, Using the ->target call, | 74 | Using the ->setpolicy call, Using the ->target/target_index call, |
75 | the limits and the the frequency closest | 75 | the limits and the the frequency closest |
76 | "policy" is set. to target_freq is set. | 76 | "policy" is set. to target_freq is set. |
77 | It is assured that it | 77 | It is assured that it |