Browse Source

knc: Attempt to express core enable/disable to controller

Luke Dashjr 12 years ago
parent
commit
95863abd00
1 changed files with 35 additions and 0 deletions
  1. 35 0
      driver-knc.c

+ 35 - 0
driver-knc.c

@@ -69,6 +69,7 @@ struct knc_device {
 
 
 struct knc_core {
 struct knc_core {
 	int asicno;
 	int asicno;
+	int coreno;
 };
 };
 
 
 static
 static
@@ -250,6 +251,7 @@ bool knc_init(struct thr_info * const thr)
 				mythr->cgpu_data = knccore = malloc(sizeof(*knccore));
 				mythr->cgpu_data = knccore = malloc(sizeof(*knccore));
 				*knccore = (struct knc_core){
 				*knccore = (struct knc_core){
 					.asicno = i2cslave - 0x20,
 					.asicno = i2cslave - 0x20,
+					.coreno = i + j,
 				};
 				};
 				if (proc != cgpu)
 				if (proc != cgpu)
 					mythr->queue_full = true;
 					mythr->queue_full = true;
@@ -535,6 +537,37 @@ void knc_poll(struct thr_info * const thr)
 	timer_set_delay_from_now(&thr->tv_poll, delay_usecs);
 	timer_set_delay_from_now(&thr->tv_poll, delay_usecs);
 }
 }
 
 
+static
+bool _knc_core_setstatus(struct thr_info * const thr, uint8_t val)
+{
+	struct cgpu_info * const proc = thr->cgpu;
+	struct knc_device * const knc = proc->device_data;
+	struct knc_core * const knccore = thr->cgpu_data;
+	const int i2c = knc->i2c;
+	const int i2cslave = 0x20 + knccore->asicno;
+	
+	if (ioctl(i2c, I2C_SLAVE, i2cslave))
+	{
+		applog(LOG_DEBUG, "%"PRIpreprv": %s: Failed to select i2c slave 0x%x",
+		       proc->proc_repr, __func__, i2cslave);
+		return false;
+	}
+	
+	return (-1 != i2c_smbus_write_byte_data(i2c, knccore->coreno, val));
+}
+
+static
+void knc_core_disable(struct thr_info * const thr)
+{
+	_knc_core_setstatus(thr, 0);
+}
+
+static
+void knc_core_enable(struct thr_info * const thr)
+{
+	_knc_core_setstatus(thr, 1);
+}
+
 static
 static
 bool knc_get_stats(struct cgpu_info * const cgpu)
 bool knc_get_stats(struct cgpu_info * const cgpu)
 {
 {
@@ -589,6 +622,8 @@ struct device_drv knc_drv = {
 	.drv_detect = knc_detect,
 	.drv_detect = knc_detect,
 	
 	
 	.thread_init = knc_init,
 	.thread_init = knc_init,
+	.thread_disable = knc_core_disable,
+	.thread_enable  = knc_core_enable,
 	
 	
 	.minerloop = minerloop_queue,
 	.minerloop = minerloop_queue,
 	.queue_append = knc_queue_append,
 	.queue_append = knc_queue_append,