コード例 #1
0
ファイル: fand.cpp プロジェクト: biddyweb/openbmc
int write_fan_speed(const int fan, const int value) {
  /*
   * The hardware fan numbers for pwm control are different from
   * both the physical order in the box, and the mapping for reading
   * the RPMs per fan, above.
   */

  int real_fan = fan_to_pwm_map[fan];

  if (value == 0) {
    return write_fan_value(real_fan, "pwm%d_en", 0);
  } else {
    int unit = value * PWM_UNIT_MAX / 100;
    int status;

    if (unit == PWM_UNIT_MAX)
      unit = 0;

    if ((status = write_fan_value(real_fan, "pwm%d_type", 0)) != 0 ||
      (status = write_fan_value(real_fan, "pwm%d_rising", 0)) != 0 ||
      (status = write_fan_value(real_fan, "pwm%d_falling", unit)) != 0 ||
      (status = write_fan_value(real_fan, "pwm%d_en", 1)) != 0) {
      return status;
    }
  }
}
コード例 #2
0
ファイル: fand.cpp プロジェクト: armedTiger/openbmc
int write_fan_speed(const int fan, const int value) {
  /*
   * The hardware fan numbers for pwm control are different from
   * both the physical order in the box, and the mapping for reading
   * the RPMs per fan, above.
   */

  int real_fan = fan_to_pwm_map[fan];

  if (value == 0) {
#if defined(CONFIG_WEDGE100)
    return write_fan_value(real_fan, "fantray%d_pwm", 0);
#else
    return write_fan_value(real_fan, "pwm%d_en", 0);
#endif
  } else {
    int unit = value * PWM_UNIT_MAX / 100;
    int status;

#if defined(CONFIG_WEDGE100)
    // Note that PWM for Wedge100 is in 32nds of a cycle
    return write_fan_value(real_fan, "fantray%d_pwm", unit);
#else
    if (unit == PWM_UNIT_MAX)
      unit = 0;

    if ((status = write_fan_value(real_fan, "pwm%d_type", 0)) != 0 ||
      (status = write_fan_value(real_fan, "pwm%d_rising", 0)) != 0 ||
      (status = write_fan_value(real_fan, "pwm%d_falling", unit)) != 0 ||
      (status = write_fan_value(real_fan, "pwm%d_en", 1)) != 0) {
      return status;
    }
#endif
  }
}