MALI: utgard: rockchip: remove code depending on rk_dvfs_module
authorJacob Chen <jacob2.chen@rock-chips.com>
Fri, 22 Jul 2016 04:41:25 +0000 (12:41 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Tue, 26 Jul 2016 09:28:29 +0000 (17:28 +0800)
Set clk_gpu to 200M when initializing.
vdd_gpu isn't initialized explicitly.
DVFS isn't implemented.

Change-Id: I82c242d7929d55b7e40277a24b5c2b06a3121a3c
Signed-off-by: chenzhen <chenzhen@rock-chips.com>
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
drivers/gpu/arm/mali400/mali/platform/rk30/custom_log.h
drivers/gpu/arm/mali400/mali/platform/rk30/mali_dvfs.c
drivers/gpu/arm/mali400/mali/platform/rk30/mali_platform.c
drivers/gpu/arm/mali400/mali/platform/rk30/mali_platform.h
drivers/gpu/arm/mali400/mali/platform/rk30/rk3066.c

index f3a801804a20c2a13a202585ec1c8f98d677fd47..3408a4e25da7d45247a1d12d9ddffa7a698fac29 100755 (executable)
@@ -58,7 +58,7 @@ extern "C" {
 #ifdef ENABLE_VERBOSE_LOG
 /** Verbose log. */
 #define V(fmt, args...) \
-       pr_debug("V : [File] : %s; [Line] : %d; [Func] : %s(); " fmt \
+       pr_info("V : [File] : %s; [Line] : %d; [Func] : %s(); " fmt \
                        "\n",   \
                __FILE__,       \
                __LINE__,       \
@@ -72,7 +72,7 @@ extern "C" {
 #ifdef ENABLE_DEBUG_LOG
 /** Debug log. */
 #define D(fmt, args...) \
-       pr_debug("D : [File] : %s; [Line] : %d; [Func] : %s(); " fmt \
+       pr_info("D : [File] : %s; [Line] : %d; [Func] : %s(); " fmt \
                        "\n",   \
                __FILE__,       \
                __LINE__,       \
index a3d8de0f1b66291a4f225bdfb96fdadb79e99dff..5435ad46a51849ab2b01d9cefa6416922cd757f8 100644 (file)
@@ -41,7 +41,7 @@
        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
@@ -53,12 +53,13 @@ static bool mali_dvfs_should_jump_down(const struct mali_dvfs *p_dvfs)
        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. */
@@ -151,7 +152,7 @@ MAKE_DVFS_LEVEL_UPDATE_EFFECTIVE:
                return;
        }
 }
-
+#endif
 /**
  * 返回 mali_dvfs_facility 当前是否被使能.
  */
@@ -213,15 +214,17 @@ int mali_dvfs_event(struct device *dev, u32 utilisation)
        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)
 {
@@ -262,11 +265,12 @@ static void mali_dvfs_threshold(u32 div,
                         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;
@@ -320,11 +324,13 @@ int mali_dvfs_init(struct device *dev)
        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;
 
@@ -333,5 +339,6 @@ void mali_dvfs_term(struct device *dev)
 
        dvfs->enabled = false;
        cancel_work_sync(&dvfs->work);
+#endif
 }
 
index fd3ecab87bad7ceb8f35dd79ef7818aee96a7aca..bd73ea4e01c6844aa2728b9c80472d90ac862800 100644 (file)
@@ -8,7 +8,7 @@
  * by a licensing agreement from ARM Limited.
  */
 
-/**
+/*
  * @file mali_platform.c
  * Platform specific Mali driver functions
  *      for a default platform
@@ -35,8 +35,7 @@
 #include "arm_core_scaling.h"
 #include "mali_platform.h"
 
-
-/**
+/*
  * 是否使能 core_scaling 机制.
  * .DP : core_scaling : 根据当前 mali_utilization_data,
  *                     配置 mali_gpu 中具体使用的 pp_core 的个数.
@@ -45,12 +44,12 @@ static int mali_core_scaling_enable;
 
 u32 mali_group_error;
 
-/**
+/*
  * anchor_of_device_of_mali_gpu.
  */
 static struct device *mali_dev;
 
-/**
+/*
  * 设置 current_dvfs_level.
  *
  * @param level
@@ -89,7 +88,7 @@ int mali_set_level(struct device *dev, int 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);
@@ -101,60 +100,43 @@ int mali_set_level(struct device *dev, int 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;
 }
 
 /*---------------------------------------------------------------------------*/
@@ -257,9 +239,15 @@ static int error_count_show(struct device *dev,
        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);
 
@@ -276,7 +264,7 @@ static const struct attribute_group mali_attr_group = {
        .attrs  = mali_sysfs_entries,
 };
 
-/**
+/*
  * 创建 sysfs_nodes_of_platform_dependent_part.
  */
 static int mali_create_sysfs(struct device *dev)
@@ -297,7 +285,7 @@ static void mali_remove_sysfs(struct device *dev)
 
 /*---------------------------------------------------------------------------*/
 
-/**
+/*
  * 对 platform_device_of_mali_gpu,
  * 完成仅和 platform_dependent_part 有关的初始化.
  */
@@ -309,10 +297,8 @@ _mali_osk_errcode_t mali_platform_init(struct platform_device *pdev)
        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);
 
@@ -320,14 +306,17 @@ _mali_osk_errcode_t mali_platform_init(struct platform_device *pdev)
 
        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;
@@ -360,12 +349,14 @@ _mali_osk_errcode_t mali_platform_deinit(struct platform_device *pdev)
 
 /*---------------------------------------------------------------------------*/
 
-/**
- * 对  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);
@@ -399,47 +390,16 @@ static _mali_osk_errcode_t mali_power_domain_control(bool bpower_off)
 
        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 通知回调到本函数.
  */
index b97a31ef0196ca7fc99dadb688fd934ce8d3a0ee..ecd0d2825d594a055eb2d8a5e9f220e232ffb0a9 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/mali/mali_utgard.h>
 #include <linux/rockchip/dvfs.h>
 #include <linux/cpufreq.h>
+#include <linux/regulator/consumer.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -113,6 +114,15 @@ struct mali_platform_drv_data {
        bool power_state;
 
        _mali_osk_mutex_t *clock_set_lock;
+
+       /*-------------------------------------------------------*/
+       
+       /**
+        * clk_mali.
+        */
+       struct clk *clock;
+       
+       struct regulator *regulator;
 };
 
 /** @brief Platform specific setup and initialisation of MALI
index 5eda6aa32cfef1178bc14cd38890b93a424f6139..f5ab28f4d3afccc2b46fdfad8f58466f79c79aa1 100644 (file)
@@ -21,7 +21,7 @@
  *     .DP : common_parts : ARM 实现的通用的部分.
  */
 
-/* #define ENABLE_DEBUG_LOG */
+#define ENABLE_DEBUG_LOG
 #include "custom_log.h"
 
 #include <linux/platform_device.h>
@@ -32,6 +32,7 @@
 #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>
@@ -217,27 +218,35 @@ static void mali_platform_device_add_config(struct platform_device *pdev)
  */
 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);