pm_opp.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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_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. int dev_pm_opp_get_opp_count(struct device *dev);
  26. struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
  27. unsigned long freq,
  28. bool available);
  29. struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
  30. unsigned long *freq);
  31. struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
  32. unsigned long *freq);
  33. int dev_pm_opp_add(struct device *dev, unsigned long freq,
  34. unsigned long u_volt);
  35. int dev_pm_opp_enable(struct device *dev, unsigned long freq);
  36. int dev_pm_opp_disable(struct device *dev, unsigned long freq);
  37. struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev);
  38. #else
  39. static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
  40. {
  41. return 0;
  42. }
  43. static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
  44. {
  45. return 0;
  46. }
  47. static inline int dev_pm_opp_get_opp_count(struct device *dev)
  48. {
  49. return 0;
  50. }
  51. static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev,
  52. unsigned long freq, bool available)
  53. {
  54. return ERR_PTR(-EINVAL);
  55. }
  56. static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
  57. unsigned long *freq)
  58. {
  59. return ERR_PTR(-EINVAL);
  60. }
  61. static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
  62. unsigned long *freq)
  63. {
  64. return ERR_PTR(-EINVAL);
  65. }
  66. static inline int dev_pm_opp_add(struct device *dev, unsigned long freq,
  67. unsigned long u_volt)
  68. {
  69. return -EINVAL;
  70. }
  71. static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)
  72. {
  73. return 0;
  74. }
  75. static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)
  76. {
  77. return 0;
  78. }
  79. static inline struct srcu_notifier_head *dev_pm_opp_get_notifier(
  80. struct device *dev)
  81. {
  82. return ERR_PTR(-EINVAL);
  83. }
  84. #endif /* CONFIG_PM_OPP */
  85. #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
  86. int of_init_opp_table(struct device *dev);
  87. #else
  88. static inline int of_init_opp_table(struct device *dev)
  89. {
  90. return -EINVAL;
  91. }
  92. #endif
  93. #endif /* __LINUX_OPP_H__ */