2 * Generic OPP Interface
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #ifndef __LINUX_OPP_H__
15 #define __LINUX_OPP_H__
17 #include <linux/err.h>
18 #include <linux/notifier.h>
23 enum dev_pm_opp_event {
24 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
27 #if defined(CONFIG_PM_OPP)
29 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
31 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
33 bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
35 int dev_pm_opp_get_opp_count(struct device *dev);
36 unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
38 struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
42 struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
45 struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
48 int dev_pm_opp_add(struct device *dev, unsigned long freq,
49 unsigned long u_volt);
50 void dev_pm_opp_remove(struct device *dev, unsigned long freq);
52 int dev_pm_opp_enable(struct device *dev, unsigned long freq);
54 int dev_pm_opp_disable(struct device *dev, unsigned long freq);
56 struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
58 static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
63 static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
68 static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
73 static inline int dev_pm_opp_get_opp_count(struct device *dev)
78 static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
83 static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
84 unsigned long freq, bool available)
86 return ERR_PTR(-EINVAL);
89 static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
92 return ERR_PTR(-EINVAL);
95 static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
98 return ERR_PTR(-EINVAL);
101 static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
102 unsigned long u_volt)
107 static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
111 static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
116 static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
121 static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
124 return ERR_PTR(-EINVAL);
126 #endif /* CONFIG_PM_OPP */
128 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
129 int of_init_opp_table(struct device *dev);
130 void of_free_opp_table(struct device *dev);
131 int of_cpumask_init_opp_table(cpumask_var_t cpumask);
132 void of_cpumask_free_opp_table(cpumask_var_t cpumask);
133 int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask);
134 int set_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask);
136 static inline int of_init_opp_table(struct device *dev)
141 static inline void of_free_opp_table(struct device *dev)
145 static inline int of_cpumask_init_opp_table(cpumask_var_t cpumask)
150 static inline void of_cpumask_free_opp_table(cpumask_var_t cpumask)
154 static inline int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask)
159 static inline int set_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask)
165 #endif /* __LINUX_OPP_H__ */