Revert "mpsse: Always perform a general reset of the MPSSE in mpsse_open()"
[fw/openocd] / src / jtag / drivers / mpsse.c
index dbca535f91b6e125a032bc4608698f5358211f46..d6cbc8404c6e93330f3f38d6ed87317776b0e617 100644 (file)
@@ -216,6 +216,9 @@ static bool open_matching_device(struct mpsse_ctx *ctx, const uint16_t *vid, con
        case 0x800:
                ctx->type = TYPE_FT4232H;
                break;
+       case 0x900:
+               ctx->type = TYPE_FT232H;
+               break;
        default:
                LOG_ERROR("unsupported FTDI chip type: 0x%04x", desc.bcdDevice);
                goto error;
@@ -440,8 +443,8 @@ int mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_off
 
        while (length > 0) {
                /* Guarantee buffer space enough for a minimum size transfer */
-               if (buffer_write_space(ctx) + (length < 8) < (out ? 4 : 3)
-                   || (in && buffer_read_space(ctx) < 1))
+               if (buffer_write_space(ctx) + (length < 8) < (out || (!out && !in) ? 4 : 3)
+                               || (in && buffer_read_space(ctx) < 1))
                        retval = mpsse_flush(ctx);
 
                if (length < 8) {
@@ -462,8 +465,8 @@ int mpsse_clock_data(struct mpsse_ctx *ctx, const uint8_t *out, unsigned out_off
                        if (this_bytes > 65536)
                                this_bytes = 65536;
                        /* Buffer space limit. We already made sure there's space for the minimum
-                        *transfer. */
-                       if (out && this_bytes + 3 > buffer_write_space(ctx))
+                        * transfer. */
+                       if ((out || (!out && !in)) && this_bytes + 3 > buffer_write_space(ctx))
                                this_bytes = buffer_write_space(ctx) - 3;
                        if (in && this_bytes > buffer_read_space(ctx))
                                this_bytes = buffer_read_space(ctx);