Implement initial part of nanofury init sequence for GPIO pin settings and add output debugging of set values.
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 8504f90..7211019 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -277,6 +277,49 @@ out_close:
return false;
}
+static bool nf1_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
+{
+ bool ret = false;
+ int i;
+
+ /* Set all pins to GPIO mode */
+ for (i = 0; i < 9; i++) {
+ if (!mcp2210_set_gpio_pindes(bitfury, i, MCP2210_PIN_GPIO))
+ return ret;
+ }
+ /* Set all pins to input mode */
+ for (i = 0; i < 9; i++) {
+ if (!mcp2210_set_gpio_pindir(bitfury, i, MCP2210_GPIO_INPUT))
+ return ret;
+ }
+ if (!mcp2210_set_gpio_pindir(bitfury, NF1_PIN_LED, MCP2210_GPIO_OUTPUT))
+ return ret;
+ if (!mcp2210_set_gpio_pindir(bitfury, NF1_PIN_PWR_EN, MCP2210_GPIO_OUTPUT))
+ return ret;
+
+ if (opt_debug) {
+ struct gpio_pin gp;
+
+ mcp2210_get_gpio_pindirs(bitfury, &gp);
+ for (i = 0; i < 9; i++) {
+ applog(LOG_DEBUG, "%s %d: Pin dir %d %d", bitfury->drv->name,
+ bitfury->device_id, i, gp.pin[i]);
+ }
+ mcp2210_get_gpio_pinvals(bitfury, &gp);
+ for (i = 0; i < 9; i++) {
+ applog(LOG_DEBUG, "%s %d: Pin val %d %d", bitfury->drv->name,
+ bitfury->device_id, i, gp.pin[i]);
+ }
+ mcp2210_get_gpio_pindes(bitfury, &gp);
+ for (i = 0; i < 9; i++) {
+ applog(LOG_DEBUG, "%s %d: Pin des %d %d", bitfury->drv->name,
+ bitfury->device_id, i, gp.pin[i]);
+ }
+ }
+out:
+ return ret;
+}
+
static struct cgpu_info *bitfury_detect_one(struct libusb_device *dev, struct usb_find_devices *found)
{
struct cgpu_info *bitfury;
@@ -303,6 +346,9 @@ static struct cgpu_info *bitfury_detect_one(struct libusb_device *dev, struct us
case IDENT_BXF:
ret = bxf_detect_one(bitfury, info);
break;
+ case IDENT_NF1:
+ ret = nf1_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 9412076..0a5f99e 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -24,6 +24,10 @@
extern int opt_bxf_temp_target;
+#define NF1_PIN_LED 0
+#define NF1_PIN_SCK_OVR 5
+#define NF1_PIN_PWR_EN 6
+
struct bitfury_info {
struct cgpu_info *base_cgpu;
struct thr_info *thr;