static void gc3355_init(struct cgpu_info *gridseed, GRIDSEED_INFO *info) { unsigned char buf[512]; int amount; applog(LOG_NOTICE, "System reseting"); gc3355_send_cmds(gridseed, str_reset); cgsleep_ms(200); usb_buffer_clear(gridseed); usb_read_timeout(gridseed, buf, sizeof(buf), &amount, 10, C_GETRESULTS); gc3355_send_cmds(gridseed, str_init); gc3355_send_cmds(gridseed, str_ltc_reset); gc3355_set_core_freq(gridseed); if (info->voltage) gc3355_increase_voltage(gridseed); }
static bool gridseed_prepare_work(struct thr_info __maybe_unused *thr, struct work *work) { struct cgpu_info *gridseed = thr->cgpu; GRIDSEED_INFO *info = gridseed->device_data; cgtime(&info->scanhash_time); gc3355_send_cmds(gridseed, str_ltc_reset); usb_buffer_clear(gridseed); return gridseed_send_task(gridseed, work); }
static void gc3355_init(struct cgpu_info *gridseed, GRIDSEED_INFO *info, bool set_nonce) { unsigned char buf[512]; int amount; applog(LOG_NOTICE, "System reseting"); gc3355_send_cmds(gridseed, str_reset); cgsleep_ms(200); usb_buffer_clear(gridseed); usb_read_timeout(gridseed, buf, sizeof(buf), &amount, 10, C_GETRESULTS); gc3355_send_cmds(gridseed, str_init); gc3355_send_cmds(gridseed, str_ltc_reset); gc3355_set_core_freq(gridseed); if (set_nonce) gc3355_set_init_nonce(gridseed); //gc3355_send_cmds(gridseed, str_baud); //gc3355_send_cmds(gridseed, str_enable_btc_cores); gc3355_enable_btc_cores(gridseed, info); if (info->usefifo == 0) gc3355_send_cmds(gridseed, str_nofifo); gridseed_request_ltc_task(gridseed, info); return; }
static void gc3355_set_core_freq(struct cgpu_info *gridseed) { GRIDSEED_INFO *info; int inx; char *p; char *cmds[4]; info = (GRIDSEED_INFO*)(gridseed->device_data); inx = info->freq; cmds[0] = (char *)str_frequency[inx*2]; cmds[1] = (char *)str_frequency[inx*2+1]; cmds[2] = NULL; cmds[3] = NULL; gc3355_send_cmds(gridseed, (const char **)cmds); applog(LOG_INFO, "Set GC3355 core frequency to %sMhz", opt_frequency[inx]); return; }
/* * check if we have LTC task. timeout 1ms */ static void gridseed_recv_ltc(struct cgpu_info *gridseed, GRIDSEED_INFO *info) { fd_set rdfs; struct timeval tv; unsigned char buf[156]; int sock; int n; sock = info->sockltc; if (sock <= 0) return; re_read: tv.tv_sec = 0; tv.tv_usec = 10000; FD_ZERO(&rdfs); FD_SET(sock, &rdfs); if (select(sock+1, &rdfs, NULL, NULL, &tv) <= 0) return; n = recvfrom(sock, buf, sizeof(buf), 0, NULL, NULL); if (n != sizeof(buf)) goto re_read; mutex_lock(&info->qlock); if (buf[0] == 0x55 || buf[1] == 0xaa) { if (buf[2] == 0x1f) { gc3355_send_cmds(gridseed, str_ltc_reset); gc3355_write_data(gridseed, buf, sizeof(buf)); } else if (buf[2] == 0x55) { // ping command unsigned char nonce[12]; memcpy(nonce, "\x55\xaa\x55\xaa\x11\x22\x33\x44\x55\x66\x77\x88", 12); gridseed_send_ltc_nonce(gridseed, info, nonce, sizeof(nonce)); } } mutex_unlock(&info->qlock); goto re_read; }