opp.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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/cpufreq.h>
  17. #include <linux/notifier.h>
  18. struct opp;
  19. struct device;
  20. enum opp_event {
  21. OPP_EVENT_ADD, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,
  22. };
  23. #if defined(CONFIG_PM_OPP)
  24. unsigned long opp_get_voltage(struct opp *opp);
  25. unsigned long opp_get_freq(struct opp *opp);
  26. int opp_get_opp_count(struct device *dev);
  27. struct opp *opp_find_freq_exact(struct device *dev, unsigned long freq,
  28. bool available);
  29. struct opp *opp_find_freq_floor(struct device *dev, unsigned long *freq);
  30. struct opp *opp_find_freq_ceil(struct device *dev, unsigned long *freq);
  31. int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt);
  32. int opp_enable(struct device *dev, unsigned long freq);
  33. int opp_disable(struct device *dev, unsigned long freq);
  34. struct srcu_notifier_head *opp_get_notifier(struct device *dev);
  35. #else
  36. static inline unsigned long opp_get_voltage(struct opp *opp)
  37. {
  38. return 0;
  39. }
  40. static inline unsigned long opp_get_freq(struct opp *opp)
  41. {
  42. return 0;
  43. }
  44. static inline int opp_get_opp_count(struct device *dev)
  45. {
  46. return 0;
  47. }
  48. static inline struct opp *opp_find_freq_exact(struct device *dev,
  49. unsigned long freq, bool available)
  50. {
  51. return ERR_PTR(-EINVAL);
  52. }
  53. static inline struct opp *opp_find_freq_floor(struct device *dev,
  54. unsigned long *freq)
  55. {
  56. return ERR_PTR(-EINVAL);
  57. }
  58. static inline struct opp *opp_find_freq_ceil(struct device *dev,
  59. unsigned long *freq)
  60. {
  61. return ERR_PTR(-EINVAL);
  62. }
  63. static inline int opp_add(struct device *dev, unsigned long freq,
  64. unsigned long u_volt)
  65. {
  66. return -EINVAL;
  67. }
  68. static inline int opp_enable(struct device *dev, unsigned long freq)
  69. {
  70. return 0;
  71. }
  72. static inline int opp_disable(struct device *dev, unsigned long freq)
  73. {
  74. return 0;
  75. }
  76. static inline struct srcu_notifier_head *opp_get_notifier(struct device *dev)
  77. {
  78. return ERR_PTR(-EINVAL);
  79. }
  80. #endif /* CONFIG_PM_OPP */
  81. #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
  82. int of_init_opp_table(struct device *dev);
  83. #else
  84. static inline int of_init_opp_table(struct device *dev)
  85. {
  86. return -EINVAL;
  87. }
  88. #endif
  89. #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
  90. int opp_init_cpufreq_table(struct device *dev,
  91. struct cpufreq_frequency_table **table);
  92. void opp_free_cpufreq_table(struct device *dev,
  93. struct cpufreq_frequency_table **table);
  94. #else
  95. static inline int opp_init_cpufreq_table(struct device *dev,
  96. struct cpufreq_frequency_table **table)
  97. {
  98. return -EINVAL;
  99. }
  100. static inline
  101. void opp_free_cpufreq_table(struct device *dev,
  102. struct cpufreq_frequency_table **table)
  103. {
  104. }
  105. #endif /* CONFIG_CPU_FREQ */
  106. #endif /* __LINUX_OPP_H__ */