From 7ff5652edc7e5883e524c5820c6ae6ebc5cf91a0 Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Wed, 24 Nov 2021 22:00:45 +0000
Subject: [PATCH] patch #9327: ft245r.c: add TPI support (patches 1-4)

Submitted by David Mosberger-Tang

With newer versions of the Linux kernel (e.g., Ubuntu's
linux-image-4.4.0-75-generic), the default for the latency timer is
set to a high value.  Since this driver needs quick turnaround times,
set it explicitly to the minium.  This improves TPI programming speed
by almost a factor of 10.




git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1484 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog | 7 +++++++
 ft245r.c  | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 31b40313..92032451 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-11-24  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	Submitted by David Mosberger-Tang:
+	patch #9327: ft245r.c: add TPI support (patches 1-4)
+	* ft245r.c (ft245r_open): add call to
+	ftdi_set_latency_timer() to improve timing
+
 2021-11-24  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	Submitted by David Mosberger-Tang:
diff --git a/ft245r.c b/ft245r.c
index d2d81b2c..588b099d 100644
--- a/ft245r.c
+++ b/ft245r.c
@@ -836,6 +836,13 @@ static int ft245r_open(PROGRAMMER * pgm, char * port) {
     ft245r_out = SET_BITS_0(ft245r_out,pgm,PIN_LED_VFY,0);
 
 
+    rv = ftdi_set_latency_timer(handle, 1);
+    if (rv) {
+        avrdude_message(MSG_INFO, "%s: unable to set latency timer to 1 (%s)\n",
+                        progname, ftdi_get_error_string(handle));
+        goto cleanup;
+    }
+
     rv = ftdi_set_bitmode(handle, ft245r_ddr, BITMODE_SYNCBB); // set Synchronous BitBang
     if (rv) {
         avrdude_message(MSG_INFO, "%s: Synchronous BitBangMode is not supported (%s)\n",