Commit 6afe3087d1a94d72c8fb314154f09b7b88539732

Con Kolivas 2014-02-15T17:36:08

Updated cointerra features.

diff --git a/cgminer.c b/cgminer.c
index 43d894b..cccb18f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -670,7 +670,7 @@ static char *set_int_0_to_10(const char *arg, int *i)
 	return set_int_range(arg, i, 0, 10);
 }
 
-#ifdef USE_AVALON
+#if (defined USE_AVALON)||(defined USE_COINTERRA)
 static char *set_int_0_to_100(const char *arg, int *i)
 {
 	return set_int_range(arg, i, 0, 100);
@@ -1253,8 +1253,11 @@ static struct opt_table opt_config_table[] = {
 #endif
 #ifdef USE_COINTERRA
 	OPT_WITH_ARG("--cta-load",
-		set_int_0_to_255, NULL, &opt_cta_load,
-		opt_hidden),
+		set_int_0_to_255, opt_show_intval, &opt_cta_load,
+		"Set load for CTA devices, 0-255 range"),
+	OPT_WITH_ARG("--ps-load",
+		set_int_0_to_100, opt_show_intval, &opt_ps_load,
+		"Set power supply load for CTA devices, 0-100 range"),
 #endif
 	OPT_WITHOUT_ARG("--debug|-D",
 		     enable_debug, &opt_debug,
diff --git a/driver-cointerra.c b/driver-cointerra.c
index 48fcccf..abc4d73 100644
--- a/driver-cointerra.c
+++ b/driver-cointerra.c
@@ -14,6 +14,8 @@
 
 static const char *cointerra_hdr = "ZZ";
 
+int opt_ps_load;
+
 static void cta_gen_message(char *msg, char type)
 {
 	memset(msg, 0, CTA_MSG_SIZE);
@@ -60,6 +62,7 @@ static bool cta_open(struct cgpu_info *cointerra)
 	buf[CTA_RESET_TYPE] = CTA_RESET_INIT | CTA_RESET_DIFF;
 	buf[CTA_RESET_DIFF] = diff_to_bits(CTA_INIT_DIFF);
 	buf[CTA_RESET_LOAD] = opt_cta_load ? opt_cta_load : 255;
+	buf[CTA_RESET_PSLOAD] = opt_ps_load;
 
 	if (cointerra->usbinfo.nodev)
 		return ret;
@@ -547,6 +550,9 @@ static void cta_parse_debug(struct cointerra_info *info, char *buf)
 	u16array_from_msg(info->tot_hw_errors, CTA_CORES, CTA_STAT_HW_ERRORS, buf);
 	info->tot_hashes = hu64_from_msg(buf, CTA_STAT_HASHES);
 	info->tot_flushed_hashes = hu64_from_msg(buf, CTA_STAT_FLUSHED_HASHES);
+	info->autovoltage = u8_from_msg(buf, CTA_STAT_AUTOVOLTAGE);
+	info->current_ps_percent = u8_from_msg(buf, CTA_STAT_POWER_PERCENT);
+	info->power_used = hu16_from_msg(buf,CTA_STAT_POWER_USED);
 
 	mutex_unlock(&info->lock);
 }
@@ -826,6 +832,7 @@ resend:
 
 	buf[CTA_RESET_TYPE] = reset_type;
 	buf[CTA_RESET_LOAD] = opt_cta_load ? opt_cta_load : 255;
+	buf[CTA_RESET_PSLOAD] = opt_ps_load;
 
 	applog(LOG_INFO, "%s %d: Sending Reset type %u with diffbits %u", cointerra->drv->name,
 	       cointerra->device_id, reset_type, diffbits);
@@ -1080,6 +1087,9 @@ static struct api_data *cta_api_stats(struct cgpu_info *cgpu)
 	root = api_add_string(root, "Asic1Core2", bitmaphex, true);
 	__bin2hex(bitmaphex, &info->pipe_bitmap[112], 16);
 	root = api_add_string(root, "Asic1Core3", bitmaphex, true);
+	root = api_add_uint8(root,"AV",&info->autovoltage, false);
+	root = api_add_uint8(root,"Power Supply Percent",&info->current_ps_percent, false);
+	root = api_add_uint16(root,"Power Used",&info->power_used, false);
 
 	return root;
 }
diff --git a/driver-cointerra.h b/driver-cointerra.h
index 9bab1a5..eb6175c 100644
--- a/driver-cointerra.h
+++ b/driver-cointerra.h
@@ -33,6 +33,7 @@
 #define CTA_RESET_TYPE		3
 #define CTA_RESET_DIFF		4
 #define CTA_RESET_LOAD		5
+#define CTA_RESET_PSLOAD	6
 #define CTA_DRIVER_TAG		3
 #define CTA_MCU_TAG		5
 #define CTA_MCU_CORE		5
@@ -116,7 +117,10 @@
 #define CTA_STAT_HW_ERRORS	5
 #define CTA_STAT_UPTIME_MS	21
 #define CTA_STAT_HASHES		25
-#define CTA_STAT_FLUSHED_HASHES	33
+#define CTA_STAT_FLUSHED_HASHES 33
+#define CTA_STAT_AUTOVOLTAGE  41
+#define CTA_STAT_POWER_PERCENT 42
+#define CTA_STAT_POWER_USED 43
 
 #define CTA_CORES		8
 #define CTA_PUMPS		2
@@ -127,6 +131,7 @@
 
 
 int opt_cta_load;
+int opt_ps_load;
 
 struct cointerra_info {
 	/* Info data */
@@ -175,6 +180,9 @@ struct cointerra_info {
 	uint64_t tot_hashes;
 	uint64_t tot_reset_hashes;
 	uint64_t tot_flushed_hashes;
+	uint8_t  autovoltage;
+	uint8_t  current_ps_percent;
+	uint16_t power_used;
 
 	/* Calculated totals based on work done and nonces found */
 	uint64_t hashes;