Skip to content

Commit 8f92058

Browse files
mchehabrafaeljw
authored andcommitted
docs: cpu-freq: convert cpu-drivers.txt to ReST
- Add a SPDX header; - Add a document title, based on the original contents of cpu-freq/index.txt; - Use lists where needed; - Comment out the existing text-only index; - Adjust some title marks; - Add table markups; - Add notes markups; - Mark literal blocks as such; - use ``foo`` for literal texts; - Some whitespace fixes and new line breaks; - Add it to cpu-freq/index.rst. Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c460f97 commit 8f92058

File tree

2 files changed

+64
-66
lines changed

2 files changed

+64
-66
lines changed

Documentation/cpu-freq/cpu-drivers.txt renamed to Documentation/cpu-freq/cpu-drivers.rst

Lines changed: 63 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
1-
CPU frequency and voltage scaling code in the Linux(TM) kernel
1+
.. SPDX-License-Identifier: GPL-2.0
22
3+
===============================================
4+
How to Implement a new CPUFreq Processor Driver
5+
===============================================
36

4-
L i n u x C P U F r e q
7+
Authors:
58

6-
C P U D r i v e r s
79

8-
- information for developers -
10+
- Dominik Brodowski <[email protected]>
11+
- Rafael J. Wysocki <[email protected]>
12+
- Viresh Kumar <[email protected]>
913

14+
.. Contents
1015
11-
Dominik Brodowski <[email protected]>
12-
Rafael J. Wysocki <[email protected]>
13-
Viresh Kumar <[email protected]>
14-
15-
16-
17-
Clock scaling allows you to change the clock speed of the CPUs on the
18-
fly. This is a nice method to save battery power, because the lower
19-
the clock speed, the less power the CPU consumes.
20-
21-
22-
Contents:
23-
---------
24-
1. What To Do?
25-
1.1 Initialization
26-
1.2 Per-CPU Initialization
27-
1.3 verify
28-
1.4 target/target_index or setpolicy?
29-
1.5 target/target_index
30-
1.6 setpolicy
31-
1.7 get_intermediate and target_intermediate
32-
2. Frequency Table Helpers
16+
1. What To Do?
17+
1.1 Initialization
18+
1.2 Per-CPU Initialization
19+
1.3 verify
20+
1.4 target/target_index or setpolicy?
21+
1.5 target/target_index
22+
1.6 setpolicy
23+
1.7 get_intermediate and target_intermediate
24+
2. Frequency Table Helpers
3325
3426
3527
@@ -49,7 +41,7 @@ function check whether this kernel runs on the right CPU and the right
4941
chipset. If so, register a struct cpufreq_driver with the CPUfreq core
5042
using cpufreq_register_driver()
5143

52-
What shall this struct cpufreq_driver contain?
44+
What shall this struct cpufreq_driver contain?
5345

5446
.name - The name of this driver.
5547

@@ -108,37 +100,42 @@ Whenever a new CPU is registered with the device model, or after the
108100
cpufreq driver registers itself, the per-policy initialization function
109101
cpufreq_driver.init is called if no cpufreq policy existed for the CPU.
110102
Note that the .init() and .exit() routines are called only once for the
111-
policy and not for each CPU managed by the policy. It takes a struct
112-
cpufreq_policy *policy as argument. What to do now?
103+
policy and not for each CPU managed by the policy. It takes a ``struct
104+
cpufreq_policy *policy`` as argument. What to do now?
113105

114106
If necessary, activate the CPUfreq support on your CPU.
115107

116108
Then, the driver must fill in the following values:
117109

118-
policy->cpuinfo.min_freq _and_
119-
policy->cpuinfo.max_freq - the minimum and maximum frequency
120-
(in kHz) which is supported by
121-
this CPU
122-
policy->cpuinfo.transition_latency the time it takes on this CPU to
123-
switch between two frequencies in
124-
nanoseconds (if appropriate, else
125-
specify CPUFREQ_ETERNAL)
126-
127-
policy->cur The current operating frequency of
128-
this CPU (if appropriate)
129-
policy->min,
130-
policy->max,
131-
policy->policy and, if necessary,
132-
policy->governor must contain the "default policy" for
133-
this CPU. A few moments later,
134-
cpufreq_driver.verify and either
135-
cpufreq_driver.setpolicy or
136-
cpufreq_driver.target/target_index is called
137-
with these values.
138-
policy->cpus Update this with the masks of the
139-
(online + offline) CPUs that do DVFS
140-
along with this CPU (i.e. that share
141-
clock/voltage rails with it).
110+
+-----------------------------------+--------------------------------------+
111+
|policy->cpuinfo.min_freq _and_ | |
112+
|policy->cpuinfo.max_freq | the minimum and maximum frequency |
113+
| | (in kHz) which is supported by |
114+
| | this CPU |
115+
+-----------------------------------+--------------------------------------+
116+
|policy->cpuinfo.transition_latency | the time it takes on this CPU to |
117+
| | switch between two frequencies in |
118+
| | nanoseconds (if appropriate, else |
119+
| | specify CPUFREQ_ETERNAL) |
120+
+-----------------------------------+--------------------------------------+
121+
|policy->cur | The current operating frequency of |
122+
| | this CPU (if appropriate) |
123+
+-----------------------------------+--------------------------------------+
124+
|policy->min, | |
125+
|policy->max, | |
126+
|policy->policy and, if necessary, | |
127+
|policy->governor | must contain the "default policy" for|
128+
| | this CPU. A few moments later, |
129+
| | cpufreq_driver.verify and either |
130+
| | cpufreq_driver.setpolicy or |
131+
| | cpufreq_driver.target/target_index is|
132+
| | called with these values. |
133+
+-----------------------------------+--------------------------------------+
134+
|policy->cpus | Update this with the masks of the |
135+
| | (online + offline) CPUs that do DVFS |
136+
| | along with this CPU (i.e. that share|
137+
| | clock/voltage rails with it). |
138+
+-----------------------------------+--------------------------------------+
142139

143140
For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the
144141
frequency table helpers might be helpful. See the section 2 for more information
@@ -151,8 +148,8 @@ on them.
151148
When the user decides a new policy (consisting of
152149
"policy,governor,min,max") shall be set, this policy must be validated
153150
so that incompatible values can be corrected. For verifying these
154-
values cpufreq_verify_within_limits(struct cpufreq_policy *policy,
155-
unsigned int min_freq, unsigned int max_freq) function might be helpful.
151+
values cpufreq_verify_within_limits(``struct cpufreq_policy *policy``,
152+
``unsigned int min_freq``, ``unsigned int max_freq``) function might be helpful.
156153
See section 2 for details on frequency table helpers.
157154

158155
You need to make sure that at least one valid frequency (or operating
@@ -163,7 +160,7 @@ policy->max first, and only if this is no solution, decrease policy->min.
163160
1.4 target or target_index or setpolicy or fast_switch?
164161
-------------------------------------------------------
165162

166-
Most cpufreq drivers or even most cpu frequency scaling algorithms
163+
Most cpufreq drivers or even most cpu frequency scaling algorithms
167164
only allow the CPU frequency to be set to predefined fixed values. For
168165
these, you use the ->target(), ->target_index() or ->fast_switch()
169166
callbacks.
@@ -175,18 +172,18 @@ limits on their own. These shall use the ->setpolicy() callback.
175172
1.5. target/target_index
176173
------------------------
177174

178-
The target_index call has two arguments: struct cpufreq_policy *policy,
179-
and unsigned int index (into the exposed frequency table).
175+
The target_index call has two arguments: ``struct cpufreq_policy *policy``,
176+
and ``unsigned int`` index (into the exposed frequency table).
180177

181178
The CPUfreq driver must set the new frequency when called here. The
182179
actual frequency must be determined by freq_table[index].frequency.
183180

184181
It should always restore to earlier frequency (i.e. policy->restore_freq) in
185182
case of errors, even if we switched to intermediate frequency earlier.
186183

187-
Deprecated:
184+
Deprecated
188185
----------
189-
The target call has three arguments: struct cpufreq_policy *policy,
186+
The target call has three arguments: ``struct cpufreq_policy *policy``,
190187
unsigned int target_frequency, unsigned int relation.
191188

192189
The CPUfreq driver must set the new frequency when called here. The
@@ -210,14 +207,14 @@ Not all drivers are expected to implement it, as sleeping from within
210207
this callback isn't allowed. This callback must be highly optimized to
211208
do switching as fast as possible.
212209

213-
This function has two arguments: struct cpufreq_policy *policy and
214-
unsigned int target_frequency.
210+
This function has two arguments: ``struct cpufreq_policy *policy`` and
211+
``unsigned int target_frequency``.
215212

216213

217214
1.7 setpolicy
218215
-------------
219216

220-
The setpolicy call only takes a struct cpufreq_policy *policy as
217+
The setpolicy call only takes a ``struct cpufreq_policy *policy`` as
221218
argument. You need to set the lower limit of the in-processor or
222219
in-chipset dynamic frequency switching to policy->min, the upper limit
223220
to policy->max, and -if supported- select a performance-oriented
@@ -278,10 +275,10 @@ table.
278275

279276
cpufreq_for_each_valid_entry(pos, table) - iterates over all entries,
280277
excluding CPUFREQ_ENTRY_INVALID frequencies.
281-
Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and
282-
"table" - the cpufreq_frequency_table * you want to iterate over.
278+
Use arguments "pos" - a ``cpufreq_frequency_table *`` as a loop cursor and
279+
"table" - the ``cpufreq_frequency_table *`` you want to iterate over.
283280

284-
For example:
281+
For example::
285282

286283
struct cpufreq_frequency_table *pos, *driver_freq_table;
287284

Documentation/cpu-freq/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Dominik Brodowski <[email protected]>
1515
:maxdepth: 1
1616

1717
core
18+
cpu-drivers
1819

1920
Mailing List
2021
------------

0 commit comments

Comments
 (0)