devfreq_cooling.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_real_power: When this is set, the framework uses it to ask the
  16. * device driver for the actual power.
  17. * Some devices have more sophisticated methods
  18. * (like power counters) to approximate the actual power
  19. * that they use.
  20. * This function provides more accurate data to the
  21. * thermal governor. When the driver does not provide
  22. * such function, framework just uses pre-calculated
  23. * table and scale the power by 'utilization'
  24. * (based on 'busy_time' and 'total_time' taken from
  25. * devfreq 'last_status').
  26. * The value returned by this function must be lower
  27. * or equal than the maximum power value
  28. * for the current state
  29. * (which can be found in power_table[state]).
  30. * When this interface is used, the power_table holds
  31. * max total (static + dynamic) power value for each OPP.
  32. */
  33. struct devfreq_cooling_power {
  34. int (*get_real_power)(struct devfreq *df, u32 *power,
  35. unsigned long freq, unsigned long voltage);
  36. };
  37. #ifdef CONFIG_DEVFREQ_THERMAL
  38. struct thermal_cooling_device *
  39. of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
  40. struct devfreq_cooling_power *dfc_power);
  41. struct thermal_cooling_device *
  42. of_devfreq_cooling_register(struct device_node *np, struct devfreq *df);
  43. struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df);
  44. void devfreq_cooling_unregister(struct thermal_cooling_device *dfc);
  45. struct thermal_cooling_device *
  46. devfreq_cooling_em_register(struct devfreq *df,
  47. struct devfreq_cooling_power *dfc_power);
  48. #else /* !CONFIG_DEVFREQ_THERMAL */
  49. static inline 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 struct thermal_cooling_device *
  66. devfreq_cooling_em_register(struct devfreq *df,
  67. struct devfreq_cooling_power *dfc_power)
  68. {
  69. return ERR_PTR(-EINVAL);
  70. }
  71. static inline void
  72. devfreq_cooling_unregister(struct thermal_cooling_device *dfc)
  73. {
  74. }
  75. #endif /* CONFIG_DEVFREQ_THERMAL */
  76. #endif /* __DEVFREQ_COOLING_H__ */