rk312x, mali_400: add comments and reform some detail codes in PDP.
[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
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /**
30  * @brief
31  * description of power change reasons
32  */
33 enum mali_power_mode {
34         MALI_POWER_MODE_ON,           /**< Power Mali on */
35         MALI_POWER_MODE_LIGHT_SLEEP,  /**< Mali has been idle for a short time, or runtime PM suspend */
36         MALI_POWER_MODE_DEEP_SLEEP,   /**< Mali has been idle for a long time, or OS suspend */
37 };
38
39 /**
40  * dvfs_level_t, 标识一个 dvfs_level (的具体配置).
41  * .DP : dvfs_level.
42  */
43 struct mali_fv_info {
44         /**
45          * 当前 dvfs_level 使用的 gpu_clk_freq.
46          */
47         unsigned long freq;
48         /**
49          * .DP : min_mali_utilization_in_percentage_in_this_level.
50          * 若当前的 mali_utilization_in_percentage
51          *      小于 min_mali_utilization_in_percentage_in_this_level,
52          * 则触发一次 requests_to_jump_down_in_dvfs_level_table,
53          * 当 对 requests_to_jump_down_in_dvfs_level_table 的连续计数
54          * (.DP : continuous_count_of_requests_to_jump_down) 达到一定数值,
55          * 则 dvfs_facility 会下跳一个 level.
56          */
57         unsigned int min;
58         /**
59          * .DP : max_mali_utilization_in_percentage_in_this_level.
60          * 若当前的 mali_utilization_in_percentage
61          *      大于 max_mali_utilization_in_percentage_in_this_level,
62          * 则触发一次 requests_to_jump_up_in_dvfs_level_table,
63          * 当 对 requests_to_jump_up_in_dvfs_level_table 的连续计数
64          * (.DP : continuous_count_of_requests_to_jump_up) 达到一定数值,
65          *      则 dvfs_facility 会上跳一个 level.
66          */
67         unsigned int max;
68 };
69
70 /**
71  * mali_driver_private_data_t.
72  * 和 平台相关的 mali_driver 的私有数据,
73  *              包含 clk, power_domain handles, mali_dvfs_facility 等.
74  *
75  * 该类型在 platform_dependent_part 中定义,
76  * 显然也只会在 platform_dependent_part 中使用.
77  */
78 struct mali_platform_drv_data {
79         /**
80          * gpu_dvfs_node
81          */
82         struct dvfs_node *clk;
83
84         /**
85          * gpu_power_domain.
86          */
87         struct clk *pd;
88
89         /**
90          * available_dvfs_level_list.
91          * 将用于保存 系统配置支持的所有 dvfs_level.
92          * .R : 实际上, 放在 mali_dvfs_context 中为宜.
93          */
94         struct mali_fv_info *fv_info;
95         /**
96          * len_of_available_dvfs_level_list, 也即 根据系统配置得到的 available_dvfs_level 的个数.
97          */
98         unsigned int fv_info_length;
99
100         /**
101          * mali_dvfs_context.
102          */
103         struct mali_dvfs dvfs;
104
105         /**
106          * device_of_mali_gpu.
107          */
108         struct device *dev;
109
110         /**
111          * gpu 是否 "被上电, 且被送入 clk".
112          */
113         bool power_state;
114
115         _mali_osk_mutex_t *clock_set_lock;
116 };
117
118 /** @brief Platform specific setup and initialisation of MALI
119  *
120  * This is called from the entrypoint of the driver to initialize the platform
121  *
122  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
123  */
124 _mali_osk_errcode_t mali_platform_init(struct platform_device *pdev);
125
126 /** @brief Platform specific deinitialisation of MALI
127  *
128  * This is called on the exit of the driver to terminate the platform
129  *
130  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
131  */
132 _mali_osk_errcode_t mali_platform_deinit(struct platform_device *pdev);
133
134 /** @brief Platform specific powerdown sequence of MALI
135  *
136  * Notification from the Mali device driver stating the new desired power mode.
137  * MALI_POWER_MODE_ON must be obeyed, while the other modes are optional.
138  * @param power_mode defines the power modes
139  * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
140  */
141 _mali_osk_errcode_t mali_platform_power_mode_change(
142                         enum mali_power_mode power_mode);
143
144
145 /**
146  * @brief
147  * Platform specific handling
148  *      of GPU utilization data
149  *
150  * When GPU utilization data is enabled,
151  * this function
152  * will be periodically called.
153  *
154  * @param utilization
155  *      The workload utilization
156  *              of the Mali GPU.
157  *      0 = no utilization,
158  *      256 = full utilization.
159  */
160 void mali_gpu_utilization_handler(struct mali_gpu_utilization_data *data);
161
162 int mali_set_level(struct device *dev, int level);
163
164 #ifdef __cplusplus
165 }
166 #endif
167 #endif