lima_devfreq.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright 2020 Martin Blumenstingl <martin.blumenstingl@googlemail.com> */
  3. #ifndef __LIMA_DEVFREQ_H__
  4. #define __LIMA_DEVFREQ_H__
  5. #include <linux/devfreq.h>
  6. #include <linux/spinlock.h>
  7. #include <linux/ktime.h>
  8. struct devfreq;
  9. struct thermal_cooling_device;
  10. struct lima_device;
  11. struct lima_devfreq {
  12. struct devfreq *devfreq;
  13. struct thermal_cooling_device *cooling;
  14. struct devfreq_simple_ondemand_data gov_data;
  15. ktime_t busy_time;
  16. ktime_t idle_time;
  17. ktime_t time_last_update;
  18. int busy_count;
  19. /*
  20. * Protect busy_time, idle_time, time_last_update and busy_count
  21. * because these can be updated concurrently, for example by the GP
  22. * and PP interrupts.
  23. */
  24. spinlock_t lock;
  25. };
  26. int lima_devfreq_init(struct lima_device *ldev);
  27. void lima_devfreq_fini(struct lima_device *ldev);
  28. void lima_devfreq_record_busy(struct lima_devfreq *devfreq);
  29. void lima_devfreq_record_idle(struct lima_devfreq *devfreq);
  30. int lima_devfreq_resume(struct lima_devfreq *devfreq);
  31. int lima_devfreq_suspend(struct lima_devfreq *devfreq);
  32. #endif