From: Hyeonseong Gil Date: Fri, 24 Mar 2017 01:49:05 +0000 (+0900) Subject: [COMMON] thermal: samsung: Move cpufreq_cooling_register X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=215f26f80520e90e84fb4f61e80d8e23868fd645;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] thermal: samsung: Move cpufreq_cooling_register 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 --- diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 5f9002169df0..e4b41a604124 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -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); diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 783a420faeb1..6756ec726ce0 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c @@ -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; diff --git a/include/linux/cpu_cooling.h b/include/linux/cpu_cooling.h index 0958f782b0d9..037e212da5f2 100644 --- a/include/linux/cpu_cooling.h +++ b/include/linux/cpu_cooling.h @@ -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) {