Commit 04a43c4d3e62f3af672fc862ac3b67f72816b67b

kanoi 2014-07-11T01:36:51

minion - make the SPI reset ms sleep a parameter and API settable

diff --git a/API-README b/API-README
index 0bbab5c..c510797 100644
--- a/API-README
+++ b/API-README
@@ -446,6 +446,7 @@ The list of requests - a (*) means it requires privileged access - and replies:
                                MBA opt=freq val=0-chip:100-1400 - set chip freq
                                MBA opt=ledcount val=0-100 - chip count for led
                                MBA opt=ledlimit val=0-200 - led off below GHs
+                               MBA opt=spireset val=0-9999 - SPI reset sleep ms
 
  lcd           LCD            An all-in-one short status summary of the miner
                               e.g. Elapsed,GHS av,GHS 5m,GHS 5s,Temp,
diff --git a/ASIC-README b/ASIC-README
index 553f345..938ed74 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -248,6 +248,7 @@ ASIC SPECIFIC COMMANDS
 --minion-idlecount  Report when IdleCount is >0 or changes
 --minion-noautofreq Disable automatic frequency adjustment
 --minion-overheat   Enable directly halting any chip when the status exceeds 100C
+--minion-spireset   Sleep time in milliseconds when doing an SPI reset (default: 200)
 --minion-temp <arg> Set minion chip temperature threshold, single value or comma list, range 120-160 (default: 135C)
 --nfu-bits <arg>    Set nanofury bits for overclocking, range 32-63 (default: 50)
 --rock-freq <arg>   Set RockMiner frequency in MHz, range 125-500 (default: 270)
diff --git a/README b/README
index 9b14346..9b705a0 100644
--- a/README
+++ b/README
@@ -225,6 +225,7 @@ Options for both config file and command line:
 --minion-ledlimit   Turn off led when chips GHs are below this (default: 90)
 --minion-noautofreq Disable automatic frequency adjustment
 --minion-overheat   Enable directly halting any chip when the status exceeds 100C
+--minion-spireset   Sleep time in milliseconds when doing an SPI reset (default: 200)
 --minion-temp <arg> Set minion chip temperature threshold, single value or comma list, range 120-160 (default: 135C)
 --monitor|-m <arg>  Use custom pipe cmd for output messages
 --nfu-bits <arg>    Set nanofury bits for overclocking, range 32-63 (default: 50)
diff --git a/cgminer.c b/cgminer.c
index ddf0605..1238b95 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -254,6 +254,7 @@ int opt_minion_ledcount;
 int opt_minion_ledlimit = 90;
 bool opt_minion_noautofreq;
 bool opt_minion_overheat;
+int opt_minion_spireset = 200;
 char *opt_minion_temp;
 #endif
 
@@ -1372,6 +1373,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITHOUT_ARG("--minion-overheat",
 		     opt_set_bool, &opt_minion_overheat,
 		     "Enable directly halting any chip when the status exceeds 100C"),
+	OPT_WITH_ARG("--minion-spireset",
+		     set_int_0_to_9999, opt_show_intval, &opt_minion_spireset,
+		     "Sleep time in milliseconds when doing an SPI reset (default: 200)"),
 	OPT_WITH_ARG("--minion-temp",
 		     opt_set_charp, NULL, &opt_minion_temp,
 		     "Set minion chip temperature threshold, single value or comma list, range 120-160 (default: 135C)"),
diff --git a/driver-minion.c b/driver-minion.c
index 2ec6a49..48f3d2d 100644
--- a/driver-minion.c
+++ b/driver-minion.c
@@ -1757,7 +1757,7 @@ static bool minion_init_spi(struct cgpu_info *minioncgpu, struct minion_info *mi
 	if (reset) {
 		// TODO: maybe slow it down?
 		close(minioninfo->spifd);
-		cgsleep_ms(100);
+		cgsleep_ms(opt_minion_spireset);
 		minioninfo->spifd = open(minioncgpu->device_path, O_RDWR);
 		if (minioninfo->spifd < 0)
 			goto bad_out;
@@ -2303,7 +2303,8 @@ static char *minion_set(struct cgpu_info *minioncgpu, char *option, char *settin
 
 	if (strcasecmp(option, "help") == 0) {
 		sprintf(replybuf, "reset: chip 0-%d freq: 0-%d:%d-%d "
-				  "ledcount: 0-100 ledlimit: 0-200",
+				  "ledcount: 0-100 ledlimit: 0-200 "
+				  "spireset: 0-9999",
 				  minioninfo->chips - 1,
 				  minioninfo->chips - 1,
 				  MINION_FREQ_MIN, MINION_FREQ_MAX);
@@ -2415,6 +2416,23 @@ static char *minion_set(struct cgpu_info *minioncgpu, char *option, char *settin
 		return NULL;
 	}
 
+	if (strcasecmp(option, "spireset") == 0) {
+		if (!setting || !*setting) {
+			sprintf(replybuf, "missing spireset value");
+			return replybuf;
+		}
+
+		val = atoi(setting);
+		if (val < 0 || val > 9999) {
+			sprintf(replybuf, "invalid spireset: ms '%s' valid range 0-9999",
+					  setting);
+			return replybuf;
+		}
+
+		opt_minion_spireset = val;
+		return NULL;
+	}
+
 	sprintf(replybuf, "Unknown option: %s", option);
 	return replybuf;
 }
diff --git a/miner.h b/miner.h
index a26f35a..3e6f08a 100644
--- a/miner.h
+++ b/miner.h
@@ -1028,6 +1028,7 @@ extern int opt_minion_ledcount;
 extern int opt_minion_ledlimit;
 extern bool opt_minion_noautofreq;
 extern bool opt_minion_overheat;
+extern int opt_minion_spireset;
 extern char *opt_minion_temp;
 #endif
 #ifdef USE_USBUTILS