|
|
@@ -55,6 +55,8 @@ bool nanofury_spi_reset(struct mcp2210_device * const mcp)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+static void nanofury_device_off(struct mcp2210_device *);
|
|
|
+
|
|
|
static
|
|
|
bool nanofury_spi_txrx(struct spi_port * const port)
|
|
|
{
|
|
|
@@ -73,7 +75,7 @@ bool nanofury_spi_txrx(struct spi_port * const port)
|
|
|
while (bufsz >= NANOFURY_MAX_BYTES_PER_SPI_TRANSFER)
|
|
|
{
|
|
|
if (!mcp2210_spi_transfer(mcp, ptrwrbuf, ptrrdbuf, NANOFURY_MAX_BYTES_PER_SPI_TRANSFER))
|
|
|
- return false;
|
|
|
+ goto err;
|
|
|
ptrrdbuf += NANOFURY_MAX_BYTES_PER_SPI_TRANSFER;
|
|
|
ptrwrbuf += NANOFURY_MAX_BYTES_PER_SPI_TRANSFER;
|
|
|
bufsz -= NANOFURY_MAX_BYTES_PER_SPI_TRANSFER;
|
|
|
@@ -83,10 +85,16 @@ bool nanofury_spi_txrx(struct spi_port * const port)
|
|
|
if (bufsz > 0)
|
|
|
{
|
|
|
if (!mcp2210_spi_transfer(mcp, ptrwrbuf, ptrrdbuf, bufsz))
|
|
|
- return false;
|
|
|
+ goto err;
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
+
|
|
|
+err:
|
|
|
+ mcp2210_spi_cancel(mcp);
|
|
|
+ nanofury_device_off(mcp);
|
|
|
+ hashes_done2(thr, -1, NULL);
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
static
|
|
|
@@ -119,6 +127,9 @@ bool nanofury_checkport(struct mcp2210_device * const mcp)
|
|
|
if (!mcp2210_set_gpio_output(mcp, NANOFURY_GP_PIN_PWR_EN, MGV_HIGH))
|
|
|
goto fail;
|
|
|
|
|
|
+ // cancel any outstanding SPI transfers
|
|
|
+ mcp2210_spi_cancel(mcp);
|
|
|
+
|
|
|
// configure SPI
|
|
|
// This is the only place where speed, mode and other settings are configured!!!
|
|
|
if (!mcp2210_configure_spi(mcp, 200000, 0xffff, 0xffef, 0, 0, 0))
|
|
|
@@ -302,6 +313,17 @@ void nanofury_enable(struct thr_info * const thr)
|
|
|
bitfury_enable(thr);
|
|
|
}
|
|
|
|
|
|
+static
|
|
|
+void nanofury_reinit(struct cgpu_info * const cgpu)
|
|
|
+{
|
|
|
+ struct thr_info * const thr = cgpu->thr[0];
|
|
|
+ struct mcp2210_device * const mcp = thr->cgpu_data;
|
|
|
+
|
|
|
+ nanofury_device_off(mcp);
|
|
|
+ cgsleep_ms(1);
|
|
|
+ nanofury_enable(thr);
|
|
|
+}
|
|
|
+
|
|
|
static
|
|
|
void nanofury_shutdown(struct thr_info * const thr)
|
|
|
{
|
|
|
@@ -318,6 +340,7 @@ struct device_drv nanofury_drv = {
|
|
|
.thread_init = nanofury_init,
|
|
|
.thread_disable = nanofury_disable,
|
|
|
.thread_enable = nanofury_enable,
|
|
|
+ .reinit_device = nanofury_reinit,
|
|
|
.thread_shutdown = nanofury_shutdown,
|
|
|
|
|
|
.minerloop = minerloop_async,
|