Lines Matching full:fan
75 struct pmac_fan fan; member
88 /* We can read the PWM and the RPM from a PWM controlled fan.
654 * Sensor and fan management
658 smu_fan_check_old_style(struct smu_fan *fan) in smu_fan_check_old_style() argument
660 device_t smu = fan->dev; in smu_fan_check_old_style()
669 * Apple has two fan control mechanisms. We can't distinguish in smu_fan_check_old_style()
677 cmd.data[1] = fan->reg; in smu_fan_check_old_style()
689 smu_fan_set_rpm(struct smu_fan *fan, int rpm) in smu_fan_set_rpm() argument
691 device_t smu = fan->dev; in smu_fan_set_rpm()
699 rpm = max(fan->fan.min_rpm, rpm); in smu_fan_set_rpm()
700 rpm = min(fan->fan.max_rpm, rpm); in smu_fan_set_rpm()
702 smu_fan_check_old_style(fan); in smu_fan_set_rpm()
704 if (!fan->old_style) { in smu_fan_set_rpm()
707 cmd.data[1] = fan->reg; in smu_fan_set_rpm()
713 fan->old_style = 1; in smu_fan_set_rpm()
716 cmd.data[0] = 0x00; /* RPM fan. */ in smu_fan_set_rpm()
717 cmd.data[1] = 1 << fan->reg; in smu_fan_set_rpm()
718 cmd.data[2 + 2*fan->reg] = (rpm >> 8) & 0xff; in smu_fan_set_rpm()
719 cmd.data[3 + 2*fan->reg] = rpm & 0xff; in smu_fan_set_rpm()
724 fan->setpoint = rpm; in smu_fan_set_rpm()
730 smu_fan_read_rpm(struct smu_fan *fan) in smu_fan_read_rpm() argument
732 device_t smu = fan->dev; in smu_fan_read_rpm()
736 smu_fan_check_old_style(fan); in smu_fan_read_rpm()
738 if (!fan->old_style) { in smu_fan_read_rpm()
742 cmd.data[1] = fan->reg; in smu_fan_read_rpm()
746 fan->old_style = 1; in smu_fan_read_rpm()
751 if (fan->old_style) { in smu_fan_read_rpm()
760 rpm = (cmd.data[fan->reg*2+1] << 8) | cmd.data[fan->reg*2+2]; in smu_fan_read_rpm()
766 smu_fan_set_pwm(struct smu_fan *fan, int pwm) in smu_fan_set_pwm() argument
768 device_t smu = fan->dev; in smu_fan_set_pwm()
776 pwm = max(fan->fan.min_rpm, pwm); in smu_fan_set_pwm()
777 pwm = min(fan->fan.max_rpm, pwm); in smu_fan_set_pwm()
780 * Apple has two fan control mechanisms. We can't distinguish in smu_fan_set_pwm()
785 if (!fan->old_style) { in smu_fan_set_pwm()
788 cmd.data[1] = fan->reg; in smu_fan_set_pwm()
794 fan->old_style = 1; in smu_fan_set_pwm()
797 if (fan->old_style) { in smu_fan_set_pwm()
799 cmd.data[0] = 0x10; /* PWM fan. */ in smu_fan_set_pwm()
800 cmd.data[1] = 1 << fan->reg; in smu_fan_set_pwm()
801 cmd.data[2 + 2*fan->reg] = (pwm >> 8) & 0xff; in smu_fan_set_pwm()
802 cmd.data[3 + 2*fan->reg] = pwm & 0xff; in smu_fan_set_pwm()
807 fan->setpoint = pwm; in smu_fan_set_pwm()
813 smu_fan_read_pwm(struct smu_fan *fan, int *pwm, int *rpm) in smu_fan_read_pwm() argument
815 device_t smu = fan->dev; in smu_fan_read_pwm()
819 if (!fan->old_style) { in smu_fan_read_pwm()
823 cmd.data[1] = fan->reg; in smu_fan_read_pwm()
827 fan->old_style = 1; in smu_fan_read_pwm()
832 if (fan->old_style) { in smu_fan_read_pwm()
841 *rpm = (cmd.data[fan->reg*2+1] << 8) | cmd.data[fan->reg*2+2]; in smu_fan_read_pwm()
843 if (fan->old_style) { in smu_fan_read_pwm()
847 cmd.data[1] = 1 << fan->reg; in smu_fan_read_pwm()
853 *pwm = cmd.data[fan->reg*2+2]; in smu_fan_read_pwm()
863 struct smu_fan *fan; in smu_fanrpm_sysctl() local
868 fan = &sc->sc_fans[arg2 & 0xff]; in smu_fanrpm_sysctl()
870 if (fan->type == SMU_FAN_RPM) { in smu_fanrpm_sysctl()
871 rpm = smu_fan_read_rpm(fan); in smu_fanrpm_sysctl()
877 error = smu_fan_read_pwm(fan, &pwm, &rpm); in smu_fanrpm_sysctl()
893 /* We can only read the RPM from a PWM controlled fan, so return. */ in smu_fanrpm_sysctl()
902 if (fan->type == SMU_FAN_RPM) in smu_fanrpm_sysctl()
903 return (smu_fan_set_rpm(fan, rpm)); in smu_fanrpm_sysctl()
905 return (smu_fan_set_pwm(fan, pwm)); in smu_fanrpm_sysctl()
911 struct smu_fan *fan; in smu_fill_fan_prop() local
916 fan = &sc->sc_fans[id]; in smu_fill_fan_prop()
920 if (strcmp(type, "fan-rpm-control") == 0) in smu_fill_fan_prop()
921 fan->type = SMU_FAN_RPM; in smu_fill_fan_prop()
923 fan->type = SMU_FAN_PWM; in smu_fill_fan_prop()
925 fan->dev = dev; in smu_fill_fan_prop()
926 fan->old_style = 0; in smu_fill_fan_prop()
927 OF_getprop(child, "reg", &fan->reg, in smu_fill_fan_prop()
929 OF_getprop(child, "min-value", &fan->fan.min_rpm, in smu_fill_fan_prop()
931 OF_getprop(child, "max-value", &fan->fan.max_rpm, in smu_fill_fan_prop()
933 OF_getprop(child, "zone", &fan->fan.zone, in smu_fill_fan_prop()
937 &fan->fan.default_rpm, in smu_fill_fan_prop()
939 fan->fan.default_rpm = fan->fan.max_rpm; in smu_fill_fan_prop()
941 OF_getprop(child, "location", fan->fan.name, in smu_fill_fan_prop()
942 sizeof(fan->fan.name)); in smu_fill_fan_prop()
944 if (fan->type == SMU_FAN_RPM) in smu_fill_fan_prop()
945 fan->setpoint = smu_fan_read_rpm(fan); in smu_fill_fan_prop()
947 smu_fan_read_pwm(fan, &fan->setpoint, &fan->rpm); in smu_fill_fan_prop()
951 * after allocating the fan struct, fill the properties of the fans.
974 /* When allocated, fill the fan properties. */ in smu_count_fans()
991 struct smu_fan *fan; in smu_attach_fans() local
1014 pmac_thermal_fan_register(&sc->sc_fans[i].fan); in smu_attach_fans()
1019 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "SMU Fan Information"); in smu_attach_fans()
1023 fan = &sc->sc_fans[i]; in smu_attach_fans()
1024 for (j = 0; j < strlen(fan->fan.name); j++) { in smu_attach_fans()
1025 sysctl_name[j] = tolower(fan->fan.name[j]); in smu_attach_fans()
1030 if (fan->type == SMU_FAN_RPM) { in smu_attach_fans()
1034 "Fan Information"); in smu_attach_fans()
1037 &fan->fan.min_rpm, 0, in smu_attach_fans()
1041 &fan->fan.max_rpm, 0, in smu_attach_fans()
1046 smu_fanrpm_sysctl, "I", "Fan RPM"); in smu_attach_fans()
1048 fan->fan.read = (int (*)(struct pmac_fan *))smu_fan_read_rpm; in smu_attach_fans()
1049 fan->fan.set = (int (*)(struct pmac_fan *, int))smu_fan_set_rpm; in smu_attach_fans()
1055 "Fan Information"); in smu_attach_fans()
1058 &fan->fan.min_rpm, 0, in smu_attach_fans()
1062 &fan->fan.max_rpm, 0, in smu_attach_fans()
1068 smu_fanrpm_sysctl, "I", "Fan PWM in %"); in smu_attach_fans()
1073 smu_fanrpm_sysctl, "I", "Fan RPM"); in smu_attach_fans()
1074 fan->fan.read = NULL; in smu_attach_fans()
1075 fan->fan.set = (int (*)(struct pmac_fan *, int))smu_fan_set_pwm; in smu_attach_fans()
1078 device_printf(dev, "Fan: %s type: %d\n", in smu_attach_fans()
1079 fan->fan.name, fan->type); in smu_attach_fans()