diff options
Diffstat (limited to 'drivers/thermal/imx_thermal.c')
-rw-r--r-- | drivers/thermal/imx_thermal.c | 50 |
1 files changed, 40 insertions, 10 deletions
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index d16c33c7f3f0..c9a55b0214e5 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c | |||
@@ -55,12 +55,6 @@ enum imx_thermal_trip { | |||
55 | */ | 55 | */ |
56 | #define IMX_TEMP_PASSIVE 85000 | 56 | #define IMX_TEMP_PASSIVE 85000 |
57 | 57 | ||
58 | /* | ||
59 | * The maximum die temperature on imx parts is 105C, let's give some cushion | ||
60 | * for noise and possible temperature rise between measurements. | ||
61 | */ | ||
62 | #define IMX_TEMP_CRITICAL 100000 | ||
63 | |||
64 | #define IMX_POLLING_DELAY 2000 /* millisecond */ | 58 | #define IMX_POLLING_DELAY 2000 /* millisecond */ |
65 | #define IMX_PASSIVE_DELAY 1000 | 59 | #define IMX_PASSIVE_DELAY 1000 |
66 | 60 | ||
@@ -70,6 +64,8 @@ struct imx_thermal_data { | |||
70 | enum thermal_device_mode mode; | 64 | enum thermal_device_mode mode; |
71 | struct regmap *tempmon; | 65 | struct regmap *tempmon; |
72 | int c1, c2; /* See formula in imx_get_sensor_data() */ | 66 | int c1, c2; /* See formula in imx_get_sensor_data() */ |
67 | unsigned long temp_passive; | ||
68 | unsigned long temp_critical; | ||
73 | }; | 69 | }; |
74 | 70 | ||
75 | static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp) | 71 | static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp) |
@@ -156,15 +152,35 @@ static int imx_get_trip_type(struct thermal_zone_device *tz, int trip, | |||
156 | static int imx_get_crit_temp(struct thermal_zone_device *tz, | 152 | static int imx_get_crit_temp(struct thermal_zone_device *tz, |
157 | unsigned long *temp) | 153 | unsigned long *temp) |
158 | { | 154 | { |
159 | *temp = IMX_TEMP_CRITICAL; | 155 | struct imx_thermal_data *data = tz->devdata; |
156 | |||
157 | *temp = data->temp_critical; | ||
160 | return 0; | 158 | return 0; |
161 | } | 159 | } |
162 | 160 | ||
163 | static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip, | 161 | static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip, |
164 | unsigned long *temp) | 162 | unsigned long *temp) |
165 | { | 163 | { |
166 | *temp = (trip == IMX_TRIP_PASSIVE) ? IMX_TEMP_PASSIVE : | 164 | struct imx_thermal_data *data = tz->devdata; |
167 | IMX_TEMP_CRITICAL; | 165 | |
166 | *temp = (trip == IMX_TRIP_PASSIVE) ? data->temp_passive : | ||
167 | data->temp_critical; | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | static int imx_set_trip_temp(struct thermal_zone_device *tz, int trip, | ||
172 | unsigned long temp) | ||
173 | { | ||
174 | struct imx_thermal_data *data = tz->devdata; | ||
175 | |||
176 | if (trip == IMX_TRIP_CRITICAL) | ||
177 | return -EPERM; | ||
178 | |||
179 | if (temp > IMX_TEMP_PASSIVE) | ||
180 | return -EINVAL; | ||
181 | |||
182 | data->temp_passive = temp; | ||
183 | |||
168 | return 0; | 184 | return 0; |
169 | } | 185 | } |
170 | 186 | ||
@@ -211,6 +227,7 @@ static const struct thermal_zone_device_ops imx_tz_ops = { | |||
211 | .get_trip_type = imx_get_trip_type, | 227 | .get_trip_type = imx_get_trip_type, |
212 | .get_trip_temp = imx_get_trip_temp, | 228 | .get_trip_temp = imx_get_trip_temp, |
213 | .get_crit_temp = imx_get_crit_temp, | 229 | .get_crit_temp = imx_get_crit_temp, |
230 | .set_trip_temp = imx_set_trip_temp, | ||
214 | }; | 231 | }; |
215 | 232 | ||
216 | static int imx_get_sensor_data(struct platform_device *pdev) | 233 | static int imx_get_sensor_data(struct platform_device *pdev) |
@@ -267,6 +284,18 @@ static int imx_get_sensor_data(struct platform_device *pdev) | |||
267 | data->c1 = 1000 * (t1 - t2) / (n1 - n2); | 284 | data->c1 = 1000 * (t1 - t2) / (n1 - n2); |
268 | data->c2 = 1000 * t2 - data->c1 * n2; | 285 | data->c2 = 1000 * t2 - data->c1 * n2; |
269 | 286 | ||
287 | /* | ||
288 | * Set the default passive cooling trip point to 20 °C below the | ||
289 | * maximum die temperature. Can be changed from userspace. | ||
290 | */ | ||
291 | data->temp_passive = 1000 * (t2 - 20); | ||
292 | |||
293 | /* | ||
294 | * The maximum die temperature is t2, let's give 5 °C cushion | ||
295 | * for noise and possible temperature rise between measurements. | ||
296 | */ | ||
297 | data->temp_critical = 1000 * (t2 - 5); | ||
298 | |||
270 | return 0; | 299 | return 0; |
271 | } | 300 | } |
272 | 301 | ||
@@ -314,7 +343,8 @@ static int imx_thermal_probe(struct platform_device *pdev) | |||
314 | } | 343 | } |
315 | 344 | ||
316 | data->tz = thermal_zone_device_register("imx_thermal_zone", | 345 | data->tz = thermal_zone_device_register("imx_thermal_zone", |
317 | IMX_TRIP_NUM, 0, data, | 346 | IMX_TRIP_NUM, |
347 | BIT(IMX_TRIP_PASSIVE), data, | ||
318 | &imx_tz_ops, NULL, | 348 | &imx_tz_ops, NULL, |
319 | IMX_PASSIVE_DELAY, | 349 | IMX_PASSIVE_DELAY, |
320 | IMX_POLLING_DELAY); | 350 | IMX_POLLING_DELAY); |