Commit fc673c9f9c25a848046e3c2e9735ee99508c6559

Con Kolivas 2014-01-06T09:18:38

Fix more init sequence for nanofury.

diff --git a/driver-bitfury.c b/driver-bitfury.c
index c31b391..ff4cffa 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -392,14 +392,16 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
 		mcp->designation.pin[i] = MCP2210_PIN_GPIO;
 		/* Set all pins to input mode */
 		mcp->direction.pin[i] = MCP2210_GPIO_INPUT;
+		mcp->value.pin[i] = MCP2210_GPIO_PIN_LOW;
 	}
 
-	if (!mcp2210_set_gpio_settings(bitfury, mcp))
-		goto out;
-
 	/* Set LED and PWR pins to output and high */
 	mcp->direction.pin[NF1_PIN_LED] = mcp->direction.pin[NF1_PIN_PWR_EN] = MCP2210_GPIO_OUTPUT;
 	mcp->value.pin[NF1_PIN_LED] = mcp->value.pin[NF1_PIN_PWR_EN] = MCP2210_GPIO_PIN_HIGH;
+
+	mcp->direction.pin[4] = MCP2210_GPIO_OUTPUT;
+	mcp->designation.pin[4] = MCP2210_PIN_CS;
+
 	if (!mcp2210_set_gpio_settings(bitfury, mcp))
 		goto out;
 
@@ -426,15 +428,14 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
 	/* Cancel any transfers in progress */
 	if (!mcp2210_spi_cancel(bitfury))
 		goto out;
-	if (!mcp2210_get_spi_transfer_settings(bitfury, &info->mcp.bitrate, &info->mcp.icsv,
-	    &info->mcp.acsv, &info->mcp.cstdd, &info->mcp.ldbtcsd, &info->mcp.sdbd,
-	    &info->mcp.bpst, &info->mcp.spimode))
+	if (!mcp2210_get_spi_transfer_settings(bitfury, &mcp->bitrate, &mcp->icsv,
+	    &mcp->acsv, &mcp->cstdd, &mcp->ldbtcsd, &mcp->sdbd, &mcp->bpst, &mcp->spimode))
 		goto out;
-	info->mcp.bitrate = 12000000;
-	info->mcp.icsv = 0xffff;
-	info->mcp.acsv = 0xffef;
-	info->mcp.cstdd = info->mcp.ldbtcsd = info->mcp.sdbd = info->mcp.spimode = 0;
-	info->mcp.sdbd = 1;
+	mcp->bitrate = 12000000;
+	mcp->icsv = 0xffff;
+	mcp->acsv = 0xffef;
+	mcp->cstdd = mcp->ldbtcsd = mcp->sdbd = mcp->spimode = 0;
+	mcp->bpst = 1;
 	if (!nf1_set_spi_settings(bitfury, info))
 		goto out;
 
@@ -450,7 +451,7 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
 		goto out;
 
 	/* switch SCK to polarity (default SCK=1 in mode 2) */
-	info->mcp.spimode = 2;
+	mcp->spimode = 2;
 	if (!nf1_set_spi_settings(bitfury, info))
 		goto out;
 	buf[0] = 0;
@@ -465,7 +466,7 @@ static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
 		goto out;
 
 	/* switch SCK to polarity (default SCK=0 in mode 0) */
-	info->mcp.spimode = 0;
+	mcp->spimode = 0;
 	if (!nf1_set_spi_settings(bitfury, info))
 		goto out;
 	buf[0] = 0;