Commit d704aa0d authored by Lukasz Luba's avatar Lukasz Luba Committed by Rafael J. Wysocki

Documentation: power: Add description about new callback for EM registration

The Energy Model (EM) registration for CPUs should now be done using
a dedicated callback added recently into CPUFreq framework and drivers.

Commit c17495b0 ("cpufreq: Add callback to register with energy model")

The callback guaranties that the EM registration is called at the right
time during driver setup. To avoid mistakes update the documentation
to align with the existing code implementation.
Signed-off-by: default avatarLukasz Luba <lukasz.luba@arm.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 88100752
...@@ -138,6 +138,10 @@ or in Section 2.4 ...@@ -138,6 +138,10 @@ or in Section 2.4
3. Example driver 3. Example driver
----------------- -----------------
The CPUFreq framework supports dedicated callback for registering
the EM for a given CPU(s) 'policy' object: cpufreq_driver::register_em().
That callback has to be implemented properly for a given driver,
because the framework would call it at the right time during setup.
This section provides a simple example of a CPUFreq driver registering a This section provides a simple example of a CPUFreq driver registering a
performance domain in the Energy Model framework using the (fake) 'foo' performance domain in the Energy Model framework using the (fake) 'foo'
protocol. The driver implements an est_power() function to be provided to the protocol. The driver implements an est_power() function to be provided to the
...@@ -167,25 +171,22 @@ EM framework:: ...@@ -167,25 +171,22 @@ EM framework::
20 return 0; 20 return 0;
21 } 21 }
22 22
23 static int foo_cpufreq_init(struct cpufreq_policy *policy) 23 static void foo_cpufreq_register_em(struct cpufreq_policy *policy)
24 { 24 {
25 struct em_data_callback em_cb = EM_DATA_CB(est_power); 25 struct em_data_callback em_cb = EM_DATA_CB(est_power);
26 struct device *cpu_dev; 26 struct device *cpu_dev;
27 int nr_opp, ret; 27 int nr_opp;
28 28
29 cpu_dev = get_cpu_device(cpumask_first(policy->cpus)); 29 cpu_dev = get_cpu_device(cpumask_first(policy->cpus));
30 30
31 /* Do the actual CPUFreq init work ... */ 31 /* Find the number of OPPs for this policy */
32 ret = do_foo_cpufreq_init(policy); 32 nr_opp = foo_get_nr_opp(policy);
33 if (ret) 33
34 return ret; 34 /* And register the new performance domain */
35 35 em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus,
36 /* Find the number of OPPs for this policy */ 36 true);
37 nr_opp = foo_get_nr_opp(policy); 37 }
38 38
39 /* And register the new performance domain */ 39 static struct cpufreq_driver foo_cpufreq_driver = {
40 em_dev_register_perf_domain(cpu_dev, nr_opp, &em_cb, policy->cpus, 40 .register_em = foo_cpufreq_register_em,
41 true); 41 };
42
43 return 0;
44 }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment