Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
[linux-2.6.git] / include / linux / pm_opp.h
blob5151b005958500c75f8b81d03e5a4bf93c962998
1 /*
2 * Generic OPP Interface
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
5 * Nishanth Menon
6 * Romit Dasgupta
7 * Kevin Hilman
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/cpufreq.h>
19 #include <linux/notifier.h>
21 struct dev_pm_opp;
22 struct device;
24 enum dev_pm_opp_event {
25 OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
28 #if defined(CONFIG_PM_OPP)
30 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
32 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
34 int dev_pm_opp_get_opp_count(struct device *dev);
36 struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
37 unsigned long freq,
38 bool available);
40 struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
41 unsigned long *freq);
43 struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
44 unsigned long *freq);
46 int dev_pm_opp_add(struct device *dev, unsigned long freq,
47 unsigned long u_volt);
49 int dev_pm_opp_enable(struct device *dev, unsigned long freq);
51 int dev_pm_opp_disable(struct device *dev, unsigned long freq);
53 struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
54 #else
55 static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
57 return 0;
60 static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
62 return 0;
65 static inline int dev_pm_opp_get_opp_count(struct device *dev)
67 return 0;
70 static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
71 unsigned long freq, bool available)
73 return ERR_PTR(-EINVAL);
76 static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
77 unsigned long *freq)
79 return ERR_PTR(-EINVAL);
82 static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
83 unsigned long *freq)
85 return ERR_PTR(-EINVAL);
88 static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
89 unsigned long u_volt)
91 return -EINVAL;
94 static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
96 return 0;
99 static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
101 return 0;
104 static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
105 struct device *dev)
107 return ERR_PTR(-EINVAL);
109 #endif /* CONFIG_PM_OPP */
111 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
112 int of_init_opp_table(struct device *dev);
113 #else
114 static inline int of_init_opp_table(struct device *dev)
116 return -EINVAL;
118 #endif
120 #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
121 int dev_pm_opp_init_cpufreq_table(struct device *dev,
122 struct cpufreq_frequency_table **table);
123 void dev_pm_opp_free_cpufreq_table(struct device *dev,
124 struct cpufreq_frequency_table **table);
125 #else
126 static inline int dev_pm_opp_init_cpufreq_table(struct device *dev,
127 struct cpufreq_frequency_table **table)
129 return -EINVAL;
132 static inline
133 void dev_pm_opp_free_cpufreq_table(struct device *dev,
134 struct cpufreq_frequency_table **table)
137 #endif /* CONFIG_CPU_FREQ */
139 #endif /* __LINUX_OPP_H__ */