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
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.
12 * @file mali_platform.h
13 * Platform specific Mali driver functions
16 #ifndef __MALI_PLATFORM_H__
17 #define __MALI_PLATFORM_H__
19 #include "mali_dvfs.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>
32 * description of power change reasons
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 */
41 * dvfs_level_t, 标识一个 dvfs_level (的具体配置).
46 * 当前 dvfs_level 使用的 gpu_clk_freq.
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.
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.
72 * mali_driver_private_data_t.
73 * 和 平台相关的 mali_driver 的私有数据,
74 * 包含 clk, power_domain handles, mali_dvfs_facility 等.
76 * 该类型在 platform_dependent_part 中定义,
77 * 显然也只会在 platform_dependent_part 中使用.
79 struct mali_platform_drv_data {
83 struct dvfs_node *clk;
91 * available_dvfs_level_list.
92 * 将用于保存 系统配置支持的所有 dvfs_level.
93 * .R : 实际上, 放在 mali_dvfs_context 中为宜.
95 struct mali_fv_info *fv_info;
97 * len_of_available_dvfs_level_list, 也即 根据系统配置得到的 available_dvfs_level 的个数.
99 unsigned int fv_info_length;
104 struct mali_dvfs dvfs;
107 * device_of_mali_gpu.
112 * gpu 是否 "被上电, 且被送入 clk".
116 _mali_osk_mutex_t *clock_set_lock;
118 /*-------------------------------------------------------*/
125 struct regulator *regulator;
128 /** @brief Platform specific setup and initialisation of MALI
130 * This is called from the entrypoint of the driver to initialize the platform
132 * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
134 _mali_osk_errcode_t mali_platform_init(struct platform_device *pdev);
136 /** @brief Platform specific deinitialisation of MALI
138 * This is called on the exit of the driver to terminate the platform
140 * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
142 _mali_osk_errcode_t mali_platform_deinit(struct platform_device *pdev);
144 /** @brief Platform specific powerdown sequence of MALI
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.
151 _mali_osk_errcode_t mali_platform_power_mode_change(
152 enum mali_power_mode power_mode);
157 * Platform specific handling
158 * of GPU utilization data
160 * When GPU utilization data is enabled,
162 * will be periodically called.
165 * The workload utilization
167 * 0 = no utilization,
168 * 256 = full utilization.
170 void mali_gpu_utilization_handler(struct mali_gpu_utilization_data *data);
172 int mali_set_level(struct device *dev, int level);