Do a shutdown routine on bxm close.
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 5cdf0e6..a55b42d 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -511,13 +511,28 @@ static uint16_t calc_divisor(uint32_t system_clock, uint32_t freq)
return divisor;
}
-static void bxm_close(struct cgpu_info *bitfury)
+static void bxm_shutdown(struct cgpu_info *bitfury, struct bitfury_info *info)
+{
+ int chip_n;
+
+ for (chip_n = 0; chip_n < 2; chip_n++) {
+ spi_clear_buf(info);
+ spi_add_break(info);
+ spi_add_fasync(info, chip_n);
+ spi_config_reg(info, 4, 0);
+ info->spi_txrx(bitfury, info);
+ }
+}
+
+static void bxm_close(struct cgpu_info *bitfury, struct bitfury_info *info)
{
unsigned char bitmask = 0;
unsigned char mode = BITMODE_RESET;
unsigned short usb_val = bitmask;
- //Need to do BITMODE_RESET before close per FTDI
+ bxm_shutdown(bitfury, info);
+
+ //Need to do BITMODE_RESET before usb close per FTDI
usb_val |= (mode << 8);
usb_transfer(bitfury, FTDI_TYPE_OUT, SIO_SET_BITMODE_REQUEST, usb_val, 1, C_BXM_SETBITMODE);
}
@@ -716,7 +731,7 @@ static bool bxm_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
info->total_nonces = 1;
out:
if (!ret)
- bxm_close(bitfury);
+ bxm_close(bitfury, info);
return ret;
}
@@ -1484,7 +1499,7 @@ static void bitfury_shutdown(struct thr_info *thr)
nf1_close(bitfury);
break;
case IDENT_BXM:
- bxm_close(bitfury);
+ bxm_close(bitfury, info);
break;
default:
break;
diff --git a/libbitfury.h b/libbitfury.h
index 7d59573..ad89632 100644
--- a/libbitfury.h
+++ b/libbitfury.h
@@ -15,6 +15,7 @@
void ms3steps(uint32_t *p);
uint32_t decnonce(uint32_t in);
void bitfury_work_to_payload(struct bitfury_payload *p, struct work *work);
+void spi_config_reg(struct bitfury_info *info, int cfgreg, int ena);
void spi_set_freq(struct bitfury_info *info);
void spi_send_conf(struct bitfury_info *info);
void spi_send_init(struct bitfury_info *info);