thermal: exynos: Add cpufreq cooling regist code.
authorPark Chungwoo <cww.park@samsung.com>
Wed, 9 Mar 2016 05:30:58 +0000 (14:30 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:09:09 +0000 (17:09 +0900)
Change-Id: I4e598f4a25f32e5e8f35aa9ef2830e626c6396a7
Signed-off-by: Park Chungwoo <cww.park@samsung.com>
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/thermal/samsung/exynos_tmu.c

index 87e39d04978ccf5a3638ea47c4d3b893149ee669..df885203c0bfd3c9a254751042341caef42f69d2 100644 (file)
@@ -220,6 +220,7 @@ struct exynos_tmu_data {
        struct regulator *regulator;
        struct thermal_zone_device *tzd;
        unsigned int ntrip;
+       struct thermal_cooling_device *cool_dev;
 
        int (*tmu_initialize)(struct platform_device *pdev);
        void (*tmu_control)(struct platform_device *pdev, bool on);
@@ -1479,6 +1480,40 @@ 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, *gchild, *ggchild;
+       struct device_node *cool_np;
+       struct of_phandle_args cooling_spec;
+       struct cpumask mask_val;
+       int cpu, ret;
+
+       np = of_find_node_by_name(NULL, "thermal-zones");
+       if (!np)
+               return -ENODEV;
+
+       /* Regist cpufreq cooling register */
+       child = of_get_next_child(np, NULL);
+       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("exynos_tmu do not get cooling spec \n");
+       }
+       cool_np = cooling_spec.np;
+
+       for_each_possible_cpu(cpu) {
+               if (cpu_topology[cpu].cluster_id == 0) {
+                       cpumask_copy(&mask_val, topology_core_cpumask(cpu));
+               }
+       }
+
+       data->cool_dev = of_cpufreq_cooling_register(cool_np, &mask_val);
+
+       return ret;
+}
+
 static int exynos_tmu_probe(struct platform_device *pdev)
 {
        struct exynos_tmu_data *data;
@@ -1514,6 +1549,12 @@ static int exynos_tmu_probe(struct platform_device *pdev)
        if (ret)
                goto err_sensor;
 
+       ret = exynos_cpufreq_cooling_register(data);
+       if (ret) {
+               dev_err(&pdev->dev, "Failed cooling register \n");
+               goto err_sensor;
+       }
+
        INIT_WORK(&data->irq_work, exynos_tmu_work);
 
        /*