devfreq_cooling.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /**
  21. * struct devfreq_cooling_power - Devfreq cooling power ops
  22. * @get_static_power: Take voltage, in mV, and return the static power
  23. * in mW. If NULL, the static power is assumed
  24. * to be 0.
  25. * @get_dynamic_power: Take voltage, in mV, and frequency, in HZ, and
  26. * return the dynamic power draw in mW. If NULL,
  27. * a simple power model is used.
  28. * @dyn_power_coeff: Coefficient for the simple dynamic power model in
  29. * mW/(MHz mV mV).
  30. * If get_dynamic_power() is NULL, then the
  31. * dynamic power is calculated as
  32. * @dyn_power_coeff * frequency * voltage^2
  33. */
  34. struct devfreq_cooling_power {
  35. unsigned long (*get_static_power)(struct devfreq *devfreq,
  36. unsigned long voltage);
  37. unsigned long (*get_dynamic_power)(struct devfreq *devfreq,
  38. unsigned long freq,
  39. unsigned long voltage);
  40. unsigned long dyn_power_coeff;
  41. };
  42. #ifdef CONFIG_DEVFREQ_THERMAL
  43. struct thermal_cooling_device *
  44. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  45. struct devfreq_cooling_power *dfc_power);
  46. struct thermal_cooling_device *
  47. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
  48. struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
  49. void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
  50. #else /* !CONFIG_DEVFREQ_THERMAL */
  51. struct thermal_cooling_device *
  52. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  53. struct devfreq_cooling_power *dfc_power)
  54. {
  55. return ERR_PTR(-EINVAL);
  56. }
  57. static inline struct thermal_cooling_device *
  58. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
  59. {
  60. return ERR_PTR(-EINVAL);
  61. }
  62. static inline struct thermal_cooling_device *
  63. devfreq_cooling_register(struct devfreq *df)
  64. {
  65. return ERR_PTR(-EINVAL);
  66. }
  67. static inline void
  68. devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
  69. {
  70. }
  71. #endif /* CONFIG_DEVFREQ_THERMAL */
  72. #endif /* __DEVFREQ_COOLING_H__ */