diff --git a/ASIC-README b/ASIC-README index 821c21bc..53a93fd6 100644 --- a/ASIC-README +++ b/ASIC-README @@ -86,6 +86,7 @@ Avalon commands: --avalon-auto Adjust avalon overclock frequency dynamically for best hashrate --avalon-cutoff Set avalon overheat cut off temperature (default: 60) +--avalon-fan Set fanspeed percentage for avalon, single value or range (default: 20-100) --avalon-options Set avalon options baud:miners:asic:timeout:freq --avalon-temp Set avalon target temperature (default: 50) diff --git a/cgminer.c b/cgminer.c index cf3b6b68..e68f8f22 100644 --- a/cgminer.c +++ b/cgminer.c @@ -1063,6 +1063,9 @@ static struct opt_table opt_config_table[] = { OPT_WITH_ARG("--avalon-cutoff", set_int_0_to_100, opt_show_intval, &opt_avalon_overheat, "Set avalon overheat cut off temperature"), + OPT_WITH_ARG("--avalon-fan", + set_avalon_fan, NULL, NULL, + "Set fanspeed percentage for avalon, single value or range (default: 20-100)"), OPT_WITH_ARG("--avalon-options", set_avalon_options, NULL, NULL, "Set avalon options baud:miners:asic:timeout:freq"), diff --git a/driver-avalon.c b/driver-avalon.c index 778caa1b..677ce33f 100644 --- a/driver-avalon.c +++ b/driver-avalon.c @@ -42,6 +42,8 @@ int opt_avalon_temp = AVALON_TEMP_TARGET; int opt_avalon_overheat = AVALON_TEMP_OVERHEAT; +int opt_avalon_fan_min = AVALON_DEFAULT_FAN_MIN; +int opt_avalon_fan_max = AVALON_DEFAULT_FAN_MAX; bool opt_avalon_auto; static int option_offset = -1; @@ -448,6 +450,25 @@ static bool get_options(int this_option_offset, int *baud, int *miner_count, return true; } +char *set_avalon_fan(char *arg) +{ + int val1, val2, ret; + + ret = sscanf(arg, "%d-%d", &val1, &val2); + if (ret < 1) + return "No values passed to avalon-fan"; + if (ret == 1) + val2 = val1; + + if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100 || val2 < val1) + return "Invalid value passed to avalon-fan"; + + opt_avalon_fan_min = val1 * AVALON_PWM_MAX / 100; + opt_avalon_fan_max = val2 * AVALON_PWM_MAX / 100; + + return NULL; +} + static void avalon_idle(struct cgpu_info *avalon, struct avalon_info *info) { int i; @@ -1011,7 +1032,7 @@ static inline void record_temp_fan(struct avalon_info *info, struct avalon_resul static void temp_rise(struct avalon_info *info, int temp) { if (temp >= opt_avalon_temp + AVALON_TEMP_HYSTERESIS * 3) { - info->fan_pwm = AVALON_DEFAULT_FAN_MAX_PWM; + info->fan_pwm = AVALON_PWM_MAX; return; } if (temp >= opt_avalon_temp + AVALON_TEMP_HYSTERESIS * 2) @@ -1023,14 +1044,14 @@ static void temp_rise(struct avalon_info *info, int temp) else return; - if (info->fan_pwm > AVALON_DEFAULT_FAN_MAX_PWM) - info->fan_pwm = AVALON_DEFAULT_FAN_MAX_PWM; + if (info->fan_pwm > opt_avalon_fan_max) + info->fan_pwm = opt_avalon_fan_max; } static void temp_drop(struct avalon_info *info, int temp) { if (temp <= opt_avalon_temp - AVALON_TEMP_HYSTERESIS * 3) { - info->fan_pwm = AVALON_DEFAULT_FAN_MIN_PWM; + info->fan_pwm = opt_avalon_fan_min; return; } if (temp <= opt_avalon_temp - AVALON_TEMP_HYSTERESIS * 2) @@ -1040,8 +1061,8 @@ static void temp_drop(struct avalon_info *info, int temp) else if (temp < opt_avalon_temp) info->fan_pwm -= 1; - if (info->fan_pwm < AVALON_DEFAULT_FAN_MIN_PWM) - info->fan_pwm = AVALON_DEFAULT_FAN_MIN_PWM; + if (info->fan_pwm < opt_avalon_fan_min) + info->fan_pwm = opt_avalon_fan_min; } static inline void adjust_fan(struct avalon_info *info) diff --git a/driver-avalon.h b/driver-avalon.h index a5ae754e..9454f246 100644 --- a/driver-avalon.h +++ b/driver-avalon.h @@ -23,6 +23,9 @@ #define AVALON_RESET_PITCH (300*1000*1000) #define AVALON_FAN_FACTOR 120 +#define AVALON_PWM_MAX 0xA0 +#define AVALON_DEFAULT_FAN_MIN 20 +#define AVALON_DEFAULT_FAN_MAX 100 #define AVALON_DEFAULT_FAN_MAX_PWM 0xA0 /* 100% */ #define AVALON_DEFAULT_FAN_MIN_PWM 0x20 /* 20% */ @@ -152,7 +155,10 @@ ASSERT1(sizeof(uint32_t) == 4); extern struct avalon_info **avalon_info; extern int opt_avalon_temp; extern int opt_avalon_overheat; +extern int opt_avalon_fan_min; +extern int opt_avalon_fan_max; extern bool opt_avalon_auto; +extern char *set_avalon_fan(char *arg); #endif /* USE_AVALON */ #endif /* AVALON_H */