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"
19 #include "mali_pm_domain.h"
22 static mali_bool mali_power_on = MALI_FALSE;
24 _mali_osk_errcode_t mali_pm_initialize(void)
26 _mali_osk_pm_dev_enable();
27 return _MALI_OSK_ERR_OK;
30 void mali_pm_terminate(void)
32 mali_pm_domain_terminate();
33 _mali_osk_pm_dev_disable();
36 /* Reset GPU after power up */
37 static void mali_pm_reset_gpu(void)
39 /* Reset all L2 caches */
40 mali_l2_cache_reset_all();
42 /* Reset all groups */
43 mali_scheduler_reset_all_groups();
46 void mali_pm_os_suspend(void)
48 MALI_DEBUG_PRINT(3, ("Mali PM: OS suspend\n"));
49 mali_gp_scheduler_suspend();
50 mali_pp_scheduler_suspend();
51 mali_utilization_suspend();
53 #if !defined(CONFIG_PM_RUNTIME)
54 mali_group_power_off(MALI_TRUE);
55 mali_power_on = MALI_FALSE;
59 void mali_pm_os_resume(void)
61 #if !defined(CONFIG_PM_RUNTIME)
62 struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core();
63 mali_bool do_reset = MALI_FALSE;
66 MALI_DEBUG_PRINT(3, ("Mali PM: OS resume\n"));
68 /******************************************************************
71 * In Pegasus prime, PMU is not enabled(Power off) while
72 * system wake up(suspend -> resume).
74 * Because PMU power is off, GPU does not work.
75 * Therefore code is commented like below.
77 *****************************************************************/
78 #if !defined(CONFIG_PM_RUNTIME)
79 if (MALI_TRUE != mali_power_on)
88 mali_power_on = MALI_TRUE;
89 _mali_osk_write_mem_barrier();
93 mali_group_power_on();
96 mali_gp_scheduler_resume();
97 mali_pp_scheduler_resume();
100 void mali_pm_runtime_suspend(void)
102 MALI_DEBUG_PRINT(3, ("Mali PM: Runtime suspend\n"));
103 mali_group_power_off(MALI_TRUE);
104 mali_power_on = MALI_FALSE;
107 void mali_pm_runtime_resume(void)
109 struct mali_pmu_core *pmu = mali_pmu_get_global_pmu_core();
110 mali_bool do_reset = MALI_FALSE;
112 MALI_DEBUG_PRINT(3, ("Mali PM: Runtime resume\n"));
114 if (MALI_TRUE != mali_power_on) {
115 do_reset = MALI_TRUE;
122 mali_power_on = MALI_TRUE;
123 _mali_osk_write_mem_barrier();
127 mali_group_power_on();
131 void mali_pm_set_power_is_on(void)
133 mali_power_on = MALI_TRUE;
136 mali_bool mali_pm_is_power_on(void)
138 return mali_power_on;