opp.h 2.7 KB

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