Commit 96a5c526043ec0e2cdff8380b29fde79a7b65d9c

Con Kolivas 2014-04-03T11:09:33

Make the bxf bits configurable on the command line

diff --git a/ASIC-README b/ASIC-README
index 235255d..3d57de6 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -211,8 +211,9 @@ ASIC SPECIFIC COMMANDS
 --bitmain-hwerror   Set bitmain device detect hardware error
 --bitmain-options   Set bitmain options baud:miners:asic:timeout:freq
 --bitmain-temp      Set bitmain target temperature
+--bxf-bits <arg>    Set max BXF bits for overclocking (default: 54)
 --bxf-temp-target <arg> Set target temperature for BXF devices (default: 82)
---bxm-bits <arg>    Set BXM bits for overclocking (default: 50)
+--bxm-bits <arg>    Set BXM bits for overclocking (default: 54)
 --hfa-hash-clock <arg> Set hashfast clock speed (default: 550)
 --hfa-fail-drop <arg> Set how many MHz to drop clockspeed each failure on an overlocked hashfast device (default: 10)
 --hfa-fan <arg>     Set fanspeed percentage for hashfast, single value or range (default: 10-85)
@@ -440,6 +441,12 @@ throttles BFLSC devices by allowing them to temporarily go idle.
 
 BITFURY Devices
 
+--bxf-bits <arg>    Set max BXF bits for overclocking (default: 54)
+
+In combination with the dynamic clocking on Bi*fury devices, this sets the
+highest bit target that cgminer will aim for.
+
+
 --bxf-temp-target <arg> Set target temperature for BXF devices (default: 82)
 
 Cgminer uses dynamic clocking on Bi*fury devices to try and maintain the
@@ -447,10 +454,10 @@ 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.
 
---bxm-bits <arg>    Set BXM bits for overclocking (default: 50)
+--bxm-bits <arg>    Set BXM bits for overclocking (default: 54)
+
+Choose the overclocking  bits for BFx2 devices.
 
-Choose the overclocking  bits for BFx2 devices, where 54~55 is optimal but
-may be beyond the power usage of USB2 specifications.
 
 --nfu-bits <arg>    Set nanofury bits for overclocking range 32-63 (default: 50)
 
diff --git a/README b/README
index c7222d7..80a4b4e 100644
--- a/README
+++ b/README
@@ -192,8 +192,9 @@ Options for both config file and command line:
 --bitmain-hwerror   Set bitmain device detect hardware error
 --bitmain-options   Set bitmain options baud:miners:asic:timeout:freq
 --bitmain-temp      Set bitmain target temperature
+--bxf-bits <arg>    Set max BXF bits for overclocking (default: 54)
 --bxf-temp-target <arg> Set target temperature for BXF devices (default: 82)
---bxm-bits <arg>    Set BXM bits for overclocking (default: 50)
+--bxm-bits <arg>    Set BXM bits for overclocking (default: 54)
 --btc-address <arg> Set bitcoin target address when solo mining to bitcoind
 --compact           Use compact display without per device statistics
 --debug|-D          Enable debug output
diff --git a/cgminer.c b/cgminer.c
index 8e592d6..95fffe7 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -1327,6 +1327,9 @@ static struct opt_table opt_config_table[] = {
 		     "Bitmine A1 options ref_clk_khz:sys_clk_khz:spi_clk_khz:override_chip_num"),
 #endif
 #ifdef USE_BITFURY
+	OPT_WITH_ARG("--bxf-bits",
+		     set_int_32_to_63, opt_show_intval, &opt_bxf_bits,
+		     "Set max BXF bits for overclocking"),
 	OPT_WITH_ARG("--bxf-temp-target",
 		     set_int_0_to_200, opt_show_intval, &opt_bxf_temp_target,
 		     "Set target temperature for BXF devices"),
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 38aa45a..854a764 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -17,7 +17,8 @@
 
 int opt_bxf_temp_target = BXF_TEMP_TARGET / 10;
 int opt_nf1_bits = 50;
-int opt_bxm_bits = 50;
+int opt_bxm_bits = 54;
+int opt_bxf_bits = 54;
 
 /* Wait longer 1/3 longer than it would take for a full nonce range */
 #define BF1WAIT 1600
@@ -903,7 +904,7 @@ static void parse_bxf_temp(struct cgpu_info *bitfury, struct bitfury_info *info,
 			goto out;
 		}
 		/* implies: decitemp < info->last_decitemp */
-		if (info->clocks >= BXF_CLOCK_DEFAULT)
+		if (info->clocks >= opt_bxf_bits)
 			goto out;
 		applog(LOG_DEBUG, "%s %d: Temp %d in target and falling, increasing clock",
 		       bitfury->drv->name, bitfury->device_id, decitemp);
@@ -911,7 +912,7 @@ static void parse_bxf_temp(struct cgpu_info *bitfury, struct bitfury_info *info,
 		goto out;
 	}
 	/* implies: decitemp < info->temp_target - BXF_TEMP_HYSTERESIS */
-	if (info->clocks >= BXF_CLOCK_DEFAULT)
+	if (info->clocks >= opt_bxf_bits)
 		goto out;
 	applog(LOG_DEBUG, "%s %d: Temp %d below target, increasing clock",
 		bitfury->drv->name, bitfury->device_id, decitemp);
@@ -1032,7 +1033,7 @@ static bool bxf_prepare(struct cgpu_info *bitfury, struct bitfury_info *info)
 	mutex_init(&info->lock);
 	if (pthread_create(&info->read_thr, NULL, bxf_get_results, (void *)bitfury))
 		quit(1, "Failed to create bxf read_thr");
-	return bxf_send_clock(bitfury, info, BXF_CLOCK_DEFAULT);
+	return bxf_send_clock(bitfury, info, opt_bxf_bits);
 }
 
 static bool bitfury_prepare(struct thr_info *thr)
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 9d76440..2b2f75a 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -14,7 +14,6 @@
 #include "usbutils.h"
 #include "mcp2210.h"
 
-#define BXF_CLOCK_DEFAULT 54
 #define BXF_CLOCK_OFF 0
 #define BXF_CLOCK_MIN 32
 #define BXF_CLOCK_MAX 63 // Not really used since we only get hw errors above default
@@ -26,6 +25,7 @@
 extern int opt_bxf_temp_target;
 extern int opt_nf1_bits;
 extern int opt_bxm_bits;
+extern int opt_bxf_bits;
 
 #define NF1_PIN_LED 0
 #define NF1_PIN_SCK_OVR 5