cpu_cooling.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifdef CONFIG_CPU_THERMAL
  29. /**
  30. * cpufreq_cooling_register - function to create cpufreq cooling device.
  31. * @clip_cpus: cpumask of cpus where the frequency constraints will happen
  32. */
  33. struct thermal_cooling_device *
  34. cpufreq_cooling_register(const struct cpumask *clip_cpus);
  35. /**
  36. * of_cpufreq_cooling_register - create cpufreq cooling device based on DT.
  37. * @np: a valid struct device_node to the cooling device device tree node.
  38. * @clip_cpus: cpumask of cpus where the frequency constraints will happen
  39. */
  40. #ifdef CONFIG_THERMAL_OF
  41. struct thermal_cooling_device *
  42. of_cpufreq_cooling_register(struct device_node *np,
  43. const struct cpumask *clip_cpus);
  44. #else
  45. static inline struct thermal_cooling_device *
  46. of_cpufreq_cooling_register(struct device_node *np,
  47. const struct cpumask *clip_cpus)
  48. {
  49. return ERR_PTR(-ENOSYS);
  50. }
  51. #endif
  52. /**
  53. * cpufreq_cooling_unregister - function to remove cpufreq cooling device.
  54. * @cdev: thermal cooling device pointer.
  55. */
  56. void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev);
  57. unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq);
  58. #else /* !CONFIG_CPU_THERMAL */
  59. static inline struct thermal_cooling_device *
  60. cpufreq_cooling_register(const struct cpumask *clip_cpus)
  61. {
  62. return ERR_PTR(-ENOSYS);
  63. }
  64. static inline struct thermal_cooling_device *
  65. of_cpufreq_cooling_register(struct device_node *np,
  66. const struct cpumask *clip_cpus)
  67. {
  68. return ERR_PTR(-ENOSYS);
  69. }
  70. static inline
  71. void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
  72. {
  73. return;
  74. }
  75. static inline
  76. unsigned long cpufreq_cooling_get_level(unsigned int cpu, unsigned int freq)
  77. {
  78. return THERMAL_CSTATE_INVALID;
  79. }
  80. #endif /* CONFIG_CPU_THERMAL */
  81. #endif /* __CPU_COOLING_H__ */