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