mali_pm.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * This confidential and proprietary software may be used only as
  3. * authorised by a licensing agreement from ARM Limited
  4. * (C) COPYRIGHT 2011-2013 ARM Limited
  5. * ALL RIGHTS RESERVED
  6. * The entire notice above must be reproduced on all authorised
  7. * copies and copies may only be made to the extent permitted
  8. * by a licensing agreement from ARM Limited.
  9. */
  10. #include "mali_pm.h"
  11. #include "mali_kernel_common.h"
  12. #include "mali_osk.h"
  13. #include "mali_gp_scheduler.h"
  14. #include "mali_pp_scheduler.h"
  15. #include "mali_scheduler.h"
  16. #include "mali_kernel_utilization.h"
  17. #include "mali_group.h"
  18. #include "mali_pm_domain.h"
  19. #include "mali_pmu.h"
  20. static mali_bool mali_power_on = MALI_FALSE;
  21. _mali_osk_errcode_t mali_pm_initialize(void)
  22. {
  23. _mali_osk_pm_dev_enable();
  24. return _MALI_OSK_ERR_OK;
  25. }
  26. void mali_pm_terminate(void)
  27. {
  28. mali_pm_domain_terminate();
  29. _mali_osk_pm_dev_disable();
  30. }
  31. /* Reset GPU after power up */
  32. static void mali_pm_reset_gpu(void)
  33. {
  34. /* Reset all L2 caches */
  35. mali_l2_cache_reset_all();
  36. /* Reset all groups */
  37. mali_scheduler_reset_all_groups();
  38. }
  39. void mali_pm_os_suspend(void)
  40. {
  41. MALI_DEBUG_PRINT(3, ("Mali PM: OS suspend\n"));
  42. mali_gp_scheduler_suspend();
  43. mali_pp_scheduler_suspend();
  44. mali_utilization_suspend();
  45. mali_group_power_off(MALI_TRUE);
  46. mali_power_on = MALI_FALSE;
  47. }
  48. void mali_pm_os_resume(void)
  49. {
  50. struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core();
  51. mali_bool do_reset = MALI_FALSE;
  52. MALI_DEBUG_PRINT(3, ("Mali PM: OS resume\n"));
  53. if (MALI_TRUE != mali_power_on) {
  54. do_reset = MALI_TRUE;
  55. }
  56. if (NULL != pmu) {
  57. mali_pmu_reset(pmu);
  58. }
  59. mali_power_on = MALI_TRUE;
  60. _mali_osk_write_mem_barrier();
  61. if (do_reset) {
  62. mali_pm_reset_gpu();
  63. mali_group_power_on();
  64. }
  65. mali_gp_scheduler_resume();
  66. mali_pp_scheduler_resume();
  67. }
  68. void mali_pm_runtime_suspend(void)
  69. {
  70. MALI_DEBUG_PRINT(3, ("Mali PM: Runtime suspend\n"));
  71. mali_group_power_off(MALI_TRUE);
  72. mali_power_on = MALI_FALSE;
  73. }
  74. void mali_pm_runtime_resume(void)
  75. {
  76. struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core();
  77. mali_bool do_reset = MALI_FALSE;
  78. MALI_DEBUG_PRINT(3, ("Mali PM: Runtime resume\n"));
  79. if (MALI_TRUE != mali_power_on) {
  80. do_reset = MALI_TRUE;
  81. }
  82. if (NULL != pmu) {
  83. mali_pmu_reset(pmu);
  84. }
  85. mali_power_on = MALI_TRUE;
  86. _mali_osk_write_mem_barrier();
  87. if (do_reset) {
  88. mali_pm_reset_gpu();
  89. mali_group_power_on();
  90. }
  91. }
  92. void mali_pm_set_power_is_on(void)
  93. {
  94. mali_power_on = MALI_TRUE;
  95. }
  96. mali_bool mali_pm_is_power_on(void)
  97. {
  98. return mali_power_on;
  99. }