driver-hashratio.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright 2013-2014 Con Kolivas <kernel@kolivas.org>
  3. * Copyright 2012-2014 Xiangfu <xiangfu@openmobilefree.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the Free
  7. * Software Foundation; either version 3 of the License, or (at your option)
  8. * any later version. See COPYING for more details.
  9. */
  10. #ifndef _HASHRATIO_H_
  11. #define _HASHRATIO_H_
  12. #include "miner.h"
  13. #include "util.h"
  14. #ifdef USE_HASHRATIO
  15. char *opt_hashratio_freq;
  16. #define HRTO_MINER_THREADS 1
  17. #define HRTO_RESET_FAULT_DECISECONDS 10
  18. #define HRTO_IO_SPEED 115200
  19. #define HRTO_DEFAULT_MODULARS 5
  20. #define HRTO_DEFAULT_MINERS_PER_MODULAR 16
  21. /* total chips number */
  22. #define HRTO_DEFAULT_MINERS (HRTO_DEFAULT_MODULARS * 16)
  23. #define HRTO_PWM_MAX 0x3FF
  24. #define HRTO_DEFAULT_FAN 20 /* N% */
  25. #define HRTO_DEFAULT_FAN_MIN 50 /* N% */
  26. #define HRTO_DEFAULT_FAN_MAX 100 /* N% */
  27. #define HRTO_DEFAULT_FREQUENCY 280 /* MHz */
  28. #define HRTO_DEFAULT_FREQUENCY_MIN 100
  29. #define HRTO_DEFAULT_FREQUENCY_MAX 750
  30. #define HRTO_FAN_COUNT 2
  31. //#define HRTO_TEMP_COUNT 1
  32. /* Hashratio protocol package type */
  33. #define HRTO_H1 'H'
  34. #define HRTO_H2 'R'
  35. #define HRTO_P_COINBASE_SIZE (6 * 1024)
  36. #define HRTO_P_MERKLES_COUNT 20
  37. #define HRTO_P_COUNT 39
  38. #define HRTO_P_DATA_LEN (HRTO_P_COUNT - 7)
  39. #define HRTO_P_DETECT 10 // 0x0a
  40. #define HRTO_P_STATIC 11 // 0x0b
  41. #define HRTO_P_JOB_ID 12 // 0x0c
  42. #define HRTO_P_COINBASE 13 // 0x0d
  43. #define HRTO_P_MERKLES 14 // 0x0e
  44. #define HRTO_P_HEADER 15 // 0x0f
  45. #define HRTO_P_POLLING 16 // 0x10
  46. #define HRTO_P_TARGET 17 // 0x11
  47. #define HRTO_P_REQUIRE 18 // 0x12
  48. #define HRTO_P_SET 19 // 0x13
  49. #define HRTO_P_TEST 20 // 0x14
  50. #define HRTO_P_ACK 51 // 0x33
  51. #define HRTO_P_NAK 52 // 0x34
  52. #define HRTO_P_NONCE 53 // 0x35
  53. #define HRTO_P_STATUS 54 // 0x36
  54. #define HRTO_P_ACKDETECT 55 // 0x37
  55. #define HRTO_P_TEST_RET 56 // 0x38
  56. /* Hashratio protocol package type */
  57. struct hashratio_pkg {
  58. uint8_t head[2];
  59. uint8_t type;
  60. uint8_t idx;
  61. uint8_t cnt;
  62. uint8_t data[32];
  63. uint8_t crc[2];
  64. };
  65. #define hashratio_ret hashratio_pkg
  66. struct hashratio_info {
  67. int default_freq;
  68. int fan_pwm;
  69. int temp;
  70. int fan[HRTO_FAN_COUNT];
  71. // uint8_t freq[HRTO_DEFAULT_MINERS];
  72. uint8_t target_freq[HRTO_DEFAULT_MINERS];
  73. int temp_max;
  74. int temp_history_count;
  75. int temp_history_index;
  76. int temp_sum;
  77. int temp_old;
  78. struct timeval last_stratum;
  79. struct pool pool;
  80. int pool_no;
  81. int local_works;
  82. int hw_works;
  83. int matching_work[HRTO_DEFAULT_MINERS];
  84. int local_work;
  85. int hw_work;
  86. // uint32_t get_result_counter;
  87. char mm_version[16];
  88. };
  89. #define HRTO_WRITE_SIZE (sizeof(struct hashratio_pkg))
  90. #define HRTO_READ_SIZE HRTO_WRITE_SIZE
  91. #define HRTO_GETS_OK 0
  92. #define HRTO_GETS_TIMEOUT -1
  93. #define HRTO_GETS_RESTART -2
  94. #define HRTO_GETS_ERROR -3
  95. #define HRTO_SEND_OK 0
  96. #define HRTO_SEND_ERROR -1
  97. #define hashratio_open(devpath, baud, purge) serial_open(devpath, baud, HRTO_RESET_FAULT_DECISECONDS, purge)
  98. #define hashratio_close(fd) close(fd)
  99. extern char *set_hashratio_fan(char *arg);
  100. extern char *set_hashratio_freq(char *arg);
  101. #endif /* USE_HASHRATIO */
  102. #endif /* _HASHRATIO_H_ */