tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / r4p0_rel0 / common / mali_pm_domain.h
1 /*
2  * Copyright (C) 2010-2012 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 typedef enum {
22         MALI_PM_DOMAIN_ON,
23         MALI_PM_DOMAIN_OFF,
24 } mali_pm_domain_state;
25
26 struct mali_pm_domain {
27         mali_pm_domain_state state;
28         _mali_osk_spinlock_irq_t *lock;
29
30         s32 use_count;
31
32         u32 pmu_mask;
33
34         int group_count;
35         struct mali_group *group_list;
36
37         struct mali_l2_cache_core *l2;
38 };
39
40 struct mali_pm_domain *mali_pm_domain_create(u32 pmu_mask);
41
42 void mali_pm_domain_add_group(u32 mask, struct mali_group *group);
43
44 void mali_pm_domain_add_l2(u32 mask, struct mali_l2_cache_core *l2);
45 void mali_pm_domain_delete(struct mali_pm_domain *domain);
46
47 void mali_pm_domain_terminate(void);
48
49 /** Get PM domain from domain ID
50  */
51 struct mali_pm_domain *mali_pm_domain_get_from_mask(u32 mask);
52 struct mali_pm_domain *mali_pm_domain_get_from_index(u32 id);
53
54 /* Ref counting */
55 void mali_pm_domain_ref_get(struct mali_pm_domain *domain);
56 void mali_pm_domain_ref_put(struct mali_pm_domain *domain);
57
58 MALI_STATIC_INLINE struct mali_l2_cache_core *mali_pm_domain_l2_get(struct mali_pm_domain *domain)
59 {
60         return domain->l2;
61 }
62
63 MALI_STATIC_INLINE mali_pm_domain_state mali_pm_domain_state_get(struct mali_pm_domain *domain)
64 {
65         return domain->state;
66 }
67
68 mali_bool mali_pm_domain_lock_state(struct mali_pm_domain *domain);
69 void mali_pm_domain_unlock_state(struct mali_pm_domain *domain);
70
71 #define MALI_PM_DOMAIN_FOR_EACH_GROUP(group, domain) for ((group) = (domain)->group_list;\
72                 NULL != (group); (group) = (group)->pm_domain_list)
73
74 #endif /* __MALI_PM_DOMAIN_H__ */