Add initial bxm opening sequence for detect one.
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-bitfury.c b/driver-bitfury.c
index 1d50e42..6b74390 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -436,6 +436,49 @@ out:
return ret;
}
+static void bxm_empty_buffer(struct cgpu_info *bitfury)
+{
+ char buf[512];
+ int amount;
+
+ do {
+ usb_read_once(bitfury, buf, 512, &amount, C_BXM_FLUSH);
+ } while (amount);
+}
+
+static bool bxm_open(struct cgpu_info *bitfury, struct bitfury_info *info)
+{
+ char buf[4];
+ int err;
+
+ bxm_empty_buffer(bitfury);
+ /* Device likes being reset first. */
+ usb_reset(bitfury);
+ err = usb_transfer(bitfury, FTDI_TYPE_OUT, SIO_RESET_REQUEST, SIO_RESET_SIO, 1, C_BXM_RESET);
+ if (err)
+ return false;
+ err = usb_transfer(bitfury, FTDI_TYPE_OUT, SIO_SET_LATENCY_TIMER_REQUEST, BXM_LATENCY_MS, 1, C_BXM_SETLATENCY);
+ if (err)
+ return false;
+ err = usb_transfer(bitfury, FTDI_TYPE_OUT, SIO_SET_EVENT_CHAR_REQUEST, 0x00, 1, C_BXM_SECR);
+ if (err)
+ return false;
+
+ return true;
+}
+
+static bool bxm_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
+{
+ bool ret;
+
+ ret = bxm_open(bitfury, info);
+ if (ret) {
+ applog(LOG_INFO, "%s %d: Successfully opened at %s", bitfury->drv->name, bitfury->device_id,
+ bitfury->device_path);
+ }
+ return ret;
+}
+
static struct cgpu_info *bitfury_detect_one(struct libusb_device *dev, struct usb_find_devices *found)
{
struct cgpu_info *bitfury;
@@ -465,6 +508,9 @@ static struct cgpu_info *bitfury_detect_one(struct libusb_device *dev, struct us
case IDENT_NF1:
ret = nf1_detect_one(bitfury, info);
break;
+ case IDENT_BXM:
+ ret = bxm_detect_one(bitfury, info);
+ break;
default:
applog(LOG_INFO, "%s %d: Unrecognised bitfury device",
bitfury->drv->name, bitfury->device_id);
diff --git a/driver-bitfury.h b/driver-bitfury.h
index a9f05a2..f7af174 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -33,6 +33,20 @@ extern int opt_nf1_bits;
#define SPIBUF_SIZE 16384
#define BITFURY_REFRESH_DELAY 100
+#define SIO_RESET_REQUEST 0
+#define SIO_SET_LATENCY_TIMER_REQUEST 0x09
+#define SIO_SET_EVENT_CHAR_REQUEST 0x06
+#define SIO_SET_ERROR_CHAR_REQUEST 0x07
+#define SIO_SET_BITMODE_REQUEST 0x0B
+#define SIO_RESET_PURGE_RX 1
+#define SIO_RESET_PURGE_TX 2
+
+#define BITMODE_RESET 0x00
+#define BITMODE_MPSSE 0x02
+#define SIO_RESET_SIO 0
+
+#define BXM_LATENCY_MS 2
+
struct bitfury_payload {
unsigned char midstate[32];
unsigned int junk[8];
diff --git a/usbutils.h b/usbutils.h
index 9fcd4f2..fa97d90 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -371,6 +371,10 @@ struct cg_usb_info {
USB_ADD_COMMAND(C_BXF_MAXROLL, "BXFMaxRoll") \
USB_ADD_COMMAND(C_BXF_FLUSH, "BXFFlush") \
USB_ADD_COMMAND(C_BXF_CLOCK, "BXFClock") \
+ USB_ADD_COMMAND(C_BXM_FLUSH, "BXMFlush") \
+ USB_ADD_COMMAND(C_BXM_RESET, "BXMReset") \
+ USB_ADD_COMMAND(C_BXM_SETLATENCY, "BXMSetLatency") \
+ USB_ADD_COMMAND(C_BXM_SECR, "BXMSetEventCharRequest") \
USB_ADD_COMMAND(C_HF_RESET, "HFReset") \
USB_ADD_COMMAND(C_HF_PLL_CONFIG, "HFPLLConfig") \
USB_ADD_COMMAND(C_HF_ADDRESS, "HFAddress") \