Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #704 from Canaan-Creative/master
Browse files Browse the repository at this point in the history
Merge downstream ava7 changes
  • Loading branch information
ckolivas committed Dec 2, 2016
2 parents 772835e + 072ddfd commit ffe588d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion driver-avalon7.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static uint32_t encode_voltage(uint32_t volt)

static uint32_t decode_voltage(struct avalon7_info *info, int modular_id, uint32_t volt)
{
return (volt * AVA7_VOLT_ADC_RATIO / info->asic_count[modular_id]);
return (volt * info->vout_adc_ratio[modular_id] / info->asic_count[modular_id] / 100);
}

static uint16_t decode_vin(uint16_t volt)
Expand Down Expand Up @@ -1353,16 +1353,19 @@ static void detect_modules(struct cgpu_info *avalon7)
if (!strncmp((char *)&(info->mm_version[i]), AVA7_MM711_PREFIXSTR, 3)) {
info->mod_type[i] = AVA7_TYPE_MM711;
info->asic_count[i] = AVA7_MM711_ASIC_CNT;
info->vout_adc_ratio[i] = AVA7_MM711_VOUT_ADC_RATIO;
}

if (!strncmp((char *)&(info->mm_version[i]), AVA7_MM721_PREFIXSTR, 3)) {
info->mod_type[i] = AVA7_TYPE_MM721;
info->asic_count[i] = AVA7_MM721_ASIC_CNT;
info->vout_adc_ratio[i] = AVA7_MM721_VOUT_ADC_RATIO;
}

if (!strncmp((char *)&(info->mm_version[i]), AVA7_MM741_PREFIXSTR, 3)) {
info->mod_type[i] = AVA7_TYPE_MM741;
info->asic_count[i] = AVA7_MM741_ASIC_CNT;
info->vout_adc_ratio[i] = AVA7_MM741_VOUT_ADC_RATIO;
}

info->temp_overheat[i] = AVA7_DEFAULT_TEMP_OVERHEAT;
Expand Down
9 changes: 7 additions & 2 deletions driver-avalon7.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

#define AVA7_DEFAULT_MODULARS 7 /* Only support 6 modules maximum with one AUC */
#define AVA7_DEFAULT_MINER_CNT 4
#define AVA7_DEFAULT_ASIC_MAX 20
#define AVA7_DEFAULT_ASIC_MAX 22
#define AVA7_DEFAULT_PLL_CNT 6
#define AVA7_DEFAULT_PMU_CNT 2

Expand Down Expand Up @@ -165,9 +165,12 @@
#define AVA7_DEFAULT_DELTA_T 0
#define AVA7_DEFAULT_DELTA_FREQ 100

#define AVA7_VOLT_ADC_RATIO (3.3 / 1024.0 * 125.0 / 43.0 * 10000.0)
#define AVA7_VIN_ADC_RATIO (3.3 / 1024.0 * 27.15 / 7.15 * 100.0)

#define AVA7_MM711_VOUT_ADC_RATIO (3.3 / 1024.0 * 125.0 / 43.0 * 10000.0 * 100.0)
#define AVA7_MM721_VOUT_ADC_RATIO (3.3 / 1024.0 * 125.0 / 43.0 * 10000.0 * 100.0)
#define AVA7_MM741_VOUT_ADC_RATIO (3.3 / 1024.0 * 63.0 / 20.0 * 10000.0 * 100.0)

struct avalon7_pkg {
uint8_t head[2];
uint8_t type;
Expand Down Expand Up @@ -269,6 +272,8 @@ struct avalon7_info {
char pmu_version[AVA7_DEFAULT_MODULARS][AVA7_DEFAULT_PMU_CNT][5];
uint64_t diff1[AVA7_DEFAULT_MODULARS];

uint16_t vout_adc_ratio[AVA7_DEFAULT_MODULARS];

bool conn_overloaded;
};

Expand Down

0 comments on commit ffe588d

Please sign in to comment.