aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Henn <Peter.Henn@web.de>2012-10-28 22:08:37 +0100
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2013-03-06 19:03:37 +0000
commitef83a9ee9371f330075a5cb57b0dd515d75df8c2 (patch)
tree07d55e242654447f20a6f4b94e6659e29706b931
parent0f1d00bda65975ede19fc20df3b490b08a7c1afd (diff)
speed up ftdi by reorder to out-in
When the ftdi driver calls finally the mpsse_flush function, it first initiate the USB in and finally the corresponding USB out transaction. Because data in is requested too early the USB device will always answer the first USB in by a NAK. That can prevented by a simple reordering of the out and then the in transfer and can improve the Jtag performance for high JTAG clock rates. Change-Id: I17abf1487c914c92e2e447ee6d30562ef629f327 Signed-off-by: Peter Henn <Peter.Henn@web.de> Reviewed-on: http://openocd.zylin.com/942 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Xiaofan <xiaofanc@gmail.com>
-rw-r--r--src/jtag/drivers/mpsse.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c
index d6cbc840..41429693 100644
--- a/src/jtag/drivers/mpsse.c
+++ b/src/jtag/drivers/mpsse.c
@@ -779,11 +779,8 @@ int mpsse_flush(struct mpsse_ctx *ctx)
if (ctx->read_count) {
buffer_write_byte(ctx, 0x87); /* SEND_IMMEDIATE */
read_result.done = false;
- read_transfer = libusb_alloc_transfer(0);
- libusb_fill_bulk_transfer(read_transfer, ctx->usb_dev, ctx->in_ep, ctx->read_chunk,
- ctx->read_chunk_size, read_cb, &read_result,
- ctx->usb_read_timeout);
- retval = libusb_submit_transfer(read_transfer);
+ /* delay read transaction to ensure the FTDI chip can support us with data
+ immediately after processing the MPSSE commands in the write transaction */
}
struct transfer_result write_result = { .ctx = ctx, .done = false };
@@ -792,6 +789,14 @@ int mpsse_flush(struct mpsse_ctx *ctx)
ctx->write_count, write_cb, &write_result, ctx->usb_write_timeout);
retval = libusb_submit_transfer(write_transfer);
+ if (ctx->read_count) {
+ read_transfer = libusb_alloc_transfer(0);
+ libusb_fill_bulk_transfer(read_transfer, ctx->usb_dev, ctx->in_ep, ctx->read_chunk,
+ ctx->read_chunk_size, read_cb, &read_result,
+ ctx->usb_read_timeout);
+ retval = libusb_submit_transfer(read_transfer);
+ }
+
/* Polling loop, more or less taken from libftdi */
while (!write_result.done || !read_result.done) {
retval = libusb_handle_events(ctx->usb_ctx);