devfreq_cooling.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. * @get_real_power: When this is set, the framework uses it to ask the
  34. * device driver for the actual power.
  35. * Some devices have more sophisticated methods
  36. * (like power counters) to approximate the actual power
  37. * that they use.
  38. * This function provides more accurate data to the
  39. * thermal governor. When the driver does not provide
  40. * such function, framework just uses pre-calculated
  41. * table and scale the power by 'utilization'
  42. * (based on 'busy_time' and 'total_time' taken from
  43. * devfreq 'last_status').
  44. * The value returned by this function must be lower
  45. * or equal than the maximum power value
  46. * for the current state
  47. * (which can be found in power_table[state]).
  48. * When this interface is used, the power_table holds
  49. * max total (static + dynamic) power value for each OPP.
  50. */
  51. struct devfreq_cooling_power {
  52. unsigned long (*get_static_power)(struct devfreq *devfreq,
  53. unsigned long voltage);
  54. unsigned long (*get_dynamic_power)(struct devfreq *devfreq,
  55. unsigned long freq,
  56. unsigned long voltage);
  57. int (*get_real_power)(struct devfreq *df, u32 *power,
  58. unsigned long freq, unsigned long voltage);
  59. unsigned long dyn_power_coeff;
  60. };
  61. #ifdef CONFIG_DEVFREQ_THERMAL
  62. struct thermal_cooling_device *
  63. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  64. struct devfreq_cooling_power *dfc_power);
  65. struct thermal_cooling_device *
  66. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
  67. struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
  68. void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
  69. #else /* !CONFIG_DEVFREQ_THERMAL */
  70. struct thermal_cooling_device *
  71. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  72. struct devfreq_cooling_power *dfc_power)
  73. {
  74. return ERR_PTR(-EINVAL);
  75. }
  76. static inline struct thermal_cooling_device *
  77. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
  78. {
  79. return ERR_PTR(-EINVAL);
  80. }
  81. static inline struct thermal_cooling_device *
  82. devfreq_cooling_register(struct devfreq *df)
  83. {
  84. return ERR_PTR(-EINVAL);
  85. }
  86. static inline void
  87. devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
  88. {
  89. }
  90. #endif /* CONFIG_DEVFREQ_THERMAL */
  91. #endif /* __DEVFREQ_COOLING_H__ */