Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / include / linux / opp.h
1 /*
2  * Generic OPP Interface
3  *
4  * Copyright (C) 2009-2010 Texas Instruments Incorporated.
5  *      Nishanth Menon
6  *      Romit Dasgupta
7  *      Kevin Hilman
8  *
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.
12  */
13
14 #ifndef __LINUX_OPP_H__
15 #define __LINUX_OPP_H__
16
17 #include <linux/err.h>
18 #include <linux/cpufreq.h>
19 #include <linux/notifier.h>
20
21 struct opp;
22
23 enum opp_event {
24         OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
25 };
26
27 #if defined(CONFIG_PM_OPP)
28
29 unsigned long opp_get_voltage(struct opp *opp);
30
31 unsigned long opp_get_freq(struct opp *opp);
32
33 int opp_get_opp_count(struct device *dev);
34
35 struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
36                                 bool available);
37
38 struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
39
40 struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
41
42 int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
43
44 int opp_enable(struct device *dev, unsigned long freq);
45
46 int opp_disable(struct device *dev, unsigned long freq);
47
48 struct srcu_notifier_head *opp_get_notifier(struct device *dev);
49
50 /* hacks */
51 int opp_enable_i(struct device *dev, int index);
52 int opp_disable_i(struct device *dev, int index);
53 int opp_hack_set_freq(struct device *dev, int index, unsigned long freq);
54 int opp_hack_get_freq(struct device *dev, int index, unsigned long *freq);
55
56 #else
57 static inline unsigned long opp_get_voltage(struct opp *opp)
58 {
59         return 0;
60 }
61
62 static inline unsigned long opp_get_freq(struct opp *opp)
63 {
64         return 0;
65 }
66
67 static inline int opp_get_opp_count(struct device *dev)
68 {
69         return 0;
70 }
71
72 static inline struct opp *opp_find_freq_exact(struct device *dev,
73                                         unsigned long freq, bool available)
74 {
75         return ERR_PTR(-EINVAL);
76 }
77
78 static inline struct opp *opp_find_freq_floor(struct device *dev,
79                                         unsigned long *freq)
80 {
81         return ERR_PTR(-EINVAL);
82 }
83
84 static inline struct opp *opp_find_freq_ceil(struct device *dev,
85                                         unsigned long *freq)
86 {
87         return ERR_PTR(-EINVAL);
88 }
89
90 static inline int opp_add(struct device *dev, unsigned long freq,
91                                         unsigned long u_volt)
92 {
93         return -EINVAL;
94 }
95
96 static inline int opp_enable(struct device *dev, unsigned long freq)
97 {
98         return 0;
99 }
100
101 static inline int opp_disable(struct device *dev, unsigned long freq)
102 {
103         return 0;
104 }
105
106 static inline struct srcu_notifier_head *opp_get_notifier(struct device *dev)
107 {
108         return ERR_PTR(-EINVAL);
109 }
110 #endif          /* CONFIG_PM_OPP */
111
112 #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
113 int opp_init_cpufreq_table(struct device *dev,
114                             struct cpufreq_frequency_table **table);
115 void opp_free_cpufreq_table(struct device *dev,
116                                 struct cpufreq_frequency_table **table);
117 #else
118 static inline int opp_init_cpufreq_table(struct device *dev,
119                             struct cpufreq_frequency_table **table)
120 {
121         return -EINVAL;
122 }
123
124 static inline
125 void opp_free_cpufreq_table(struct device *dev,
126                                 struct cpufreq_frequency_table **table)
127 {
128 }
129 #endif          /* CONFIG_CPU_FREQ */
130
131 #endif          /* __LINUX_OPP_H__ */