Lines Matching +full:fan +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-only
36 static int smu_supports_new_fans_ops = 1;
46 int fan_type; /* 0 = rpm, 1 = pwm */
64 /* The SMU has an "old" and a "new" way of setting the fan speed in smu_set_fan()
73 buffer[1] = id; in smu_set_fan()
78 return -EINVAL; in smu_set_fan()
82 buffer[1] = 0x01 << id; in smu_set_fan()
100 printk(KERN_WARNING "windfarm: SMU failed new fan command " in smu_set_fan()
120 if (value < fct->min) in smu_fan_set()
121 value = fct->min; in smu_fan_set()
122 if (value > fct->max) in smu_fan_set()
123 value = fct->max; in smu_fan_set()
124 fct->value = value; in smu_fan_set()
126 return smu_set_fan(fct->fan_type, fct->reg, value); in smu_fan_set()
132 *value = fct->value; /* todo: read from SMU */ in smu_fan_get()
139 return fct->min; in smu_fan_min()
145 return fct->max; in smu_fan_max()
168 fct->ctrl.ops = &smu_fan_ops; in smu_fan_create()
173 fct->fan_type = pwm_fan; in smu_fan_create()
174 fct->ctrl.type = pwm_fan ? WF_CONTROL_PWM_FAN : WF_CONTROL_RPM_FAN; in smu_fan_create()
185 fct->ctrl.name = NULL; in smu_fan_create()
188 if (!strcmp(l, "Rear Fan 0") || !strcmp(l, "Rear Fan") || in smu_fan_create()
189 !strcmp(l, "Rear fan 0") || !strcmp(l, "Rear fan") || in smu_fan_create()
191 fct->ctrl.name = "cpu-rear-fan-0"; in smu_fan_create()
192 else if (!strcmp(l, "Rear Fan 1") || !strcmp(l, "Rear fan 1") || in smu_fan_create()
194 fct->ctrl.name = "cpu-rear-fan-1"; in smu_fan_create()
195 else if (!strcmp(l, "Front Fan 0") || !strcmp(l, "Front Fan") || in smu_fan_create()
196 !strcmp(l, "Front fan 0") || !strcmp(l, "Front fan") || in smu_fan_create()
198 fct->ctrl.name = "cpu-front-fan-0"; in smu_fan_create()
199 else if (!strcmp(l, "Front Fan 1") || !strcmp(l, "Front fan 1") || in smu_fan_create()
201 fct->ctrl.name = "cpu-front-fan-1"; in smu_fan_create()
203 fct->ctrl.name = "cpu-pump-0"; in smu_fan_create()
205 fct->ctrl.name = "cpu-pump-1"; in smu_fan_create()
206 else if (!strcmp(l, "Slots Fan") || !strcmp(l, "Slots fan") || in smu_fan_create()
208 fct->ctrl.name = "slots-fan"; in smu_fan_create()
211 fct->ctrl.name = "drive-bay-fan"; in smu_fan_create()
213 fct->ctrl.name = "backside-fan"; in smu_fan_create()
216 if (!strcmp(l, "System Fan") || !strcmp(l, "System fan")) in smu_fan_create()
217 fct->ctrl.name = "system-fan"; in smu_fan_create()
218 else if (!strcmp(l, "CPU Fan") || !strcmp(l, "CPU fan")) in smu_fan_create()
219 fct->ctrl.name = "cpu-fan"; in smu_fan_create()
221 fct->ctrl.name = "drive-bay-fan"; in smu_fan_create()
222 else if (!strcmp(l, "HDD Fan")) /* seen on iMac G5 iSight */ in smu_fan_create()
223 fct->ctrl.name = "hard-drive-fan"; in smu_fan_create()
224 else if (!strcmp(l, "ODD Fan")) /* same */ in smu_fan_create()
225 fct->ctrl.name = "optical-drive-fan"; in smu_fan_create()
227 /* Unrecognized fan, bail out */ in smu_fan_create()
228 if (fct->ctrl.name == NULL) in smu_fan_create()
232 v = of_get_property(node, "min-value", NULL); in smu_fan_create()
235 fct->min = *v; in smu_fan_create()
236 v = of_get_property(node, "max-value", NULL); in smu_fan_create()
239 fct->max = *v; in smu_fan_create()
245 fct->reg = *reg; in smu_fan_create()
247 if (wf_register_control(&fct->ctrl)) in smu_fan_create()
259 struct device_node *smu, *fans, *fan; in smu_controls_init() local
262 return -ENODEV; in smu_controls_init()
266 return -ENODEV; in smu_controls_init()
270 if (of_node_name_eq(fans, "rpm-fans") || in smu_controls_init()
271 of_device_is_compatible(fans, "smu-rpm-fans")) in smu_controls_init()
273 for_each_child_of_node(fans, fan) { in smu_controls_init()
276 fct = smu_fan_create(fan, 0); in smu_controls_init()
279 "RPM fan %pOFn\n", fan); in smu_controls_init()
282 list_add(&fct->link, &smu_fans); in smu_controls_init()
289 if (of_node_name_eq(fans, "pwm-fans")) in smu_controls_init()
291 for_each_child_of_node(fans, fan) { in smu_controls_init()
294 fct = smu_fan_create(fan, 1); in smu_controls_init()
297 "PWM fan %pOFn\n", fan); in smu_controls_init()
300 list_add(&fct->link, &smu_fans); in smu_controls_init()
314 list_del(&fct->link); in smu_controls_exit()
315 wf_unregister_control(&fct->ctrl); in smu_controls_exit()