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