Commit 017e51420cc44098308b00dffd9d4e514ddf40f3
Committed by
Zhang Rui
1 parent
cba77f5312
Exists in
master
and in
20 other branches
thermal: imx: dynamic passive and SoC specific critical trip points
Set passive and critical trip point values depending on the maximum die temperature stored in the OCOTP fuses. This allows higher trip points for industrial and automotive rated i.MX6 SoCs. Also allow to configure the passive trip point from userspace. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Showing 1 changed file with 40 additions and 10 deletions Side-by-side Diff
drivers/thermal/imx_thermal.c
... | ... | @@ -55,12 +55,6 @@ |
55 | 55 | */ |
56 | 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 | 58 | #define IMX_POLLING_DELAY 2000 /* millisecond */ |
65 | 59 | #define IMX_PASSIVE_DELAY 1000 |
66 | 60 | |
... | ... | @@ -70,6 +64,8 @@ |
70 | 64 | enum thermal_device_mode mode; |
71 | 65 | struct regmap *tempmon; |
72 | 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 | 71 | static int imx_get_temp(struct thermal_zone_device *tz, unsigned long *temp) |
76 | 72 | |
77 | 73 | |
... | ... | @@ -156,18 +152,38 @@ |
156 | 152 | static int imx_get_crit_temp(struct thermal_zone_device *tz, |
157 | 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 | 158 | return 0; |
161 | 159 | } |
162 | 160 | |
163 | 161 | static int imx_get_trip_temp(struct thermal_zone_device *tz, int trip, |
164 | 162 | unsigned long *temp) |
165 | 163 | { |
166 | - *temp = (trip == IMX_TRIP_PASSIVE) ? IMX_TEMP_PASSIVE : | |
167 | - IMX_TEMP_CRITICAL; | |
164 | + struct imx_thermal_data *data = tz->devdata; | |
165 | + | |
166 | + *temp = (trip == IMX_TRIP_PASSIVE) ? data->temp_passive : | |
167 | + data->temp_critical; | |
168 | 168 | return 0; |
169 | 169 | } |
170 | 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 | + | |
184 | + return 0; | |
185 | +} | |
186 | + | |
171 | 187 | static int imx_bind(struct thermal_zone_device *tz, |
172 | 188 | struct thermal_cooling_device *cdev) |
173 | 189 | { |
... | ... | @@ -211,6 +227,7 @@ |
211 | 227 | .get_trip_type = imx_get_trip_type, |
212 | 228 | .get_trip_temp = imx_get_trip_temp, |
213 | 229 | .get_crit_temp = imx_get_crit_temp, |
230 | + .set_trip_temp = imx_set_trip_temp, | |
214 | 231 | }; |
215 | 232 | |
216 | 233 | static int imx_get_sensor_data(struct platform_device *pdev) |
... | ... | @@ -267,6 +284,18 @@ |
267 | 284 | data->c1 = 1000 * (t1 - t2) / (n1 - n2); |
268 | 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 | 299 | return 0; |
271 | 300 | } |
272 | 301 | |
... | ... | @@ -314,7 +343,8 @@ |
314 | 343 | } |
315 | 344 | |
316 | 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 | 348 | &imx_tz_ops, NULL, |
319 | 349 | IMX_PASSIVE_DELAY, |
320 | 350 | IMX_POLLING_DELAY); |