Lines Matching full:fan
54 * /u3@0,f8000000/i2c@f8001000/fan@15e
69 struct pmac_fan fan; member
89 /* We can read the PWM and the RPM from a PWM controlled fan.
106 static int fcu_fan_set_rpm(struct fcu_fan *fan, int rpm);
107 static int fcu_fan_get_rpm(struct fcu_fan *fan);
108 static int fcu_fan_set_pwm(struct fcu_fan *fan, int pwm);
109 static int fcu_fan_get_pwm(device_t dev, struct fcu_fan *fan, int *pwm,
201 if (strcmp(name, "fan") != 0 || strcmp(compatible, "fcu") != 0) in fcu_probe()
208 device_set_desc(dev, "Apple Fan Control Unit"); in fcu_probe()
265 fcu_fan_set_rpm(struct fcu_fan *fan, int rpm) in fcu_fan_set_rpm() argument
271 sc = device_get_softc(fan->dev); in fcu_fan_set_rpm()
274 rpm = max(fan->fan.min_rpm, rpm); in fcu_fan_set_rpm()
275 rpm = min(fan->fan.max_rpm, rpm); in fcu_fan_set_rpm()
277 if (fan->type == FCU_FAN_RPM) { in fcu_fan_set_rpm()
278 reg = FCU_RPM_SET(fan->id); in fcu_fan_set_rpm()
279 fan->setpoint = rpm; in fcu_fan_set_rpm()
281 device_printf(fan->dev, "Unknown fan type: %d\n", fan->type); in fcu_fan_set_rpm()
295 fcu_fan_get_rpm(struct fcu_fan *fan) in fcu_fan_get_rpm() argument
303 sc = device_get_softc(fan->dev); in fcu_fan_get_rpm()
305 if (fan->type == FCU_FAN_RPM) { in fcu_fan_get_rpm()
306 /* Check if the fan is available. */ in fcu_fan_get_rpm()
310 if ((avail & (1 << fan->id)) == 0) { in fcu_fan_get_rpm()
311 device_printf(fan->dev, in fcu_fan_get_rpm()
312 "RPM Fan not available ID: %d\n", fan->id); in fcu_fan_get_rpm()
315 /* Check if we have a failed fan. */ in fcu_fan_get_rpm()
319 if ((fail & (1 << fan->id)) != 0) { in fcu_fan_get_rpm()
320 device_printf(fan->dev, in fcu_fan_get_rpm()
321 "RPM Fan failed ID: %d\n", fan->id); in fcu_fan_get_rpm()
324 /* Check if fan is active. */ in fcu_fan_get_rpm()
328 if ((active & (1 << fan->id)) == 0) { in fcu_fan_get_rpm()
329 device_printf(fan->dev, "RPM Fan not active ID: %d\n", in fcu_fan_get_rpm()
330 fan->id); in fcu_fan_get_rpm()
333 reg = FCU_RPM_READ(fan->id); in fcu_fan_get_rpm()
336 device_printf(fan->dev, "Unknown fan type: %d\n", fan->type); in fcu_fan_get_rpm()
350 fcu_fan_set_pwm(struct fcu_fan *fan, int pwm) in fcu_fan_set_pwm() argument
356 sc = device_get_softc(fan->dev); in fcu_fan_set_pwm()
359 pwm = max(fan->fan.min_rpm, pwm); in fcu_fan_set_pwm()
360 pwm = min(fan->fan.max_rpm, pwm); in fcu_fan_set_pwm()
362 if (fan->type == FCU_FAN_PWM) { in fcu_fan_set_pwm()
363 reg = FCU_PWM_SGET(fan->id); in fcu_fan_set_pwm()
368 fan->setpoint = pwm; in fcu_fan_set_pwm()
370 device_printf(fan->dev, "Unknown fan type: %d\n", fan->type); in fcu_fan_set_pwm()
382 fcu_fan_get_pwm(device_t dev, struct fcu_fan *fan, int *pwm, int *rpm) in fcu_fan_get_pwm() argument
391 if (fan->type == FCU_FAN_PWM) { in fcu_fan_get_pwm()
392 /* Check if the fan is available. */ in fcu_fan_get_pwm()
396 if ((avail & (1 << fan->id)) == 0) { in fcu_fan_get_pwm()
397 device_printf(dev, "PWM Fan not available ID: %d\n", in fcu_fan_get_pwm()
398 fan->id); in fcu_fan_get_pwm()
401 /* Check if we have a failed fan. */ in fcu_fan_get_pwm()
405 if ((fail & (1 << fan->id)) != 0) { in fcu_fan_get_pwm()
406 device_printf(dev, "PWM Fan failed ID: %d\n", fan->id); in fcu_fan_get_pwm()
409 /* Check if fan is active. */ in fcu_fan_get_pwm()
413 if ((active & (1 << fan->id)) == 0) { in fcu_fan_get_pwm()
414 device_printf(dev, "PWM Fan not active ID: %d\n", in fcu_fan_get_pwm()
415 fan->id); in fcu_fan_get_pwm()
418 reg = FCU_PWM_SGET(fan->id); in fcu_fan_get_pwm()
420 device_printf(dev, "Unknown fan type: %d\n", fan->type); in fcu_fan_get_pwm()
431 reg = FCU_PWM_RPM(fan->id); in fcu_fan_get_pwm()
458 /* Fill the fan location property. */ in fcu_fill_fan_prop()
463 strcpy(sc->sc_fans[i].fan.name, location + len); in fcu_fill_fan_prop()
472 /* Fill the fan type property. */ in fcu_fill_fan_prop()
478 if (strcmp(type + len, "fan-rpm") == 0) in fcu_fill_fan_prop()
487 /* Fill the fan ID property. */ in fcu_fill_fan_prop()
492 /* Fill the fan zone property. */ in fcu_fill_fan_prop()
495 sc->sc_fans[j].fan.zone = id[j]; in fcu_fill_fan_prop()
497 /* Finish setting up fan properties */ in fcu_fill_fan_prop()
501 sc->sc_fans[j].fan.min_rpm = 4800 >> fcu_rpm_shift; in fcu_fill_fan_prop()
502 sc->sc_fans[j].fan.max_rpm = 56000 >> fcu_rpm_shift; in fcu_fill_fan_prop()
505 sc->sc_fans[j].fan.read = in fcu_fill_fan_prop()
507 sc->sc_fans[j].fan.set = in fcu_fill_fan_prop()
510 sc->sc_fans[j].fan.min_rpm = 30; /* Percent */ in fcu_fill_fan_prop()
511 sc->sc_fans[j].fan.max_rpm = 100; in fcu_fill_fan_prop()
512 sc->sc_fans[j].fan.read = NULL; in fcu_fill_fan_prop()
513 sc->sc_fans[j].fan.set = in fcu_fill_fan_prop()
516 sc->sc_fans[j].fan.default_rpm = sc->sc_fans[j].fan.max_rpm; in fcu_fill_fan_prop()
527 struct fcu_fan *fan; in fcu_fanrpm_sysctl() local
532 fan = &sc->sc_fans[arg2 & 0x00ff]; in fcu_fanrpm_sysctl()
533 if (fan->type == FCU_FAN_RPM) { in fcu_fanrpm_sysctl()
534 rpm = fcu_fan_get_rpm(fan); in fcu_fanrpm_sysctl()
539 error = fcu_fan_get_pwm(fcu, fan, &pwm, &rpm); in fcu_fanrpm_sysctl()
556 /* We can only read the RPM from a PWM controlled fan, so return. */ in fcu_fanrpm_sysctl()
563 if (fan->type == FCU_FAN_RPM) in fcu_fanrpm_sysctl()
564 return (fcu_fan_set_rpm(fan, rpm)); in fcu_fanrpm_sysctl()
566 return (fcu_fan_set_pwm(fan, pwm)); in fcu_fanrpm_sysctl()
598 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "FCU Fan Information"); in fcu_attach_fans()
605 pmac_thermal_fan_register(&sc->sc_fans[i].fan); in fcu_attach_fans()
609 for (j = 0; j < strlen(sc->sc_fans[i].fan.name); j++) { in fcu_attach_fans()
610 sysctl_name[j] = tolower(sc->sc_fans[i].fan.name[j]); in fcu_attach_fans()
619 0, "Fan Information"); in fcu_attach_fans()
622 &(sc->sc_fans[i].fan.min_rpm), 0, in fcu_attach_fans()
626 &(sc->sc_fans[i].fan.max_rpm), 0, in fcu_attach_fans()
628 /* I use i to pass the fan id. */ in fcu_attach_fans()
631 dev, i, fcu_fanrpm_sysctl, "I", "Fan RPM"); in fcu_attach_fans()
639 0, "Fan Information"); in fcu_attach_fans()
642 &(sc->sc_fans[i].fan.min_rpm), 0, in fcu_attach_fans()
646 &(sc->sc_fans[i].fan.max_rpm), 0, in fcu_attach_fans()
648 /* I use i to pass the fan id or'ed with the type in fcu_attach_fans()
654 "Fan PWM in %"); in fcu_attach_fans()
658 "Fan RPM"); in fcu_attach_fans()
662 /* Dump fan location, type & RPM. */ in fcu_attach_fans()
667 "RPM: %d\n", sc->sc_fans[i].fan.name, in fcu_attach_fans()