[COMMON] thermal: samsung: Move isp_cooling_register
authorHyeonseong Gil <hs.gil@samsung.com>
Thu, 30 Mar 2017 01:46:22 +0000 (10:46 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:18:35 +0000 (17:18 +0900)
Change-Id: I15f4aa845684c3d1811f69799520618d6075159a
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/isp_cooling.c
drivers/thermal/samsung/exynos_tmu.c
include/linux/isp_cooling.h

index e8b2227082a61dd2b6c3ef6afa7c5fdf4ecf1d5c..0df3cf1f5a5ace3a3f9a0ef521141633c26dbe41 100644 (file)
@@ -485,36 +485,29 @@ EXPORT_SYMBOL_GPL(isp_cooling_unregister);
 
 /**
  * isp_cooling_table_init - function to make ISP fps throttling table.
- * @pdev : struct platform_device pointer
  *
  * Return : a valid struct isp_fps_table pointer on success,
  * on failture, it returns a corresponding ERR_PTR().
  */
-int isp_cooling_table_init(struct platform_device *pdev)
+static int isp_cooling_table_init(void)
 {
        int ret = 0, i = 0;
 #if defined(CONFIG_ECT)
-       struct exynos_tmu_data *exynos_data;
        void *thermal_block;
        struct ect_ap_thermal_function *function;
        int last_fps = -1, count = 0;
-#else
-       unsigned int table_size;
-       u32 isp_idx_num = 0;
 #endif
 
 #if defined(CONFIG_ECT)
-       exynos_data = platform_get_drvdata(pdev);
-
        thermal_block = ect_get_block(BLOCK_AP_THERMAL);
        if (thermal_block == NULL) {
-               dev_err(&pdev->dev, "Failed to get thermal block");
+               pr_err("Failed to get thermal block");
                return -ENODEV;
        }
 
-       function = ect_ap_thermal_get_function(thermal_block, exynos_data->tmu_name);
+       function = ect_ap_thermal_get_function(thermal_block, "ISP");
        if (function == NULL) {
-               dev_err(&pdev->dev, "Failed to get %s information", exynos_data->tmu_name);
+               pr_err("Failed to get ISP thermal information");
                return -ENODEV;
        }
 
@@ -530,7 +523,7 @@ int isp_cooling_table_init(struct platform_device *pdev)
                isp_fps_table[count].fps = function->range_list[i].max_frequency;
                last_fps = isp_fps_table[count].fps;
 
-               dev_info(&pdev->dev, "[ISP TMU] index : %d, fps : %d \n",
+               pr_info("[ISP TMU] index : %d, fps : %d\n",
                        isp_fps_table[count].driver_data, isp_fps_table[count].fps);
                count++;
        }
@@ -538,27 +531,39 @@ int isp_cooling_table_init(struct platform_device *pdev)
        if (i == function->num_of_range)
                isp_fps_table[count].fps = ISP_FPS_TABLE_END;
 #else
-       /* isp cooling frequency table parse */
-       ret = of_property_read_u32(pdev->dev.of_node, "isp_idx_num", &isp_idx_num);
-       if (ret < 0)
-               dev_err(&pdev->dev, "isp_idx_num happend error value\n");
-
-       if (isp_idx_num) {
-               isp_fps_table = kzalloc(sizeof(struct isp_fps_table)* isp_idx_num, GFP_KERNEL);
-               if (!isp_fps_table) {
-                       dev_err(&pdev->dev, "failed to allocate for isp_table\n");
-                       return -ENODEV;
-               }
-               table_size = sizeof(struct isp_fps_table) / sizeof(unsigned int);
-               ret = of_property_read_u32_array(pdev->dev.of_node, "isp_cooling_table",
-                       (unsigned int *)isp_fps_table, table_size * isp_idx_num);
+       pr_err("[ISP cooling] could not find ECT information\n");
+       ret = -EINVAL;
+#endif
+       return ret;
+}
 
-               for (i = 0; i < isp_idx_num; i++) {
-                       dev_info(&pdev->dev, "[ISP TMU] index : %d, fps : %d \n",
-                               isp_fps_table[i].driver_data, isp_fps_table[i].fps);
-               }
+static int __init exynos_isp_cooling_init(void)
+{
+       struct device_node *np;
+       struct thermal_cooling_device *dev;
+       int ret = 0;
+
+       ret = isp_cooling_table_init();
+
+       if (ret) {
+               pr_err("Fail to initialize isp_cooling_table\n");
+               return ret;
        }
-#endif
+
+       np = of_find_node_by_name(NULL, "fimc_is");
+
+       if (!np) {
+               pr_err("Fail to find device node\n");
+               return -EINVAL;
+       }
+
+       dev = of_isp_cooling_register(np, 0);
+
+       if (IS_ERR(dev)) {
+               pr_err("Fail to register isp cooling\n");
+               return -EINVAL;
+       }
+
        return ret;
 }
-EXPORT_SYMBOL_GPL(isp_cooling_table_init);
+device_initcall(exynos_isp_cooling_init);
index e81006b067a16d5f1dc9d69682902ba790992955..94e6bccbe3e1a91275e103f8e3e4d1a11cdbd4e7 100644 (file)
@@ -1441,49 +1441,6 @@ static const struct thermal_zone_of_device_ops exynos_sensor_ops = {
        .get_trend = exynos_get_trend,
 };
 
-#ifdef CONFIG_ISP_THERMAL
-static int exynos_isp_cooling_register(struct exynos_tmu_data *data)
-{
-       struct device_node *np, *child = NULL, *gchild, *ggchild;
-       struct device_node *cool_np;
-       struct of_phandle_args cooling_spec;
-       int ret;
-
-       np = of_find_node_by_name(NULL, "thermal-zones");
-       if (!np)
-               return -ENODEV;
-
-       /* Regist isp cooling device */
-       for_each_child_of_node(np, child) {
-               struct device_node *zone_np;
-               zone_np = of_parse_phandle(child, "thermal-sensors", 0);
-
-               if (zone_np == data->np) break;
-       }
-
-       gchild = of_get_child_by_name(child, "cooling-maps");
-       ggchild = of_get_next_child(gchild, NULL);
-       ret = of_parse_phandle_with_args(ggchild, "cooling-device", "#cooling-cells",
-                                        0, &cooling_spec);
-       if (ret < 0)
-               pr_err("%s do not get cooling spec(err = %d) \n", data->tmu_name, ret);
-
-       cool_np = cooling_spec.np;
-
-       data->cool_dev = of_isp_cooling_register(cool_np, NULL);
-
-       if (IS_ERR(data->cool_dev)) {
-               data->cool_dev = NULL;
-               pr_err("isp cooling device register fail \n");
-               return -ENODEV;
-       }
-
-       return ret;
-}
-#else
-static int exynos_isp_cooling_register(struct exynos_tmu_data *data) {return 0;}
-#endif
-
 static ssize_t
 balance_offset_show(struct device *dev, struct device_attribute *devattr,
                       char *buf)
@@ -1655,18 +1612,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
        if (ret)
                goto err_sensor;
 
-       if (data->id == 3) {
-               ret = isp_cooling_table_init(pdev);
-               if (ret)
-                       goto err_sensor;
-
-               ret = exynos_isp_cooling_register(data);
-               if (ret) {
-                       dev_err(&pdev->dev, "Failed cooling register \n");
-                       goto err_sensor;
-               }
-       }
-
        INIT_WORK(&data->irq_work, exynos_tmu_work);
 
        /*
index ea90308f27b5be3912a874a4486c79ec05ff6109..d3302d62c0de61fe4a50a6320b41b8fe760ea23f 100644 (file)
@@ -106,12 +106,7 @@ void isp_cooling_unregister(struct thermal_cooling_device *cdev);
 
 unsigned long isp_cooling_get_level(unsigned int isp, unsigned int fps);
 unsigned long isp_cooling_get_fps(unsigned int isp, unsigned long level);
-/**
- * isp_cooling_table_init - function to make ISP fps throttling table.
- * @pdev : platform_device pointer
- */
-int isp_cooling_table_init(struct platform_device *pdev);
-#else /* !CONFIG_GPU_THERMAL */
+#else /* !CONFIG_ISP_THERMAL */
 static inline struct thermal_cooling_device *
 isp_cooling_register(const struct cpumask *clip_gpus)
 {
@@ -138,10 +133,6 @@ unsigned long isp_cooling_get_fps(unsigned int isp, unsigned long level)
 {
        return ISP_FPS_INVALID;
 }
-static inline int isp_cooling_table_init(struct platform_device *dev)
-{
-       return true;
-}
 #endif /* CONFIG_ISP_THERMAL */
 
 #endif /* __ISP_COOLING_H__ */