• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_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 
35 struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
36 					      unsigned long freq,
37 					      bool available);
38 
39 struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
40 					      unsigned long *freq);
41 
42 struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
43 					     unsigned long *freq);
44 
45 int dev_pm_opp_add(struct device *dev, unsigned long freq,
46 		   unsigned long u_volt);
47 
48 int dev_pm_opp_enable(struct device *dev, unsigned long freq);
49 
50 int dev_pm_opp_disable(struct device *dev, unsigned long freq);
51 
52 struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
53 #else
dev_pm_opp_get_voltage(struct dev_pm_opp * opp)54 static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
55 {
56 	return 0;
57 }
58 
dev_pm_opp_get_freq(struct dev_pm_opp * opp)59 static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
60 {
61 	return 0;
62 }
63 
dev_pm_opp_get_opp_count(struct device * dev)64 static inline int dev_pm_opp_get_opp_count(struct device *dev)
65 {
66 	return 0;
67 }
68 
dev_pm_opp_find_freq_exact(struct device * dev,unsigned long freq,bool available)69 static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
70 					unsigned long freq, bool available)
71 {
72 	return ERR_PTR(-EINVAL);
73 }
74 
dev_pm_opp_find_freq_floor(struct device * dev,unsigned long * freq)75 static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
76 					unsigned long *freq)
77 {
78 	return ERR_PTR(-EINVAL);
79 }
80 
dev_pm_opp_find_freq_ceil(struct device * dev,unsigned long * freq)81 static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
82 					unsigned long *freq)
83 {
84 	return ERR_PTR(-EINVAL);
85 }
86 
dev_pm_opp_add(struct device * dev,unsigned long freq,unsigned long u_volt)87 static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
88 					unsigned long u_volt)
89 {
90 	return -EINVAL;
91 }
92 
dev_pm_opp_enable(struct device * dev,unsigned long freq)93 static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
94 {
95 	return 0;
96 }
97 
dev_pm_opp_disable(struct device * dev,unsigned long freq)98 static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
99 {
100 	return 0;
101 }
102 
dev_pm_opp_get_notifier(struct device * dev)103 static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
104 							struct device *dev)
105 {
106 	return ERR_PTR(-EINVAL);
107 }
108 #endif		/* CONFIG_PM_OPP */
109 
110 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
111 int of_init_opp_table(struct device *dev);
112 #else
of_init_opp_table(struct device * dev)113 static inline int of_init_opp_table(struct device *dev)
114 {
115 	return -EINVAL;
116 }
117 #endif
118 
119 #endif		/* __LINUX_OPP_H__ */
120