MALI: utgard: upgrade DDK to r7p0-00rel0
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / mali400 / mali / platform / rk30 / mali_platform.h
1 /*
2  * This confidential and proprietary software may be used only as
3  * authorised by a licensing agreement from ARM Limited
4  * (C) COPYRIGHT 2009-2012 ARM Limited
5  * ALL RIGHTS RESERVED
6  * The entire notice above must be reproduced on all authorised
7  * copies and copies may only be made to the extent permitted
8  * by a licensing agreement from ARM Limited.
9  */
10
11 /**
12  * @file mali_platform.h
13  * Platform specific Mali driver functions
14  */
15
16 #ifndef __MALI_PLATFORM_H__
17 #define __MALI_PLATFORM_H__
18
19 #include "mali_dvfs.h"
20 #include "mali_osk.h"
21 #include <linux/mali/mali_utgard.h>
22 #include <linux/rockchip/dvfs.h>
23 #include <linux/cpufreq.h>
24 #include <linux/regulator/consumer.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31  * @brief
32  * description of power change reasons
33  */
34 enum mali_power_mode {
35         MALI_POWER_MODE_ON,           /**< Power Mali on */
36         MALI_POWER_MODE_LIGHT_SLEEP,  /**< Mali has been idle for a short time, or runtime PM suspend */
37         MALI_POWER_MODE_DEEP_SLEEP,   /**< Mali has been idle for a long time, or OS suspend */
38 };
39
40 /**
41  * dvfs_level_t, 标识一个 dvfs_level (的具体配置).
42  * .DP : dvfs_level.
43  */
44 struct mali_fv_info {
45         /**
46          * 当前 dvfs_level 使用的 gpu_clk_freq.
47          */
48         unsigned long freq;
49         /**
50          * .DP : min_mali_utilization_in_percentage_in_this_level.
51          * 若当前的 mali_utilization_in_percentage
52          *      小于 min_mali_utilization_in_percentage_in_this_level,
53          * 则触发一次 requests_to_jump_down_in_dvfs_level_table,
54          * 当 对 requests_to_jump_down_in_dvfs_level_table 的连续计数
55          * (.DP : continuous_count_of_requests_to_jump_down) 达到一定数值,
56          * 则 dvfs_facility 会下跳一个 level.
57          */
58         unsigned int min;
59         /**
60          * .DP : max_mali_utilization_in_percentage_in_this_level.
61          * 若当前的 mali_utilization_in_percentage
62          *      大于 max_mali_utilization_in_percentage_in_this_level,
63          * 则触发一次 requests_to_jump_up_in_dvfs_level_table,
64          * 当 对 requests_to_jump_up_in_dvfs_level_table 的连续计数
65          * (.DP : continuous_count_of_requests_to_jump_up) 达到一定数值,
66          *      则 dvfs_facility 会上跳一个 level.
67          */
68         unsigned int max;
69 };
70
71 /**
72  * mali_driver_private_data_t.
73  * 和 平台相关的 mali_driver 的私有数据,
74  *              包含 clk, power_domain handles, mali_dvfs_facility 等.
75  *
76  * 该类型在 platform_dependent_part 中定义,
77  * 显然也只会在 platform_dependent_part 中使用.
78  */
79 struct mali_platform_drv_data {
80         /**
81          * gpu_dvfs_node
82          */
83         struct dvfs_node *clk;
84
85         /**
86          * gpu_power_domain.
87          */
88         struct clk *pd;
89
90         /**
91          * available_dvfs_level_list.
92          * 将用于保存 系统配置支持的所有 dvfs_level.
93          * .R : 实际上, 放在 mali_dvfs_context 中为宜.
94          */
95         struct mali_fv_info *fv_info;
96         /**
97          * len_of_available_dvfs_level_list, 也即 根据系统配置得到的 available_dvfs_level 的个数.
98          */
99         unsigned int fv_info_length;
100
101         /**
102          * mali_dvfs_context.
103          */
104         struct mali_dvfs dvfs;
105
106         /**
107          * device_of_mali_gpu.
108          */
109         struct device *dev;
110
111         /**
112          * gpu 是否 "被上电, 且被送入 clk".
113          */
114         bool power_state;
115
116         _mali_osk_mutex_t *clock_set_lock;
117
118         /*-------------------------------------------------------*/
119         
120         /**
121          * clk_mali.
122          */
123         struct clk *clock;
124         
125         struct regulator *regulator;
126 };
127
128 /** @brief Platform specific setup and initialisation of MALI
129  *
130  * This is called from the entrypoint of the driver to initialize the platform
131  *
132  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
133  */
134 _mali_osk_errcode_t mali_platform_init(struct platform_device *pdev);
135
136 /** @brief Platform specific deinitialisation of MALI
137  *
138  * This is called on the exit of the driver to terminate the platform
139  *
140  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
141  */
142 _mali_osk_errcode_t mali_platform_deinit(struct platform_device *pdev);
143
144 /** @brief Platform specific powerdown sequence of MALI
145  *
146  * Notification from the Mali device driver stating the new desired power mode.
147  * MALI_POWER_MODE_ON must be obeyed, while the other modes are optional.
148  * @param power_mode defines the power modes
149  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
150  */
151 _mali_osk_errcode_t mali_platform_power_mode_change(
152                         enum mali_power_mode power_mode);
153
154
155 /**
156  * @brief
157  * Platform specific handling
158  *      of GPU utilization data
159  *
160  * When GPU utilization data is enabled,
161  * this function
162  * will be periodically called.
163  *
164  * @param utilization
165  *      The workload utilization
166  *              of the Mali GPU.
167  *      0 = no utilization,
168  *      256 = full utilization.
169  */
170 void mali_gpu_utilization_handler(struct mali_gpu_utilization_data *data);
171
172 int mali_set_level(struct device *dev, int level);
173
174 #ifdef __cplusplus
175 }
176 #endif
177 #endif