Lines Matching +full:target +full:- +full:rpm
32 nvkm_fan_update(struct nvkm_fan *fan, bool immediate, int target) in nvkm_fan_update() argument
34 struct nvkm_therm *therm = fan->parent; in nvkm_fan_update()
35 struct nvkm_subdev *subdev = &therm->subdev; in nvkm_fan_update()
36 struct nvkm_timer *tmr = subdev->device->timer; in nvkm_fan_update()
41 /* update target fan speed, restricting to allowed range */ in nvkm_fan_update()
42 spin_lock_irqsave(&fan->lock, flags); in nvkm_fan_update()
43 if (target < 0) in nvkm_fan_update()
44 target = fan->percent; in nvkm_fan_update()
45 target = max_t(u8, target, fan->bios.min_duty); in nvkm_fan_update()
46 target = min_t(u8, target, fan->bios.max_duty); in nvkm_fan_update()
47 if (fan->percent != target) { in nvkm_fan_update()
48 nvkm_debug(subdev, "FAN target: %d\n", target); in nvkm_fan_update()
49 fan->percent = target; in nvkm_fan_update()
52 /* check that we're not already at the target duty cycle */ in nvkm_fan_update()
53 duty = fan->get(therm); in nvkm_fan_update()
54 if (duty == target) { in nvkm_fan_update()
55 spin_unlock_irqrestore(&fan->lock, flags); in nvkm_fan_update()
65 if (duty < target) in nvkm_fan_update()
66 duty = min(duty + 3, target); in nvkm_fan_update()
67 else if (duty > target) in nvkm_fan_update()
68 duty = max(duty - 3, target); in nvkm_fan_update()
70 duty = target; in nvkm_fan_update()
74 ret = fan->set(therm, duty); in nvkm_fan_update()
76 spin_unlock_irqrestore(&fan->lock, flags); in nvkm_fan_update()
81 * alarm-scheduling lock and risking a deadlock in nvkm_fan_update()
83 spin_unlock_irqrestore(&fan->lock, flags); in nvkm_fan_update()
85 /* schedule next fan update, if not at target speed already */ in nvkm_fan_update()
86 if (target != duty) { in nvkm_fan_update()
87 u16 bump_period = fan->bios.bump_period; in nvkm_fan_update()
88 u16 slow_down_period = fan->bios.slow_down_period; in nvkm_fan_update()
91 if (duty > target) in nvkm_fan_update()
93 else if (duty == target) in nvkm_fan_update()
98 nvkm_timer_alarm(tmr, delay * 1000 * 1000, &fan->alarm); in nvkm_fan_update()
108 nvkm_fan_update(fan, false, -1); in nvkm_fan_alarm()
114 return therm->fan->get(therm); in nvkm_therm_fan_get()
120 return nvkm_fan_update(therm->fan, immediate, percent); in nvkm_therm_fan_set()
126 struct nvkm_device *device = therm->subdev.device; in nvkm_therm_fan_sense()
127 struct nvkm_timer *tmr = device->timer; in nvkm_therm_fan_sense()
128 struct nvkm_gpio *gpio = device->gpio; in nvkm_therm_fan_sense()
132 if (therm->func->fan_sense) in nvkm_therm_fan_sense()
133 return therm->func->fan_sense(therm); in nvkm_therm_fan_sense()
135 if (therm->fan->tach.func == DCB_GPIO_UNUSED) in nvkm_therm_fan_sense()
136 return -ENODEV; in nvkm_therm_fan_sense()
138 /* Time a complete rotation and extrapolate to RPM: in nvkm_therm_fan_sense()
140 * We get 4 changes (0 -> 1 -> 0 -> 1) per complete rotation. in nvkm_therm_fan_sense()
143 prev = nvkm_gpio_get(gpio, 0, therm->fan->tach.func, in nvkm_therm_fan_sense()
144 therm->fan->tach.line); in nvkm_therm_fan_sense()
147 usleep_range(500, 1000); /* supports 0 < rpm < 7500 */ in nvkm_therm_fan_sense()
149 cur = nvkm_gpio_get(gpio, 0, therm->fan->tach.func, in nvkm_therm_fan_sense()
150 therm->fan->tach.line); in nvkm_therm_fan_sense()
157 } while (cycles < 5 && nvkm_timer_read(tmr) - start < 250000000); in nvkm_therm_fan_sense()
162 do_div(tach, (end - start)); in nvkm_therm_fan_sense()
177 if (therm->mode != NVKM_THERM_CTRL_MANUAL) in nvkm_therm_fan_user_set()
178 return -EINVAL; in nvkm_therm_fan_user_set()
186 therm->fan->bios.pwm_freq = 0; in nvkm_therm_fan_set_defaults()
187 therm->fan->bios.min_duty = 0; in nvkm_therm_fan_set_defaults()
188 therm->fan->bios.max_duty = 100; in nvkm_therm_fan_set_defaults()
189 therm->fan->bios.bump_period = 500; in nvkm_therm_fan_set_defaults()
190 therm->fan->bios.slow_down_period = 2000; in nvkm_therm_fan_set_defaults()
191 therm->fan->bios.linear_min_temp = 40; in nvkm_therm_fan_set_defaults()
192 therm->fan->bios.linear_max_temp = 85; in nvkm_therm_fan_set_defaults()
198 if (therm->fan->bios.min_duty > 100) in nvkm_therm_fan_safety_checks()
199 therm->fan->bios.min_duty = 100; in nvkm_therm_fan_safety_checks()
200 if (therm->fan->bios.max_duty > 100) in nvkm_therm_fan_safety_checks()
201 therm->fan->bios.max_duty = 100; in nvkm_therm_fan_safety_checks()
203 if (therm->fan->bios.min_duty > therm->fan->bios.max_duty) in nvkm_therm_fan_safety_checks()
204 therm->fan->bios.min_duty = therm->fan->bios.max_duty; in nvkm_therm_fan_safety_checks()
216 struct nvkm_timer *tmr = therm->subdev.device->timer; in nvkm_therm_fan_fini()
218 nvkm_timer_alarm(tmr, 0, &therm->fan->alarm); in nvkm_therm_fan_fini()
225 struct nvkm_subdev *subdev = &therm->subdev; in nvkm_therm_fan_ctor()
226 struct nvkm_device *device = subdev->device; in nvkm_therm_fan_ctor()
227 struct nvkm_gpio *gpio = device->gpio; in nvkm_therm_fan_ctor()
228 struct nvkm_bios *bios = device->bios; in nvkm_therm_fan_ctor()
238 ret = -EINVAL; in nvkm_therm_fan_ctor()
253 nvkm_debug(subdev, "FAN control: %s\n", therm->fan->type); in nvkm_therm_fan_ctor()
256 therm->fan->percent = nvkm_therm_fan_get(therm); in nvkm_therm_fan_ctor()
260 &therm->fan->tach); in nvkm_therm_fan_ctor()
262 therm->fan->tach.func = DCB_GPIO_UNUSED; in nvkm_therm_fan_ctor()
265 therm->fan->parent = therm; in nvkm_therm_fan_ctor()
266 nvkm_alarm_init(&therm->fan->alarm, nvkm_fan_alarm); in nvkm_therm_fan_ctor()
267 spin_lock_init(&therm->fan->lock); in nvkm_therm_fan_ctor()
271 nvbios_perf_fan_parse(bios, &therm->fan->perf); in nvkm_therm_fan_ctor()
272 if (!nvbios_fan_parse(bios, &therm->fan->bios)) { in nvkm_therm_fan_ctor()
274 if (nvbios_therm_fan_parse(bios, &therm->fan->bios)) in nvkm_therm_fan_ctor()