cpu_cooling.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * linux/include/linux/cpu_cooling.h
  3. *
  4. * Copyright (C) 2012 Samsung Electronics Co., Ltd(http://www.samsung.com)
  5. * Copyright (C) 2012 Amit Daniel <amit.kachhap@linaro.org>
  6. *
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, write to the Free Software Foundation, Inc.,
  19. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  20. *
  21. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. */
  23. #ifndef __CPU_COOLING_H__
  24. #define __CPU_COOLING_H__
  25. #include <linux/of.h>
  26. #include <linux/thermal.h>
  27. #include <linux/cpumask.h>
  28. struct cpufreq_policy;
  29. typedef int (*get_static_t)(cpumask_t *cpumask, int interval,
  30. unsigned long voltage, u32 *power);
  31. #ifdef CONFIG_CPU_THERMAL
  32. /**
  33. * cpufreq_cooling_register - function to create cpufreq cooling device.
  34. * @policy: cpufreq policy.
  35. */
  36. struct thermal_cooling_device *
  37. cpufreq_cooling_register(struct cpufreq_policy *policy);
  38. struct thermal_cooling_device *
  39. cpufreq_power_cooling_register(struct cpufreq_policy *policy,
  40. u32 capacitance, get_static_t plat_static_func);
  41. /**
  42. * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
  43. * @np: a valid struct device_node to the cooling device device tree node.
  44. * @policy: cpufreq policy.
  45. */
  46. #ifdef CONFIG_THERMAL_OF
  47. struct thermal_cooling_device *
  48. of_cpufreq_cooling_register(struct device_node *np,
  49. struct cpufreq_policy *policy);
  50. struct thermal_cooling_device *
  51. of_cpufreq_power_cooling_register(struct cpufreq_policy *policy);
  52. #else
  53. static inline struct thermal_cooling_device *
  54. of_cpufreq_cooling_register(struct device_node *np,
  55. struct cpufreq_policy *policy)
  56. {
  57. return ERR_PTR(-ENOSYS);
  58. }
  59. static inline struct thermal_cooling_device *
  60. of_cpufreq_power_cooling_register(struct cpufreq_policy *policy)
  61. {
  62. return NULL;
  63. }
  64. #endif
  65. /**
  66. * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
  67. * @cdev: thermal cooling device pointer.
  68. */
  69. void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
  70. #else /* !CONFIG_CPU_THERMAL */
  71. static inline struct thermal_cooling_device *
  72. cpufreq_cooling_register(struct cpufreq_policy *policy)
  73. {
  74. return ERR_PTR(-ENOSYS);
  75. }
  76. static inline struct thermal_cooling_device *
  77. cpufreq_power_cooling_register(struct cpufreq_policy *policy,
  78. u32 capacitance, get_static_t plat_static_func)
  79. {
  80. return NULL;
  81. }
  82. static inline struct thermal_cooling_device *
  83. of_cpufreq_cooling_register(struct device_node *np,
  84. struct cpufreq_policy *policy)
  85. {
  86. return ERR_PTR(-ENOSYS);
  87. }
  88. static inline struct thermal_cooling_device *
  89. of_cpufreq_power_cooling_register(struct cpufreq_policy *policy)
  90. {
  91. return NULL;
  92. }
  93. static inline
  94. void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
  95. {
  96. return;
  97. }
  98. #endif /* CONFIG_CPU_THERMAL */
  99. #endif /* __CPU_COOLING_H__ */