Lines Matching refs:therm
30 nvkm_therm_temp_get(struct nvkm_therm *therm) in nvkm_therm_temp_get() argument
32 if (therm->func->temp_get) in nvkm_therm_temp_get()
33 return therm->func->temp_get(therm); in nvkm_therm_temp_get()
38 nvkm_therm_update_trip(struct nvkm_therm *therm) in nvkm_therm_update_trip() argument
40 struct nvbios_therm_trip_point *trip = therm->fan->bios.trip, in nvkm_therm_update_trip()
42 *last_trip = therm->last_trip; in nvkm_therm_update_trip()
43 u8 temp = therm->func->temp_get(therm); in nvkm_therm_update_trip()
48 for (i = 0; i < therm->fan->bios.nr_fan_trip; i++) { in nvkm_therm_update_trip()
60 therm->last_trip = cur_trip; in nvkm_therm_update_trip()
63 therm->last_trip = NULL; in nvkm_therm_update_trip()
70 nvkm_therm_compute_linear_duty(struct nvkm_therm *therm, u8 linear_min_temp, in nvkm_therm_compute_linear_duty() argument
73 u8 temp = therm->func->temp_get(therm); in nvkm_therm_compute_linear_duty()
78 return therm->fan->bios.min_duty; in nvkm_therm_compute_linear_duty()
80 return therm->fan->bios.max_duty; in nvkm_therm_compute_linear_duty()
84 duty *= (therm->fan->bios.max_duty - therm->fan->bios.min_duty); in nvkm_therm_compute_linear_duty()
86 duty += therm->fan->bios.min_duty; in nvkm_therm_compute_linear_duty()
91 nvkm_therm_update_linear(struct nvkm_therm *therm) in nvkm_therm_update_linear() argument
93 u8 min = therm->fan->bios.linear_min_temp; in nvkm_therm_update_linear()
94 u8 max = therm->fan->bios.linear_max_temp; in nvkm_therm_update_linear()
95 return nvkm_therm_compute_linear_duty(therm, min, max); in nvkm_therm_update_linear()
99 nvkm_therm_update_linear_fallback(struct nvkm_therm *therm) in nvkm_therm_update_linear_fallback() argument
101 u8 max = therm->bios_sensor.thrs_fan_boost.temp; in nvkm_therm_update_linear_fallback()
102 return nvkm_therm_compute_linear_duty(therm, 30, max); in nvkm_therm_update_linear_fallback()
106 nvkm_therm_update(struct nvkm_therm *therm, int mode) in nvkm_therm_update() argument
108 struct nvkm_subdev *subdev = &therm->subdev; in nvkm_therm_update()
115 spin_lock_irqsave(&therm->lock, flags); in nvkm_therm_update()
117 mode = therm->mode; in nvkm_therm_update()
118 therm->mode = mode; in nvkm_therm_update()
122 nvkm_timer_alarm(tmr, 0, &therm->alarm); in nvkm_therm_update()
123 duty = nvkm_therm_fan_get(therm); in nvkm_therm_update()
129 switch(therm->fan->bios.fan_mode) { in nvkm_therm_update()
131 duty = nvkm_therm_update_trip(therm); in nvkm_therm_update()
134 duty = nvkm_therm_update_linear(therm); in nvkm_therm_update()
137 if (therm->cstate) { in nvkm_therm_update()
138 duty = therm->cstate; in nvkm_therm_update()
141 duty = nvkm_therm_update_linear_fallback(therm); in nvkm_therm_update()
149 nvkm_timer_alarm(tmr, 0, &therm->alarm); in nvkm_therm_update()
154 nvkm_timer_alarm(tmr, 1000000000ULL, &therm->alarm); in nvkm_therm_update()
155 spin_unlock_irqrestore(&therm->lock, flags); in nvkm_therm_update()
159 nvkm_therm_fan_set(therm, immd, duty); in nvkm_therm_update()
164 nvkm_therm_cstate(struct nvkm_therm *therm, int fan, int dir) in nvkm_therm_cstate() argument
166 struct nvkm_subdev *subdev = &therm->subdev; in nvkm_therm_cstate()
167 if (!dir || (dir < 0 && fan < therm->cstate) || in nvkm_therm_cstate()
168 (dir > 0 && fan > therm->cstate)) { in nvkm_therm_cstate()
170 therm->cstate = fan; in nvkm_therm_cstate()
171 nvkm_therm_update(therm, -1); in nvkm_therm_cstate()
179 struct nvkm_therm *therm = in nvkm_therm_alarm() local
181 nvkm_therm_update(therm, -1); in nvkm_therm_alarm()
185 nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode) in nvkm_therm_fan_mode() argument
187 struct nvkm_subdev *subdev = &therm->subdev; in nvkm_therm_fan_mode()
203 therm->func->temp_get(therm) < 0) in nvkm_therm_fan_mode()
206 if (therm->mode == mode) in nvkm_therm_fan_mode()
210 nvkm_therm_update(therm, mode); in nvkm_therm_fan_mode()
215 nvkm_therm_attr_get(struct nvkm_therm *therm, enum nvkm_therm_attr_type type) in nvkm_therm_attr_get() argument
219 return therm->fan->bios.min_duty; in nvkm_therm_attr_get()
221 return therm->fan->bios.max_duty; in nvkm_therm_attr_get()
223 return therm->mode; in nvkm_therm_attr_get()
225 return therm->bios_sensor.thrs_fan_boost.temp; in nvkm_therm_attr_get()
227 return therm->bios_sensor.thrs_fan_boost.hysteresis; in nvkm_therm_attr_get()
229 return therm->bios_sensor.thrs_down_clock.temp; in nvkm_therm_attr_get()
231 return therm->bios_sensor.thrs_down_clock.hysteresis; in nvkm_therm_attr_get()
233 return therm->bios_sensor.thrs_critical.temp; in nvkm_therm_attr_get()
235 return therm->bios_sensor.thrs_critical.hysteresis; in nvkm_therm_attr_get()
237 return therm->bios_sensor.thrs_shutdown.temp; in nvkm_therm_attr_get()
239 return therm->bios_sensor.thrs_shutdown.hysteresis; in nvkm_therm_attr_get()
246 nvkm_therm_attr_set(struct nvkm_therm *therm, in nvkm_therm_attr_set() argument
253 if (value > therm->fan->bios.max_duty) in nvkm_therm_attr_set()
254 value = therm->fan->bios.max_duty; in nvkm_therm_attr_set()
255 therm->fan->bios.min_duty = value; in nvkm_therm_attr_set()
260 if (value < therm->fan->bios.min_duty) in nvkm_therm_attr_set()
261 value = therm->fan->bios.min_duty; in nvkm_therm_attr_set()
262 therm->fan->bios.max_duty = value; in nvkm_therm_attr_set()
265 return nvkm_therm_fan_mode(therm, value); in nvkm_therm_attr_set()
267 therm->bios_sensor.thrs_fan_boost.temp = value; in nvkm_therm_attr_set()
268 therm->func->program_alarms(therm); in nvkm_therm_attr_set()
271 therm->bios_sensor.thrs_fan_boost.hysteresis = value; in nvkm_therm_attr_set()
272 therm->func->program_alarms(therm); in nvkm_therm_attr_set()
275 therm->bios_sensor.thrs_down_clock.temp = value; in nvkm_therm_attr_set()
276 therm->func->program_alarms(therm); in nvkm_therm_attr_set()
279 therm->bios_sensor.thrs_down_clock.hysteresis = value; in nvkm_therm_attr_set()
280 therm->func->program_alarms(therm); in nvkm_therm_attr_set()
283 therm->bios_sensor.thrs_critical.temp = value; in nvkm_therm_attr_set()
284 therm->func->program_alarms(therm); in nvkm_therm_attr_set()
287 therm->bios_sensor.thrs_critical.hysteresis = value; in nvkm_therm_attr_set()
288 therm->func->program_alarms(therm); in nvkm_therm_attr_set()
291 therm->bios_sensor.thrs_shutdown.temp = value; in nvkm_therm_attr_set()
292 therm->func->program_alarms(therm); in nvkm_therm_attr_set()
295 therm->bios_sensor.thrs_shutdown.hysteresis = value; in nvkm_therm_attr_set()
296 therm->func->program_alarms(therm); in nvkm_therm_attr_set()
304 nvkm_therm_clkgate_enable(struct nvkm_therm *therm) in nvkm_therm_clkgate_enable() argument
306 if (!therm || !therm->func->clkgate_enable || !therm->clkgating_enabled) in nvkm_therm_clkgate_enable()
309 nvkm_debug(&therm->subdev, in nvkm_therm_clkgate_enable()
311 therm->func->clkgate_enable(therm); in nvkm_therm_clkgate_enable()
315 nvkm_therm_clkgate_fini(struct nvkm_therm *therm, bool suspend) in nvkm_therm_clkgate_fini() argument
317 if (!therm || !therm->func->clkgate_fini || !therm->clkgating_enabled) in nvkm_therm_clkgate_fini()
320 nvkm_debug(&therm->subdev, in nvkm_therm_clkgate_fini()
323 therm->func->clkgate_fini(therm, suspend); in nvkm_therm_clkgate_fini()
327 nvkm_therm_clkgate_oneinit(struct nvkm_therm *therm) in nvkm_therm_clkgate_oneinit() argument
329 if (!therm->func->clkgate_enable || !therm->clkgating_enabled) in nvkm_therm_clkgate_oneinit()
332 nvkm_info(&therm->subdev, "Clockgating enabled\n"); in nvkm_therm_clkgate_oneinit()
338 struct nvkm_therm *therm = nvkm_therm(subdev); in nvkm_therm_intr() local
339 if (therm->func->intr) in nvkm_therm_intr()
340 therm->func->intr(therm); in nvkm_therm_intr()
346 struct nvkm_therm *therm = nvkm_therm(subdev); in nvkm_therm_fini() local
348 if (therm->func->fini) in nvkm_therm_fini()
349 therm->func->fini(therm); in nvkm_therm_fini()
351 nvkm_therm_fan_fini(therm, suspend); in nvkm_therm_fini()
352 nvkm_therm_sensor_fini(therm, suspend); in nvkm_therm_fini()
355 therm->suspend = therm->mode; in nvkm_therm_fini()
356 therm->mode = NVKM_THERM_CTRL_NONE; in nvkm_therm_fini()
365 struct nvkm_therm *therm = nvkm_therm(subdev); in nvkm_therm_oneinit() local
366 nvkm_therm_sensor_ctor(therm); in nvkm_therm_oneinit()
367 nvkm_therm_ic_ctor(therm); in nvkm_therm_oneinit()
368 nvkm_therm_fan_ctor(therm); in nvkm_therm_oneinit()
369 nvkm_therm_fan_mode(therm, NVKM_THERM_CTRL_AUTO); in nvkm_therm_oneinit()
370 nvkm_therm_sensor_preinit(therm); in nvkm_therm_oneinit()
371 nvkm_therm_clkgate_oneinit(therm); in nvkm_therm_oneinit()
378 struct nvkm_therm *therm = nvkm_therm(subdev); in nvkm_therm_init() local
380 if (therm->func->init) in nvkm_therm_init()
381 therm->func->init(therm); in nvkm_therm_init()
383 if (therm->suspend >= 0) { in nvkm_therm_init()
385 if (therm->suspend > 0) in nvkm_therm_init()
386 nvkm_therm_fan_set(therm, true, therm->fan->percent); in nvkm_therm_init()
388 nvkm_therm_fan_mode(therm, therm->suspend); in nvkm_therm_init()
391 nvkm_therm_sensor_init(therm); in nvkm_therm_init()
392 nvkm_therm_fan_init(therm); in nvkm_therm_init()
397 nvkm_therm_clkgate_init(struct nvkm_therm *therm, in nvkm_therm_clkgate_init() argument
400 if (!therm || !therm->func->clkgate_init || !therm->clkgating_enabled) in nvkm_therm_clkgate_init()
403 therm->func->clkgate_init(therm, p); in nvkm_therm_clkgate_init()
409 struct nvkm_therm *therm = nvkm_therm(subdev); in nvkm_therm_dtor() local
410 kfree(therm->fan); in nvkm_therm_dtor()
411 return therm; in nvkm_therm_dtor()
424 nvkm_therm_ctor(struct nvkm_therm *therm, struct nvkm_device *device, enum nvkm_subdev_type type, in nvkm_therm_ctor() argument
427 nvkm_subdev_ctor(&nvkm_therm, device, type, inst, &therm->subdev); in nvkm_therm_ctor()
428 therm->func = func; in nvkm_therm_ctor()
430 nvkm_alarm_init(&therm->alarm, nvkm_therm_alarm); in nvkm_therm_ctor()
431 spin_lock_init(&therm->lock); in nvkm_therm_ctor()
432 spin_lock_init(&therm->sensor.alarm_program_lock); in nvkm_therm_ctor()
434 therm->fan_get = nvkm_therm_fan_user_get; in nvkm_therm_ctor()
435 therm->fan_set = nvkm_therm_fan_user_set; in nvkm_therm_ctor()
436 therm->attr_get = nvkm_therm_attr_get; in nvkm_therm_ctor()
437 therm->attr_set = nvkm_therm_attr_set; in nvkm_therm_ctor()
438 therm->mode = therm->suspend = -1; /* undefined */ in nvkm_therm_ctor()
440 therm->clkgating_enabled = nvkm_boolopt(device->cfgopt, in nvkm_therm_ctor()
448 struct nvkm_therm *therm; in nvkm_therm_new_() local
450 if (!(therm = *ptherm = kzalloc(sizeof(*therm), GFP_KERNEL))) in nvkm_therm_new_()
453 nvkm_therm_ctor(therm, device, type, inst, func); in nvkm_therm_new_()