tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / r4p0_rel0 / common / mali_pmu.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 /**
12  * @file mali_platform.h
13  * Platform specific Mali driver functions
14  */
15
16 #ifndef __MALI_PMU_H__
17 #define __MALI_PMU_H__
18
19 #include "mali_osk.h"
20
21 #define MALI_GP_DOMAIN_INDEX    0
22 #define MALI_PP0_DOMAIN_INDEX   1
23 #define MALI_PP1_DOMAIN_INDEX   2
24 #define MALI_PP2_DOMAIN_INDEX   3
25 #define MALI_PP3_DOMAIN_INDEX   4
26 #define MALI_PP4_DOMAIN_INDEX   5
27 #define MALI_PP5_DOMAIN_INDEX   6
28 #define MALI_PP6_DOMAIN_INDEX   7
29 #define MALI_PP7_DOMAIN_INDEX   8
30 #define MALI_L20_DOMAIN_INDEX   9
31 #define MALI_L21_DOMAIN_INDEX   10
32 #define MALI_L22_DOMAIN_INDEX   11
33
34 #define MALI_MAX_NUMBER_OF_DOMAINS      12
35
36 /* Record the domain config from the customer or default config */
37 extern u16 mali_pmu_global_domain_config[];
38
39 static inline u16 mali_pmu_get_domain_mask(u32 index)
40 {
41         MALI_DEBUG_ASSERT(MALI_MAX_NUMBER_OF_DOMAINS > index);
42
43         return mali_pmu_global_domain_config[index];
44 }
45
46 static inline void mali_pmu_set_domain_mask(u32 index, u16 value)
47 {
48         MALI_DEBUG_ASSERT(MALI_MAX_NUMBER_OF_DOMAINS > index);
49
50         mali_pmu_global_domain_config[index] = value;
51 }
52
53 static inline void mali_pmu_copy_domain_mask(void *src, u32 len)
54 {
55         _mali_osk_memcpy(mali_pmu_global_domain_config, src, len);
56 }
57
58 struct mali_pmu_core;
59
60 /** @brief Initialisation of MALI PMU
61  *
62  * This is called from entry point of the driver in order to create and intialize the PMU resource
63  *
64  * @param resource it will be a pointer to a PMU resource
65  * @param number_of_pp_cores Number of found PP resources in configuration
66  * @param number_of_l2_caches Number of found L2 cache resources in configuration
67  * @return The created PMU object, or NULL in case of failure.
68  */
69 struct mali_pmu_core *mali_pmu_create(_mali_osk_resource_t *resource);
70
71 /** @brief It deallocates the PMU resource
72  *
73  * This is called on the exit of the driver to terminate the PMU resource
74  *
75  * @param pmu Pointer to PMU core object to delete
76  */
77 void mali_pmu_delete(struct mali_pmu_core *pmu);
78
79 /** @brief Reset PMU core
80  *
81  * @param pmu Pointer to PMU core object to reset
82  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
83  */
84 _mali_osk_errcode_t mali_pmu_reset(struct mali_pmu_core *pmu);
85
86 /** @brief MALI GPU power down using MALI in-built PMU
87  *
88  * Called to power down the specified cores. The mask will be saved so that \a
89  * mali_pmu_power_up_all will bring the PMU back to the previous state set with
90  * this function or \a mali_pmu_power_up.
91  *
92  * @param pmu Pointer to PMU core object to power down
93  * @param mask Mask specifying which power domains to power down
94  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
95  */
96 _mali_osk_errcode_t mali_pmu_power_down(struct mali_pmu_core *pmu, u32 mask);
97
98 /** @brief MALI GPU power up using MALI in-built PMU
99  *
100  * Called to power up the specified cores. The mask will be saved so that \a
101  * mali_pmu_power_up_all will bring the PMU back to the previous state set with
102  * this function or \a mali_pmu_power_down.
103  *
104  * @param pmu Pointer to PMU core object to power up
105  * @param mask Mask specifying which power domains to power up
106  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
107  */
108 _mali_osk_errcode_t mali_pmu_power_up(struct mali_pmu_core *pmu, u32 mask);
109
110 /** @brief MALI GPU power down using MALI in-built PMU
111  *
112  * called to power down all cores
113  *
114  * @param pmu Pointer to PMU core object to power down
115  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
116  */
117 _mali_osk_errcode_t mali_pmu_power_down_all(struct mali_pmu_core *pmu);
118
119 /** @brief MALI GPU power up using MALI in-built PMU
120  *
121  * called to power up all cores
122  *
123  * @param pmu Pointer to PMU core object to power up
124  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
125  */
126 _mali_osk_errcode_t mali_pmu_power_up_all(struct mali_pmu_core *pmu);
127
128 /** @brief Retrieves the Mali PMU core object (if any)
129  *
130  * @return The Mali PMU object, or NULL if no PMU exists.
131  */
132 struct mali_pmu_core *mali_pmu_get_global_pmu_core(void);
133
134 #endif /* __MALI_PMU_H__ */