Merge tag 'lsk-v4.4-16.06-android'
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / common / mali_pm_domain.h
1 /*
2  * Copyright (C) 2013-2015 ARM Limited. All rights reserved.
3  * 
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.
6  * 
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.
9  */
10
11 #ifndef __MALI_PM_DOMAIN_H__
12 #define __MALI_PM_DOMAIN_H__
13
14 #include "mali_kernel_common.h"
15 #include "mali_osk.h"
16
17 #include "mali_l2_cache.h"
18 #include "mali_group.h"
19 #include "mali_pmu.h"
20
21 /* Instances are protected by PM state lock */
22 struct mali_pm_domain {
23         mali_bool power_is_on;
24         s32 use_count;
25         u32 pmu_mask;
26
27         /* Zero or more groups can belong to this domain */
28         _mali_osk_list_t group_list;
29
30         /* Zero or more L2 caches can belong to this domain */
31         _mali_osk_list_t l2_cache_list;
32 };
33
34
35 void mali_pm_domain_initialize(void);
36 void mali_pm_domain_terminate(void);
37
38 struct mali_pm_domain *mali_pm_domain_create(u32 pmu_mask);
39 void mali_pm_domain_delete(struct mali_pm_domain *domain);
40
41 void mali_pm_domain_add_l2_cache(
42         struct mali_pm_domain *domain,
43         struct mali_l2_cache_core *l2_cache);
44 void mali_pm_domain_add_group(struct mali_pm_domain *domain,
45                               struct mali_group *group);
46
47 struct mali_pm_domain *mali_pm_domain_get_from_mask(u32 mask);
48 struct mali_pm_domain *mali_pm_domain_get_from_index(u32 id);
49
50 /* Ref counting */
51 u32 mali_pm_domain_ref_get(struct mali_pm_domain *domain);
52 u32 mali_pm_domain_ref_put(struct mali_pm_domain *domain);
53
54 MALI_STATIC_INLINE _mali_osk_list_t *mali_pm_domain_get_group_list(
55         struct mali_pm_domain *domain)
56 {
57         MALI_DEBUG_ASSERT_POINTER(domain);
58         return &domain->group_list;
59 }
60
61 MALI_STATIC_INLINE _mali_osk_list_t *mali_pm_domain_get_l2_cache_list(
62         struct mali_pm_domain *domain)
63 {
64         MALI_DEBUG_ASSERT_POINTER(domain);
65         return &domain->l2_cache_list;
66 }
67
68 MALI_STATIC_INLINE mali_bool mali_pm_domain_power_is_on(
69         struct mali_pm_domain *domain)
70 {
71         MALI_DEBUG_ASSERT_POINTER(domain);
72         return domain->power_is_on;
73 }
74
75 MALI_STATIC_INLINE void mali_pm_domain_set_power_on(
76         struct mali_pm_domain *domain,
77         mali_bool power_is_on)
78 {
79         MALI_DEBUG_ASSERT_POINTER(domain);
80         domain->power_is_on = power_is_on;
81 }
82
83 MALI_STATIC_INLINE u32 mali_pm_domain_get_use_count(
84         struct mali_pm_domain *domain)
85 {
86         MALI_DEBUG_ASSERT_POINTER(domain);
87         return domain->use_count;
88 }
89
90 #if MALI_STATE_TRACKING
91 u32 mali_pm_domain_get_id(struct mali_pm_domain *domain);
92
93 MALI_STATIC_INLINE u32 mali_pm_domain_get_mask(struct mali_pm_domain *domain)
94 {
95         MALI_DEBUG_ASSERT_POINTER(domain);
96         return domain->pmu_mask;
97 }
98 #endif
99
100 #if defined(DEBUG)
101 mali_bool mali_pm_domain_all_unused(void);
102 #endif
103
104 #endif /* __MALI_PM_DOMAIN_H__ */