opp.h 2.5 KB

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