Lines Matching +full:fan +full:- +full:0

39 nvkm_fantog_update(struct nvkm_fantog *fan, int percent)  in nvkm_fantog_update()  argument
41 struct nvkm_therm *therm = fan->base.parent; in nvkm_fantog_update()
42 struct nvkm_device *device = therm->subdev.device; in nvkm_fantog_update()
43 struct nvkm_timer *tmr = device->timer; in nvkm_fantog_update()
44 struct nvkm_gpio *gpio = device->gpio; in nvkm_fantog_update()
48 spin_lock_irqsave(&fan->lock, flags); in nvkm_fantog_update()
49 if (percent < 0) in nvkm_fantog_update()
50 percent = fan->percent; in nvkm_fantog_update()
51 fan->percent = percent; in nvkm_fantog_update()
53 duty = !nvkm_gpio_get(gpio, 0, DCB_GPIO_FAN, 0xff); in nvkm_fantog_update()
54 nvkm_gpio_set(gpio, 0, DCB_GPIO_FAN, 0xff, duty); in nvkm_fantog_update()
57 u64 next_change = (percent * fan->period_us) / 100; in nvkm_fantog_update()
59 next_change = fan->period_us - next_change; in nvkm_fantog_update()
60 nvkm_timer_alarm(tmr, next_change * 1000, &fan->alarm); in nvkm_fantog_update()
62 spin_unlock_irqrestore(&fan->lock, flags); in nvkm_fantog_update()
68 struct nvkm_fantog *fan = in nvkm_fantog_alarm() local
70 nvkm_fantog_update(fan, -1); in nvkm_fantog_alarm()
76 struct nvkm_fantog *fan = (void *)therm->fan; in nvkm_fantog_get() local
77 return fan->percent; in nvkm_fantog_get()
83 struct nvkm_fantog *fan = (void *)therm->fan; in nvkm_fantog_set() local
84 if (therm->func->pwm_ctrl) in nvkm_fantog_set()
85 therm->func->pwm_ctrl(therm, fan->func.line, false); in nvkm_fantog_set()
86 nvkm_fantog_update(fan, percent); in nvkm_fantog_set()
87 return 0; in nvkm_fantog_set()
93 struct nvkm_fantog *fan; in nvkm_fantog_create() local
96 if (therm->func->pwm_ctrl) { in nvkm_fantog_create()
97 ret = therm->func->pwm_ctrl(therm, func->line, false); in nvkm_fantog_create()
102 fan = kzalloc(sizeof(*fan), GFP_KERNEL); in nvkm_fantog_create()
103 if (!fan) in nvkm_fantog_create()
104 return -ENOMEM; in nvkm_fantog_create()
106 therm->fan = &fan->base; in nvkm_fantog_create()
107 fan->base.type = "toggle"; in nvkm_fantog_create()
108 fan->base.get = nvkm_fantog_get; in nvkm_fantog_create()
109 fan->base.set = nvkm_fantog_set; in nvkm_fantog_create()
110 nvkm_alarm_init(&fan->alarm, nvkm_fantog_alarm); in nvkm_fantog_create()
111 fan->period_us = 100000; /* 10Hz */ in nvkm_fantog_create()
112 fan->percent = 100; in nvkm_fantog_create()
113 fan->func = *func; in nvkm_fantog_create()
114 spin_lock_init(&fan->lock); in nvkm_fantog_create()
115 return 0; in nvkm_fantog_create()