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>
31 * description of power change reasons
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 */
40 * dvfs_level_t, 标识一个 dvfs_level (的具体配置).
45 * 当前 dvfs_level 使用的 gpu_clk_freq.
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.
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.
71 * mali_driver_private_data_t.
72 * 和 平台相关的 mali_driver 的私有数据,
73 * 包含 clk, power_domain handles, mali_dvfs_facility 等.
75 * 该类型在 platform_dependent_part 中定义,
76 * 显然也只会在 platform_dependent_part 中使用.
78 struct mali_platform_drv_data {
82 struct dvfs_node *clk;
90 * available_dvfs_level_list.
91 * 将用于保存 系统配置支持的所有 dvfs_level.
92 * .R : 实际上, 放在 mali_dvfs_context 中为宜.
94 struct mali_fv_info *fv_info;
96 * len_of_available_dvfs_level_list, 也即 根据系统配置得到的 available_dvfs_level 的个数.
98 unsigned int fv_info_length;
103 struct mali_dvfs dvfs;
106 * device_of_mali_gpu.
111 * gpu 是否 "被上电, 且被送入 clk".
115 _mali_osk_mutex_t *clock_set_lock;
118 /** @brief Platform specific setup and initialisation of MALI
120 * This is called from the entrypoint of the driver to initialize the platform
122 * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
124 _mali_osk_errcode_t mali_platform_init(struct platform_device *pdev);
126 /** @brief Platform specific deinitialisation of MALI
128 * This is called on the exit of the driver to terminate the platform
130 * @return _MALI_OSK_ERR_OK on success otherwise, a suitable _mali_osk_errcode_t error.
132 _mali_osk_errcode_t mali_platform_deinit(struct platform_device *pdev);
134 /** @brief Platform specific powerdown sequence of MALI
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.
141 _mali_osk_errcode_t mali_platform_power_mode_change(
142 enum mali_power_mode power_mode);
147 * Platform specific handling
148 * of GPU utilization data
150 * When GPU utilization data is enabled,
152 * will be periodically called.
155 * The workload utilization
157 * 0 = no utilization,
158 * 256 = full utilization.
160 void mali_gpu_utilization_handler(struct mali_gpu_utilization_data *data);
162 int mali_set_level(struct device *dev, int level);