pm_opp.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. #else
  55. static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
  56. {
  57. return 0;
  58. }
  59. static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
  60. {
  61. return 0;
  62. }
  63. static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
  64. {
  65. return false;
  66. }
  67. static inline int dev_pm_opp_get_opp_count(struct device *dev)
  68. {
  69. return 0;
  70. }
  71. static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
  72. {
  73. return 0;
  74. }
  75. static inline unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
  76. {
  77. return 0;
  78. }
  79. static inline unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev)
  80. {
  81. return 0;
  82. }
  83. static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
  84. {
  85. return NULL;
  86. }
  87. static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
  88. unsigned long freq, bool available)
  89. {
  90. return ERR_PTR(-ENOTSUPP);
  91. }
  92. static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
  93. unsigned long *freq)
  94. {
  95. return ERR_PTR(-ENOTSUPP);
  96. }
  97. static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
  98. unsigned long *freq)
  99. {
  100. return ERR_PTR(-ENOTSUPP);
  101. }
  102. static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
  103. unsigned long u_volt)
  104. {
  105. return -ENOTSUPP;
  106. }
  107. static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
  108. {
  109. }
  110. static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
  111. {
  112. return 0;
  113. }
  114. static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
  115. {
  116. return 0;
  117. }
  118. static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
  119. struct device *dev)
  120. {
  121. return ERR_PTR(-ENOTSUPP);
  122. }
  123. static inline int dev_pm_opp_set_supported_hw(struct device *dev,
  124. const u32 *versions,
  125. unsigned int count)
  126. {
  127. return -ENOTSUPP;
  128. }
  129. static inline void dev_pm_opp_put_supported_hw(struct device *dev) {}
  130. static inline int dev_pm_opp_set_prop_name(struct device *dev, const char *name)
  131. {
  132. return -ENOTSUPP;
  133. }
  134. static inline void dev_pm_opp_put_prop_name(struct device *dev) {}
  135. static inline int dev_pm_opp_set_regulator(struct device *dev, const char *name)
  136. {
  137. return -ENOTSUPP;
  138. }
  139. static inline void dev_pm_opp_put_regulator(struct device *dev) {}
  140. static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
  141. {
  142. return -ENOTSUPP;
  143. }
  144. static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask)
  145. {
  146. return -ENOTSUPP;
  147. }
  148. static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
  149. {
  150. return -EINVAL;
  151. }
  152. #endif /* CONFIG_PM_OPP */
  153. #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
  154. int dev_pm_opp_of_add_table(struct device *dev);
  155. void dev_pm_opp_of_remove_table(struct device *dev);
  156. int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask);
  157. void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask);
  158. int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
  159. #else
  160. static inline int dev_pm_opp_of_add_table(struct device *dev)
  161. {
  162. return -ENOTSUPP;
  163. }
  164. static inline void dev_pm_opp_of_remove_table(struct device *dev)
  165. {
  166. }
  167. static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask)
  168. {
  169. return -ENOTSUPP;
  170. }
  171. static inline void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask)
  172. {
  173. }
  174. static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
  175. {
  176. return -ENOTSUPP;
  177. }
  178. #endif
  179. #endif /* __LINUX_OPP_H__ */