devfreq_cooling.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * devfreq_cooling: Thermal cooling device implementation for devices using
  4. * devfreq
  5. *
  6. * Copyright (C) 2014-2015 ARM Limited
  7. *
  8. */
  9. #ifndef __DEVFREQ_COOLING_H__
  10. #define __DEVFREQ_COOLING_H__
  11. #include <linux/devfreq.h>
  12. #include <linux/thermal.h>
  13. /**
  14. * struct devfreq_cooling_power - Devfreq cooling power ops
  15. * @get_static_power: Take voltage, in mV, and return the static power
  16. * in mW. If NULL, the static power is assumed
  17. * to be 0.
  18. * @get_dynamic_power: Take voltage, in mV, and frequency, in HZ, and
  19. * return the dynamic power draw in mW. If NULL,
  20. * a simple power model is used.
  21. * @dyn_power_coeff: Coefficient for the simple dynamic power model in
  22. * mW/(MHz mV mV).
  23. * If get_dynamic_power() is NULL, then the
  24. * dynamic power is calculated as
  25. * @dyn_power_coeff * frequency * voltage^2
  26. * @get_real_power: When this is set, the framework uses it to ask the
  27. * device driver for the actual power.
  28. * Some devices have more sophisticated methods
  29. * (like power counters) to approximate the actual power
  30. * that they use.
  31. * This function provides more accurate data to the
  32. * thermal governor. When the driver does not provide
  33. * such function, framework just uses pre-calculated
  34. * table and scale the power by 'utilization'
  35. * (based on 'busy_time' and 'total_time' taken from
  36. * devfreq 'last_status').
  37. * The value returned by this function must be lower
  38. * or equal than the maximum power value
  39. * for the current state
  40. * (which can be found in power_table[state]).
  41. * When this interface is used, the power_table holds
  42. * max total (static + dynamic) power value for each OPP.
  43. */
  44. struct devfreq_cooling_power {
  45. unsigned long (*get_static_power)(struct devfreq *devfreq,
  46. unsigned long voltage);
  47. unsigned long (*get_dynamic_power)(struct devfreq *devfreq,
  48. unsigned long freq,
  49. unsigned long voltage);
  50. int (*get_real_power)(struct devfreq *df, u32 *power,
  51. unsigned long freq, unsigned long voltage);
  52. unsigned long dyn_power_coeff;
  53. };
  54. #ifdef CONFIG_DEVFREQ_THERMAL
  55. struct thermal_cooling_device *
  56. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  57. struct devfreq_cooling_power *dfc_power);
  58. struct thermal_cooling_device *
  59. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
  60. struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
  61. void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
  62. #else /* !CONFIG_DEVFREQ_THERMAL */
  63. static inline struct thermal_cooling_device *
  64. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  65. struct devfreq_cooling_power *dfc_power)
  66. {
  67. return ERR_PTR(-EINVAL);
  68. }
  69. static inline struct thermal_cooling_device *
  70. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
  71. {
  72. return ERR_PTR(-EINVAL);
  73. }
  74. static inline struct thermal_cooling_device *
  75. devfreq_cooling_register(struct devfreq *df)
  76. {
  77. return ERR_PTR(-EINVAL);
  78. }
  79. static inline void
  80. devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
  81. {
  82. }
  83. #endif /* CONFIG_DEVFREQ_THERMAL */
  84. #endif /* __DEVFREQ_COOLING_H__ */