Commit 0c3f00c5679efd4413d3b0a6c1c7733585f718f8

Kano 2013-05-20T21:58:04

icarus ICA initialisation

diff --git a/driver-icarus.c b/driver-icarus.c
index 5515356..000abf7 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -294,6 +294,26 @@ static void icarus_initialise(struct cgpu_info *icarus, __maybe_unused int baud)
 
 			break;
 		case IDENT_ICA:
+			// Set Data Control
+			transfer(icarus, PL2303_CTRL_OUT, PL2303_REQUEST_CTRL, PL2303_VALUE_CTRL,
+				 icarus->usbdev->found->interface, C_SETDATA);
+
+			if (icarus->usbinfo.nodev)
+				return;
+
+			// Set Line Control
+			uint32_t ica_data[2] = { PL2303_VALUE_LINE0, PL2303_VALUE_LINE1 };
+			_transfer(icarus, PL2303_CTRL_OUT, PL2303_REQUEST_LINE, PL2303_VALUE_LINE,
+				 icarus->usbdev->found->interface,
+				 &ica_data[0], PL2303_VALUE_LINE_SIZE, C_SETLINE);
+
+			if (icarus->usbinfo.nodev)
+				return;
+
+			// Vendor
+			transfer(icarus, PL2303_VENDOR_OUT, PL2303_REQUEST_VENDOR, PL2303_VALUE_VENDOR,
+				 icarus->usbdev->found->interface, C_VENDOR);
+
 			break;
 		case IDENT_AMU:
 			// Set data control
diff --git a/usbutils.c b/usbutils.c
index fb1be64..afad52e 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -409,6 +409,8 @@ static const char *C_QUEFLUSHREPLY_S = "QueFlushReply";
 static const char *C_REQUESTVOLTS_S = "RequestVolts";
 static const char *C_SENDTESTWORK_S = "SendTestWork";
 static const char *C_LATENCY_S = "SetLatency";
+static const char *C_SETLINE_S = "SetLine";
+static const char *C_VENDOR_S = "Vendor";
 
 #ifdef EOL
 #undef EOL
@@ -879,6 +881,8 @@ static void cgusb_check_init()
 		usb_commands[C_REQUESTVOLTS] = C_REQUESTVOLTS_S;
 		usb_commands[C_SENDTESTWORK] = C_SENDTESTWORK_S;
 		usb_commands[C_LATENCY] = C_LATENCY_S;
+		usb_commands[C_SETLINE] = C_SETLINE_S;
+		usb_commands[C_VENDOR] = C_VENDOR_S;
 
 		stats_initialised = true;
 	}
diff --git a/usbutils.h b/usbutils.h
index 7273e9f..1a24be2 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -13,7 +13,7 @@
 #include <libusb.h>
 
 
-// For 0x0403:0x6014/0x6001 FT232H (and possibly others?)
+// For 0x0403:0x6014/0x6001 FT232H (and possibly others?) - BFL, BAS, BLT, LLT, AVA
 #define FTDI_TYPE_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT)
 
 #define FTDI_REQUEST_RESET ((uint8_t)0)
@@ -47,7 +47,7 @@
 #define FTDI_VALUE_MODEM 0x0303
 
 
-// For 0x10c4:0xea60 USB cp210x chip
+// For 0x10c4:0xea60 USB cp210x chip - AMU
 #define CP210X_TYPE_OUT 0x41
 
 #define CP210X_REQUEST_DATA 0x07
@@ -56,6 +56,25 @@
 #define CP210X_VALUE_DATA 0x0303
 #define CP210X_DATA_BAUD 0x0001c200
 
+
+// For 0x067b:0x2303 Prolific PL2303 - ICA
+#define PL2303_CTRL_DTR 0x01
+#define PL2303_CTRL_RTS 0x02
+
+#define PL2303_CTRL_OUT 0x21
+#define PL2303_VENDOR_OUT 0x40
+
+#define PL2303_REQUEST_CTRL 0x22
+#define PL2303_REQUEST_LINE 0x20
+#define PL2303_REQUEST_VENDOR 0x01
+
+#define PL2303_VALUE_CTRL (PL2303_CTRL_DTR | PL2303_CTRL_RTS)
+#define PL2303_VALUE_LINE 0
+#define PL2303_VALUE_LINE0 0x0001c200
+#define PL2303_VALUE_LINE1 0x08000000
+#define PL2303_VALUE_LINE_SIZE 7
+#define PL2303_VALUE_VENDOR 0
+
 // Use the device defined timeout
 #define DEVTIMEOUT 0
 
@@ -184,6 +203,8 @@ enum usb_cmds {
 	C_REQUESTVOLTS,
 	C_SENDTESTWORK,
 	C_LATENCY,
+	C_SETLINE,
+	C_VENDOR,
 	C_MAX
 };