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. #ifdef CONFIG_OF
  36. int of_init_opp_table(struct device *dev);
  37. #else
  38. static inline int of_init_opp_table(struct device *dev)
  39. {
  40. return -EINVAL;
  41. }
  42. #endif /* CONFIG_OF */
  43. #else
  44. static inline unsigned long opp_get_voltage(struct opp *opp)
  45. {
  46. return 0;
  47. }
  48. static inline unsigned long opp_get_freq(struct opp *opp)
  49. {
  50. return 0;
  51. }
  52. static inline int opp_get_opp_count(struct device *dev)
  53. {
  54. return 0;
  55. }
  56. static inline struct opp *opp_find_freq_exact(struct device *dev,
  57. unsigned long freq, bool available)
  58. {
  59. return ERR_PTR(-EINVAL);
  60. }
  61. static inline struct opp *opp_find_freq_floor(struct device *dev,
  62. unsigned long *freq)
  63. {
  64. return ERR_PTR(-EINVAL);
  65. }
  66. static inline struct opp *opp_find_freq_ceil(struct device *dev,
  67. unsigned long *freq)
  68. {
  69. return ERR_PTR(-EINVAL);
  70. }
  71. static inline int opp_add(struct device *dev, unsigned long freq,
  72. unsigned long u_volt)
  73. {
  74. return -EINVAL;
  75. }
  76. static inline int opp_enable(struct device *dev, unsigned long freq)
  77. {
  78. return 0;
  79. }
  80. static inline int opp_disable(struct device *dev, unsigned long freq)
  81. {
  82. return 0;
  83. }
  84. static inline struct srcu_notifier_head *opp_get_notifier(struct device *dev)
  85. {
  86. return ERR_PTR(-EINVAL);
  87. }
  88. #endif /* CONFIG_PM_OPP */
  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__ */