driver-knc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. /*
  2. * Copyright 2013 Luke Dashjr
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. */
  9. #include "config.h"
  10. #include <stdbool.h>
  11. #include <stddef.h>
  12. #include <stdint.h>
  13. #include <sys/ioctl.h>
  14. #include <sys/types.h>
  15. #include <sys/stat.h>
  16. #include <fcntl.h>
  17. #include <math.h>
  18. #ifdef HAVE_LINUX_I2C_DEV_USER_H
  19. #include <linux/i2c-dev-user.h>
  20. #else
  21. #include <linux/i2c-dev.h>
  22. #endif
  23. #include <linux/spi/spidev.h>
  24. #include <uthash.h>
  25. #include "deviceapi.h"
  26. #include "logging.h"
  27. #include "miner.h"
  28. #include "spidevc.h"
  29. #define KNC_POLL_INTERVAL_US 10000
  30. #define KNC_SPI_SPEED 3000000
  31. #define KNC_SPI_DELAY 0
  32. #define KNC_SPI_MODE (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH)
  33. #define KNC_SPI_BITS 8
  34. static const char * const i2cpath = "/dev/i2c-2";
  35. #define KNC_I2C_TEMPLATE "/dev/i2c-%d"
  36. enum knc_request_cmd {
  37. KNC_REQ_SUBMIT_WORK = 2,
  38. KNC_REQ_FLUSH_QUEUE = 3,
  39. };
  40. enum knc_reply_type {
  41. KNC_REPLY_NONCE_FOUND = 1,
  42. KNC_REPLY_WORK_DONE = 2,
  43. };
  44. struct device_drv knc_drv;
  45. struct knc_device {
  46. int i2c;
  47. struct spi_port *spi;
  48. struct cgpu_info *cgpu;
  49. bool need_flush;
  50. struct work *workqueue;
  51. int workqueue_size;
  52. int workqueue_max;
  53. int next_id;
  54. struct work *devicework;
  55. };
  56. struct knc_core {
  57. int asicno;
  58. int coreno;
  59. };
  60. static
  61. bool knc_detect_one(const char *devpath)
  62. {
  63. static struct cgpu_info *prev_cgpu = NULL;
  64. struct cgpu_info *cgpu;
  65. int i;
  66. const int fd = open(i2cpath, O_RDWR);
  67. char *leftover = NULL;
  68. const int i2cslave = strtol(devpath, &leftover, 0);
  69. uint8_t buf[0x20];
  70. if (leftover && leftover[0])
  71. return false;
  72. if (unlikely(fd == -1))
  73. {
  74. applog(LOG_DEBUG, "%s: Failed to open %s", __func__, i2cpath);
  75. return false;
  76. }
  77. if (ioctl(fd, I2C_SLAVE, i2cslave))
  78. {
  79. close(fd);
  80. applog(LOG_DEBUG, "%s: Failed to select i2c slave 0x%x",
  81. __func__, i2cslave);
  82. return false;
  83. }
  84. i = i2c_smbus_read_i2c_block_data(fd, 0, 0x20, buf);
  85. close(fd);
  86. if (-1 == i)
  87. {
  88. applog(LOG_DEBUG, "%s: 0x%x: Failed to read i2c block data",
  89. __func__, i2cslave);
  90. return false;
  91. }
  92. for (i = 0; ; ++i)
  93. {
  94. if (buf[i] == 3)
  95. break;
  96. if (i == 0x1f)
  97. return false;
  98. }
  99. cgpu = malloc(sizeof(*cgpu));
  100. *cgpu = (struct cgpu_info){
  101. .drv = &knc_drv,
  102. .device_path = strdup(devpath),
  103. .deven = DEV_ENABLED,
  104. .procs = 192,
  105. .threads = prev_cgpu ? 0 : 1,
  106. };
  107. const bool rv = add_cgpu_slave(cgpu, prev_cgpu);
  108. prev_cgpu = cgpu;
  109. return rv;
  110. }
  111. static int knc_detect_auto(void)
  112. {
  113. const int first = 0x20, last = 0x26;
  114. char devpath[4];
  115. int found = 0, i;
  116. for (i = first; i <= last; ++i)
  117. {
  118. sprintf(devpath, "%d", i);
  119. if (knc_detect_one(devpath))
  120. ++found;
  121. }
  122. return found;
  123. }
  124. static void knc_detect(void)
  125. {
  126. generic_detect(&knc_drv, knc_detect_one, knc_detect_auto, GDF_REQUIRE_DNAME | GDF_DEFAULT_NOAUTO);
  127. }
  128. static
  129. bool knc_spi_open(const char *repr, struct spi_port * const spi)
  130. {
  131. const char * const spipath = "/dev/spidev1.0";
  132. const int fd = open(spipath, O_RDWR);
  133. const uint8_t lsbfirst = 0;
  134. if (fd == -1)
  135. return false;
  136. if (ioctl(fd, SPI_IOC_WR_MODE , &spi->mode )) goto fail;
  137. if (ioctl(fd, SPI_IOC_WR_LSB_FIRST , &lsbfirst )) goto fail;
  138. if (ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &spi->bits )) goto fail;
  139. if (ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ , &spi->speed)) goto fail;
  140. spi->fd = fd;
  141. return true;
  142. fail:
  143. close(fd);
  144. spi->fd = -1;
  145. applog(LOG_WARNING, "%s: Failed to open %s", repr, spipath);
  146. return false;
  147. }
  148. static
  149. bool knc_spi_txrx(struct spi_port * const spi)
  150. {
  151. const void * const wrbuf = spi_gettxbuf(spi);
  152. void * const rdbuf = spi_getrxbuf(spi);
  153. const size_t bufsz = spi_getbufsz(spi);
  154. const int fd = spi->fd;
  155. struct spi_ioc_transfer xf = {
  156. .tx_buf = (uintptr_t) wrbuf,
  157. .rx_buf = (uintptr_t) rdbuf,
  158. .len = bufsz,
  159. .delay_usecs = spi->delay,
  160. .speed_hz = spi->speed,
  161. .bits_per_word = spi->bits,
  162. };
  163. return (ioctl(fd, SPI_IOC_MESSAGE(1), &xf) > 0);
  164. }
  165. static
  166. void knc_clean_flush(struct spi_port * const spi)
  167. {
  168. const uint8_t flushcmd = KNC_REQ_FLUSH_QUEUE << 4;
  169. const size_t spi_req_sz = 0x1000;
  170. spi_clear_buf(spi);
  171. spi_emit_buf(spi, &flushcmd, 1);
  172. spi_emit_nop(spi, spi_req_sz - spi_getbufsz(spi));
  173. applog(LOG_DEBUG, "%s: Issuing flush command to clear out device queues", knc_drv.dname);
  174. spi_txrx(spi);
  175. }
  176. static
  177. bool knc_init(struct thr_info * const thr)
  178. {
  179. const int max_cores = 192;
  180. struct thr_info *mythr;
  181. struct cgpu_info * const cgpu = thr->cgpu, *proc;
  182. struct knc_device *knc;
  183. struct knc_core *knccore;
  184. struct spi_port *spi;
  185. const int i2c = open(i2cpath, O_RDWR);
  186. int i2cslave, i, j;
  187. uint8_t buf[0x20];
  188. if (unlikely(i2c == -1))
  189. {
  190. applog(LOG_DEBUG, "%s: Failed to open %s", __func__, i2cpath);
  191. return false;
  192. }
  193. knc = malloc(sizeof(*knc));
  194. for (proc = cgpu; proc; )
  195. {
  196. if (proc->device != proc)
  197. {
  198. applog(LOG_WARNING, "%"PRIpreprv": Extra processor?", proc->proc_repr);
  199. continue;
  200. }
  201. i2cslave = atoi(proc->device_path);
  202. if (ioctl(i2c, I2C_SLAVE, i2cslave))
  203. {
  204. applog(LOG_DEBUG, "%s: Failed to select i2c slave 0x%x",
  205. __func__, i2cslave);
  206. return false;
  207. }
  208. for (i = 0; i < max_cores; i += 0x20)
  209. {
  210. i2c_smbus_read_i2c_block_data(i2c, i, 0x20, buf);
  211. for (j = 0; j < 0x20; ++j)
  212. {
  213. mythr = proc->thr[0];
  214. mythr->cgpu_data = knccore = malloc(sizeof(*knccore));
  215. *knccore = (struct knc_core){
  216. .asicno = i2cslave - 0x20,
  217. .coreno = i + j,
  218. };
  219. if (proc != cgpu)
  220. mythr->queue_full = true;
  221. proc->device_data = knc;
  222. if (buf[j] != 3)
  223. proc->deven = DEV_DISABLED;
  224. proc = proc->next_proc;
  225. if ((!proc) || proc->device == proc)
  226. goto nomorecores;
  227. }
  228. }
  229. nomorecores: ;
  230. }
  231. spi = malloc(sizeof(*spi));
  232. *knc = (struct knc_device){
  233. .i2c = i2c,
  234. .spi = spi,
  235. .cgpu = cgpu,
  236. .workqueue_max = 1,
  237. };
  238. *spi = (struct spi_port){
  239. .txrx = knc_spi_txrx,
  240. .cgpu = cgpu,
  241. .repr = knc_drv.dname,
  242. .logprio = LOG_ERR,
  243. .speed = KNC_SPI_SPEED,
  244. .delay = KNC_SPI_DELAY,
  245. .mode = KNC_SPI_MODE,
  246. .bits = KNC_SPI_BITS,
  247. };
  248. if (!knc_spi_open(cgpu->dev_repr, spi))
  249. return false;
  250. knc_clean_flush(spi);
  251. timer_set_now(&thr->tv_poll);
  252. return true;
  253. }
  254. static
  255. void knc_remove_local_queue(struct knc_device * const knc, struct work * const work)
  256. {
  257. DL_DELETE(knc->workqueue, work);
  258. free_work(work);
  259. --knc->workqueue_size;
  260. }
  261. static
  262. void knc_prune_local_queue(struct thr_info *thr)
  263. {
  264. struct cgpu_info * const cgpu = thr->cgpu;
  265. struct knc_device * const knc = cgpu->device_data;
  266. struct work *work, *tmp;
  267. DL_FOREACH_SAFE(knc->workqueue, work, tmp)
  268. {
  269. if (stale_work(work, false))
  270. knc_remove_local_queue(knc, work);
  271. }
  272. thr->queue_full = (knc->workqueue_size >= knc->workqueue_max);
  273. }
  274. static
  275. bool knc_queue_append(struct thr_info * const thr, struct work * const work)
  276. {
  277. struct cgpu_info * const cgpu = thr->cgpu;
  278. struct knc_device * const knc = cgpu->device_data;
  279. if (knc->workqueue_size >= knc->workqueue_max)
  280. {
  281. knc_prune_local_queue(thr);
  282. if (thr->queue_full)
  283. return false;
  284. }
  285. DL_APPEND(knc->workqueue, work);
  286. ++knc->workqueue_size;
  287. thr->queue_full = (knc->workqueue_size >= knc->workqueue_max);
  288. if (thr->queue_full)
  289. knc_prune_local_queue(thr);
  290. return true;
  291. }
  292. #define HASH_LAST_ADDED(head, out) \
  293. (out = (head) ? (ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail)) : NULL)
  294. static
  295. void knc_queue_flush(struct thr_info * const thr)
  296. {
  297. struct cgpu_info * const cgpu = thr->cgpu;
  298. struct knc_device * const knc = cgpu->device_data;
  299. struct work *work, *tmp;
  300. if (knc->cgpu != cgpu)
  301. return;
  302. DL_FOREACH_SAFE(knc->workqueue, work, tmp)
  303. {
  304. knc_remove_local_queue(knc, work);
  305. }
  306. thr->queue_full = false;
  307. HASH_LAST_ADDED(knc->devicework, work);
  308. if (work && stale_work(work, true))
  309. {
  310. knc->need_flush = true;
  311. timer_set_now(&thr->tv_poll);
  312. }
  313. }
  314. static inline
  315. uint16_t get_u16be(const void * const p)
  316. {
  317. const uint8_t * const b = p;
  318. return (((uint16_t)b[0]) << 8) | b[1];
  319. }
  320. static inline
  321. uint32_t get_u32be(const void * const p)
  322. {
  323. const uint8_t * const b = p;
  324. return (((uint32_t)b[0]) << 0x18)
  325. | (((uint32_t)b[1]) << 0x10)
  326. | (((uint32_t)b[2]) << 8)
  327. | b[3];
  328. }
  329. static
  330. void knc_poll(struct thr_info * const thr)
  331. {
  332. struct thr_info *mythr;
  333. struct cgpu_info * const cgpu = thr->cgpu, *proc;
  334. struct knc_device * const knc = cgpu->device_data;
  335. struct spi_port * const spi = knc->spi;
  336. struct knc_core *knccore;
  337. struct work *work, *tmp;
  338. uint8_t buf[0x30], *rxbuf;
  339. int works_sent = 0, asicno, i;
  340. uint16_t workaccept;
  341. int workid = knc->next_id;
  342. uint32_t nonce, coreno;
  343. size_t spi_req_sz = 0x1000;
  344. unsigned long delay_usecs = KNC_POLL_INTERVAL_US;
  345. knc_prune_local_queue(thr);
  346. spi_clear_buf(spi);
  347. if (knc->need_flush)
  348. {
  349. applog(LOG_NOTICE, "%s: Abandoning stale searches to restart", knc_drv.dname);
  350. buf[0] = KNC_REQ_FLUSH_QUEUE << 4;
  351. spi_emit_buf(spi, buf, sizeof(buf));
  352. }
  353. DL_FOREACH(knc->workqueue, work)
  354. {
  355. buf[0] = KNC_REQ_SUBMIT_WORK << 4;
  356. buf[1] = 0;
  357. buf[2] = (workid >> 8) & 0x7f;
  358. buf[3] = workid & 0xff;
  359. for (i = 0; i < 0x20; ++i)
  360. buf[4 + i] = work->midstate[0x1f - i];
  361. for (i = 0; i < 0xc; ++i)
  362. buf[0x24 + i] = work->data[0x4b - i];
  363. spi_emit_buf(spi, buf, sizeof(buf));
  364. ++works_sent;
  365. ++workid;
  366. }
  367. spi_emit_nop(spi, spi_req_sz - spi_getbufsz(spi));
  368. spi_txrx(spi);
  369. rxbuf = spi_getrxbuf(spi);
  370. if (rxbuf[3] & 1)
  371. applog(LOG_DEBUG, "%s: Receive buffer overflow reported", knc_drv.dname);
  372. workaccept = get_u16be(&rxbuf[6]);
  373. applog(LOG_DEBUG, "%s: %lu/%d jobs accepted to queue (max=%d)",
  374. knc_drv.dname, (unsigned long)workaccept, works_sent, knc->workqueue_max);
  375. while (true)
  376. {
  377. rxbuf += 0xc;
  378. spi_req_sz -= 0xc;
  379. if (spi_req_sz < 0xc)
  380. break;
  381. const int rtype = rxbuf[0] >> 6;
  382. if (rtype && opt_debug)
  383. {
  384. char x[(0xc * 2) + 1];
  385. bin2hex(x, rxbuf, 0xc);
  386. applog(LOG_DEBUG, "%s: RECV: %s", knc_drv.dname, x);
  387. }
  388. if (rtype != KNC_REPLY_NONCE_FOUND && rtype != KNC_REPLY_WORK_DONE)
  389. continue;
  390. asicno = (rxbuf[0] & 0x38) >> 3;
  391. coreno = get_u32be(&rxbuf[8]);
  392. proc = cgpu;
  393. while (true)
  394. {
  395. knccore = proc->thr[0]->cgpu_data;
  396. if (knccore->asicno == asicno)
  397. break;
  398. do {
  399. proc = proc->next_proc;
  400. } while(proc != proc->device);
  401. }
  402. for (i = 0; i < coreno; ++i)
  403. proc = proc->next_proc;
  404. mythr = proc->thr[0];
  405. i = get_u16be(&rxbuf[2]);
  406. HASH_FIND_INT(knc->devicework, &i, work);
  407. if (!work)
  408. {
  409. const char * const msgtype = (rtype == KNC_REPLY_NONCE_FOUND) ? "nonce found" : "work done";
  410. applog(LOG_WARNING, "%"PRIpreprv": Got %s message about unknown work 0x%04x",
  411. proc->proc_repr, msgtype, i);
  412. if (KNC_REPLY_NONCE_FOUND == rtype)
  413. {
  414. nonce = get_u32be(&rxbuf[4]);
  415. nonce = le32toh(nonce);
  416. inc_hw_errors2(mythr, NULL, &nonce);
  417. }
  418. else
  419. inc_hw_errors2(mythr, NULL, NULL);
  420. continue;
  421. }
  422. switch (rtype)
  423. {
  424. case KNC_REPLY_NONCE_FOUND:
  425. nonce = get_u32be(&rxbuf[4]);
  426. nonce = le32toh(nonce);
  427. submit_nonce(mythr, work, nonce);
  428. break;
  429. case KNC_REPLY_WORK_DONE:
  430. HASH_DEL(knc->devicework, work);
  431. free_work(work);
  432. hashes_done2(mythr, 0x100000000, NULL);
  433. break;
  434. }
  435. }
  436. if (knc->need_flush)
  437. {
  438. knc->need_flush = false;
  439. HASH_ITER(hh, knc->devicework, work, tmp)
  440. {
  441. HASH_DEL(knc->devicework, work);
  442. free_work(work);
  443. }
  444. delay_usecs = 0;
  445. }
  446. if (workaccept)
  447. {
  448. if (workaccept >= knc->workqueue_max)
  449. {
  450. knc->workqueue_max = workaccept;
  451. delay_usecs = 0;
  452. }
  453. DL_FOREACH_SAFE(knc->workqueue, work, tmp)
  454. {
  455. --knc->workqueue_size;
  456. DL_DELETE(knc->workqueue, work);
  457. work->device_id = knc->next_id++ & 0x7fff;
  458. HASH_ADD_INT(knc->devicework, device_id, work);
  459. if (!--workaccept)
  460. break;
  461. }
  462. thr->queue_full = (knc->workqueue_size >= knc->workqueue_max);
  463. }
  464. timer_set_delay_from_now(&thr->tv_poll, delay_usecs);
  465. }
  466. static
  467. bool _knc_core_setstatus(struct thr_info * const thr, uint8_t val)
  468. {
  469. struct cgpu_info * const proc = thr->cgpu;
  470. struct knc_device * const knc = proc->device_data;
  471. struct knc_core * const knccore = thr->cgpu_data;
  472. const int i2c = knc->i2c;
  473. const int i2cslave = 0x20 + knccore->asicno;
  474. if (ioctl(i2c, I2C_SLAVE, i2cslave))
  475. {
  476. applog(LOG_DEBUG, "%"PRIpreprv": %s: Failed to select i2c slave 0x%x",
  477. proc->proc_repr, __func__, i2cslave);
  478. return false;
  479. }
  480. return (-1 != i2c_smbus_write_byte_data(i2c, knccore->coreno, val));
  481. }
  482. static
  483. void knc_core_disable(struct thr_info * const thr)
  484. {
  485. _knc_core_setstatus(thr, 0);
  486. }
  487. static
  488. void knc_core_enable(struct thr_info * const thr)
  489. {
  490. _knc_core_setstatus(thr, 1);
  491. }
  492. static
  493. float knc_dcdc_decode_5_11(uint16_t raw)
  494. {
  495. if (raw == 0)
  496. return 0.0;
  497. int dcdc_vin_exp = (raw & 0xf800) >> 11;
  498. float dcdc_vin_man = raw & 0x07ff;
  499. if (dcdc_vin_exp >= 16)
  500. dcdc_vin_exp = -32 + dcdc_vin_exp;
  501. float dcdc_vin = dcdc_vin_man * exp2(dcdc_vin_exp);
  502. return dcdc_vin;
  503. }
  504. static
  505. bool knc_get_stats(struct cgpu_info * const cgpu)
  506. {
  507. if (cgpu->device != cgpu)
  508. return true;
  509. struct knc_core * const knccore = cgpu->thr[0]->cgpu_data;
  510. struct cgpu_info *proc;
  511. const int i2cdev = knccore->asicno + 3;
  512. const int i2cslave_temp = 0x48;
  513. const int i2cslave_dcdc[] = {0x10, 0x12, 0x14, 0x17};
  514. int die;
  515. int i2c;
  516. int32_t rawtemp, rawvolt, rawcurrent;
  517. float temp;
  518. bool rv = false;
  519. char i2cpath[sizeof(KNC_I2C_TEMPLATE)];
  520. sprintf(i2cpath, KNC_I2C_TEMPLATE, i2cdev);
  521. i2c = open(i2cpath, O_RDWR);
  522. if (i2c == -1)
  523. {
  524. applog(LOG_DEBUG, "%s: %s: Failed to open %s",
  525. cgpu->dev_repr, __func__, i2cpath);
  526. return false;
  527. }
  528. if (ioctl(i2c, I2C_SLAVE, i2cslave_temp))
  529. {
  530. applog(LOG_DEBUG, "%s: %s: Failed to select i2c slave 0x%x",
  531. cgpu->dev_repr, __func__, i2cslave_temp);
  532. goto out;
  533. }
  534. rawtemp = i2c_smbus_read_word_data(i2c, 0);
  535. if (rawtemp == -1)
  536. goto out;
  537. temp = ((float)(rawtemp & 0xff));
  538. if (rawtemp & 0x8000)
  539. temp += 0.5;
  540. /* DCDC i2c slaves are on 0x10 + [0-7]
  541. 8 DCDC boards have all populated
  542. 4 DCDC boards only have 0,2,4,7 populated
  543. Only 0,2,4,7 are used
  544. Each DCDC powers one die in the chip, each die has 48 cores
  545. Datasheet at http://www.lineagepower.com/oem/pdf/MDT040A0X.pdf
  546. */
  547. for (die = 0; die < 4; die++)
  548. {
  549. if (ioctl(i2c, I2C_SLAVE, i2cslave_dcdc[die]))
  550. {
  551. applog(LOG_DEBUG, "%s: %s: Failed to select i2c slave 0x%x",
  552. cgpu->dev_repr, __func__, i2cslave_dcdc[die]);
  553. goto out;
  554. }
  555. rawvolt = i2c_smbus_read_word_data(i2c, 0x8b); // VOUT
  556. if (rawvolt == -1)
  557. goto out;
  558. rawcurrent = i2c_smbus_read_word_data(i2c, 0x8c); // IOUT
  559. if (rawcurrent == -1)
  560. goto out;
  561. float volt = (float)rawvolt * exp2(-10);
  562. float current = (float)knc_dcdc_decode_5_11(rawcurrent);
  563. applog(LOG_DEBUG, "%s: die %d %6.3fV %5.2fA",
  564. cgpu->dev_repr, die, volt, current);
  565. }
  566. for (proc = cgpu; proc && proc->device == cgpu; proc = proc->next_proc)
  567. proc->temp = temp;
  568. rv = true;
  569. out:
  570. close(i2c);
  571. return rv;
  572. }
  573. struct device_drv knc_drv = {
  574. .dname = "knc",
  575. .name = "KNC",
  576. .drv_detect = knc_detect,
  577. .thread_init = knc_init,
  578. .thread_disable = knc_core_disable,
  579. .thread_enable = knc_core_enable,
  580. .minerloop = minerloop_queue,
  581. .queue_append = knc_queue_append,
  582. .queue_flush = knc_queue_flush,
  583. .poll = knc_poll,
  584. .get_stats = knc_get_stats,
  585. };