kgsl_pwrscale.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #ifndef __KGSL_PWRSCALE_H
  14. #define __KGSL_PWRSCALE_H
  15. #include <linux/devfreq.h>
  16. #include <linux/msm_adreno_devfreq.h>
  17. /* devfreq governor call window in msec */
  18. #define KGSL_GOVERNOR_CALL_INTERVAL 5
  19. struct kgsl_power_stats {
  20. u64 busy_time;
  21. u64 ram_time;
  22. u64 ram_wait;
  23. };
  24. struct kgsl_pwrscale {
  25. struct devfreq *devfreq;
  26. struct devfreq_dev_profile profile;
  27. unsigned int freq_table[KGSL_MAX_PWRLEVELS];
  28. char last_governor[DEVFREQ_NAME_LEN];
  29. struct kgsl_power_stats accum_stats;
  30. bool enabled;
  31. s64 time;
  32. s64 on_time;
  33. struct srcu_notifier_head nh;
  34. struct workqueue_struct *devfreq_wq;
  35. struct work_struct devfreq_suspend_ws;
  36. struct work_struct devfreq_resume_ws;
  37. struct work_struct devfreq_notify_ws;
  38. unsigned long next_governor_call;
  39. };
  40. int kgsl_pwrscale_init(struct device *dev, const char *governor);
  41. void kgsl_pwrscale_close(struct kgsl_device *device);
  42. void kgsl_pwrscale_update(struct kgsl_device *device);
  43. void kgsl_pwrscale_busy(struct kgsl_device *device);
  44. void kgsl_pwrscale_sleep(struct kgsl_device *device);
  45. void kgsl_pwrscale_wake(struct kgsl_device *device);
  46. void kgsl_pwrscale_enable(struct kgsl_device *device);
  47. void kgsl_pwrscale_disable(struct kgsl_device *device);
  48. int kgsl_devfreq_target(struct device *dev, unsigned long *freq, u32 flags);
  49. int kgsl_devfreq_get_dev_status(struct device *, struct devfreq_dev_status *);
  50. int kgsl_devfreq_get_cur_freq(struct device *dev, unsigned long *freq);
  51. #define KGSL_PWRSCALE_INIT(_gov_list, _num_gov) { \
  52. .enabled = true, \
  53. .profile = { \
  54. .target = kgsl_devfreq_target, \
  55. .get_dev_status = kgsl_devfreq_get_dev_status, \
  56. .get_cur_freq = kgsl_devfreq_get_cur_freq, \
  57. .governor_data = (_gov_list), \
  58. .num_governor_data = (_num_gov), \
  59. } }
  60. #endif