pm_opp.h 6.1 KB

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