summaryrefslogtreecommitdiffstats
path: root/include/linux/cpufreq.h
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2021-08-10 12:04:33 +0530
committerViresh Kumar <viresh.kumar@linaro.org>2021-08-12 09:54:07 +0530
commitc17495b01b72b53bd290f442d39b060e015c7aea (patch)
tree9a7d29bb6a9bcafe21aaa5ee87a24c3a9ba60289 /include/linux/cpufreq.h
parentbb8c26d9387fe428068dcab35b1873ea3b881de1 (diff)
downloadlinux-stable-c17495b01b72b53bd290f442d39b060e015c7aea.tar.gz
linux-stable-c17495b01b72b53bd290f442d39b060e015c7aea.tar.bz2
linux-stable-c17495b01b72b53bd290f442d39b060e015c7aea.zip
cpufreq: Add callback to register with energy model
Many cpufreq drivers register with the energy model for each policy and do exactly the same thing. Follow the footsteps of thermal-cooling, to get it done from the cpufreq core itself. Provide a new callback, which will be called, if present, by the cpufreq core at the right moment (more on that in the code's comment). Also provide a generic implementation that uses dev_pm_opp_of_register_em(). This also allows us to register with the EM at a later point of time, compared to ->init(), from where the EM core can access cpufreq policy directly using cpufreq_cpu_get() type of helpers and perform other work, like marking few frequencies inefficient, this will be done separately. Reviewed-by: Quentin Perret <qperret@google.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'include/linux/cpufreq.h')
-rw-r--r--include/linux/cpufreq.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 9fd719475fcd..c65a1d7385f8 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -9,10 +9,12 @@
#define _LINUX_CPUFREQ_H
#include <linux/clk.h>
+#include <linux/cpu.h>
#include <linux/cpumask.h>
#include <linux/completion.h>
#include <linux/kobject.h>
#include <linux/notifier.h>
+#include <linux/pm_opp.h>
#include <linux/pm_qos.h>
#include <linux/spinlock.h>
#include <linux/sysfs.h>
@@ -373,6 +375,12 @@ struct cpufreq_driver {
/* platform specific boost support code */
bool boost_enabled;
int (*set_boost)(struct cpufreq_policy *policy, int state);
+
+ /*
+ * Set by drivers that want to register with the energy model after the
+ * policy is properly initialized, but before the governor is started.
+ */
+ void (*register_em)(struct cpufreq_policy *policy);
};
/* flags */
@@ -1046,4 +1054,10 @@ unsigned int cpufreq_generic_get(unsigned int cpu);
void cpufreq_generic_init(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table,
unsigned int transition_latency);
+
+static inline void cpufreq_register_em_with_opp(struct cpufreq_policy *policy)
+{
+ dev_pm_opp_of_register_em(get_cpu_device(policy->cpu),
+ policy->related_cpus);
+}
#endif /* _LINUX_CPUFREQ_H */