diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/thermal/samsung/exynos_thermal_common.c | 67 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_thermal_common.h | 3 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 5 |
3 files changed, 47 insertions, 28 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, | |||
79 | static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, | 79 | static 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, | |||
113 | static int exynos_get_crit_temp(struct thermal_zone_device *thermal, | 121 | static 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"); |
diff --git a/drivers/thermal/samsung/exynos_thermal_common.h b/drivers/thermal/samsung/exynos_thermal_common.h index 6ca3096568e4..bfcf69ecd123 100644 --- a/drivers/thermal/samsung/exynos_thermal_common.h +++ b/drivers/thermal/samsung/exynos_thermal_common.h | |||
@@ -42,8 +42,6 @@ | |||
42 | #define GET_ZONE(trip) (trip + 2) | 42 | #define GET_ZONE(trip) (trip + 2) |
43 | #define GET_TRIP(zone) (zone - 2) | 43 | #define GET_TRIP(zone) (zone - 2) |
44 | 44 | ||
45 | #define EXYNOS_ZONE_COUNT 3 | ||
46 | |||
47 | enum trigger_type { | 45 | enum trigger_type { |
48 | THROTTLE_ACTIVE = 1, | 46 | THROTTLE_ACTIVE = 1, |
49 | THROTTLE_PASSIVE, | 47 | THROTTLE_PASSIVE, |
@@ -69,6 +67,7 @@ struct freq_clip_table { | |||
69 | 67 | ||
70 | struct thermal_trip_point_conf { | 68 | struct thermal_trip_point_conf { |
71 | int trip_val[MAX_TRIP_COUNT]; | 69 | int trip_val[MAX_TRIP_COUNT]; |
70 | int trip_type[MAX_TRIP_COUNT]; | ||
72 | int trip_count; | 71 | int trip_count; |
73 | unsigned char trigger_falling; | 72 | unsigned char trigger_falling; |
74 | }; | 73 | }; |
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 40e0cfd3e84f..acbd29546783 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -509,9 +509,12 @@ static int exynos_tmu_probe(struct platform_device *pdev) | |||
509 | pdata->trigger_enable[1] + pdata->trigger_enable[2]+ | 509 | pdata->trigger_enable[1] + pdata->trigger_enable[2]+ |
510 | pdata->trigger_enable[3]; | 510 | pdata->trigger_enable[3]; |
511 | 511 | ||
512 | for (i = 0; i < exynos_sensor_conf.trip_data.trip_count; i++) | 512 | for (i = 0; i < exynos_sensor_conf.trip_data.trip_count; i++) { |
513 | exynos_sensor_conf.trip_data.trip_val[i] = | 513 | exynos_sensor_conf.trip_data.trip_val[i] = |
514 | pdata->threshold + pdata->trigger_levels[i]; | 514 | pdata->threshold + pdata->trigger_levels[i]; |
515 | exynos_sensor_conf.trip_data.trip_type[i] = | ||
516 | pdata->trigger_type[i]; | ||
517 | } | ||
515 | 518 | ||
516 | exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling; | 519 | exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling; |
517 | 520 | ||