driver-bitfury.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright 2013-2014 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. #ifndef BITFURY_H
  10. #define BITFURY_H
  11. #include "miner.h"
  12. #include "usbutils.h"
  13. #include "mcp2210.h"
  14. #define BXF_CLOCK_OFF 0
  15. #define BXF_CLOCK_MIN 32
  16. #define BXF_CLOCK_MAX 63 // Not really used since we only get hw errors above default
  17. /* In tenths of a degree */
  18. #define BXF_TEMP_TARGET 820
  19. #define BXF_TEMP_HYSTERESIS 30
  20. extern int opt_bxf_temp_target;
  21. extern int opt_nfu_bits;
  22. extern int opt_bxm_bits;
  23. extern int opt_bxf_bits;
  24. extern int opt_bxf_debug;
  25. extern int opt_osm_led_mode;
  26. #define NFU_PIN_LED 0
  27. #define NFU_PIN_SCK_OVR 5
  28. #define NFU_PIN_PWR_EN 6
  29. #define NFU_PIN_PWR_EN0 7
  30. #define SPIBUF_SIZE 16384
  31. #define BITFURY_REFRESH_DELAY 100
  32. #define SIO_RESET_REQUEST 0
  33. #define SIO_SET_LATENCY_TIMER_REQUEST 0x09
  34. #define SIO_SET_EVENT_CHAR_REQUEST 0x06
  35. #define SIO_SET_ERROR_CHAR_REQUEST 0x07
  36. #define SIO_SET_BITMODE_REQUEST 0x0B
  37. #define SIO_RESET_PURGE_RX 1
  38. #define SIO_RESET_PURGE_TX 2
  39. #define BITMODE_RESET 0x00
  40. #define BITMODE_MPSSE 0x02
  41. #define SIO_RESET_SIO 0
  42. #define BXM_LATENCY_MS 2
  43. struct bitfury_payload {
  44. unsigned char midstate[32];
  45. unsigned int junk[8];
  46. unsigned m7;
  47. unsigned ntime;
  48. unsigned nbits;
  49. unsigned nnonce;
  50. };
  51. struct bitfury_info {
  52. struct cgpu_info *base_cgpu;
  53. struct thr_info *thr;
  54. enum sub_ident ident;
  55. int nonces;
  56. int total_nonces;
  57. double saved_nonces;
  58. int cycles;
  59. bool valid; /* Set on first valid data being found */
  60. bool failing; /* Set when an attempted restart has been sent */
  61. int chips;
  62. char product[8];
  63. /* BF1 specific data */
  64. uint8_t version;
  65. uint32_t serial;
  66. struct timeval tv_start;
  67. /* BXF specific data */
  68. pthread_mutex_t lock;
  69. pthread_t read_thr;
  70. int last_decitemp;
  71. int max_decitemp;
  72. int temp_target;
  73. int work_id; // Current work->subid
  74. int no_matching_work;
  75. int maxroll; // Last maxroll sent to device
  76. int ver_major;
  77. int ver_minor;
  78. int hw_rev;
  79. uint8_t clocks; // There are two but we set them equal
  80. int *filtered_hw; // Hardware errors we're told about but are filtered
  81. int *job; // Completed jobs we're told about
  82. int *submits; // Submitted responses
  83. /* NFU specific data */
  84. struct mcp_settings mcp;
  85. char spibuf[SPIBUF_SIZE];
  86. unsigned int spibufsz;
  87. int osc6_bits;
  88. /* Chip sized arrays */
  89. struct bitfury_payload *payload;
  90. unsigned int *oldbuf; // 17 vals per chip
  91. bool *job_switched;
  92. bool *second_run;
  93. struct work **work;
  94. struct work **owork;
  95. bool (*spi_txrx)(struct cgpu_info *, struct bitfury_info *info);
  96. };
  97. #endif /* BITFURY_H */