[COMMON] thermal: samsung: Move cpufreq_cooling_register
authorHyeonseong Gil <hs.gil@samsung.com>
Fri, 24 Mar 2017 01:49:05 +0000 (10:49 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:18:34 +0000 (17:18 +0900)
To remove the dependency of cpu_cooling and exynos_tmu, cooling_register will
be called by cpufreq driver.

Change-Id: Ic3fc64c5d7eeda8f4ca2c7475ad8aec753626389
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/cpu_cooling.c
drivers/thermal/samsung/exynos_tmu.c
include/linux/cpu_cooling.h

index 5f9002169df007a0f804144ef0d8337e4f599e96..e4b41a60412478d6d0590e551436d041a10d8e43 100644 (file)
@@ -1108,3 +1108,25 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
        kfree(cpufreq_cdev);
 }
 EXPORT_SYMBOL_GPL(cpufreq_cooling_unregister);
+
+struct thermal_cooling_device *
+exynos_cpufreq_cooling_register(const struct cpumask *clip_cpus)
+{
+       struct device *dev;
+       struct device_node *np;
+       u32 capacitance = 0;
+
+       dev = get_cpu_device(cpumask_first(clip_cpus));
+
+       if (!dev)
+               return ERR_PTR(-EINVAL);
+
+       np = of_node_get(dev->of_node);
+
+       if (!np)
+               return ERR_PTR(-EINVAL);
+
+       return __cpufreq_cooling_register(np, clip_cpus, capacitance,
+                               NULL);
+}
+EXPORT_SYMBOL_GPL(exynos_cpufreq_cooling_register);
index 783a420faeb1b7229769680d12ac2d0a00ab01bc..6756ec726ce0c24c99517beac2600aa0166c369a 100644 (file)
@@ -1441,70 +1441,6 @@ static const struct thermal_zone_of_device_ops exynos_sensor_ops = {
        .get_trend = exynos_get_trend,
 };
 
-static int exynos_cpufreq_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;
-       struct cpumask mask_val;
-       int cpu, ret;
-       const char *governor_name;
-       u32 power_coefficient = 0;
-       void *gen_block;
-       struct ect_gen_param_table *pwr_coeff;
-
-       np = of_find_node_by_name(NULL, "thermal-zones");
-       if (!np)
-               return -ENODEV;
-
-       /* Register cpufreq 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;
-
-       for_each_possible_cpu(cpu)
-               if (cpu < NR_CPUS && cpu_topology[cpu].cluster_id == data->id)
-                       cpumask_copy(&mask_val, topology_core_cpumask(cpu));
-
-       if (!of_property_read_string(child, "governor", &governor_name)) {
-               if (!strncasecmp(governor_name, "power_allocator", THERMAL_NAME_LENGTH)) {
-                       gen_block = ect_get_block("GEN");
-                       if (gen_block == NULL) {
-                               pr_err("%s: Failed to get gen block from ECT\n", __func__);
-                               return -EINVAL;
-                       }
-                       pwr_coeff = ect_gen_param_get_table(gen_block, "DTM_PWR_Coeff");
-                       if (pwr_coeff == NULL) {
-                               pr_err("%s: Failed to get power coeff from ECT\n", __func__);
-                               return -EINVAL;
-                       }
-                       power_coefficient = pwr_coeff->parameter[data->id];
-               }
-       }
-
-       data->cool_dev = of_cpufreq_power_cooling_register(cool_np, &mask_val, power_coefficient, NULL);
-
-       if (IS_ERR(data->cool_dev)) {
-               data->cool_dev = NULL;
-               pr_err("cooling device register fail (mask = %x) \n", *(unsigned int*)cpumask_bits(&mask_val));
-               return -ENODEV;
-       }
-
-       return ret;
-}
-
 #ifdef CONFIG_GPU_THERMAL
 
 #ifdef CONFIG_MALI_DEBUG_KERNEL_SYSFS
@@ -1787,13 +1723,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
        if (ret)
                goto err_sensor;
 
-       if (data->id == 0 || data->id == 1) {
-               ret = exynos_cpufreq_cooling_register(data);
-               if (ret) {
-                       dev_err(&pdev->dev, "Failed cooling register \n");
-                       goto err_sensor;
-               }
-       } else if (data->id == 2) {
+       if (data->id == 2) {
                ret = gpu_cooling_table_init(pdev);
                if (ret)
                        goto err_sensor;
index 0958f782b0d979ad60b799f0ec5d28850d50f146..037e212da5f2c7bdf595c67d7e9fbc18a9a11130 100644 (file)
@@ -101,6 +101,10 @@ of_cpufreq_power_cooling_register(struct device_node *np,
                                  struct cpufreq_policy *policy,
                                  u32 capacitance,
                                  get_static_t plat_static_func);
+
+struct thermal_cooling_device *
+exynos_cpufreq_cooling_register(const struct cpumask *clip_cpus);
+
 #else
 static inline struct thermal_cooling_device *
 of_cpufreq_cooling_register(struct device_node *np,
@@ -117,6 +121,13 @@ of_cpufreq_power_cooling_register(struct device_node *np,
 {
        return NULL;
 }
+
+static inline struct thermal_cooling_device *
+exynos_cpufreq_cooling_register(const struct cpumask *clip_cpus);
+{
+       return NULL;
+}
+
 #endif
 
 /**
@@ -154,6 +165,12 @@ of_cpufreq_power_cooling_register(struct device_node *np,
        return NULL;
 }
 
+static inline struct thermal_cooling_device *
+exynos_cpufreq_cooling_register(const struct cpumask *clip_cpus);
+{
+       return NULL;
+}
+
 static inline
 void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
 {