]>
Commit | Line | Data |
---|---|---|
e1f60b29 NM |
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> | |
03ca370f | 19 | #include <linux/notifier.h> |
e1f60b29 NM |
20 | |
21 | struct opp; | |
313162d0 | 22 | struct device; |
e1f60b29 | 23 | |
03ca370f MH |
24 | enum opp_event { |
25 | OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, | |
26 | }; | |
27 | ||
e1f60b29 NM |
28 | #if defined(CONFIG_PM_OPP) |
29 | ||
5d4879cd | 30 | unsigned long dev_pm_opp_get_voltage(struct opp *opp); |
e1f60b29 | 31 | |
5d4879cd | 32 | unsigned long dev_pm_opp_get_freq(struct opp *opp); |
e1f60b29 | 33 | |
5d4879cd | 34 | int dev_pm_opp_get_opp_count(struct device *dev); |
e1f60b29 | 35 | |
5d4879cd | 36 | struct opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, |
e1f60b29 NM |
37 | bool available); |
38 | ||
5d4879cd | 39 | struct opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq); |
e1f60b29 | 40 | |
5d4879cd | 41 | struct opp *dev_pm_opp_find_freq_ceil(struct device *dev, unsigned long *freq); |
e1f60b29 | 42 | |
5d4879cd NM |
43 | int dev_pm_opp_add(struct device *dev, unsigned long freq, |
44 | unsigned long u_volt); | |
e1f60b29 | 45 | |
5d4879cd | 46 | int dev_pm_opp_enable(struct device *dev, unsigned long freq); |
e1f60b29 | 47 | |
5d4879cd | 48 | int dev_pm_opp_disable(struct device *dev, unsigned long freq); |
e1f60b29 | 49 | |
5d4879cd | 50 | struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev); |
e1f60b29 | 51 | #else |
5d4879cd | 52 | static inline unsigned long dev_pm_opp_get_voltage(struct opp *opp) |
e1f60b29 NM |
53 | { |
54 | return 0; | |
55 | } | |
56 | ||
5d4879cd | 57 | static inline unsigned long dev_pm_opp_get_freq(struct opp *opp) |
e1f60b29 NM |
58 | { |
59 | return 0; | |
60 | } | |
61 | ||
5d4879cd | 62 | static inline int dev_pm_opp_get_opp_count(struct device *dev) |
e1f60b29 NM |
63 | { |
64 | return 0; | |
65 | } | |
66 | ||
5d4879cd | 67 | static inline struct opp *dev_pm_opp_find_freq_exact(struct device *dev, |
e1f60b29 NM |
68 | unsigned long freq, bool available) |
69 | { | |
70 | return ERR_PTR(-EINVAL); | |
71 | } | |
72 | ||
5d4879cd | 73 | static inline struct opp *dev_pm_opp_find_freq_floor(struct device *dev, |
e1f60b29 NM |
74 | unsigned long *freq) |
75 | { | |
76 | return ERR_PTR(-EINVAL); | |
77 | } | |
78 | ||
5d4879cd | 79 | static inline struct opp *dev_pm_opp_find_freq_ceil(struct device *dev, |
e1f60b29 NM |
80 | unsigned long *freq) |
81 | { | |
82 | return ERR_PTR(-EINVAL); | |
83 | } | |
84 | ||
5d4879cd | 85 | static inline int dev_pm_opp_add(struct device *dev, unsigned long freq, |
e1f60b29 NM |
86 | unsigned long u_volt) |
87 | { | |
88 | return -EINVAL; | |
89 | } | |
90 | ||
5d4879cd | 91 | static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq) |
e1f60b29 NM |
92 | { |
93 | return 0; | |
94 | } | |
95 | ||
5d4879cd | 96 | static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq) |
e1f60b29 NM |
97 | { |
98 | return 0; | |
99 | } | |
03ca370f | 100 | |
5d4879cd NM |
101 | static inline struct srcu_notifier_head *dev_pm_opp_get_notifier( |
102 | struct device *dev) | |
03ca370f MH |
103 | { |
104 | return ERR_PTR(-EINVAL); | |
105 | } | |
a96d69d1 | 106 | #endif /* CONFIG_PM_OPP */ |
e1f60b29 | 107 | |
d6561bb2 SG |
108 | #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) |
109 | int of_init_opp_table(struct device *dev); | |
110 | #else | |
111 | static inline int of_init_opp_table(struct device *dev) | |
112 | { | |
113 | return -EINVAL; | |
114 | } | |
115 | #endif | |
116 | ||
e1f60b29 | 117 | #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) |
5d4879cd | 118 | int dev_pm_opp_init_cpufreq_table(struct device *dev, |
e1f60b29 | 119 | struct cpufreq_frequency_table **table); |
5d4879cd | 120 | void dev_pm_opp_free_cpufreq_table(struct device *dev, |
99f381d3 | 121 | struct cpufreq_frequency_table **table); |
e1f60b29 | 122 | #else |
5d4879cd | 123 | static inline int dev_pm_opp_init_cpufreq_table(struct device *dev, |
e1f60b29 NM |
124 | struct cpufreq_frequency_table **table) |
125 | { | |
126 | return -EINVAL; | |
127 | } | |
99f381d3 NM |
128 | |
129 | static inline | |
5d4879cd | 130 | void dev_pm_opp_free_cpufreq_table(struct device *dev, |
99f381d3 NM |
131 | struct cpufreq_frequency_table **table) |
132 | { | |
133 | } | |
e1f60b29 NM |
134 | #endif /* CONFIG_CPU_FREQ */ |
135 | ||
136 | #endif /* __LINUX_OPP_H__ */ |