[COMMON] thermal: gpu_cooling: Use g3d_cmu_cal_id from dt
authorHyeonseong Gil <hs.gil@samsung.com>
Fri, 23 Mar 2018 08:01:26 +0000 (17:01 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:22:28 +0000 (17:22 +0900)
Change-Id: Ibbdd6813d9b4482497b0c4fa6b7020a9f8e42790
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/gpu_cooling.c
drivers/thermal/samsung/exynos_tmu.c

index 37b605d6d32f0aaacaab21d8f75f110314d21d91..8170e8c7606b80b81921d18359e1bd88e3afc744 100644 (file)
 #include <soc/samsung/ect_parser.h>
 #include "samsung/exynos_tmu.h"
 
-#if defined(CONFIG_SOC_EXYNOS8895) && defined(CONFIG_SOC_EMULATOR8895)
-#include <dt-bindings/clock/emulator8895.h>
-#elif defined(CONFIG_SOC_EXYNOS8895) && !defined(CONFIG_SOC_EMULATOR8895)
-#include <dt-bindings/clock/exynos8895.h>
-#elif defined(CONFIG_SOC_EXYNOS7872)
-#include <dt-bindings/clock/exynos7872.h>
-#elif defined(CONFIG_SOC_EXYNOS9810)
-#include <dt-bindings/clock/exynos9810.h>
-#endif
-
 /**
  * struct power_table - frequency to power conversion
  * @frequency: frequency in KHz
@@ -333,15 +323,23 @@ static int build_dyn_power_table(struct gpufreq_cooling_device *gpufreq_cdev,
        return 0;
 }
 
-static int build_static_power_table(struct gpufreq_cooling_device *gpufreq_cdev)
+static int build_static_power_table(struct device_node *np, struct gpufreq_cooling_device *gpufreq_cdev)
 {
        int i, j;
-       int ratio = cal_asv_get_ids_info(ACPM_DVFS_G3D);
-       int asv_group = cal_asv_get_grp(ACPM_DVFS_G3D);
+       int ratio = 0, asv_group = 0, cal_id = 0, ret = 0;
        void *gen_block;
        struct ect_gen_param_table *volt_temp_param, *asv_param;
        int ratio_table[16] = { 0, 25, 29, 35, 41, 48, 57, 67, 79, 94, 110, 130, 151, 162, 162, 162};
 
+       ret = of_property_read_u32(np, "g3d_cmu_cal_id", &cal_id);
+       if (ret) {
+               pr_err("%s: Failed to get cal-id\n", __func__);
+               return -EINVAL;
+       }
+
+       ratio = cal_asv_get_ids_info(cal_id);
+       asv_group = cal_asv_get_grp(cal_id);
+
        if (asv_group < 0 || asv_group > 15)
                asv_group = 0;
 
@@ -870,7 +868,7 @@ __gpufreq_cooling_register(struct device_node *np,
                if (ret)
                        return ERR_PTR(ret);
 
-               ret = build_static_power_table(gpufreq_cdev);
+               ret = build_static_power_table(np, gpufreq_cdev);
                if (ret)
                        return ERR_PTR(ret);
        }
index afca16b4d2d2710bc1cc7c5d1c0442977e38c0cb..e569971f2e09be647b1c00fce2ef86aa8669369c 100644 (file)
 #define EXYNOS_TMU_LPI_MODE_SHIFT              (10)
 #define EXYNOS_TMU_LPI_MODE_MASK               (1)
 
+#define EXYNOS_GPU_THERMAL_ZONE_ID             (2)
+
 #define TOTAL_SENSORS          16
 #define DEFAULT_BALANCE_OFFSET 20
 
@@ -1472,7 +1474,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
                data->tzd->ops->set_mode(data->tzd, THERMAL_DEVICE_ENABLED);
 
 #ifdef CONFIG_MALI_DEBUG_KERNEL_SYSFS
-       if (data->id == 2)
+       if (data->id == EXYNOS_GPU_THERMAL_ZONE_ID)
                gpu_thermal_data = data;
 #endif
 
@@ -1669,7 +1671,7 @@ static ssize_t ipc_dump2_read(struct file *file, char __user *user_buf,
        char buf[48];
        ssize_t ret;
 
-       exynos_acpm_tmu_ipc_dump(2, data.dump);
+       exynos_acpm_tmu_ipc_dump(EXYNOS_GPU_THERMAL_ZONE_ID, data.dump);
 
        ret = snprintf(buf, sizeof(buf), "%3d %3d %3d %3d %3d %3d %3d\n",
                        data.val[1], data.val[2], data.val[3],