container_of(dvfs, struct mali_platform_drv_data, dvfs)
/*---------------------------------------------------------------------------*/
-
+#if 0
static bool mali_dvfs_should_jump_up(const struct mali_dvfs *p_dvfs)
{
return (p_dvfs->m_count_of_requests_to_jump_up
return (p_dvfs->m_count_of_requests_to_jump_down
>= NUM_OF_CONTINUOUS_REQUESTS_TO_TRIGGER_REAL_JUMPING_DOWN);
}
-
+#endif
/**
* .KP :
* work_to_handle_mali_utilization_event 的实现主体,
* 将根据 current_mali_utilization_data, 改变 current_dvfs_level.
*/
+ #if 0
static void mali_dvfs_event_proc(struct work_struct *w)
{
struct mali_dvfs *dvfs = work_to_dvfs(w);/* mali_dvfs_context. */
return;
}
}
-
+#endif
/**
* 返回 mali_dvfs_facility 当前是否被使能.
*/
dvfs->utilisation = utilisation;
V("mali_utilization_in_percentage : %d", utilisation * 100 / 256);
+#if 0
if (dvfs->enabled) {
/* 将 work_to_handle_mali_utilization_event,
* 放置到 kernel_global_workqueue, 待执行. */
schedule_work(&dvfs->work);
}
+#endif
return MALI_TRUE;
}
-
+#if 0
static void mali_dvfs_threshold(u32 div,
struct mali_platform_drv_data *drv_data)
{
drv_data->fv_info[level].max);
}
}
-
+#endif
/*---------------------------------------------------------------------------*/
int mali_dvfs_init(struct device *dev)
{
+#if 0
struct mali_platform_drv_data *drv_data = dev_get_drvdata(dev);
/*mali_dvfs_context. */
struct mali_dvfs *dvfs = &drv_data->dvfs;
dvfs->m_count_of_requests_to_jump_up = 0;
dvfs->m_count_of_requests_to_jump_down = 0;
+#endif
return 0;
}
void mali_dvfs_term(struct device *dev)
{
+#if 0
struct mali_platform_drv_data *drv_data = dev_get_drvdata(dev);
struct mali_dvfs *dvfs = &drv_data->dvfs;
dvfs->enabled = false;
cancel_work_sync(&dvfs->work);
+#endif
}
* by a licensing agreement from ARM Limited.
*/
-/**
+/*
* @file mali_platform.c
* Platform specific Mali driver functions
* for a default platform
#include "arm_core_scaling.h"
#include "mali_platform.h"
-
-/**
+/*
* 是否使能 core_scaling 机制.
* .DP : core_scaling : 根据当前 mali_utilization_data,
* 配置 mali_gpu 中具体使用的 pp_core 的个数.
u32 mali_group_error;
-/**
+/*
* anchor_of_device_of_mali_gpu.
*/
static struct device *mali_dev;
-/**
+/*
* 设置 current_dvfs_level.
*
* @param level
return ret;
}
- D("have set gpu_clk to %lu of new_level %d, " "the old_level is %d.",
+ D("have set gpu_clk to %lu of new_level %d, the old_level is %d.",
freq,
level,
current_level);
return 0;
}
-/**
+/*
* 初始化 gpu_dvfs_node 和 gpu_power_domain.
*/
static int mali_clock_init(struct device *dev)
{
- int ret;
-
struct mali_platform_drv_data *drv_data = dev_get_drvdata(dev);
+ int err;
+ unsigned long rate = 200 * 1000 * 1000;
- drv_data->pd = devm_clk_get(dev, "pd_gpu");
- if (IS_ERR(drv_data->pd)) {
- ret = PTR_ERR(drv_data->pd);
- /* rk3228 gpu has no power domain,save NULL for compatible*/
- if (ret != -ENOENT) {
- dev_err(dev, "get pd_clk failed, %d\n", ret);
- return ret;
- }
- drv_data->pd = NULL;
- }
+ D("to get clk_mali.");
+ drv_data->clock = clk_get(drv_data->dev, "clk_mali");
+ if (IS_ERR_OR_NULL(drv_data->clock)) {
+ err = PTR_ERR(drv_data->clock);
- if (drv_data->pd) {
- ret = clk_prepare_enable(drv_data->pd);
- if (ret) {
- dev_err(dev, "prepare pd_clk failed, %d\n", ret);
- return ret;
- }
+ drv_data->clock = NULL;
+ E("fail to get clk_mali, err : %d", err);
+ return err;
}
-
- drv_data->clk = clk_get_dvfs_node("clk_gpu");
- if (IS_ERR(drv_data->clk)) {
- ret = PTR_ERR(drv_data->clk);
- dev_err(dev, "prepare clk gpu failed, %d\n", ret);
- return ret;
+ D("to preare and enable clk_mali.");
+ err = clk_prepare_enable(drv_data->clock);
+ if (err) {
+ E("Failed to prepare and enable clock (%d)\n", err);
+ return err;
}
-
- ret = dvfs_clk_prepare_enable(drv_data->clk);
- if (ret) {
- dev_err(dev, "prepare clk failed, %d\n", ret);
- return ret;
+ I("to set freq_of_clk_gpu to %lu.", rate);
+ err = clk_set_rate(drv_data->clock, rate);
+ if (err) {
+ E("Failed to set clock.");
+ return err;
}
- drv_data->power_state = true;
-
+ D("success to init clk_mali.");
return 0;
}
static void mali_clock_term(struct device *dev)
{
- struct mali_platform_drv_data *drv_data = dev_get_drvdata(dev);
-
- dvfs_clk_disable_unprepare(drv_data->clk);
- if (drv_data->pd)
- clk_disable_unprepare(drv_data->pd);
- drv_data->power_state = false;
}
/*---------------------------------------------------------------------------*/
return sprintf(buf, "%d\n", mali_group_error);
}
-static DEVICE_ATTR(available_frequencies, S_IRUGO, show_available_frequencies, NULL);
+static DEVICE_ATTR(available_frequencies,
+ S_IRUGO,
+ show_available_frequencies,
+ NULL);
static DEVICE_ATTR(clock, S_IRUGO | S_IWUSR, show_clock, set_clock);
-static DEVICE_ATTR(dvfs_enable, S_IRUGO | S_IWUSR, show_dvfs_enable, set_dvfs_enable);
+static DEVICE_ATTR(dvfs_enable,
+ S_IRUGO | S_IWUSR,
+ show_dvfs_enable,
+ set_dvfs_enable);
static DEVICE_ATTR(utilisation, S_IRUGO, show_utilisation, NULL);
static DEVICE_ATTR(error_count, 0644, error_count_show, NULL);
.attrs = mali_sysfs_entries,
};
-/**
+/*
* 创建 sysfs_nodes_of_platform_dependent_part.
*/
static int mali_create_sysfs(struct device *dev)
/*---------------------------------------------------------------------------*/
-/**
+/*
* 对 platform_device_of_mali_gpu,
* 完成仅和 platform_dependent_part 有关的初始化.
*/
int ret;
mali_drv_data = devm_kzalloc(dev, sizeof(*mali_drv_data), GFP_KERNEL);
- if (!mali_drv_data) {
- dev_err(dev, "no mem\n");
+ if (!mali_drv_data)
return _MALI_OSK_ERR_NOMEM;
- }
dev_set_drvdata(dev, mali_drv_data);
mali_dev = dev;
+ D("to c all mali_clock_init.");
ret = mali_clock_init(dev);
if (ret)
goto err_init;
+ D("to call mali_dvfs_init.");
ret = mali_dvfs_init(dev);
if (ret)
goto err_init;
+ D("to call mali_create_sysfs.");
ret = mali_create_sysfs(dev);
if (ret)
goto term_clk;
/*---------------------------------------------------------------------------*/
-/**
- * 对 gpu_power_domain(mali_power_domain), "上电, 开 clk" / "下电, 关 clk".
+/*
+ * 对 gpu_power_domain(mali_power_domain),
+ * "上电, 开 clk" / "下电, 关 clk".
* @param bpower_off
* true, 下电.
* false, 对 gpu_power_domain 上电.
*/
+ #if 0
static _mali_osk_errcode_t mali_power_domain_control(bool bpower_off)
{
struct mali_platform_drv_data *drv_data = dev_get_drvdata(mali_dev);
return 0;
}
-
+#endif
_mali_osk_errcode_t mali_platform_power_mode_change(
enum mali_power_mode power_mode)
{
- bool bpower_off;/* 下电. */
-
- switch (power_mode) {
- case MALI_POWER_MODE_ON:
- MALI_DEBUG_PRINT(2, ("MALI_POWER_MODE_ON\r\n"));
- mali_dvfs_enable(mali_dev);
- bpower_off = false;
- break;
-
- case MALI_POWER_MODE_LIGHT_SLEEP:
- MALI_DEBUG_PRINT(2, ("MALI_POWER_MODE_LIGHT_SLEEP\r\n"));
- mali_dvfs_disable(mali_dev);
- /* 预置将下电. */
- bpower_off = true;
- break;
-
- case MALI_POWER_MODE_DEEP_SLEEP:
- MALI_DEBUG_PRINT(2, ("MALI_POWER_MODE_DEEP_SLEEP\r\n"));
- mali_dvfs_disable(mali_dev);
- /* 预置将下电. */
- bpower_off = true;
- break;
-
- default:
- MALI_DEBUG_PRINT(2,
- ("power_mode(%d) not support\n", power_mode));
- return _MALI_OSK_ERR_INVALID_ARGS;
- }
-
- mali_power_domain_control(bpower_off);
-
return 0;
}
/*---------------------------------------------------------------------------*/
-/**
+/*
* 将注册到 common_part 中的, 对 mali_utilization_event 的 handler,
* 即 common_part 会直接将 mali_utilization_event 通知回调到本函数.
*/
* .DP : common_parts : ARM 实现的通用的部分.
*/
-/* #define ENABLE_DEBUG_LOG */
+#define ENABLE_DEBUG_LOG
#include "custom_log.h"
#include <linux/platform_device.h>
#endif
#include <linux/workqueue.h>
#include <linux/dma-mapping.h>
+#include <linux/pm_runtime.h>
#include <linux/rockchip/cpu.h>
#include <linux/mali/mali_utgard.h>
*/
int mali_platform_device_init(struct platform_device *pdev)
{
+// error
int err = 0;
int num_pp_cores = 0;
- MALI_DEBUG_PRINT(2, ("mali_platform_device_register() called\n"));
+ D("mali_platform_device_register() called\n");
+ /*
if (cpu_is_rk312x())
num_pp_cores = 2;
else if (cpu_is_rk3036())
+ */
num_pp_cores = 1;
+ /*
else if (cpu_is_rk3188())
num_pp_cores = 4;
else if (cpu_is_rk3228())
num_pp_cores = 2;
+ */
+ D("to add config.");
mali_platform_device_add_config(pdev);
+ D("to add data to platform_device..");
/* 将 platform_specific_data 添加到 platform_device_of_mali_gpu.
* 这里的 platform_specific_data 的类型由 common_part 定义. */
err = platform_device_add_data(pdev, &mali_gpu_data,
sizeof(mali_gpu_data));
if (err == 0) {
+ D("to init internal_platform_specific_code.");
/* .KP : 初始化 platform_device_of_mali_gpu 中,
* 仅和 platform_dependent_part 相关的部分. */
err = mali_platform_init(pdev);