Commit 5c3cf552 authored by Amit Daniel Kachhap's avatar Amit Daniel Kachhap Committed by Eduardo Valentin

thermal: exynos: Make the zone handling use trip information

This code simplifies the zone handling to use the trip information passed
by the TMU driver and not the hardcoded macros. This also helps in adding
more zone support.
Acked-by: default avatarKukjin Kim <kgene.kim@samsung.com>
Acked-by: default avatarJonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: default avatarAmit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: default avatarEduardo Valentin <eduardo.valentin@ti.com>
parent 23a3eb10
...@@ -79,17 +79,24 @@ static int exynos_set_mode(struct thermal_zone_device *thermal, ...@@ -79,17 +79,24 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
enum thermal_trip_type *type) enum thermal_trip_type *type)
{ {
switch (GET_ZONE(trip)) { struct exynos_thermal_zone *th_zone = thermal->devdata;
case MONITOR_ZONE: int max_trip = th_zone->sensor_conf->trip_data.trip_count;
case WARN_ZONE: int trip_type;
*type = THERMAL_TRIP_ACTIVE;
break; if (trip < 0 || trip >= max_trip)
case PANIC_ZONE: return -EINVAL;
trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
if (trip_type == SW_TRIP)
*type = THERMAL_TRIP_CRITICAL; *type = THERMAL_TRIP_CRITICAL;
break; else if (trip_type == THROTTLE_ACTIVE)
default: *type = THERMAL_TRIP_ACTIVE;
else if (trip_type == THROTTLE_PASSIVE)
*type = THERMAL_TRIP_PASSIVE;
else
return -EINVAL; return -EINVAL;
}
return 0; return 0;
} }
...@@ -98,8 +105,9 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, ...@@ -98,8 +105,9 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
unsigned long *temp) unsigned long *temp)
{ {
struct exynos_thermal_zone *th_zone = thermal->devdata; struct exynos_thermal_zone *th_zone = thermal->devdata;
int max_trip = th_zone->sensor_conf->trip_data.trip_count;
if (trip < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE)) if (trip < 0 || trip >= max_trip)
return -EINVAL; return -EINVAL;
*temp = th_zone->sensor_conf->trip_data.trip_val[trip]; *temp = th_zone->sensor_conf->trip_data.trip_val[trip];
...@@ -113,10 +121,10 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, ...@@ -113,10 +121,10 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
static int exynos_get_crit_temp(struct thermal_zone_device *thermal, static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
unsigned long *temp) unsigned long *temp)
{ {
int ret; struct exynos_thermal_zone *th_zone = thermal->devdata;
/* Panic zone */ int max_trip = th_zone->sensor_conf->trip_data.trip_count;
ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp); /* Get the temp of highest trip*/
return ret; return exynos_get_trip_temp(thermal, max_trip - 1, temp);
} }
/* Bind callback functions for thermal zone */ /* Bind callback functions for thermal zone */
...@@ -348,19 +356,28 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) ...@@ -348,19 +356,28 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
return -ENOMEM; return -ENOMEM;
th_zone->sensor_conf = sensor_conf; th_zone->sensor_conf = sensor_conf;
/*
* TODO: 1) Handle multiple cooling devices in a thermal zone
* 2) Add a flag/name in cooling info to map to specific
* sensor
*/
if (sensor_conf->cooling_data.freq_clip_count > 0) {
cpumask_set_cpu(0, &mask_val); cpumask_set_cpu(0, &mask_val);
th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); th_zone->cool_dev[th_zone->cool_dev_size] =
if (IS_ERR(th_zone->cool_dev[0])) { cpufreq_cooling_register(&mask_val);
if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
pr_err("Failed to register cpufreq cooling device\n"); pr_err("Failed to register cpufreq cooling device\n");
ret = -EINVAL; ret = -EINVAL;
goto err_unregister; goto err_unregister;
} }
th_zone->cool_dev_size++; th_zone->cool_dev_size++;
}
th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, th_zone->therm_dev = thermal_zone_device_register(
EXYNOS_ZONE_COUNT, 0, th_zone, &exynos_dev_ops, NULL, 0, sensor_conf->name, sensor_conf->trip_data.trip_count,
sensor_conf->trip_data.trigger_falling ? 0, th_zone, &exynos_dev_ops, NULL, 0,
0 : IDLE_INTERVAL); sensor_conf->trip_data.trigger_falling ? 0 :
IDLE_INTERVAL);
if (IS_ERR(th_zone->therm_dev)) { if (IS_ERR(th_zone->therm_dev)) {
pr_err("Failed to register thermal zone device\n"); pr_err("Failed to register thermal zone device\n");
......
...@@ -42,8 +42,6 @@ ...@@ -42,8 +42,6 @@
#define GET_ZONE(trip) (trip + 2) #define GET_ZONE(trip) (trip + 2)
#define GET_TRIP(zone) (zone - 2) #define GET_TRIP(zone) (zone - 2)
#define EXYNOS_ZONE_COUNT 3
enum trigger_type { enum trigger_type {
THROTTLE_ACTIVE = 1, THROTTLE_ACTIVE = 1,
THROTTLE_PASSIVE, THROTTLE_PASSIVE,
...@@ -69,6 +67,7 @@ struct freq_clip_table { ...@@ -69,6 +67,7 @@ struct freq_clip_table {
struct thermal_trip_point_conf { struct thermal_trip_point_conf {
int trip_val[MAX_TRIP_COUNT]; int trip_val[MAX_TRIP_COUNT];
int trip_type[MAX_TRIP_COUNT];
int trip_count; int trip_count;
unsigned char trigger_falling; unsigned char trigger_falling;
}; };
......
...@@ -509,9 +509,12 @@ static int exynos_tmu_probe(struct platform_device *pdev) ...@@ -509,9 +509,12 @@ static int exynos_tmu_probe(struct platform_device *pdev)
pdata->trigger_enable[1] + pdata->trigger_enable[2]+ pdata->trigger_enable[1] + pdata->trigger_enable[2]+
pdata->trigger_enable[3]; pdata->trigger_enable[3];
for (i = 0; i < exynos_sensor_conf.trip_data.trip_count; i++) for (i = 0; i < exynos_sensor_conf.trip_data.trip_count; i++) {
exynos_sensor_conf.trip_data.trip_val[i] = exynos_sensor_conf.trip_data.trip_val[i] =
pdata->threshold + pdata->trigger_levels[i]; pdata->threshold + pdata->trigger_levels[i];
exynos_sensor_conf.trip_data.trip_type[i] =
pdata->trigger_type[i];
}
exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling; exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling;
......
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