pm_opp.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev);
  29. struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
  30. unsigned long freq,
  31. bool available);
  32. struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
  33. unsigned long *freq);
  34. struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
  35. unsigned long *freq);
  36. int dev_pm_opp_add(struct device *dev, unsigned long freq,
  37. unsigned long u_volt);
  38. void dev_pm_opp_remove(struct device *dev, unsigned long freq);
  39. int dev_pm_opp_enable(struct device *dev, unsigned long freq);
  40. int dev_pm_opp_disable(struct device *dev, unsigned long freq);
  41. struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
  42. int dev_pm_opp_set_supported_hw(struct device *dev, const u32 *versions,
  43. unsigned int count);
  44. void dev_pm_opp_put_supported_hw(struct device *dev);
  45. #else
  46. static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
  47. {
  48. return 0;
  49. }
  50. static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
  51. {
  52. return 0;
  53. }
  54. static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
  55. {
  56. return false;
  57. }
  58. static inline int dev_pm_opp_get_opp_count(struct device *dev)
  59. {
  60. return 0;
  61. }
  62. static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
  63. {
  64. return 0;
  65. }
  66. static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)
  67. {
  68. return NULL;
  69. }
  70. static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
  71. unsigned long freq, bool available)
  72. {
  73. return ERR_PTR(-EINVAL);
  74. }
  75. static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
  76. unsigned long *freq)
  77. {
  78. return ERR_PTR(-EINVAL);
  79. }
  80. static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
  81. unsigned long *freq)
  82. {
  83. return ERR_PTR(-EINVAL);
  84. }
  85. static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
  86. unsigned long u_volt)
  87. {
  88. return -EINVAL;
  89. }
  90. static inline void dev_pm_opp_remove(struct device *dev, unsigned long freq)
  91. {
  92. }
  93. static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
  94. {
  95. return 0;
  96. }
  97. static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
  98. {
  99. return 0;
  100. }
  101. static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
  102. struct device *dev)
  103. {
  104. return ERR_PTR(-EINVAL);
  105. }
  106. static inline int dev_pm_opp_set_supported_hw(struct device *dev,
  107. const u32 *versions,
  108. unsigned int count)
  109. {
  110. return -EINVAL;
  111. }
  112. static inline void dev_pm_opp_put_supported_hw(struct device *dev) {}
  113. #endif /* CONFIG_PM_OPP */
  114. #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
  115. int dev_pm_opp_of_add_table(struct device *dev);
  116. void dev_pm_opp_of_remove_table(struct device *dev);
  117. int dev_pm_opp_of_cpumask_add_table(cpumask_var_t cpumask);
  118. void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask);
  119. int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);
  120. int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);
  121. #else
  122. static inline int dev_pm_opp_of_add_table(struct device *dev)
  123. {
  124. return -EINVAL;
  125. }
  126. static inline void dev_pm_opp_of_remove_table(struct device *dev)
  127. {
  128. }
  129. static inline int dev_pm_opp_of_cpumask_add_table(cpumask_var_t cpumask)
  130. {
  131. return -ENOSYS;
  132. }
  133. static inline void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask)
  134. {
  135. }
  136. static inline int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)
  137. {
  138. return -ENOSYS;
  139. }
  140. static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)
  141. {
  142. return -ENOSYS;
  143. }
  144. #endif
  145. #endif /* __LINUX_OPP_H__ */