aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/samsung/exynos_thermal_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/samsung/exynos_thermal_common.c')
-rw-r--r--drivers/thermal/samsung/exynos_thermal_common.c67
1 files changed, 42 insertions, 25 deletions
diff --git a/drivers/thermal/samsung/exynos_thermal_common.c b/drivers/thermal/samsung/exynos_thermal_common.c
index 99318e533c44..af0ae77eb019 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.c
+++ b/drivers/thermal/samsung/exynos_thermal_common.c
@@ -79,17 +79,24 @@ static int exynos_set_mode(struct thermal_zone_device *thermal,
79static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, 79static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
80 enum thermal_trip_type *type) 80 enum thermal_trip_type *type)
81{ 81{
82 switch (GET_ZONE(trip)) { 82 struct exynos_thermal_zone *th_zone = thermal->devdata;
83 case MONITOR_ZONE: 83 int max_trip = th_zone->sensor_conf->trip_data.trip_count;
84 case WARN_ZONE: 84 int trip_type;
85 *type = THERMAL_TRIP_ACTIVE; 85
86 break; 86 if (trip < 0 || trip >= max_trip)
87 case PANIC_ZONE: 87 return -EINVAL;
88
89 trip_type = th_zone->sensor_conf->trip_data.trip_type[trip];
90
91 if (trip_type == SW_TRIP)
88 *type = THERMAL_TRIP_CRITICAL; 92 *type = THERMAL_TRIP_CRITICAL;
89 break; 93 else if (trip_type == THROTTLE_ACTIVE)
90 default: 94 *type = THERMAL_TRIP_ACTIVE;
95 else if (trip_type == THROTTLE_PASSIVE)
96 *type = THERMAL_TRIP_PASSIVE;
97 else
91 return -EINVAL; 98 return -EINVAL;
92 } 99
93 return 0; 100 return 0;
94} 101}
95 102
@@ -98,8 +105,9 @@ static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
98 unsigned long *temp) 105 unsigned long *temp)
99{ 106{
100 struct exynos_thermal_zone *th_zone = thermal->devdata; 107 struct exynos_thermal_zone *th_zone = thermal->devdata;
108 int max_trip = th_zone->sensor_conf->trip_data.trip_count;
101 109
102 if (trip < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE)) 110 if (trip < 0 || trip >= max_trip)
103 return -EINVAL; 111 return -EINVAL;
104 112
105 *temp = th_zone->sensor_conf->trip_data.trip_val[trip]; 113 *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,
113static int exynos_get_crit_temp(struct thermal_zone_device *thermal, 121static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
114 unsigned long *temp) 122 unsigned long *temp)
115{ 123{
116 int ret; 124 struct exynos_thermal_zone *th_zone = thermal->devdata;
117 /* Panic zone */ 125 int max_trip = th_zone->sensor_conf->trip_data.trip_count;
118 ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp); 126 /* Get the temp of highest trip*/
119 return ret; 127 return exynos_get_trip_temp(thermal, max_trip - 1, temp);
120} 128}
121 129
122/* Bind callback functions for thermal zone */ 130/* Bind callback functions for thermal zone */
@@ -348,19 +356,28 @@ int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf)
348 return -ENOMEM; 356 return -ENOMEM;
349 357
350 th_zone->sensor_conf = sensor_conf; 358 th_zone->sensor_conf = sensor_conf;
351 cpumask_set_cpu(0, &mask_val); 359 /*
352 th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); 360 * TODO: 1) Handle multiple cooling devices in a thermal zone
353 if (IS_ERR(th_zone->cool_dev[0])) { 361 * 2) Add a flag/name in cooling info to map to specific
354 pr_err("Failed to register cpufreq cooling device\n"); 362 * sensor
355 ret = -EINVAL; 363 */
356 goto err_unregister; 364 if (sensor_conf->cooling_data.freq_clip_count > 0) {
365 cpumask_set_cpu(0, &mask_val);
366 th_zone->cool_dev[th_zone->cool_dev_size] =
367 cpufreq_cooling_register(&mask_val);
368 if (IS_ERR(th_zone->cool_dev[th_zone->cool_dev_size])) {
369 pr_err("Failed to register cpufreq cooling device\n");
370 ret = -EINVAL;
371 goto err_unregister;
372 }
373 th_zone->cool_dev_size++;
357 } 374 }
358 th_zone->cool_dev_size++;
359 375
360 th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, 376 th_zone->therm_dev = thermal_zone_device_register(
361 EXYNOS_ZONE_COUNT, 0, th_zone, &exynos_dev_ops, NULL, 0, 377 sensor_conf->name, sensor_conf->trip_data.trip_count,
362 sensor_conf->trip_data.trigger_falling ? 378 0, th_zone, &exynos_dev_ops, NULL, 0,
363 0 : IDLE_INTERVAL); 379 sensor_conf->trip_data.trigger_falling ? 0 :
380 IDLE_INTERVAL);
364 381
365 if (IS_ERR(th_zone->therm_dev)) { 382 if (IS_ERR(th_zone->therm_dev)) {
366 pr_err("Failed to register thermal zone device\n"); 383 pr_err("Failed to register thermal zone device\n");