Implement smarter PID type fan control for ava2 allowing more generous temperatures and far lower fan speeds for optimal power and noise usage. Adjust default frequency to 450 as per recommendation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
diff --git a/driver-avalon2.c b/driver-avalon2.c
index b2eeaf9..0da00d0 100644
--- a/driver-avalon2.c
+++ b/driver-avalon2.c
@@ -46,8 +46,10 @@ ASSERT1(sizeof(uint32_t) == 4);
int opt_avalon2_freq_min;
int opt_avalon2_freq_max;
-int opt_avalon2_fan_min = get_fan_pwm(AVA2_DEFAULT_FAN_MIN);
-int opt_avalon2_fan_max = get_fan_pwm(AVA2_DEFAULT_FAN_MAX);
+int opt_avalon2_fan_min = AVA2_DEFAULT_FAN_MIN;
+int opt_avalon2_fan_max = AVA2_DEFAULT_FAN_MAX;
+static int avalon2_fan_min = get_fan_pwm(AVA2_DEFAULT_FAN_MIN);
+static int avalon2_fan_max = get_fan_pwm(AVA2_DEFAULT_FAN_MAX);
int opt_avalon2_voltage_min;
int opt_avalon2_voltage_max;
@@ -57,15 +59,15 @@ enum avalon2_fan_fixed opt_avalon2_fan_fixed = FAN_AUTO;
static inline uint8_t rev8(uint8_t d)
{
- int i;
- uint8_t out = 0;
+ int i;
+ uint8_t out = 0;
- /* (from left to right) */
- for (i = 0; i < 8; i++)
- if (d & (1 << i))
- out |= (1 << (7 - i));
+ /* (from left to right) */
+ for (i = 0; i < 8; i++)
+ if (d & (1 << i))
+ out |= (1 << (7 - i));
- return out;
+ return out;
}
char *set_avalon2_fan(char *arg)
@@ -81,8 +83,10 @@ char *set_avalon2_fan(char *arg)
if (val1 < 0 || val1 > 100 || val2 < 0 || val2 > 100 || val2 < val1)
return "Invalid value passed to avalon2-fan";
- opt_avalon2_fan_min = get_fan_pwm(val1);
- opt_avalon2_fan_max = get_fan_pwm(val2);
+ opt_avalon2_fan_min = val1;
+ opt_avalon2_fan_max = val2;
+ avalon2_fan_min = get_fan_pwm(val1);
+ avalon2_fan_max = get_fan_pwm(val2);
return NULL;
}
@@ -221,12 +225,12 @@ static void adjust_fan(struct avalon2_info *info)
t = get_current_temp_max(info);
/* TODO: Add options for temperature range and fan adjust function */
- if (t < 50)
- info->fan_pct = 40;
- else if (t > 70)
- info->fan_pct = 70;
+ if (t < 60)
+ info->fan_pct = opt_avalon2_fan_min;
+ else if (t > 80)
+ info->fan_pct = opt_avalon2_fan_max;
else
- info->fan_pct = 3 * t - 110;
+ info->fan_pct = (t - 60) * (opt_avalon2_fan_max - opt_avalon2_fan_min) / 20 + opt_avalon2_fan_min;
info->fan_pwm = get_fan_pwm(info->fan_pct);
}
diff --git a/driver-avalon2.h b/driver-avalon2.h
index bb50fe9..e10e469 100644
--- a/driver-avalon2.h
+++ b/driver-avalon2.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Con Kolivas <kernel@kolivas.org>
+ * Copyright 2013-2014 Con Kolivas <kernel@kolivas.org>
* Copyright 2012-2014 Xiangfu <xiangfu@openmobilefree.com>
*
* This program is free software; you can redistribute it and/or modify it
@@ -24,9 +24,9 @@
#define AVA2_DEFAULT_MODULARS 4
#define AVA2_PWM_MAX 0x3FF
-#define AVA2_DEFAULT_FAN_PWM 50 /* % */
-#define AVA2_DEFAULT_FAN_MIN 20
-#define AVA2_DEFAULT_FAN_MAX 100
+#define AVA2_DEFAULT_FAN_PWM 15 /* % */
+#define AVA2_DEFAULT_FAN_MIN 10
+#define AVA2_DEFAULT_FAN_MAX 85
#define AVALON2_TEMP_OVERHEAT 88
@@ -44,7 +44,7 @@
/* Avalon3 default values */
#define AVA2_AVA3_MINERS 5
#define AVA2_AVA3_VOLTAGE 6625 /* 0.6625v */
-#define AVA2_AVA3_FREQUENCY 400 /* MHz * 11.8 = MHs: 400MHz means ~4.7GHs */
+#define AVA2_AVA3_FREQUENCY 450 /* MHz * 11.8 = MHs: 450MHz means ~5.3GHs */
/* Avalon2 protocol package type */
#define AVA2_H1 'A'