2 * Generic OPP Interface
4 * Copyright (C) 2009-2010 Texas Instruments Incorporated.
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.
14 #ifndef __LINUX_OPP_H__
15 #define __LINUX_OPP_H__
17 #include <linux/err.h>
18 #include <linux/notifier.h>
23 enum dev_pm_opp_event {
24 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
27 #if defined(CONFIG_PM_OPP)
29 unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
31 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
33 int dev_pm_opp_get_opp_count(struct device *dev);
35 struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
39 struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
42 struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
45 int dev_pm_opp_add(struct device *dev, unsigned long freq,
46 unsigned long u_volt);
47 void dev_pm_opp_remove(struct device *dev, unsigned long freq);
49 int dev_pm_opp_enable(struct device *dev, unsigned long freq);
51 int dev_pm_opp_disable(struct device *dev, unsigned long freq);
53 struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
55 static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
60 static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
65 static inline int dev_pm_opp_get_opp_count(struct device *dev)
70 static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
71 unsigned long freq, bool available)
73 return ERR_PTR(-EINVAL);
76 static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
79 return ERR_PTR(-EINVAL);
82 static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
85 return ERR_PTR(-EINVAL);
88 static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
94 static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
98 static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
103 static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
108 static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
111 return ERR_PTR(-EINVAL);
113 #endif /* CONFIG_PM_OPP */
115 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
116 int of_init_opp_table(struct device *dev);
117 void of_free_opp_table(struct device *dev);
119 static inline int of_init_opp_table(struct device *dev)
124 static inline void of_free_opp_table(struct device *dev)
129 #endif /* __LINUX_OPP_H__ */