Lines Matching refs:therm

35 nvkm_therm_temp_get(struct nvkm_therm *therm)
37 if (therm->func->temp_get)
38 return therm->func->temp_get(therm);
43 nvkm_therm_update_trip(struct nvkm_therm *therm)
45 struct nvbios_therm_trip_point *trip = therm->fan->bios.trip,
47 *last_trip = therm->last_trip;
48 u8 temp = therm->func->temp_get(therm);
53 for (i = 0; i < therm->fan->bios.nr_fan_trip; i++) {
65 therm->last_trip = cur_trip;
68 therm->last_trip = NULL;
75 nvkm_therm_compute_linear_duty(struct nvkm_therm *therm, u8 linear_min_temp,
78 u8 temp = therm->func->temp_get(therm);
83 return therm->fan->bios.min_duty;
85 return therm->fan->bios.max_duty;
89 duty *= (therm->fan->bios.max_duty - therm->fan->bios.min_duty);
91 duty += therm->fan->bios.min_duty;
96 nvkm_therm_update_linear(struct nvkm_therm *therm)
98 u8 min = therm->fan->bios.linear_min_temp;
99 u8 max = therm->fan->bios.linear_max_temp;
100 return nvkm_therm_compute_linear_duty(therm, min, max);
104 nvkm_therm_update_linear_fallback(struct nvkm_therm *therm)
106 u8 max = therm->bios_sensor.thrs_fan_boost.temp;
107 return nvkm_therm_compute_linear_duty(therm, 30, max);
111 nvkm_therm_update(struct nvkm_therm *therm, int mode)
113 struct nvkm_subdev *subdev = &therm->subdev;
120 spin_lock_irqsave(&therm->lock, flags);
122 mode = therm->mode;
123 therm->mode = mode;
127 nvkm_timer_alarm(tmr, 0, &therm->alarm);
128 duty = nvkm_therm_fan_get(therm);
134 switch(therm->fan->bios.fan_mode) {
136 duty = nvkm_therm_update_trip(therm);
139 duty = nvkm_therm_update_linear(therm);
142 if (therm->cstate) {
143 duty = therm->cstate;
146 duty = nvkm_therm_update_linear_fallback(therm);
154 nvkm_timer_alarm(tmr, 0, &therm->alarm);
159 nvkm_timer_alarm(tmr, 1000000000ULL, &therm->alarm);
160 spin_unlock_irqrestore(&therm->lock, flags);
166 nvkm_therm_fan_set(therm, immd, duty);
171 nvkm_therm_cstate(struct nvkm_therm *therm, int fan, int dir)
173 struct nvkm_subdev *subdev = &therm->subdev;
174 if (!dir || (dir < 0 && fan < therm->cstate) ||
175 (dir > 0 && fan > therm->cstate)) {
177 therm->cstate = fan;
178 nvkm_therm_update(therm, -1);
186 struct nvkm_therm *therm =
188 nvkm_therm_update(therm, -1);
192 nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode)
194 struct nvkm_subdev *subdev = &therm->subdev;
210 therm->func->temp_get(therm) < 0)
213 if (therm->mode == mode)
217 nvkm_therm_update(therm, mode);
222 nvkm_therm_attr_get(struct nvkm_therm *therm, enum nvkm_therm_attr_type type)
226 return therm->fan->bios.min_duty;
228 return therm->fan->bios.max_duty;
230 return therm->mode;
232 return therm->bios_sensor.thrs_fan_boost.temp;
234 return therm->bios_sensor.thrs_fan_boost.hysteresis;
236 return therm->bios_sensor.thrs_down_clock.temp;
238 return therm->bios_sensor.thrs_down_clock.hysteresis;
240 return therm->bios_sensor.thrs_critical.temp;
242 return therm->bios_sensor.thrs_critical.hysteresis;
244 return therm->bios_sensor.thrs_shutdown.temp;
246 return therm->bios_sensor.thrs_shutdown.hysteresis;
253 nvkm_therm_attr_set(struct nvkm_therm *therm,
260 if (value > therm->fan->bios.max_duty)
261 value = therm->fan->bios.max_duty;
262 therm->fan->bios.min_duty = value;
267 if (value < therm->fan->bios.min_duty)
268 value = therm->fan->bios.min_duty;
269 therm->fan->bios.max_duty = value;
272 return nvkm_therm_fan_mode(therm, value);
274 therm->bios_sensor.thrs_fan_boost.temp = value;
275 therm->func->program_alarms(therm);
278 therm->bios_sensor.thrs_fan_boost.hysteresis = value;
279 therm->func->program_alarms(therm);
282 therm->bios_sensor.thrs_down_clock.temp = value;
283 therm->func->program_alarms(therm);
286 therm->bios_sensor.thrs_down_clock.hysteresis = value;
287 therm->func->program_alarms(therm);
290 therm->bios_sensor.thrs_critical.temp = value;
291 therm->func->program_alarms(therm);
294 therm->bios_sensor.thrs_critical.hysteresis = value;
295 therm->func->program_alarms(therm);
298 therm->bios_sensor.thrs_shutdown.temp = value;
299 therm->func->program_alarms(therm);
302 therm->bios_sensor.thrs_shutdown.hysteresis = value;
303 therm->func->program_alarms(therm);
311 nvkm_therm_clkgate_enable(struct nvkm_therm *therm)
313 if (!therm || !therm->func->clkgate_enable || !therm->clkgating_enabled)
316 nvkm_debug(&therm->subdev,
318 therm->func->clkgate_enable(therm);
322 nvkm_therm_clkgate_fini(struct nvkm_therm *therm, bool suspend)
324 if (!therm || !therm->func->clkgate_fini || !therm->clkgating_enabled)
327 nvkm_debug(&therm->subdev,
330 therm->func->clkgate_fini(therm, suspend);
334 nvkm_therm_clkgate_oneinit(struct nvkm_therm *therm)
336 if (!therm->func->clkgate_enable || !therm->clkgating_enabled)
339 nvkm_info(&therm->subdev, "Clockgating enabled\n");
345 struct nvkm_therm *therm = nvkm_therm(subdev);
346 if (therm->func->intr)
347 therm->func->intr(therm);
353 struct nvkm_therm *therm = nvkm_therm(subdev);
355 if (therm->func->fini)
356 therm->func->fini(therm);
358 nvkm_therm_fan_fini(therm, suspend);
359 nvkm_therm_sensor_fini(therm, suspend);
362 therm->suspend = therm->mode;
363 therm->mode = NVKM_THERM_CTRL_NONE;
372 struct nvkm_therm *therm = nvkm_therm(subdev);
373 nvkm_therm_sensor_ctor(therm);
374 nvkm_therm_ic_ctor(therm);
375 nvkm_therm_fan_ctor(therm);
376 nvkm_therm_fan_mode(therm, NVKM_THERM_CTRL_AUTO);
377 nvkm_therm_sensor_preinit(therm);
378 nvkm_therm_clkgate_oneinit(therm);
385 struct nvkm_therm *therm = nvkm_therm(subdev);
387 if (therm->func->init)
388 therm->func->init(therm);
390 if (therm->suspend >= 0) {
392 if (therm->suspend > 0)
393 nvkm_therm_fan_set(therm, true, therm->fan->percent);
395 nvkm_therm_fan_mode(therm, therm->suspend);
398 nvkm_therm_sensor_init(therm);
399 nvkm_therm_fan_init(therm);
404 nvkm_therm_clkgate_init(struct nvkm_therm *therm,
407 if (!therm || !therm->func->clkgate_init || !therm->clkgating_enabled)
410 therm->func->clkgate_init(therm, p);
416 struct nvkm_therm *therm = nvkm_therm(subdev);
417 nvkm_therm_fan_dtor(therm);
418 kfree(therm->fan);
419 spin_lock_destroy(&therm->sensor.alarm_program_lock);
420 spin_lock_destroy(&therm->lock);
421 return therm;
434 nvkm_therm_ctor(struct nvkm_therm *therm, struct nvkm_device *device,
437 nvkm_subdev_ctor(&nvkm_therm, device, index, &therm->subdev);
438 therm->func = func;
440 nvkm_alarm_init(&therm->alarm, nvkm_therm_alarm);
441 spin_lock_init(&therm->lock);
442 spin_lock_init(&therm->sensor.alarm_program_lock);
444 therm->fan_get = nvkm_therm_fan_user_get;
445 therm->fan_set = nvkm_therm_fan_user_set;
446 therm->attr_get = nvkm_therm_attr_get;
447 therm->attr_set = nvkm_therm_attr_set;
448 therm->mode = therm->suspend = -1; /* undefined */
450 therm->clkgating_enabled = nvkm_boolopt(device->cfgopt,
458 struct nvkm_therm *therm;
460 if (!(therm = *ptherm = kzalloc(sizeof(*therm), GFP_KERNEL)))
463 nvkm_therm_ctor(therm, device, index, func);