Index: src/jtag/ft2232.c
===================================================================
--- src/jtag/ft2232.c	(revision 2596)
+++ src/jtag/ft2232.c	(working copy)
@@ -68,8 +68,15 @@
 /* this speed value tells that RTCK is requested */
 #define RTCK_SPEED -1
 
+#ifndef BUILD_FT2232_HIGHSPEED
+ #if BUILD_FT2232_FTD2XX == 1
+	enum { FT_DEVICE_2232H = 6, FT_DEVICE_4232H };
+ #elif BUILD_FT2232_LIBFTDI == 1
+	enum { TYPE_2232H = 4, TYPE_4232H = 5 };
+ #endif
+#endif
+
 static int ft2232_execute_queue(void);
-
 static int ft2232_speed(int speed);
 static int ft2232_speed_div(int speed, int* khz);
 static int ft2232_khz(int khz, int* jtag_speed);
@@ -82,6 +89,7 @@
 static int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
 static int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
 static int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
+static int ft2232_handle_legacy_mode_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc);
 
 /**
  * Send out \a num_cycles on the TCK line while the TAP(s) are in a
@@ -101,6 +109,7 @@
 static char*        ft2232_layout  = NULL;
 static uint8_t		ft2232_latency = 2;
 static unsigned		ft2232_max_tck = FTDI_2232C_MAX_TCK;
+static unsigned		ft2232_legacy_mode = 0;
 
 #define MAX_USB_IDS 8
 /* vid = pid = 0 marks the end of the list */
@@ -416,14 +425,10 @@
 
 static bool ft2232_device_is_highspeed(void)
 {
-#ifdef BUILD_FT2232_HIGHSPEED
-	#if BUILD_FT2232_FTD2XX == 1
+#if BUILD_FT2232_FTD2XX == 1
 	return (ftdi_device == FT_DEVICE_2232H) || (ftdi_device == FT_DEVICE_4232H);
-	#elif BUILD_FT2232_LIBFTDI == 1
+#elif BUILD_FT2232_LIBFTDI == 1
 	return (ftdi_device == TYPE_2232H || ftdi_device == TYPE_4232H);
-	#endif
-#else
-	return false;
 #endif
 }
 
@@ -529,10 +534,6 @@
 		else
 		{
 			LOG_DEBUG("RCLK not supported");
-#ifndef BUILD_FT2232_HIGHSPEED
-			LOG_DEBUG("If you have a high-speed FTDI device, then "
-				"OpenOCD may be built with --enable-ft2232-highspeed.");
-#endif
 			return ERROR_FAIL;
 		}
 	}
@@ -581,6 +582,8 @@
 			COMMAND_CONFIG, "the vendor ID and product ID of the FTDI FT2232 device");
 	register_command(cmd_ctx, NULL, "ft2232_latency", ft2232_handle_latency_command,
 			COMMAND_CONFIG, "set the FT2232 latency timer to a new value");
+	register_command(cmd_ctx, NULL, "ft2232_legacy_mode", ft2232_handle_legacy_mode_command,
+				COMMAND_CONFIG, "enable FT2232H legacy mode");
 	return ERROR_OK;
 }
 
@@ -1941,7 +1944,7 @@
 			{"BM", "AM", "100AX", "UNKNOWN", "2232C", "232R", "2232H", "4232H"};
 		unsigned no_of_known_types = sizeof(type_str) / sizeof(type_str[0]) - 1;
 		unsigned type_index = ((unsigned)ftdi_device < no_of_known_types)
-			? ftdi_device : 3;
+			? ftdi_device : FT_DEVICE_UNKNOWN;
 		LOG_INFO("device: %lu \"%s\"", ftdi_device, type_str[type_index]);
 		LOG_INFO("deviceID: %lu", deviceID);
 		LOG_INFO("SerialNumber: %s", SerialNumber);
@@ -2118,8 +2121,24 @@
 
 	if (ft2232_device_is_highspeed())
 	{
-		if (ft2232h_ft4232h_clk_divide_by_5(false) != ERROR_OK)
-			return ERROR_JTAG_INIT_FAILED;
+#ifndef BUILD_FT2232_HIGHSPEED
+ #if BUILD_FT2232_FTD2XX == 1
+		LOG_WARNING("High Speed device found - You need a newer FTD2XX driver (version 2.04.16 or later)");
+ #elif BUILD_FT2232_LIBFTDI == 1
+		LOG_WARNING("High Speed device found - You need a newer libftdi version (0.16 or later)");
+ #endif
+#endif
+		if (ft2232_legacy_mode)
+		{
+			if (ft2232h_ft4232h_clk_divide_by_5(true) != ERROR_OK)
+				return ERROR_JTAG_INIT_FAILED;
+			LOG_USER("Enabling FTDI Legacy Mode");
+		}
+		else
+		{
+			if (ft2232h_ft4232h_clk_divide_by_5(false) != ERROR_OK)
+				return ERROR_JTAG_INIT_FAILED;
+		}
 	}
 
 	ft2232_speed(jtag_get_speed());
@@ -2890,6 +2909,27 @@
 	return ERROR_OK;
 }
 
+static int ft2232_handle_legacy_mode_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc)
+{
+	if (argc > 0)
+	{
+		if (!strcmp(args[0], "enable"))
+		{
+			ft2232_legacy_mode = 1;
+		}
+		else if (!strcmp(args[0], "disable"))
+		{
+			ft2232_legacy_mode = 0;
+		}
+		else
+		{
+			command_print(cmd_ctx, "usage: ft2232_legacy_mode ['enable'|'disable']");
+		}
+	}
+
+	return ERROR_OK;
+}
+
 static int ft2232_stableclocks(int num_cycles, jtag_command_t* cmd)
 {
 	int retval = 0;

