Commit 8d7d764f1de2ac083f611ac5e0dd2843f47a8266

Con Kolivas 2014-01-23T23:19:19

Change the default clockspeed bits on nanofury devices to 50 and add a command line option to allow it to be changed.

diff --git a/ASIC-README b/ASIC-README
index b206d43..2f881b5 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -330,6 +330,12 @@ temperature just below an optimal target. This option allows you to change the
 target temperature. When actively cooled below this, the devices will run at
 maximum speed.
 
+--nfu-bits <arg>    Set nanofury bits for overclocking range 32-63 (default: 50)
+
+Cgminer by default sets the clockspeed on nanofury devices to the highest that
+is still within USB2 spec. This value allows you to alter the clockspeed, with
+~54 being the optimal but requiring a higher power or USB3 port.
+
 
 BITFURY Devices
 
diff --git a/cgminer.c b/cgminer.c
index 47a9f7b..bfc1303 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -655,6 +655,13 @@ static char *set_int_0_to_200(const char *arg, int *i)
 }
 #endif
 
+#ifdef USE_BITFURY
+static char *set_int_32_to_63(const char *arg, int *i)
+{
+	return set_int_range(arg, i, 32, 63);
+}
+#endif
+
 static char *set_int_1_to_10(const char *arg, int *i)
 {
 	return set_int_range(arg, i, 1, 10);
@@ -1244,6 +1251,11 @@ static struct opt_table opt_config_table[] = {
 		     opt_set_charp, NULL, &opt_stderr_cmd,
 		     "Use custom pipe cmd for output messages"),
 #endif // defined(unix)
+#ifdef USE_BITFURY
+	OPT_WITH_ARG("--nfu-bits",
+		     set_int_32_to_63, opt_show_intval, &opt_nf1_bits,
+		     "Set nanofury bits for overclocking, range 32-63"),
+#endif
 	OPT_WITHOUT_ARG("--net-delay",
 			opt_set_bool, &opt_delaynet,
 			"Impose small delays in networking to not overload slow routers"),
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 3bad374..202c8af 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -16,6 +16,7 @@
 #include "libbitfury.h"
 
 int opt_bxf_temp_target = BXF_TEMP_TARGET / 10;
+int opt_nf1_bits = 50;
 
 /* Wait longer 1/3 longer than it would take for a full nonce range */
 #define BF1WAIT 1600
@@ -414,7 +415,7 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
 	if (val != MCP2210_GPIO_PIN_LOW)
 		goto out;
 
-	info->osc6_bits = 54;
+	info->osc6_bits = opt_nf1_bits;
 	if (!nf1_reinit(bitfury, info))
 		goto out;
 
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 30d7e4d..e802915 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -24,6 +24,7 @@
 #define BXF_TEMP_HYSTERESIS 30
 
 extern int opt_bxf_temp_target;
+extern int opt_nf1_bits;
 
 #define NF1_PIN_LED 0
 #define NF1_PIN_SCK_OVR 5