devfreq_cooling.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * devfreq_cooling: Thermal cooling device implementation for devices using
  3. * devfreq
  4. *
  5. * Copyright (C) 2014-2015 ARM Limited
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  12. * kind, whether express or implied; without even the implied warranty
  13. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #ifndef __DEVFREQ_COOLING_H__
  17. #define __DEVFREQ_COOLING_H__
  18. #include <linux/devfreq.h>
  19. #include <linux/thermal.h>
  20. #ifdef CONFIG_DEVFREQ_THERMAL
  21. /**
  22. * struct devfreq_cooling_power - Devfreq cooling power ops
  23. * @get_static_power: Take voltage, in mV, and return the static power
  24. * in mW. If NULL, the static power is assumed
  25. * to be 0.
  26. * @get_dynamic_power: Take voltage, in mV, and frequency, in HZ, and
  27. * return the dynamic power draw in mW. If NULL,
  28. * a simple power model is used.
  29. * @dyn_power_coeff: Coefficient for the simple dynamic power model in
  30. * mW/(MHz mV mV).
  31. * If get_dynamic_power() is NULL, then the
  32. * dynamic power is calculated as
  33. * @dyn_power_coeff * frequency * voltage^2
  34. */
  35. struct devfreq_cooling_power {
  36. unsigned long (*get_static_power)(unsigned long voltage);
  37. unsigned long (*get_dynamic_power)(unsigned long freq,
  38. unsigned long voltage);
  39. unsigned long dyn_power_coeff;
  40. };
  41. struct thermal_cooling_device *
  42. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  43. struct devfreq_cooling_power *dfc_power);
  44. struct thermal_cooling_device *
  45. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
  46. struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
  47. void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
  48. #else /* !CONFIG_DEVFREQ_THERMAL */
  49. struct thermal_cooling_device *
  50. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  51. struct devfreq_cooling_power *dfc_power)
  52. {
  53. return ERR_PTR(-EINVAL);
  54. }
  55. static inline struct thermal_cooling_device *
  56. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
  57. {
  58. return ERR_PTR(-EINVAL);
  59. }
  60. static inline struct thermal_cooling_device *
  61. devfreq_cooling_register(struct devfreq *df)
  62. {
  63. return ERR_PTR(-EINVAL);
  64. }
  65. static inline void
  66. devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
  67. {
  68. }
  69. #endif /* CONFIG_DEVFREQ_THERMAL */
  70. #endif /* __DEVFREQ_COOLING_H__ */