2 * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
4 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
7 * A copy of the licence is included with the program, and can also be obtained from Free Software
8 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 #include "mali_kernel_common.h"
14 #include "mali_gp_scheduler.h"
15 #include "mali_pp_scheduler.h"
16 #include "mali_scheduler.h"
17 #include "mali_kernel_utilization.h"
18 #include "mali_group.h"
20 static mali_bool mali_power_on = MALI_FALSE;
22 _mali_osk_errcode_t mali_pm_initialize(void)
24 _mali_osk_pm_dev_enable();
25 return _MALI_OSK_ERR_OK;
28 void mali_pm_terminate(void)
30 _mali_osk_pm_dev_disable();
33 void mali_pm_core_event(enum mali_core_event core_event)
35 MALI_DEBUG_ASSERT(MALI_CORE_EVENT_GP_START == core_event ||
36 MALI_CORE_EVENT_PP_START == core_event ||
37 MALI_CORE_EVENT_GP_STOP == core_event ||
38 MALI_CORE_EVENT_PP_STOP == core_event);
40 if (MALI_CORE_EVENT_GP_START == core_event || MALI_CORE_EVENT_PP_START == core_event)
42 _mali_osk_pm_dev_ref_add();
43 if (mali_utilization_enabled())
45 mali_utilization_core_start(_mali_osk_time_get_ns());
50 _mali_osk_pm_dev_ref_dec();
51 if (mali_utilization_enabled())
53 mali_utilization_core_end(_mali_osk_time_get_ns());
58 /* Reset GPU after power up */
59 static void mali_pm_reset_gpu(void)
61 /* Reset all L2 caches */
62 mali_l2_cache_reset_all();
64 /* Reset all groups */
65 mali_scheduler_reset_all_groups();
68 void mali_pm_os_suspend(void)
70 MALI_DEBUG_PRINT(3, ("Mali PM: OS suspend\n"));
71 mali_gp_scheduler_suspend();
72 mali_pp_scheduler_suspend();
73 mali_group_power_off();
74 mali_power_on = MALI_FALSE;
77 void mali_pm_os_resume(void)
79 MALI_DEBUG_PRINT(3, ("Mali PM: OS resume\n"));
80 if (MALI_TRUE != mali_power_on)
83 mali_group_power_on();
85 mali_gp_scheduler_resume();
86 mali_pp_scheduler_resume();
87 mali_power_on = MALI_TRUE;
90 void mali_pm_runtime_suspend(void)
92 MALI_DEBUG_PRINT(3, ("Mali PM: Runtime suspend\n"));
93 mali_group_power_off();
94 mali_power_on = MALI_FALSE;
97 void mali_pm_runtime_resume(void)
99 MALI_DEBUG_PRINT(3, ("Mali PM: Runtime resume\n"));
100 if (MALI_TRUE != mali_power_on)
103 mali_group_power_on();
105 mali_power_on = MALI_TRUE;