pm_opp.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. #ifndef __LINUX_OPP_H__
  14. #define __LINUX_OPP_H__
  15. #include <linux/err.h>
  16. #include <linux/notifier.h>
  17. struct dev_pm_opp;
  18. struct device;
  19. enum dev_pm_opp_event {
  20. OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
  21. };
  22. #if defined(CONFIG_PM_OPP)
  23. unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
  24. unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
  25. bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
  26. int dev_pm_opp_get_opp_count(struct device *dev);
  27. unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
  28. unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev);
  29. unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev);
  30. struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev);
  31. struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
  32. unsigned long freq,
  33. bool available);
  34. struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
  35. unsigned long *freq);
  36. struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
  37. unsigned long *freq);
  38. int dev_pm_opp_add(struct device *dev, unsigned long freq,
  39. unsigned long u_volt);
  40. void dev_pm_opp_remove(struct device *dev, unsigned long freq);
  41. int dev_pm_opp_enable(struct device *dev, unsigned long freq);
  42. int dev_pm_opp_disable(struct device *dev, unsigned long freq);
  43. struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
  44. int dev_pm_opp_set_supported_hw(struct device *dev, const u32 *versions,
  45. unsigned int count);
  46. void dev_pm_opp_put_supported_hw(struct device *dev);
  47. int dev_pm_opp_set_prop_name(struct device *dev, const char *name);
  48. void dev_pm_opp_put_prop_name(struct device *dev);
  49. int dev_pm_opp_set_regulator(struct device *dev, const char *name);
  50. void dev_pm_opp_put_regulator(struct device *dev);
  51. int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
  52. int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask);
  53. int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
  54. void dev_pm_opp_remove_table(struct device *dev);
  55. void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask);
  56. #else
  57. static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
  58. {
  59. return 0;
  60. }
  61. static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
  62. {
  63. return 0;
  64. }
  65. static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
  66. {
  67. return false;
  68. }
  69. static inline int dev_pm_opp_get_opp_count(struct device *dev)
  70. {
  71. return 0;
  72. }
  73. static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
  74. {
  75. return 0;
  76. }
  77. static inline unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
  78. {
  79. return 0;
  80. }
  81. static inline unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev)
  82. {
  83. return 0;
  84. }
  85. static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
  86. {
  87. return NULL;
  88. }
  89. static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
  90. unsigned long freq, bool available)
  91. {
  92. return ERR_PTR(-ENOTSUPP);
  93. }
  94. static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
  95. unsigned long *freq)
  96. {
  97. return ERR_PTR(-ENOTSUPP);
  98. }
  99. static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
  100. unsigned long *freq)
  101. {
  102. return ERR_PTR(-ENOTSUPP);
  103. }
  104. static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
  105. unsigned long u_volt)
  106. {
  107. return -ENOTSUPP;
  108. }
  109. static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
  110. {
  111. }
  112. static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
  113. {
  114. return 0;
  115. }
  116. static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
  117. {
  118. return 0;
  119. }
  120. static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
  121. struct device *dev)
  122. {
  123. return ERR_PTR(-ENOTSUPP);
  124. }
  125. static inline int dev_pm_opp_set_supported_hw(struct device *dev,
  126. const u32 *versions,
  127. unsigned int count)
  128. {
  129. return -ENOTSUPP;
  130. }
  131. static inline void dev_pm_opp_put_supported_hw(struct device *dev) {}
  132. static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name)
  133. {
  134. return -ENOTSUPP;
  135. }
  136. static inline void dev_pm_opp_put_prop_name(struct device *dev) {}
  137. static inline int dev_pm_opp_set_regulator(struct device *dev, const char *name)
  138. {
  139. return -ENOTSUPP;
  140. }
  141. static inline void dev_pm_opp_put_regulator(struct device *dev) {}
  142. static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
  143. {
  144. return -ENOTSUPP;
  145. }
  146. static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask)
  147. {
  148. return -ENOTSUPP;
  149. }
  150. static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
  151. {
  152. return -EINVAL;
  153. }
  154. static inline void dev_pm_opp_remove_table(struct device *dev)
  155. {
  156. }
  157. static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask)
  158. {
  159. }
  160. #endif /* CONFIG_PM_OPP */
  161. #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
  162. int dev_pm_opp_of_add_table(struct device *dev);
  163. void dev_pm_opp_of_remove_table(struct device *dev);
  164. int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask);
  165. void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask);
  166. int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
  167. #else
  168. static inline int dev_pm_opp_of_add_table(struct device *dev)
  169. {
  170. return -ENOTSUPP;
  171. }
  172. static inline void dev_pm_opp_of_remove_table(struct device *dev)
  173. {
  174. }
  175. static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask)
  176. {
  177. return -ENOTSUPP;
  178. }
  179. static inline void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask)
  180. {
  181. }
  182. static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
  183. {
  184. return -ENOTSUPP;
  185. }
  186. #endif
  187. #endif /* __LINUX_OPP_H__ */