Commit 1fe391bf authored by Lukasz Majewski's avatar Lukasz Majewski Committed by Eduardo Valentin

thermal: exynos: Modify exynos thermal code to use device tree for cpu cooling configuration

Up till now exynos_tmu_data.c was used for storing CPU cooling configuration
data. Now the Exynos thermal core code uses device tree to get this data.
For this purpose generic thermal code for configuring CPU cooling was
used.
Signed-off-by: default avatarLukasz Majewski <l.majewski@samsung.com>
Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
parent f5576e3a
...@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal, ...@@ -133,47 +133,62 @@ static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
static int exynos_bind(struct thermal_zone_device *thermal, static int exynos_bind(struct thermal_zone_device *thermal,
struct thermal_cooling_device *cdev) struct thermal_cooling_device *cdev)
{ {
int ret = 0, i, tab_size, level;
struct freq_clip_table *tab_ptr, *clip_data;
struct exynos_thermal_zone *th_zone = thermal->devdata; struct exynos_thermal_zone *th_zone = thermal->devdata;
struct thermal_sensor_conf *data = th_zone->sensor_conf; struct thermal_sensor_conf *data = th_zone->sensor_conf;
struct device_node *child, *gchild, *np;
struct of_phandle_args cooling_spec;
unsigned long max, state = 0;
int ret = 0, i = 0;
tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data; /*
tab_size = data->cooling_data.freq_clip_count; * Below code is necessary to skip binding when cpufreq's
* frequency table is not yet initialized.
if (tab_ptr == NULL || tab_size == 0) */
cdev->ops->get_max_state(cdev, &state);
if (!state && !th_zone->cool_dev_size) {
th_zone->cool_dev_size = 1;
th_zone->cool_dev[0] = cdev;
th_zone->bind = false;
return 0; return 0;
}
/* find the cooling device registered*/ np = of_find_node_by_path("/thermal-zones/cpu-thermal");
for (i = 0; i < th_zone->cool_dev_size; i++) if (!np) {
if (cdev == th_zone->cool_dev[i]) pr_err("failed to find thmerla-zones/cpu-thermal node\n");
break; return -ENOENT;
}
/* No matching cooling device */ child = of_get_child_by_name(np, "cooling-maps");
if (i == th_zone->cool_dev_size)
return 0;
/* Bind the thermal zone to the cpufreq cooling device */ for_each_child_of_node(child, gchild) {
for (i = 0; i < tab_size; i++) { ret = of_parse_phandle_with_args(gchild, "cooling-device",
clip_data = (struct freq_clip_table *)&(tab_ptr[i]); "#cooling-cells",
level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max); 0, &cooling_spec);
if (level == THERMAL_CSTATE_INVALID) if (ret < 0) {
return 0; pr_err("missing cooling_device property\n");
switch (GET_ZONE(i)) { goto end;
case MONITOR_ZONE: }
case WARN_ZONE:
if (thermal_zone_bind_cooling_device(thermal, i, cdev, if (cooling_spec.args_count < 2) {
level, 0)) {
dev_err(data->dev,
"error unbinding cdev inst=%d\n", i);
ret = -EINVAL;
}
th_zone->bind = true;
break;
default:
ret = -EINVAL; ret = -EINVAL;
goto end;
} }
max = cooling_spec.args[0];
if (thermal_zone_bind_cooling_device(thermal, i, cdev,
max, 0)) {
dev_err(data->dev,
"thermal error unbinding cdev inst=%d\n", i);
ret = -EINVAL;
goto end;
}
i++;
} }
th_zone->bind = true;
end:
of_node_put(child);
of_node_put(np);
return ret; return ret;
} }
...@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal, ...@@ -182,16 +197,12 @@ static int exynos_bind(struct thermal_zone_device *thermal,
static int exynos_unbind(struct thermal_zone_device *thermal, static int exynos_unbind(struct thermal_zone_device *thermal,
struct thermal_cooling_device *cdev) struct thermal_cooling_device *cdev)
{ {
int ret = 0, i, tab_size; int ret = 0, i;
struct exynos_thermal_zone *th_zone = thermal->devdata; struct exynos_thermal_zone *th_zone = thermal->devdata;
struct thermal_sensor_conf *data = th_zone->sensor_conf; struct thermal_sensor_conf *data = th_zone->sensor_conf;
struct device_node *child, *gchild, *np;
if (th_zone->bind == false) if (th_zone->bind == false || !th_zone->cool_dev_size)
return 0;
tab_size = data->cooling_data.freq_clip_count;
if (tab_size == 0)
return 0; return 0;
/* find the cooling device registered*/ /* find the cooling device registered*/
...@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal, ...@@ -203,23 +214,30 @@ static int exynos_unbind(struct thermal_zone_device *thermal,
if (i == th_zone->cool_dev_size) if (i == th_zone->cool_dev_size)
return 0; return 0;
/* Bind the thermal zone to the cpufreq cooling device */ np = of_find_node_by_path("/thermal-zones/cpu-thermal");
for (i = 0; i < tab_size; i++) { if (!np) {
switch (GET_ZONE(i)) { pr_err("failed to find thmerla-zones/cpu-thermal node\n");
case MONITOR_ZONE: return -ENOENT;
case WARN_ZONE: }
if (thermal_zone_unbind_cooling_device(thermal, i,
cdev)) { child = of_get_child_by_name(np, "cooling-maps");
dev_err(data->dev,
"error unbinding cdev inst=%d\n", i); i = 0;
ret = -EINVAL; for_each_child_of_node(child, gchild) {
} if (thermal_zone_unbind_cooling_device(thermal, i,
th_zone->bind = false; cdev)) {
break; dev_err(data->dev,
default: "error unbinding cdev inst=%d\n", i);
ret = -EINVAL; ret = -EINVAL;
goto end;
} }
i++;
} }
th_zone->bind = false;
end:
of_node_put(child);
of_node_put(np);
return ret; return ret;
} }
......
...@@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev) ...@@ -916,13 +916,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
sensor_conf->trip_data.trigger_falling = pdata->threshold_falling; sensor_conf->trip_data.trigger_falling = pdata->threshold_falling;
sensor_conf->cooling_data.freq_clip_count = pdata->freq_tab_count;
for (i = 0; i < pdata->freq_tab_count; i++) {
sensor_conf->cooling_data.freq_data[i].freq_clip_max =
pdata->freq_tab[i].freq_clip_max;
sensor_conf->cooling_data.freq_data[i].temp_level =
pdata->freq_tab[i].temp_level;
}
sensor_conf->dev = &pdev->dev; sensor_conf->dev = &pdev->dev;
/* Register the sensor with thermal management interface */ /* Register the sensor with thermal management interface */
ret = exynos_register_thermal(sensor_conf); ret = exynos_register_thermal(sensor_conf);
......
...@@ -83,9 +83,6 @@ enum soc_type { ...@@ -83,9 +83,6 @@ enum soc_type {
* @second_point_trim: temp value of the second point trimming * @second_point_trim: temp value of the second point trimming
* @default_temp_offset: default temperature offset in case of no trimming * @default_temp_offset: default temperature offset in case of no trimming
* @cal_type: calibration type for temperature * @cal_type: calibration type for temperature
* @freq_clip_table: Table representing frequency reduction percentage.
* @freq_tab_count: Count of the above table as frequency reduction may
* applicable to only some of the trigger levels.
* *
* This structure is required for configuration of exynos_tmu driver. * This structure is required for configuration of exynos_tmu driver.
*/ */
...@@ -111,8 +108,6 @@ struct exynos_tmu_platform_data { ...@@ -111,8 +108,6 @@ struct exynos_tmu_platform_data {
enum soc_type type; enum soc_type type;
u32 cal_type; u32 cal_type;
u32 cal_mode; u32 cal_mode;
struct freq_clip_table freq_tab[4];
unsigned int freq_tab_count;
}; };
/** /**
......
...@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = { ...@@ -47,15 +47,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
.first_point_trim = 25, .first_point_trim = 25,
.second_point_trim = 85, .second_point_trim = 85,
.default_temp_offset = 50, .default_temp_offset = 50,
.freq_tab[0] = {
.freq_clip_max = 800 * 1000,
.temp_level = 85,
},
.freq_tab[1] = {
.freq_clip_max = 200 * 1000,
.temp_level = 100,
},
.freq_tab_count = 2,
.type = SOC_ARCH_EXYNOS4210, .type = SOC_ARCH_EXYNOS4210,
}, },
}, },
...@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = { ...@@ -87,16 +78,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
.max_efuse_value = 100, \ .max_efuse_value = 100, \
.first_point_trim = 25, \ .first_point_trim = 25, \
.second_point_trim = 85, \ .second_point_trim = 85, \
.default_temp_offset = 50, \ .default_temp_offset = 50
.freq_tab[0] = { \
.freq_clip_max = 800 * 1000, \
.temp_level = 70, \
}, \
.freq_tab[1] = { \
.freq_clip_max = 400 * 1000, \
.temp_level = 95, \
}, \
.freq_tab_count = 2
struct exynos_tmu_init_data const exynos3250_default_tmu_data = { struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
.tmu_data = { .tmu_data = {
...@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = { ...@@ -133,16 +115,7 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
.max_efuse_value = 100, \ .max_efuse_value = 100, \
.first_point_trim = 25, \ .first_point_trim = 25, \
.second_point_trim = 85, \ .second_point_trim = 85, \
.default_temp_offset = 50, \ .default_temp_offset = 50
.freq_tab[0] = { \
.freq_clip_max = 1400 * 1000, \
.temp_level = 70, \
}, \
.freq_tab[1] = { \
.freq_clip_max = 400 * 1000, \
.temp_level = 95, \
}, \
.freq_tab_count = 2
struct exynos_tmu_init_data const exynos4412_default_tmu_data = { struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
.tmu_data = { .tmu_data = {
...@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = { ...@@ -189,16 +162,7 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
.max_efuse_value = 100, \ .max_efuse_value = 100, \
.first_point_trim = 25, \ .first_point_trim = 25, \
.second_point_trim = 85, \ .second_point_trim = 85, \
.default_temp_offset = 50, \ .default_temp_offset = 50,
.freq_tab[0] = { \
.freq_clip_max = 800 * 1000, \
.temp_level = 85, \
}, \
.freq_tab[1] = { \
.freq_clip_max = 200 * 1000, \
.temp_level = 103, \
}, \
.freq_tab_count = 2, \
#define EXYNOS5260_TMU_DATA \ #define EXYNOS5260_TMU_DATA \
__EXYNOS5260_TMU_DATA \ __EXYNOS5260_TMU_DATA \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment