PM / OPP: Add helpers for initializing CPU OPPs
[platform/kernel/linux-exynos.git] / include / linux / pm_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/notifier.h>
19
20 struct dev_pm_opp;
21 struct device;
22
23 enum dev_pm_opp_event {
24         OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
25 };
26
27 #if defined(CONFIG_PM_OPP)
28
29 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
30
31 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
32
33 int dev_pm_opp_get_opp_count(struct device *dev);
34 unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
35
36 struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
37                                               unsigned long freq,
38                                               bool available);
39
40 struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
41                                               unsigned long *freq);
42
43 struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
44                                              unsigned long *freq);
45
46 int dev_pm_opp_add(struct device *dev, unsigned long freq,
47                    unsigned long u_volt);
48 void dev_pm_opp_remove(struct device *dev, unsigned long freq);
49
50 int dev_pm_opp_enable(struct device *dev, unsigned long freq);
51
52 int dev_pm_opp_disable(struct device *dev, unsigned long freq);
53
54 struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
55 #else
56 static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
57 {
58         return 0;
59 }
60
61 static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
62 {
63         return 0;
64 }
65
66 static inline int dev_pm_opp_get_opp_count(struct device *dev)
67 {
68         return 0;
69 }
70
71 static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
72 {
73         return 0;
74 }
75
76 static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
77                                         unsigned long freq, bool available)
78 {
79         return ERR_PTR(-EINVAL);
80 }
81
82 static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
83                                         unsigned long *freq)
84 {
85         return ERR_PTR(-EINVAL);
86 }
87
88 static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
89                                         unsigned long *freq)
90 {
91         return ERR_PTR(-EINVAL);
92 }
93
94 static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
95                                         unsigned long u_volt)
96 {
97         return -EINVAL;
98 }
99
100 static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
101 {
102 }
103
104 static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
105 {
106         return 0;
107 }
108
109 static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
110 {
111         return 0;
112 }
113
114 static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
115                                                         struct device *dev)
116 {
117         return ERR_PTR(-EINVAL);
118 }
119 #endif          /* CONFIG_PM_OPP */
120
121 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
122 int of_init_opp_table(struct device *dev);
123 void of_free_opp_table(struct device *dev);
124 int of_cpumask_init_opp_table(cpumask_var_t cpumask);
125 void of_cpumask_free_opp_table(cpumask_var_t cpumask);
126 int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask);
127 int set_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask);
128 #else
129 static inline int of_init_opp_table(struct device *dev)
130 {
131         return -EINVAL;
132 }
133
134 static inline void of_free_opp_table(struct device *dev)
135 {
136 }
137
138 static inline int of_cpumask_init_opp_table(cpumask_var_t cpumask)
139 {
140         return -ENOSYS;
141 }
142
143 static inline void of_cpumask_free_opp_table(cpumask_var_t cpumask)
144 {
145 }
146
147 static inline int of_get_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask)
148 {
149         return -ENOSYS;
150 }
151
152 static inline int set_cpus_sharing_opps(struct device *cpu_dev, cpumask_var_t cpumask)
153 {
154         return -ENOSYS;
155 }
156 #endif
157
158 #endif          /* __LINUX_OPP_H__ */