Lines Matching full:fan
75 struct pmac_fan fan;
88 /* We can read the PWM and the RPM from a PWM controlled fan.
653 * Sensor and fan management
657 smu_fan_check_old_style(struct smu_fan *fan)
659 device_t smu = fan->dev;
668 * Apple has two fan control mechanisms. We can't distinguish
676 cmd.data[1] = fan->reg;
688 smu_fan_set_rpm(struct smu_fan *fan, int rpm)
690 device_t smu = fan->dev;
698 rpm = max(fan->fan.min_rpm, rpm);
699 rpm = min(fan->fan.max_rpm, rpm);
701 smu_fan_check_old_style(fan);
703 if (!fan->old_style) {
706 cmd.data[1] = fan->reg;
712 fan->old_style = 1;
715 cmd.data[0] = 0x00; /* RPM fan. */
716 cmd.data[1] = 1 << fan->reg;
717 cmd.data[2 + 2*fan->reg] = (rpm >> 8) & 0xff;
718 cmd.data[3 + 2*fan->reg] = rpm & 0xff;
723 fan->setpoint = rpm;
729 smu_fan_read_rpm(struct smu_fan *fan)
731 device_t smu = fan->dev;
735 smu_fan_check_old_style(fan);
737 if (!fan->old_style) {
741 cmd.data[1] = fan->reg;
745 fan->old_style = 1;
750 if (fan->old_style) {
759 rpm = (cmd.data[fan->reg*2+1] << 8) | cmd.data[fan->reg*2+2];
765 smu_fan_set_pwm(struct smu_fan *fan, int pwm)
767 device_t smu = fan->dev;
775 pwm = max(fan->fan.min_rpm, pwm);
776 pwm = min(fan->fan.max_rpm, pwm);
779 * Apple has two fan control mechanisms. We can't distinguish
784 if (!fan->old_style) {
787 cmd.data[1] = fan->reg;
793 fan->old_style = 1;
796 if (fan->old_style) {
798 cmd.data[0] = 0x10; /* PWM fan. */
799 cmd.data[1] = 1 << fan->reg;
800 cmd.data[2 + 2*fan->reg] = (pwm >> 8) & 0xff;
801 cmd.data[3 + 2*fan->reg] = pwm & 0xff;
806 fan->setpoint = pwm;
812 smu_fan_read_pwm(struct smu_fan *fan, int *pwm, int *rpm)
814 device_t smu = fan->dev;
818 if (!fan->old_style) {
822 cmd.data[1] = fan->reg;
826 fan->old_style = 1;
831 if (fan->old_style) {
840 *rpm = (cmd.data[fan->reg*2+1] << 8) | cmd.data[fan->reg*2+2];
842 if (fan->old_style) {
846 cmd.data[1] = 1 << fan->reg;
852 *pwm = cmd.data[fan->reg*2+2];
862 struct smu_fan *fan;
867 fan = &sc->sc_fans[arg2 & 0xff];
869 if (fan->type == SMU_FAN_RPM) {
870 rpm = smu_fan_read_rpm(fan);
876 error = smu_fan_read_pwm(fan, &pwm, &rpm);
892 /* We can only read the RPM from a PWM controlled fan, so return. */
901 if (fan->type == SMU_FAN_RPM)
902 return (smu_fan_set_rpm(fan, rpm));
904 return (smu_fan_set_pwm(fan, pwm));
910 struct smu_fan *fan;
915 fan = &sc->sc_fans[id];
919 if (strcmp(type, "fan-rpm-control") == 0)
920 fan->type = SMU_FAN_RPM;
922 fan->type = SMU_FAN_PWM;
924 fan->dev = dev;
925 fan->old_style = 0;
926 OF_getprop(child, "reg", &fan->reg,
928 OF_getprop(child, "min-value", &fan->fan.min_rpm,
930 OF_getprop(child, "max-value", &fan->fan.max_rpm,
932 OF_getprop(child, "zone", &fan->fan.zone,
936 &fan->fan.default_rpm,
938 fan->fan.default_rpm = fan->fan.max_rpm;
940 OF_getprop(child, "location", fan->fan.name,
941 sizeof(fan->fan.name));
943 if (fan->type == SMU_FAN_RPM)
944 fan->setpoint = smu_fan_read_rpm(fan);
946 smu_fan_read_pwm(fan, &fan->setpoint, &fan->rpm);
950 * after allocating the fan struct, fill the properties of the fans.
973 /* When allocated, fill the fan properties. */
990 struct smu_fan *fan;
1013 pmac_thermal_fan_register(&sc->sc_fans[i].fan);
1018 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "SMU Fan Information");
1022 fan = &sc->sc_fans[i];
1023 for (j = 0; j < strlen(fan->fan.name); j++) {
1024 sysctl_name[j] = tolower(fan->fan.name[j]);
1029 if (fan->type == SMU_FAN_RPM) {
1033 "Fan Information");
1036 &fan->fan.min_rpm, 0,
1040 &fan->fan.max_rpm, 0,
1045 smu_fanrpm_sysctl, "I", "Fan RPM");
1047 fan->fan.read = (int (*)(struct pmac_fan *))smu_fan_read_rpm;
1048 fan->fan.set = (int (*)(struct pmac_fan *, int))smu_fan_set_rpm;
1054 "Fan Information");
1057 &fan->fan.min_rpm, 0,
1061 &fan->fan.max_rpm, 0,
1067 smu_fanrpm_sysctl, "I", "Fan PWM in %");
1072 smu_fanrpm_sysctl, "I", "Fan RPM");
1073 fan->fan.read = NULL;
1074 fan->fan.set = (int (*)(struct pmac_fan *, int))smu_fan_set_pwm;
1077 device_printf(dev, "Fan: %s type: %d\n",
1078 fan->fan.name, fan->type);