Commit 20773656bc56fdf70f194cf04f21466e2307f566

Xiangfu Liu 2014-04-18T12:35:58

Avalon2: Parser the power good signal

diff --git a/driver-avalon2.c b/driver-avalon2.c
index 85fa6a1..5261054 100644
--- a/driver-avalon2.c
+++ b/driver-avalon2.c
@@ -262,6 +262,7 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
 			memcpy(&(info->get_voltage[modular_id]), ar->data + 12, 4);
 			memcpy(&(info->local_work[modular_id]), ar->data + 16, 4);
 			memcpy(&(info->hw_work[modular_id]), ar->data + 20, 4);
+			memcpy(&(info->power_good[modular_id]), ar->data + 24, 4);
 
 			info->get_frequency[modular_id] = be32toh(info->get_frequency[modular_id]);
 			info->get_voltage[modular_id] = be32toh(info->get_voltage[modular_id]);
@@ -272,6 +273,8 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
 			info->hw_works[modular_id] += info->hw_work[modular_id];
 
 			info->get_voltage[modular_id] = decode_voltage(info->get_voltage[modular_id]);
+			info->power_good[modular_id] = info->power_good[modular_id]  >> 24;
+
 			avalon2->temp = get_temp_max(info);
 			break;
 		case AVA2_P_ACKDETECT:
@@ -796,6 +799,11 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 		sprintf(buf, "Frequency%d", i + 1);
 		root = api_add_int(root, buf, &(info->get_frequency[i]), false);
 	}
+	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+		sprintf(buf, "Power good %02x", i + 1);
+	root = api_add_int(root, buf, &(info->power_good[i]), false);
+	}
+
 
 	return root;
 }
diff --git a/driver-avalon2.h b/driver-avalon2.h
index f89bab8..ca2e2df 100644
--- a/driver-avalon2.h
+++ b/driver-avalon2.h
@@ -86,6 +86,7 @@ struct avalon2_info {
 
 	int get_voltage[AVA2_DEFAULT_MODULARS];
 	int get_frequency[AVA2_DEFAULT_MODULARS];
+	int power_good[AVA2_DEFAULT_MODULARS];
 
 	int fan_pwm;