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