1 /*******************************************************************************
2 * Driver for OpenJTAG Project (www.openjtag.org) *
3 * Compatible with libftdi and ftd2xx drivers. *
5 * Copyright (C) 2010 by Ivan Meleca <mileca@gmail.com> *
7 * Copyright (C) 2013 by Ryan Corbin, GlueLogix Inc. <corbin.ryan@gmail.com> *
8 * Updated to work with OpenOCD v0.7.0. Fixed libftdi read speed issue. *
10 * Based on usb_blaster.c *
11 * Copyright (C) 2009 Catalin Patulea *
12 * Copyright (C) 2006 Kolja Waschk *
15 * Copyright (C) 2008 by Spencer Oliver *
16 * spen@spen-soft.co.uk *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the *
30 * Free Software Foundation, Inc., *
31 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
32 ***************************************************************************/
34 /***************************************************************************
35 * Version 1.0 Tested on a MCBSTM32 board using a Cortex M3 (stm32f103x), *
36 * GDB and Eclipse under Linux (Ubuntu 10.04) *
38 ***************************************************************************/
44 #include <jtag/interface.h>
45 #include <jtag/commands.h>
46 #include "usb_common.h"
49 * OpenJTAG-OpenOCD state conversion
51 typedef enum openjtag_tap_state
{
52 OPENJTAG_TAP_INVALID
= -1,
53 OPENJTAG_TAP_RESET
= 0,
54 OPENJTAG_TAP_IDLE
= 1,
55 OPENJTAG_TAP_SELECT_DR
= 2,
56 OPENJTAG_TAP_CAPTURE_DR
= 3,
57 OPENJTAG_TAP_SHIFT_DR
= 4,
58 OPENJTAG_TAP_EXIT1_DR
= 5,
59 OPENJTAG_TAP_PAUSE_DR
= 6,
60 OPENJTAG_TAP_EXIT2_DR
= 7,
61 OPENJTAG_TAP_UPDATE_DR
= 8,
62 OPENJTAG_TAP_SELECT_IR
= 9,
63 OPENJTAG_TAP_CAPURE_IR
= 10,
64 OPENJTAG_TAP_SHIFT_IR
= 11,
65 OPENJTAG_TAP_EXIT1_IR
= 12,
66 OPENJTAG_TAP_PAUSE_IR
= 13,
67 OPENJTAG_TAP_EXIT2_IR
= 14,
68 OPENJTAG_TAP_UPDATE_IR
= 15,
69 } openjtag_tap_state_t
;
71 #if (BUILD_OPENJTAG_FTD2XX == 1 && BUILD_OPENJTAG_LIBFTDI == 1)
72 #error "BUILD_OPENJTAG_FTD2XX && BUILD_OPENJTAG_LIBFTDI "
73 "are mutually exclusive"
74 #elif (BUILD_OPENJTAG_FTD2XX != 1 && BUILD_OPENJTAG_LIBFTDI != 1)
75 #error "BUILD_OPENJTAG_FTD2XX || BUILD_OPENJTAG_LIBFTDI must be chosen"
78 /* OPENJTAG access library includes */
79 #if BUILD_OPENJTAG_FTD2XX == 1
81 #elif BUILD_OPENJTAG_LIBFTDI == 1
85 /* OpenJTAG vid/pid */
86 static uint16_t openjtag_vid
= 0x0403;
87 static uint16_t openjtag_pid
= 0x6001;
89 static char *openjtag_device_desc
;
91 #if BUILD_OPENJTAG_FTD2XX == 1
92 static FT_HANDLE ftdih
;
94 #elif BUILD_OPENJTAG_LIBFTDI == 1
95 static struct ftdi_context ftdic
;
98 #define OPENJTAG_BUFFER_SIZE 504
99 #define OPENJTAG_MAX_PENDING_RESULTS 256
101 struct openjtag_scan_result
{
102 uint32_t bits
; /* Length in bits*/
103 struct scan_command
*command
; /* Corresponding scan command */
107 /* USB RX/TX buffers */
108 static int usb_tx_buf_offs
;
109 static uint8_t usb_tx_buf
[OPENJTAG_BUFFER_SIZE
];
110 static uint32_t usb_rx_buf_len
;
111 static uint8_t usb_rx_buf
[OPENJTAG_BUFFER_SIZE
];
113 /* Pending readings */
114 static struct openjtag_scan_result openjtag_scan_result_buffer
[OPENJTAG_MAX_PENDING_RESULTS
];
115 static int openjtag_scan_result_count
;
117 /* Openocd usb handler */
119 struct usb_dev_handle
*usb_handle
;
122 #ifdef _DEBUG_USB_COMMS_
124 #define DEBUG_TYPE_READ 0
125 #define DEBUG_TYPE_WRITE 1
126 #define DEBUG_TYPE_OCD_READ 2
127 #define DEBUG_TYPE_BUFFER 3
130 static void openjtag_debug_buffer(uint8_t *buffer
, int length
, uint8_t type
)
138 case DEBUG_TYPE_READ
:
139 sprintf(line
, "USB READ %d bytes", length
);
141 case DEBUG_TYPE_WRITE
:
142 sprintf(line
, "USB WRITE %d bytes", length
);
144 case DEBUG_TYPE_OCD_READ
:
145 sprintf(line
, "TO OpenOCD %d bytes", length
);
147 case DEBUG_TYPE_BUFFER
:
148 sprintf(line
, "Buffer %d bytes", length
);
152 LOG_DEBUG("%s", line
);
154 for (i
= 0; i
< length
; i
+= LINE_LEN
) {
156 case DEBUG_TYPE_READ
:
157 sprintf(line
, "USB READ: %04x", i
);
159 case DEBUG_TYPE_WRITE
:
160 sprintf(line
, "USB WRITE: %04x", i
);
162 case DEBUG_TYPE_OCD_READ
:
163 sprintf(line
, "TO OpenOCD: %04x", i
);
165 case DEBUG_TYPE_BUFFER
:
166 sprintf(line
, "BUFFER: %04x", i
);
170 for (j
= i
; j
< i
+ LINE_LEN
&& j
< length
; j
++) {
171 sprintf(s
, " %02x", buffer
[j
]);
174 LOG_DEBUG("%s", line
);
181 static int8_t openjtag_get_tap_state(int8_t state
)
185 case TAP_DREXIT2
: return OPENJTAG_TAP_EXIT2_DR
;
186 case TAP_DREXIT1
: return OPENJTAG_TAP_EXIT1_DR
;
187 case TAP_DRSHIFT
: return OPENJTAG_TAP_SHIFT_DR
;
188 case TAP_DRPAUSE
: return OPENJTAG_TAP_PAUSE_DR
;
189 case TAP_IRSELECT
: return OPENJTAG_TAP_SELECT_IR
;
190 case TAP_DRUPDATE
: return OPENJTAG_TAP_UPDATE_DR
;
191 case TAP_DRCAPTURE
: return OPENJTAG_TAP_CAPTURE_DR
;
192 case TAP_DRSELECT
: return OPENJTAG_TAP_SELECT_DR
;
193 case TAP_IREXIT2
: return OPENJTAG_TAP_EXIT2_IR
;
194 case TAP_IREXIT1
: return OPENJTAG_TAP_EXIT1_IR
;
195 case TAP_IRSHIFT
: return OPENJTAG_TAP_SHIFT_IR
;
196 case TAP_IRPAUSE
: return OPENJTAG_TAP_PAUSE_IR
;
197 case TAP_IDLE
: return OPENJTAG_TAP_IDLE
;
198 case TAP_IRUPDATE
: return OPENJTAG_TAP_UPDATE_IR
;
199 case TAP_IRCAPTURE
: return OPENJTAG_TAP_CAPURE_IR
;
200 case TAP_RESET
: return OPENJTAG_TAP_RESET
;
202 default: return OPENJTAG_TAP_INVALID
;
206 static int openjtag_buf_write(
207 uint8_t *buf
, int size
, uint32_t *bytes_written
)
209 #if BUILD_OPENJTAG_FTD2XX == 1
211 DWORD dw_bytes_written
;
213 #ifdef _DEBUG_USB_COMMS_
214 openjtag_debug_buffer(buf
, size
, DEBUG_TYPE_WRITE
);
217 status
= FT_Write(ftdih
, buf
, size
, &dw_bytes_written
);
218 if (status
!= FT_OK
) {
219 *bytes_written
= dw_bytes_written
;
220 LOG_ERROR("FT_Write returned: %u", status
);
221 return ERROR_JTAG_DEVICE_ERROR
;
223 *bytes_written
= dw_bytes_written
;
225 #elif BUILD_OPENJTAG_LIBFTDI == 1
227 #ifdef _DEBUG_USB_COMMS_
228 openjtag_debug_buffer(buf
, size
, DEBUG_TYPE_WRITE
);
231 retval
= ftdi_write_data(&ftdic
, buf
, size
);
234 LOG_ERROR("ftdi_write_data: %s", ftdi_get_error_string(&ftdic
));
235 return ERROR_JTAG_DEVICE_ERROR
;
238 *bytes_written
+= retval
;
244 static int openjtag_buf_read(uint8_t *buf
, uint32_t qty
, uint32_t *bytes_read
)
247 #if BUILD_OPENJTAG_FTD2XX == 1
253 while (qty
&& (*bytes_read
< qty
) && timeout
--) {
255 status
= FT_Read(ftdih
, buf
+ *bytes_read
,
256 qty
- *bytes_read
, &dw_bytes_read
);
257 if (status
!= FT_OK
) {
258 *bytes_read
= dw_bytes_read
;
259 LOG_ERROR("FT_Read returned: %u", status
);
260 return ERROR_JTAG_DEVICE_ERROR
;
262 *bytes_read
+= dw_bytes_read
;
265 #ifdef _DEBUG_USB_COMMS_
266 openjtag_debug_buffer(buf
, *bytes_read
, DEBUG_TYPE_READ
);
270 #elif BUILD_OPENJTAG_LIBFTDI == 1
276 while ((*bytes_read
< qty
) && timeout
--) {
277 retval
= ftdi_read_data(&ftdic
, buf
+ *bytes_read
,
281 DEBUG_JTAG_IO("ftdi_read_data: %s",
282 ftdi_get_error_string(&ftdic
));
283 return ERROR_JTAG_DEVICE_ERROR
;
285 *bytes_read
+= retval
;
288 #ifdef _DEBUG_USB_COMMS_
289 openjtag_debug_buffer(buf
, *bytes_read
, DEBUG_TYPE_READ
);
296 static int openjtag_sendcommand(uint8_t cmd
)
299 return openjtag_buf_write(&cmd
, 1, &written
);
302 static int openjtag_speed(int speed
)
332 LOG_WARNING("adapter speed not recognized, reverting to 375 kHz");
335 openjtag_sendcommand(clockcmd
);
340 static int openjtag_init(void)
342 uint8_t latency_timer
;
344 #if BUILD_OPENJTAG_FTD2XX == 1
350 openjtag_scan_result_count
= 0;
352 #if BUILD_OPENJTAG_FTD2XX == 1
353 LOG_DEBUG("'openjtag' interface using FTD2XX");
354 #elif BUILD_OPENJTAG_LIBFTDI == 1
355 LOG_DEBUG("'openjtag' interface using libftdi");
358 /* Open by device description */
359 if (openjtag_device_desc
== NULL
) {
360 LOG_WARNING("no openjtag device description specified, "
361 "using default 'Open JTAG Project'");
362 openjtag_device_desc
= "Open JTAG Project";
365 #if BUILD_OPENJTAG_FTD2XX == 1
368 /* Add non-standard Vid/Pid to the linux driver */
369 status
= FT_SetVIDPID(openjtag_vid
, openjtag_pid
);
370 if (status
!= FT_OK
) {
371 LOG_WARNING("couldn't add %4.4x:%4.4x",
372 openjtag_vid
, openjtag_pid
);
376 status
= FT_OpenEx(openjtag_device_desc
, FT_OPEN_BY_DESCRIPTION
,
378 if (status
!= FT_OK
) {
381 LOG_ERROR("unable to open ftdi device: %u", status
);
382 status
= FT_ListDevices(&num_devices
, NULL
,
383 FT_LIST_NUMBER_ONLY
);
384 if (status
== FT_OK
) {
385 char **desc_array
= malloc(sizeof(char *)
386 * (num_devices
+ 1));
389 for (i
= 0; i
< num_devices
; i
++)
390 desc_array
[i
] = malloc(64);
391 desc_array
[num_devices
] = NULL
;
393 status
= FT_ListDevices(desc_array
, &num_devices
,
394 FT_LIST_ALL
| FT_OPEN_BY_DESCRIPTION
);
396 if (status
== FT_OK
) {
397 LOG_ERROR("ListDevices: %u\n", num_devices
);
398 for (i
= 0; i
< num_devices
; i
++)
399 LOG_ERROR("%i: %s", i
, desc_array
[i
]);
402 for (i
= 0; i
< num_devices
; i
++)
406 LOG_ERROR("ListDevices: NONE\n");
408 return ERROR_JTAG_INIT_FAILED
;
411 status
= FT_SetLatencyTimer(ftdih
, 2);
412 if (status
!= FT_OK
) {
413 LOG_ERROR("unable to set latency timer: %u", status
);
414 return ERROR_JTAG_INIT_FAILED
;
417 status
= FT_GetLatencyTimer(ftdih
, &latency_timer
);
418 if (status
!= FT_OK
) {
419 LOG_ERROR("unable to get latency timer: %u", status
);
420 return ERROR_JTAG_INIT_FAILED
;
422 LOG_DEBUG("current latency timer: %i", latency_timer
);
424 status
= FT_SetBitMode(ftdih
, 0x00, 0x40);
425 if (status
!= FT_OK
) {
426 LOG_ERROR("unable to disable bit i/o mode: %u", status
);
427 return ERROR_JTAG_INIT_FAILED
;
430 status
= FT_SetTimeouts(ftdih
, 50, 0);
431 if (status
!= FT_OK
) {
432 LOG_ERROR("unable to set timeouts: %u", status
);
433 return ERROR_JTAG_INIT_FAILED
;
436 status
= FT_Purge(ftdih
, FT_PURGE_RX
| FT_PURGE_TX
);
437 if (status
!= FT_OK
) {
438 LOG_ERROR("unable to FT_Purge() %u", status
);
439 return ERROR_JTAG_INIT_FAILED
;
442 #elif BUILD_OPENJTAG_LIBFTDI == 1
443 if (ftdi_init(&ftdic
) < 0)
444 return ERROR_JTAG_INIT_FAILED
;
446 /* context, vendor id, product id, description, serial id */
447 if (ftdi_usb_open_desc(&ftdic
, openjtag_vid
, openjtag_pid
, openjtag_device_desc
, NULL
) < 0) {
448 LOG_ERROR("unable to open ftdi device: %s", ftdic
.error_str
);
449 return ERROR_JTAG_INIT_FAILED
;
452 if (ftdi_usb_reset(&ftdic
) < 0) {
453 LOG_ERROR("unable to reset ftdi device");
454 return ERROR_JTAG_INIT_FAILED
;
457 if (ftdi_set_latency_timer(&ftdic
, 2) < 0) {
458 LOG_ERROR("unable to set latency timer");
459 return ERROR_JTAG_INIT_FAILED
;
462 if (ftdi_get_latency_timer(&ftdic
, &latency_timer
) < 0) {
463 LOG_ERROR("unable to get latency timer");
464 return ERROR_JTAG_INIT_FAILED
;
466 LOG_DEBUG("current latency timer: %u", latency_timer
);
468 ftdi_disable_bitbang(&ftdic
);
469 /* was (3000000 / 4) with a comment about a bug in libftdi when using high baudrate */
470 if (ftdi_set_baudrate(&ftdic
, 3000000) < 0) {
471 LOG_ERROR("Can't set baud rate to max: %s",
472 ftdi_get_error_string(&ftdic
));
473 return ERROR_JTAG_DEVICE_ERROR
;
477 #if BUILD_OPENJTAG_FTD2XX == 1
478 status
= FT_Purge(ftdih
, FT_PURGE_RX
| FT_PURGE_TX
);
480 return ERROR_JTAG_INIT_FAILED
;
481 #elif BUILD_OPENJTAG_LIBFTDI == 1
482 if (ftdi_usb_purge_buffers(&ftdic
) < 0) {
483 LOG_ERROR("ftdi_purge_buffers: %s", ftdic
.error_str
);
484 return ERROR_JTAG_INIT_FAILED
;
489 openjtag_sendcommand(0xE0); /*Start at slowest adapter speed*/
492 openjtag_sendcommand(0x75);
497 static int openjtag_quit(void)
499 #if BUILD_OPENJTAG_FTD2XX == 1
501 #elif BUILD_OPENJTAG_LIBFTDI == 1
502 ftdi_usb_close(&ftdic
);
509 static void openjtag_write_tap_buffer(void)
513 openjtag_buf_write(usb_tx_buf
, usb_tx_buf_offs
, &written
);
514 openjtag_buf_read(usb_rx_buf
, usb_tx_buf_offs
, &usb_rx_buf_len
);
519 static int openjtag_execute_tap_queue(void)
521 openjtag_write_tap_buffer();
525 if (openjtag_scan_result_count
&& usb_rx_buf_len
) {
531 /* for every pending result */
532 while (res_count
< openjtag_scan_result_count
) {
535 len
= openjtag_scan_result_buffer
[res_count
].bits
;
539 uint8_t *buffer
= openjtag_scan_result_buffer
[res_count
].buffer
;
543 DEBUG_JTAG_IO("bits < 8 buf = 0x%X, will be 0x%X",
544 usb_rx_buf
[rx_offs
], usb_rx_buf
[rx_offs
] >> (8 - len
));
545 buffer
[count
] = usb_rx_buf
[rx_offs
] >> (8 - len
);
548 buffer
[count
] = usb_rx_buf
[rx_offs
];
556 #ifdef _DEBUG_USB_COMMS_
557 openjtag_debug_buffer(buffer
,
558 DIV_ROUND_UP(openjtag_scan_result_buffer
[res_count
].bits
, 8), DEBUG_TYPE_OCD_READ
);
560 jtag_read_buffer(buffer
, openjtag_scan_result_buffer
[res_count
].command
);
562 if (openjtag_scan_result_buffer
[res_count
].buffer
)
563 free(openjtag_scan_result_buffer
[res_count
].buffer
);
569 openjtag_scan_result_count
= 0;
574 static void openjtag_add_byte(char buf
)
577 if (usb_tx_buf_offs
== OPENJTAG_BUFFER_SIZE
) {
578 DEBUG_JTAG_IO("Forcing execute_tap_queue");
579 DEBUG_JTAG_IO("TX Buff offs=%d", usb_tx_buf_offs
);
580 openjtag_execute_tap_queue();
583 usb_tx_buf
[usb_tx_buf_offs
] = buf
;
587 static void openjtag_add_scan(uint8_t *buffer
, int length
, struct scan_command
*scan_cmd
)
590 /* Ensure space to send long chains */
591 /* We add two byte for each eight (or less) bits, one for command, one for data */
592 if (usb_tx_buf_offs
+ (DIV_ROUND_UP(length
, 8) * 2) >= OPENJTAG_BUFFER_SIZE
) {
593 DEBUG_JTAG_IO("Forcing execute_tap_queue from scan");
594 DEBUG_JTAG_IO("TX Buff offs=%d len=%d", usb_tx_buf_offs
, DIV_ROUND_UP(length
, 8) * 2);
595 openjtag_execute_tap_queue();
598 openjtag_scan_result_buffer
[openjtag_scan_result_count
].bits
= length
;
599 openjtag_scan_result_buffer
[openjtag_scan_result_count
].command
= scan_cmd
;
600 openjtag_scan_result_buffer
[openjtag_scan_result_count
].buffer
= buffer
;
615 /* bits to transfer */
617 command
|= bits
<< 5;
622 /* bits to transfer */
628 openjtag_add_byte(command
);
629 openjtag_add_byte(buffer
[count
]);
633 openjtag_scan_result_count
++;
636 static void openjtag_execute_reset(struct jtag_command
*cmd
)
639 DEBUG_JTAG_IO("reset trst: %i srst %i",
640 cmd
->cmd
.reset
->trst
, cmd
->cmd
.reset
->srst
);
644 if (cmd
->cmd
.reset
->trst
) {
651 openjtag_add_byte(buf
);
654 static void openjtag_execute_sleep(struct jtag_command
*cmd
)
656 jtag_sleep(cmd
->cmd
.sleep
->us
);
659 static void openjtag_set_state(uint8_t openocd_state
)
661 int8_t state
= openjtag_get_tap_state(openocd_state
);
667 openjtag_add_byte(buf
);
670 static void openjtag_execute_statemove(struct jtag_command
*cmd
)
672 DEBUG_JTAG_IO("state move to %i", cmd
->cmd
.statemove
->end_state
);
674 tap_set_end_state(cmd
->cmd
.statemove
->end_state
);
676 openjtag_set_state(cmd
->cmd
.statemove
->end_state
);
678 tap_set_state(tap_get_end_state());
682 static void openjtag_execute_scan(struct jtag_command
*cmd
)
685 int scan_size
, old_state
;
688 DEBUG_JTAG_IO("scan ends in %s", tap_state_name(cmd
->cmd
.scan
->end_state
));
691 tap_set_end_state(cmd
->cmd
.scan
->end_state
);
692 scan_size
= jtag_build_buffer(cmd
->cmd
.scan
, &buffer
);
694 #ifdef _DEBUG_USB_COMMS_
695 openjtag_debug_buffer(buffer
, (scan_size
+ 7) / 8, DEBUG_TYPE_BUFFER
);
698 old_state
= tap_get_end_state();
699 openjtag_set_state(cmd
->cmd
.scan
->ir_scan
? TAP_IRSHIFT
: TAP_DRSHIFT
);
700 tap_set_state(cmd
->cmd
.scan
->ir_scan
? TAP_IRSHIFT
: TAP_DRSHIFT
);
701 tap_set_end_state(old_state
);
703 openjtag_add_scan(buffer
, scan_size
, cmd
->cmd
.scan
);
705 openjtag_set_state(cmd
->cmd
.scan
->ir_scan
? TAP_IRPAUSE
: TAP_DRPAUSE
);
706 tap_set_state(cmd
->cmd
.scan
->ir_scan
? TAP_IRPAUSE
: TAP_DRPAUSE
);
708 if (tap_get_state() != tap_get_end_state()) {
709 openjtag_set_state(tap_get_end_state());
710 tap_set_state(tap_get_end_state());
714 static void openjtag_execute_runtest(struct jtag_command
*cmd
)
717 tap_state_t end_state
= cmd
->cmd
.runtest
->end_state
;
718 tap_set_end_state(end_state
);
720 /* only do a state_move when we're not already in IDLE */
721 if (tap_get_state() != TAP_IDLE
) {
722 openjtag_set_state(TAP_IDLE
);
723 tap_set_state(TAP_IDLE
);
726 if (cmd
->cmd
.runtest
->num_cycles
> 16)
727 LOG_WARNING("num_cycles > 16 on run test");
731 command
|= ((cmd
->cmd
.runtest
->num_cycles
- 1) & 0x0F) << 4;
733 openjtag_add_byte(command
);
735 tap_set_end_state(end_state
);
736 if (tap_get_end_state() != tap_get_state()) {
737 openjtag_set_state(end_state
);
738 tap_set_state(end_state
);
742 static void openjtag_execute_command(struct jtag_command
*cmd
)
744 DEBUG_JTAG_IO("openjtag_execute_command %i", cmd
->type
);
747 openjtag_execute_reset(cmd
);
750 openjtag_execute_sleep(cmd
);
753 openjtag_execute_statemove(cmd
);
756 openjtag_execute_scan(cmd
);
759 openjtag_execute_runtest(cmd
);
762 /* jlink_execute_pathmove(cmd); break; */
764 LOG_ERROR("BUG: unknown Open JTAG command type encountered");
769 static int openjtag_execute_queue(void)
771 struct jtag_command
*cmd
= jtag_command_queue
;
773 while (cmd
!= NULL
) {
774 openjtag_execute_command(cmd
);
778 return openjtag_execute_tap_queue();
781 static int openjtag_speed_div(int speed
, int *khz
)
788 static int openjtag_khz(int khz
, int *jtag_speed
)
793 else if (khz
>= 24000)
795 else if (khz
>= 12000)
797 else if (khz
>= 6000)
799 else if (khz
>= 3000)
801 else if (khz
>= 1500)
811 COMMAND_HANDLER(openjtag_handle_device_desc_command
)
814 openjtag_device_desc
= strdup(CMD_ARGV
[0]);
816 LOG_ERROR("require exactly one argument to "
817 "openjtag_device_desc <description>");
822 static const struct command_registration openjtag_command_handlers
[] = {
824 .name
= "openjtag_device_desc",
825 .handler
= openjtag_handle_device_desc_command
,
826 .mode
= COMMAND_CONFIG
,
827 .help
= "set the USB device description of the OpenJTAG",
828 .usage
= "description-string",
830 COMMAND_REGISTRATION_DONE
833 struct jtag_interface openjtag_interface
= {
835 .commands
= openjtag_command_handlers
,
837 .execute_queue
= openjtag_execute_queue
,
838 .speed
= openjtag_speed
,
839 .speed_div
= openjtag_speed_div
,
841 .init
= openjtag_init
,
842 .quit
= openjtag_quit
,