knc-asic.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _CGMINER_NEPTUNE_H
  2. #define _CGMINER_NEPTUNE_H
  3. #include <stdint.h>
  4. #include "miner.h"
  5. /* ASIC Command codes */
  6. #define KNC_ASIC_CMD_GETINFO 0x80
  7. #define KNC_ASIC_CMD_SETWORK 0x81
  8. #define KNC_ASIC_CMD_SETWORK_CLEAN 0x83 /* Neptune */
  9. #define KNC_ASIC_CMD_HALT 0x83 /* Jupiter */
  10. #define KNC_ASIC_CMD_REPORT 0x82
  11. /* Status byte */
  12. #define KNC_ASIC_ACK_CRC (1<<5)
  13. #define KNC_ASIC_ACK_ACCEPT (1<<2)
  14. #define KNC_ASIC_ACK_MASK (~(KNC_ASIC_ACK_CRC|KNC_ASIC_ACK_ACCEPT))
  15. #define KNC_ASIC_ACK_MATCH ((1<<7)|(1<<0))
  16. /* Version word */
  17. #define KNC_ASIC_VERSION_JUPITER 0xa001
  18. #define KNC_ASIC_VERSION_NEPTUNE 0xa002
  19. /* Limits of current chips & I/O board */
  20. #define KNC_MAX_CORES_PER_DIE 360
  21. #define KNC_MAX_ASICS 6
  22. struct knc_die_info {
  23. enum {
  24. KNC_VERSION_UNKNOWN = 0,
  25. KNC_VERSION_JUPITER,
  26. KNC_VERSION_NEPTUNE
  27. } version;
  28. char want_work[KNC_MAX_CORES_PER_DIE];
  29. int cores;
  30. int pll_locked;
  31. int hash_reset_n;
  32. int pll_reset_n;
  33. int pll_power_down;
  34. };
  35. #define KNC_NONCES_PER_REPORT 5
  36. struct knc_report {
  37. int next_state;
  38. int state;
  39. int next_slot;
  40. int active_slot;
  41. uint32_t progress;
  42. struct {
  43. int slot;
  44. uint32_t nonce;
  45. } nonce[KNC_NONCES_PER_REPORT];
  46. };
  47. int knc_prepare_info(uint8_t *request, int die, struct knc_die_info *die_info, int *response_size);
  48. int knc_prepare_report(uint8_t *request, int die, int core);
  49. int knc_prepare_neptune_setwork(uint8_t *request, int die, int core, int slot, struct work *work, int clean);
  50. int knc_prepare_jupiter_setwork(uint8_t *request, int die, int core, int slot, struct work *work);
  51. int knc_prepare_jupiter_halt(uint8_t *request, int die, int core);
  52. int knc_prepare_neptune_halt(uint8_t *request, int die, int core);
  53. int knc_decode_info(uint8_t *response, struct knc_die_info *die_info);
  54. int knc_decode_report(uint8_t *response, struct knc_report *report, int version);
  55. void knc_prepare_neptune_message(int request_length, const uint8_t *request, uint8_t *buffer);
  56. #define KNC_ACCEPTED (1<<0)
  57. #define KNC_ERR_CRC (1<<1)
  58. #define KNC_ERR_ACK (1<<2)
  59. #define KNC_ERR_CRCACK (1<<3)
  60. #define KNC_ERR_UNAVAIL (1<<4)
  61. #define KNC_ERR_MASK (~(KNC_ACCEPTED))
  62. #define KNC_IS_ERROR(x) (((x) & KNC_ERR_MASK) != 0)
  63. int knc_prepare_transfer(uint8_t *txbuf, int offset, int size, int channel, int request_length, const uint8_t *request, int response_length);
  64. int knc_decode_response(uint8_t *rxbuf, int request_length, uint8_t **response, int response_length);
  65. int knc_syncronous_transfer(void *ctx, int channel, int request_length, const uint8_t *request, int response_length, uint8_t *response);
  66. /* Detect ASIC DIE version */
  67. int knc_detect_die(void *ctx, int channel, int die, struct knc_die_info *die_info);
  68. /* red, green, blue valid range 0 - 15. No response or checksum from controller */
  69. int knc_prepare_led(uint8_t *txbuf, int offset, int size, int red, int green, int blue);
  70. /* Reset controller */
  71. int knc_prepare_reset(uint8_t *txbuf, int offset, int size);
  72. #endif