cpu_cooling.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. typedef int (*get_static_t)(cpumask_t *cpumask, int interval,
  29. unsigned long voltage, u32 *power);
  30. #ifdef CONFIG_CPU_THERMAL
  31. /**
  32. * cpufreq_cooling_register - function to create cpufreq cooling device.
  33. * @clip_cpus: cpumask of cpus where the frequency constraints will happen
  34. */
  35. struct thermal_cooling_device *
  36. cpufreq_cooling_register(const struct cpumask *clip_cpus);
  37. struct thermal_cooling_device *
  38. cpufreq_power_cooling_register(const struct cpumask *clip_cpus,
  39. u32 capacitance, get_static_t plat_static_func);
  40. /**
  41. * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
  42. * @np: a valid struct device_node to the cooling device device tree node.
  43. * @clip_cpus: cpumask of cpus where the frequency constraints will happen
  44. */
  45. #ifdef CONFIG_THERMAL_OF
  46. struct thermal_cooling_device *
  47. of_cpufreq_cooling_register(struct device_node *np,
  48. const struct cpumask *clip_cpus);
  49. struct thermal_cooling_device *
  50. of_cpufreq_power_cooling_register(struct device_node *np,
  51. const struct cpumask *clip_cpus,
  52. u32 capacitance,
  53. get_static_t plat_static_func);
  54. #else
  55. static inline struct thermal_cooling_device *
  56. of_cpufreq_cooling_register(struct device_node *np,
  57. const struct cpumask *clip_cpus)
  58. {
  59. return ERR_PTR(-ENOSYS);
  60. }
  61. static inline struct thermal_cooling_device *
  62. of_cpufreq_power_cooling_register(struct device_node *np,
  63. const struct cpumask *clip_cpus,
  64. u32 capacitance,
  65. get_static_t plat_static_func)
  66. {
  67. return NULL;
  68. }
  69. #endif
  70. /**
  71. * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
  72. * @cdev: thermal cooling device pointer.
  73. */
  74. void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
  75. unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq);
  76. #else /* !CONFIG_CPU_THERMAL */
  77. static inline struct thermal_cooling_device *
  78. cpufreq_cooling_register(const struct cpumask *clip_cpus)
  79. {
  80. return ERR_PTR(-ENOSYS);
  81. }
  82. static inline struct thermal_cooling_device *
  83. cpufreq_power_cooling_register(const struct cpumask *clip_cpus,
  84. u32 capacitance, get_static_t plat_static_func)
  85. {
  86. return NULL;
  87. }
  88. static inline struct thermal_cooling_device *
  89. of_cpufreq_cooling_register(struct device_node *np,
  90. const struct cpumask *clip_cpus)
  91. {
  92. return ERR_PTR(-ENOSYS);
  93. }
  94. static inline struct thermal_cooling_device *
  95. of_cpufreq_power_cooling_register(struct device_node *np,
  96. const struct cpumask *clip_cpus,
  97. u32 capacitance,
  98. get_static_t plat_static_func)
  99. {
  100. return NULL;
  101. }
  102. static inline
  103. void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
  104. {
  105. return;
  106. }
  107. static inline
  108. unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
  109. {
  110. return THERMAL_CSTATE_INVALID;
  111. }
  112. #endif /* CONFIG_CPU_THERMAL */
  113. #endif /* __CPU_COOLING_H__ */