driver-bitfury.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright 2013 Con Kolivas
  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 "miner.h"
  11. #include "driver-bitfury.h"
  12. struct device_drv bitfury_drv;
  13. static void bitfury_open(struct cgpu_info *bitfury)
  14. {
  15. /* Magic open sequence */
  16. usb_transfer(bitfury, 0x21, 0x22, 0x0003, 0, C_BFO_OPEN);
  17. }
  18. static void bitfury_close(struct cgpu_info *bitfury)
  19. {
  20. /* Magic close sequence */
  21. usb_transfer(bitfury, 0x21, 0x22, 0, 0, C_BFO_CLOSE);
  22. }
  23. static void bitfury_initialise(struct cgpu_info *bitfury)
  24. {
  25. bitfury_open(bitfury);
  26. }
  27. static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_devices *found)
  28. {
  29. struct cgpu_info *bitfury;
  30. bitfury = usb_alloc_cgpu(&bitfury_drv, 1);
  31. if (!usb_init(bitfury, dev, found)) {
  32. bitfury = usb_free_cgpu(bitfury);
  33. return false;
  34. }
  35. applog(LOG_WARNING, "%s%d: Found at %s", bitfury->drv->name,
  36. bitfury->device_id, bitfury->device_path);
  37. bitfury_initialise(bitfury);
  38. bitfury_close(bitfury);
  39. return false;
  40. }
  41. static void bitfury_detect(void)
  42. {
  43. usb_detect(&bitfury_drv, bitfury_detect_one);
  44. }
  45. static bool bitfury_prepare(struct thr_info __maybe_unused *thr)
  46. {
  47. return false;
  48. }
  49. static bool bitfury_fill(struct cgpu_info __maybe_unused *bitfury)
  50. {
  51. return true;
  52. }
  53. static int64_t bitfury_scanhash(struct thr_info __maybe_unused *thr)
  54. {
  55. return 0;
  56. }
  57. static void bitfury_flush_work(struct cgpu_info __maybe_unused *bitfury)
  58. {
  59. }
  60. static struct api_data *bitfury_api_stats(struct cgpu_info __maybe_unused *cgpu)
  61. {
  62. return NULL;
  63. }
  64. static void get_bitfury_statline_before(char __maybe_unused *buf, size_t __maybe_unused bufsiz,
  65. struct cgpu_info __maybe_unused *bitfury)
  66. {
  67. }
  68. static void bitfury_init(struct cgpu_info __maybe_unused *bitfury)
  69. {
  70. }
  71. static void bitfury_shutdown(struct thr_info __maybe_unused *thr)
  72. {
  73. struct cgpu_info *bitfury = thr->cgpu;
  74. bitfury_close(bitfury);
  75. }
  76. /* Currently hardcoded to BF1 devices */
  77. struct device_drv bitfury_drv = {
  78. .drv_id = DRIVER_BITFURY,
  79. .dname = "bitfury",
  80. .name = "BFO",
  81. .drv_detect = bitfury_detect,
  82. .thread_prepare = bitfury_prepare,
  83. .hash_work = hash_queued_work,
  84. .queue_full = bitfury_fill,
  85. .scanwork = bitfury_scanhash,
  86. .flush_work = bitfury_flush_work,
  87. .get_api_stats = bitfury_api_stats,
  88. .get_statline_before = get_bitfury_statline_before,
  89. .reinit_device = bitfury_init,
  90. .thread_shutdown = bitfury_shutdown
  91. };