Nishanth Menon | e1f60b2 | 2010-10-13 00:13:10 +0200 | [diff] [blame] | 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> |
MyungJoo Ham | 03ca370 | 2011-09-30 22:35:12 +0200 | [diff] [blame] | 19 | #include <linux/notifier.h> |
Nishanth Menon | e1f60b2 | 2010-10-13 00:13:10 +0200 | [diff] [blame] | 20 | |
| 21 | struct opp; |
Paul Gortmaker | 313162d | 2012-01-30 11:46:54 -0500 | [diff] [blame] | 22 | struct device; |
Nishanth Menon | e1f60b2 | 2010-10-13 00:13:10 +0200 | [diff] [blame] | 23 | |
MyungJoo Ham | 03ca370 | 2011-09-30 22:35:12 +0200 | [diff] [blame] | 24 | enum opp_event { |
| 25 | OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE, |
| 26 | }; |
| 27 | |
Nishanth Menon | e1f60b2 | 2010-10-13 00:13:10 +0200 | [diff] [blame] | 28 | #if defined(CONFIG_PM_OPP) |
| 29 | |
| 30 | unsigned long opp_get_voltage(struct opp *opp); |
| 31 | |
| 32 | unsigned long opp_get_freq(struct opp *opp); |
| 33 | |
| 34 | int opp_get_opp_count(struct device *dev); |
| 35 | |
| 36 | struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq, |
| 37 | bool available); |
| 38 | |
| 39 | struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq); |
| 40 | |
| 41 | struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq); |
| 42 | |
| 43 | int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt); |
| 44 | |
| 45 | int opp_enable(struct device *dev, unsigned long freq); |
| 46 | |
| 47 | int opp_disable(struct device *dev, unsigned long freq); |
| 48 | |
MyungJoo Ham | 03ca370 | 2011-09-30 22:35:12 +0200 | [diff] [blame] | 49 | struct srcu_notifier_head *opp_get_notifier(struct device *dev); |
| 50 | |
Nishanth Menon | e1f60b2 | 2010-10-13 00:13:10 +0200 | [diff] [blame] | 51 | #else |
| 52 | static inline unsigned long opp_get_voltage(struct opp *opp) |
| 53 | { |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | static inline unsigned long opp_get_freq(struct opp *opp) |
| 58 | { |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | static inline int opp_get_opp_count(struct device *dev) |
| 63 | { |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | static inline struct opp *opp_find_freq_exact(struct device *dev, |
| 68 | unsigned long freq, bool available) |
| 69 | { |
| 70 | return ERR_PTR(-EINVAL); |
| 71 | } |
| 72 | |
| 73 | static inline struct opp *opp_find_freq_floor(struct device *dev, |
| 74 | unsigned long *freq) |
| 75 | { |
| 76 | return ERR_PTR(-EINVAL); |
| 77 | } |
| 78 | |
| 79 | static inline struct opp *opp_find_freq_ceil(struct device *dev, |
| 80 | unsigned long *freq) |
| 81 | { |
| 82 | return ERR_PTR(-EINVAL); |
| 83 | } |
| 84 | |
| 85 | static inline int opp_add(struct device *dev, unsigned long freq, |
| 86 | unsigned long u_volt) |
| 87 | { |
| 88 | return -EINVAL; |
| 89 | } |
| 90 | |
| 91 | static inline int opp_enable(struct device *dev, unsigned long freq) |
| 92 | { |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | static inline int opp_disable(struct device *dev, unsigned long freq) |
| 97 | { |
| 98 | return 0; |
| 99 | } |
MyungJoo Ham | 03ca370 | 2011-09-30 22:35:12 +0200 | [diff] [blame] | 100 | |
Tony Lindgren | a96d69d | 2011-11-03 10:12:27 +0100 | [diff] [blame] | 101 | static inline struct srcu_notifier_head *opp_get_notifier(struct device *dev) |
MyungJoo Ham | 03ca370 | 2011-09-30 22:35:12 +0200 | [diff] [blame] | 102 | { |
| 103 | return ERR_PTR(-EINVAL); |
| 104 | } |
Tony Lindgren | a96d69d | 2011-11-03 10:12:27 +0100 | [diff] [blame] | 105 | #endif /* CONFIG_PM_OPP */ |
Nishanth Menon | e1f60b2 | 2010-10-13 00:13:10 +0200 | [diff] [blame] | 106 | |
| 107 | #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) |
| 108 | int opp_init_cpufreq_table(struct device *dev, |
| 109 | struct cpufreq_frequency_table **table); |
Nishanth Menon | 99f381d | 2011-06-10 20:24:57 +0200 | [diff] [blame] | 110 | void opp_free_cpufreq_table(struct device *dev, |
| 111 | struct cpufreq_frequency_table **table); |
Nishanth Menon | e1f60b2 | 2010-10-13 00:13:10 +0200 | [diff] [blame] | 112 | #else |
| 113 | static inline int opp_init_cpufreq_table(struct device *dev, |
| 114 | struct cpufreq_frequency_table **table) |
| 115 | { |
| 116 | return -EINVAL; |
| 117 | } |
Nishanth Menon | 99f381d | 2011-06-10 20:24:57 +0200 | [diff] [blame] | 118 | |
| 119 | static inline |
| 120 | void opp_free_cpufreq_table(struct device *dev, |
| 121 | struct cpufreq_frequency_table **table) |
| 122 | { |
| 123 | } |
Nishanth Menon | e1f60b2 | 2010-10-13 00:13:10 +0200 | [diff] [blame] | 124 | #endif /* CONFIG_CPU_FREQ */ |
| 125 | |
| 126 | #endif /* __LINUX_OPP_H__ */ |