Commit e3f25e6e authored by Zhang Rui's avatar Zhang Rui

Thermal: Introduce multiple cooling states support

This is because general active cooling devices, like fans,
may have multiple speeds, which can be mapped to different cooling states.
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
Reviewed-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: default avatarValentin, Eduardo <eduardo.valentin@ti.com>
parent 0d7614f0
...@@ -1059,6 +1059,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) ...@@ -1059,6 +1059,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
enum thermal_trip_type trip_type; enum thermal_trip_type trip_type;
struct thermal_cooling_device_instance *instance; struct thermal_cooling_device_instance *instance;
struct thermal_cooling_device *cdev; struct thermal_cooling_device *cdev;
unsigned long cur_state, max_state;
mutex_lock(&tz->lock); mutex_lock(&tz->lock);
...@@ -1098,10 +1099,17 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) ...@@ -1098,10 +1099,17 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
cdev = instance->cdev; cdev = instance->cdev;
cdev->ops->get_cur_state(cdev, &cur_state);
cdev->ops->get_max_state(cdev, &max_state);
if (temp >= trip_temp) if (temp >= trip_temp)
cdev->ops->set_cur_state(cdev, 1); cur_state = cur_state < max_state ?
(cur_state + 1) : max_state;
else else
cdev->ops->set_cur_state(cdev, 0); cur_state = cur_state > 0 ?
(cur_state - 1) : 0;
cdev->ops->set_cur_state(cdev, cur_state);
} }
break; break;
case THERMAL_TRIP_PASSIVE: case THERMAL_TRIP_PASSIVE:
......
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