Browse Source

avalon: display the FPGA controller version on API

Xiangfu 12 years ago
parent
commit
088a340342
2 changed files with 14 additions and 3 deletions
  1. 13 3
      driver-avalon.c
  2. 1 0
      driver-avalon.h

+ 13 - 3
driver-avalon.c

@@ -273,6 +273,7 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
 	struct avalon_task at;
 	uint8_t *buf, *tmp;
 	struct timespec p;
+	struct avalon_info *info = avalon->device_data;
 
 	/* Send reset, then check for result */
 	avalon_init_task(&at, 1, 0,
@@ -329,9 +330,17 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
 		       " (%d: %02x %02x %02x %02x)", avalon->drv->name, avalon->device_id,
 		       i, buf[0], buf[1], buf[2], buf[3]);
 		/* FIXME: return 1; */
-	} else
-		applog(LOG_WARNING, "%s%d: Reset succeeded",
-		       avalon->drv->name, avalon->device_id);
+	} else {
+		/* buf[44]: minor
+		 * buf[45]: day
+		 * buf[46]: year,month, d6: 201306
+		 */
+		info->ctlr_ver = ((buf[46] >> 4) + 2000) * 1000000 +
+			(buf[46] & 0x0f) * 10000 +
+			buf[45] * 100 +	buf[44];
+		applog(LOG_WARNING, "%s%d: Reset succeeded (Controller version: %d)",
+		       avalon->drv->name, avalon->device_id, info->ctlr_ver);
+	}
 
 	return 0;
 }
@@ -1522,6 +1531,7 @@ static struct api_data *avalon_api_stats(struct cgpu_info *cgpu)
 				info->version1, info->version2, info->version3);
 		root = api_add_string(root, "version", buf, true);
 	}
+	root = api_add_int(root, "Controller Version", &(info->ctlr_ver), false);
 
 	return root;
 }

+ 1 - 0
driver-avalon.h

@@ -125,6 +125,7 @@ struct avalon_info {
 	int matching_work[AVALON_DEFAULT_MINER_NUM];
 
 	int frequency;
+	uint32_t ctlr_ver;
 
 	struct thr_info *thr;
 	pthread_t read_thr;