objtool: Re-arrange validate_functions()
[linux-block.git] / Documentation / cpu-freq / core.txt
CommitLineData
1da177e4
LT
1 CPU frequency and voltage scaling code in the Linux(TM) kernel
2
3
4 L i n u x C P U F r e q
5
6 C P U F r e q C o r e
7
8
9 Dominik Brodowski <linux@brodo.de>
10 David Kimdon <dwhedon@debian.org>
7de962c0
VK
11 Rafael J. Wysocki <rafael.j.wysocki@intel.com>
12 Viresh Kumar <viresh.kumar@linaro.org>
1da177e4
LT
13
14
15
16 Clock scaling allows you to change the clock speed of the CPUs on the
17 fly. This is a nice method to save battery power, because the lower
18 the clock speed, the less power the CPU consumes.
19
20
21Contents:
22---------
231. CPUFreq core and interfaces
242. CPUFreq notifiers
a0dd7b79 253. CPUFreq Table Generation with Operating Performance Point (OPP)
1da177e4
LT
26
271. General Information
28=======================
29
eff0df65 30The CPUFreq core code is located in drivers/cpufreq/cpufreq.c. This
1da177e4
LT
31cpufreq code offers a standardized interface for the CPUFreq
32architecture drivers (those pieces of code that do actual
33frequency transitions), as well as to "notifiers". These are device
34drivers or other part of the kernel that need to be informed of
35policy changes (ex. thermal modules like ACPI) or of all
36frequency changes (ex. timing code) or even need to force certain
37speed limits (like LCD drivers on ARM architecture). Additionally, the
38kernel "constant" loops_per_jiffy is updated on frequency changes
39here.
40
7de962c0
VK
41Reference counting of the cpufreq policies is done by cpufreq_cpu_get
42and cpufreq_cpu_put, which make sure that the cpufreq driver is
43correctly registered with the core, and will not be unloaded until
44cpufreq_put_cpu is called. That also ensures that the respective cpufreq
45policy doesn't get freed while being used.
1da177e4
LT
46
472. CPUFreq notifiers
48====================
49
50CPUFreq notifiers conform to the standard kernel notifier interface.
51See linux/include/linux/notifier.h for details on notifiers.
52
53There are two different CPUFreq notifiers - policy notifiers and
54transition notifiers.
55
56
572.1 CPUFreq policy notifiers
58----------------------------
59
c27c38af 60These are notified when a new policy is created or removed.
1da177e4 61
c27c38af
VK
62The phase is specified in the second argument to the notifier. The phase is
63CPUFREQ_CREATE_POLICY when the policy is first created and it is
64CPUFREQ_REMOVE_POLICY when the policy is removed.
1da177e4
LT
65
66The third argument, a void *pointer, points to a struct cpufreq_policy
7de962c0
VK
67consisting of several values, including min, max (the lower and upper
68frequencies (in kHz) of the new policy).
1da177e4
LT
69
70
712.2 CPUFreq transition notifiers
72--------------------------------
73
7de962c0
VK
74These are notified twice for each online CPU in the policy, when the
75CPUfreq driver switches the CPU core frequency and this change has no
76any external implications.
1da177e4
LT
77
78The second argument specifies the phase - CPUFREQ_PRECHANGE or
79CPUFREQ_POSTCHANGE.
80
81The third argument is a struct cpufreq_freqs with the following
82values:
83cpu - number of the affected CPU
84old - old frequency
85new - new frequency
7de962c0 86flags - flags of the cpufreq driver
a0dd7b79
NM
87
883. CPUFreq Table Generation with Operating Performance Point (OPP)
89==================================================================
151f4e2b 90For details about OPP, see Documentation/power/opp.rst
a0dd7b79 91
2dd0df84
VK
92dev_pm_opp_init_cpufreq_table -
93 This function provides a ready to use conversion routine to translate
94 the OPP layer's internal information about the available frequencies
95 into a format readily providable to cpufreq.
a0dd7b79
NM
96
97 WARNING: Do not use this function in interrupt context.
98
99 Example:
100 soc_pm_init()
101 {
102 /* Do things */
103 r = dev_pm_opp_init_cpufreq_table(dev, &freq_table);
104 if (!r)
2dd0df84 105 policy->freq_table = freq_table;
a0dd7b79
NM
106 /* Do other things */
107 }
108
109 NOTE: This function is available only if CONFIG_CPU_FREQ is enabled in
110 addition to CONFIG_PM_OPP.
111
112dev_pm_opp_free_cpufreq_table - Free up the table allocated by dev_pm_opp_init_cpufreq_table