static void gridseed_initialise(struct cgpu_info *gridseed, GRIDSEED_INFO *info) { int err, interface; enum sub_ident ident; if (gridseed->usbinfo.nodev) return; interface = usb_interface(gridseed); ident = usb_ident(gridseed); switch(ident) { case IDENT_GSD: err = 0; break; case IDENT_GSD1: err = gridseed_cp210x_init(gridseed, interface); break; case IDENT_GSD2: err = gridseed_ftdi_init(gridseed, interface); break; case IDENT_GSD3: err = gridseed_pl2303_init(gridseed, interface); break; default: quit(1, "gridseed_intialise() called with invalid %s cgid %i ident=%d", gridseed->drv->name, gridseed->sgminer_id, ident); } if (err) return; }
static void bitforce_initialise(struct cgpu_info *bitforce, bool lock) { int err, interface; if (lock) mutex_lock(&bitforce->device_mutex); if (bitforce->usbinfo.nodev) goto failed; interface = usb_interface(bitforce); // Reset err = usb_transfer(bitforce, FTDI_TYPE_OUT, FTDI_REQUEST_RESET, FTDI_VALUE_RESET, interface, C_RESET); if (opt_debug) applog(LOG_DEBUG, "%s%i: reset got err %d", bitforce->drv->name, bitforce->device_id, err); if (bitforce->usbinfo.nodev) goto failed; // Set data control err = usb_transfer(bitforce, FTDI_TYPE_OUT, FTDI_REQUEST_DATA, FTDI_VALUE_DATA_BFL, interface, C_SETDATA); if (opt_debug) applog(LOG_DEBUG, "%s%i: setdata got err %d", bitforce->drv->name, bitforce->device_id, err); if (bitforce->usbinfo.nodev) goto failed; // Set the baud err = usb_transfer(bitforce, FTDI_TYPE_OUT, FTDI_REQUEST_BAUD, FTDI_VALUE_BAUD_BFL, (FTDI_INDEX_BAUD_BFL & 0xff00) | interface, C_SETBAUD); if (opt_debug) applog(LOG_DEBUG, "%s%i: setbaud got err %d", bitforce->drv->name, bitforce->device_id, err); if (bitforce->usbinfo.nodev) goto failed; // Set Flow Control err = usb_transfer(bitforce, FTDI_TYPE_OUT, FTDI_REQUEST_FLOW, FTDI_VALUE_FLOW, interface, C_SETFLOW); if (opt_debug) applog(LOG_DEBUG, "%s%i: setflowctrl got err %d", bitforce->drv->name, bitforce->device_id, err); if (bitforce->usbinfo.nodev) goto failed; // Set Modem Control err = usb_transfer(bitforce, FTDI_TYPE_OUT, FTDI_REQUEST_MODEM, FTDI_VALUE_MODEM, interface, C_SETMODEM); if (opt_debug) applog(LOG_DEBUG, "%s%i: setmodemctrl got err %d", bitforce->drv->name, bitforce->device_id, err); if (bitforce->usbinfo.nodev) goto failed; // Clear any sent data err = usb_transfer(bitforce, FTDI_TYPE_OUT, FTDI_REQUEST_RESET, FTDI_VALUE_PURGE_TX, interface, C_PURGETX); if (opt_debug) applog(LOG_DEBUG, "%s%i: purgetx got err %d", bitforce->drv->name, bitforce->device_id, err); if (bitforce->usbinfo.nodev) goto failed; // Clear any received data err = usb_transfer(bitforce, FTDI_TYPE_OUT, FTDI_REQUEST_RESET, FTDI_VALUE_PURGE_RX, interface, C_PURGERX); if (opt_debug) applog(LOG_DEBUG, "%s%i: purgerx got err %d", bitforce->drv->name, bitforce->device_id, err); failed: if (lock) mutex_unlock(&bitforce->device_mutex); }
static void hashratio_initialise(struct cgpu_info *hashratio) { int err, interface; if (hashratio->usbinfo.nodev) return; interface = usb_interface(hashratio); // Reset err = usb_transfer(hashratio, FTDI_TYPE_OUT, FTDI_REQUEST_RESET, FTDI_VALUE_RESET, interface, C_RESET); applog(LOG_DEBUG, "%s%i: reset got err %d", hashratio->drv->name, hashratio->device_id, err); if (hashratio->usbinfo.nodev) return; // Set latency err = usb_transfer(hashratio, FTDI_TYPE_OUT, FTDI_REQUEST_LATENCY, HASHRATIO_LATENCY, interface, C_LATENCY); applog(LOG_DEBUG, "%s%i: latency got err %d", hashratio->drv->name, hashratio->device_id, err); if (hashratio->usbinfo.nodev) return; // Set data err = usb_transfer(hashratio, FTDI_TYPE_OUT, FTDI_REQUEST_DATA, FTDI_VALUE_DATA_AVA, interface, C_SETDATA); applog(LOG_DEBUG, "%s%i: data got err %d", hashratio->drv->name, hashratio->device_id, err); if (hashratio->usbinfo.nodev) return; // Set the baud err = usb_transfer(hashratio, FTDI_TYPE_OUT, FTDI_REQUEST_BAUD, FTDI_VALUE_BAUD_AVA, (FTDI_INDEX_BAUD_AVA & 0xff00) | interface, C_SETBAUD); applog(LOG_DEBUG, "%s%i: setbaud got err %d", hashratio->drv->name, hashratio->device_id, err); if (hashratio->usbinfo.nodev) return; // Set Modem Control err = usb_transfer(hashratio, FTDI_TYPE_OUT, FTDI_REQUEST_MODEM, FTDI_VALUE_MODEM, interface, C_SETMODEM); applog(LOG_DEBUG, "%s%i: setmodemctrl got err %d", hashratio->drv->name, hashratio->device_id, err); if (hashratio->usbinfo.nodev) return; // Set Flow Control err = usb_transfer(hashratio, FTDI_TYPE_OUT, FTDI_REQUEST_FLOW, FTDI_VALUE_FLOW, interface, C_SETFLOW); applog(LOG_DEBUG, "%s%i: setflowctrl got err %d", hashratio->drv->name, hashratio->device_id, err); if (hashratio->usbinfo.nodev) return; /* hashratio repeats the following */ // Set Modem Control err = usb_transfer(hashratio, FTDI_TYPE_OUT, FTDI_REQUEST_MODEM, FTDI_VALUE_MODEM, interface, C_SETMODEM); applog(LOG_DEBUG, "%s%i: setmodemctrl 2 got err %d", hashratio->drv->name, hashratio->device_id, err); if (hashratio->usbinfo.nodev) return; // Set Flow Control err = usb_transfer(hashratio, FTDI_TYPE_OUT, FTDI_REQUEST_FLOW, FTDI_VALUE_FLOW, interface, C_SETFLOW); applog(LOG_DEBUG, "%s%i: setflowctrl 2 got err %d", hashratio->drv->name, hashratio->device_id, err); }