1 // SPDX-License-Identifier: GPL-2.0-or-later
3 /***************************************************************************
4 * Copyright (C) 2009-2010 by Simon Qian <SimonQian@SimonQian.com> *
5 ***************************************************************************/
7 /* Versaloon is a programming tool for multiple MCUs.
8 * It's distributed under GPLv3.
9 * You can find it at http://www.Versaloon.com/.
16 #include <jtag/adapter.h>
17 #include <jtag/interface.h>
18 #include <jtag/commands.h>
22 #include "versaloon/versaloon_include.h"
23 #include "versaloon/versaloon.h"
25 static int vsllink_tms_offset
;
27 struct pending_scan_result
{
30 int length
; /* Number of bits to read */
31 struct scan_command
*command
; /* Corresponding scan command */
34 bool last
; /* indicate the last scan pending */
37 #define MAX_PENDING_SCAN_RESULTS 256
39 static int pending_scan_results_length
;
40 static struct pending_scan_result
41 pending_scan_results_buffer
[MAX_PENDING_SCAN_RESULTS
];
43 /* Queue command functions */
44 static void vsllink_end_state(tap_state_t state
);
45 static void vsllink_state_move(void);
46 static void vsllink_path_move(unsigned int num_states
, tap_state_t
*path
);
47 static void vsllink_tms(int num_bits
, const uint8_t *bits
);
48 static void vsllink_runtest(unsigned int num_cycles
);
49 static void vsllink_stableclocks(unsigned int num_cycles
, int tms
);
50 static void vsllink_scan(bool ir_scan
, enum scan_type type
,
51 uint8_t *buffer
, int scan_size
, struct scan_command
*command
);
52 static int vsllink_reset(int trst
, int srst
);
54 /* VSLLink tap buffer functions */
55 static void vsllink_tap_append_step(int tms
, int tdi
);
56 static void vsllink_tap_init(void);
57 static int vsllink_tap_execute(void);
58 static void vsllink_tap_ensure_pending(int scans
);
59 static void vsllink_tap_append_scan(int length
, uint8_t *buffer
,
60 struct scan_command
*command
);
62 /* VSLLink SWD functions */
63 static int_least32_t vsllink_swd_frequency(int_least32_t hz
);
64 static int vsllink_swd_switch_seq(enum swd_special_seq seq
);
66 /* VSLLink lowlevel functions */
68 struct libusb_context
*libusb_ctx
;
69 struct libusb_device_handle
*usb_device_handle
;
72 static int vsllink_usb_open(struct vsllink
*vsllink
);
73 static void vsllink_usb_close(struct vsllink
*vsllink
);
75 static void vsllink_debug_buffer(uint8_t *buffer
, int length
);
77 static int tap_length
;
78 static int tap_buffer_size
;
79 static uint8_t *tms_buffer
;
80 static uint8_t *tdi_buffer
;
81 static uint8_t *tdo_buffer
;
85 static struct vsllink
*vsllink_handle
;
87 static int vsllink_execute_queue(struct jtag_command
*cmd_queue
)
89 struct jtag_command
*cmd
= cmd_queue
;
94 LOG_DEBUG_IO("-------------------------------------"
96 "-------------------------------------");
101 LOG_DEBUG_IO("runtest %u cycles, end in %s",
102 cmd
->cmd
.runtest
->num_cycles
,
103 tap_state_name(cmd
->cmd
.runtest
->end_state
));
105 vsllink_end_state(cmd
->cmd
.runtest
->end_state
);
106 vsllink_runtest(cmd
->cmd
.runtest
->num_cycles
);
110 LOG_DEBUG_IO("statemove end in %s",
111 tap_state_name(cmd
->cmd
.statemove
->end_state
));
113 vsllink_end_state(cmd
->cmd
.statemove
->end_state
);
114 vsllink_state_move();
118 LOG_DEBUG_IO("pathmove: %u states, end in %s",
119 cmd
->cmd
.pathmove
->num_states
,
120 tap_state_name(cmd
->cmd
.pathmove
->path
[cmd
->cmd
.pathmove
->num_states
- 1]));
122 vsllink_path_move(cmd
->cmd
.pathmove
->num_states
, cmd
->cmd
.pathmove
->path
);
126 LOG_DEBUG_IO("JTAG Scan...");
128 vsllink_end_state(cmd
->cmd
.scan
->end_state
);
130 scan_size
= jtag_build_buffer(
131 cmd
->cmd
.scan
, &buffer
);
133 if (cmd
->cmd
.scan
->ir_scan
)
135 "JTAG Scan write IR(%d bits), "
138 tap_state_name(cmd
->cmd
.scan
->end_state
));
142 "JTAG Scan write DR(%d bits), "
145 tap_state_name(cmd
->cmd
.scan
->end_state
));
147 if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO
))
148 vsllink_debug_buffer(buffer
, DIV_ROUND_UP(scan_size
, 8));
150 type
= jtag_scan_type(cmd
->cmd
.scan
);
152 vsllink_scan(cmd
->cmd
.scan
->ir_scan
,
153 type
, buffer
, scan_size
,
158 LOG_DEBUG_IO("sleep %" PRIu32
, cmd
->cmd
.sleep
->us
);
159 vsllink_tap_execute();
160 jtag_sleep(cmd
->cmd
.sleep
->us
);
163 case JTAG_STABLECLOCKS
:
164 LOG_DEBUG_IO("add %u clocks",
165 cmd
->cmd
.stableclocks
->num_cycles
);
167 switch (tap_get_state()) {
169 /* tms must be '1' to stay
179 /* else, tms should be '0' */
182 /* above stable states are OK */
184 LOG_ERROR("jtag_add_clocks() "
185 "in non-stable state \"%s\"",
186 tap_state_name(tap_get_state())
190 vsllink_stableclocks(cmd
->cmd
.stableclocks
->num_cycles
, scan_size
);
194 LOG_DEBUG_IO("add %d jtag tms",
195 cmd
->cmd
.tms
->num_bits
);
197 vsllink_tms(cmd
->cmd
.tms
->num_bits
, cmd
->cmd
.tms
->bits
);
201 LOG_ERROR("BUG: unknown JTAG command type "
202 "encountered: %d", cmd
->type
);
208 return vsllink_tap_execute();
211 static int vsllink_speed(int speed
)
214 vsllink_swd_frequency(speed
* 1000);
218 versaloon_interface
.adaptors
.jtag_raw
.config(0, (uint16_t)speed
);
219 return versaloon_interface
.adaptors
.peripheral_commit();
222 static int vsllink_khz(int khz
, int *jtag_speed
)
229 static int vsllink_speed_div(int jtag_speed
, int *khz
)
236 static void vsllink_free_buffer(void)
248 static int vsllink_quit(void)
250 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
| GPIO_TRST
,
251 0, 0, GPIO_SRST
| GPIO_TRST
);
252 versaloon_interface
.adaptors
.gpio
.fini(0);
255 versaloon_interface
.adaptors
.swd
.fini(0);
257 versaloon_interface
.adaptors
.jtag_raw
.fini(0);
259 versaloon_interface
.adaptors
.peripheral_commit();
260 versaloon_interface
.fini();
262 vsllink_free_buffer();
263 vsllink_usb_close(vsllink_handle
);
265 libusb_exit(vsllink_handle
->libusb_ctx
);
266 free(vsllink_handle
);
271 static int vsllink_interface_init(void)
273 vsllink_handle
= malloc(sizeof(struct vsllink
));
274 if (!vsllink_handle
) {
275 LOG_ERROR("unable to allocate memory");
279 libusb_init(&vsllink_handle
->libusb_ctx
);
281 if (vsllink_usb_open(vsllink_handle
) != ERROR_OK
) {
282 LOG_ERROR("Can't find USB JTAG Interface!"
283 "Please check connection and permissions.");
284 return ERROR_JTAG_INIT_FAILED
;
286 LOG_DEBUG("vsllink found on %04X:%04X",
287 versaloon_interface
.usb_setting
.vid
,
288 versaloon_interface
.usb_setting
.pid
);
289 versaloon_usb_device_handle
= vsllink_handle
->usb_device_handle
;
291 if (versaloon_interface
.init() != ERROR_OK
)
293 if (versaloon_interface
.usb_setting
.buf_size
< 32) {
294 versaloon_interface
.fini();
301 static int vsllink_init(void)
303 int retval
= vsllink_interface_init();
304 if (retval
!= ERROR_OK
)
307 versaloon_interface
.adaptors
.gpio
.init(0);
308 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, 0, GPIO_SRST
,
310 versaloon_interface
.adaptors
.delay
.delayms(100);
311 versaloon_interface
.adaptors
.peripheral_commit();
314 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_TRST
, 0,
315 GPIO_TRST
, GPIO_TRST
);
316 versaloon_interface
.adaptors
.swd
.init(0);
317 vsllink_swd_frequency(adapter_get_speed_khz() * 1000);
318 vsllink_swd_switch_seq(JTAG_TO_SWD
);
321 /* malloc buffer size for tap */
322 tap_buffer_size
= versaloon_interface
.usb_setting
.buf_size
/ 2 - 32;
323 vsllink_free_buffer();
324 tdi_buffer
= malloc(tap_buffer_size
);
325 tdo_buffer
= malloc(tap_buffer_size
);
326 tms_buffer
= malloc(tap_buffer_size
);
327 if ((!tdi_buffer
) || (!tdo_buffer
) || (!tms_buffer
)) {
332 versaloon_interface
.adaptors
.jtag_raw
.init(0);
333 versaloon_interface
.adaptors
.jtag_raw
.config(0, adapter_get_speed_khz());
334 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
| GPIO_TRST
,
335 GPIO_TRST
, GPIO_SRST
, GPIO_SRST
);
338 if (versaloon_interface
.adaptors
.peripheral_commit() != ERROR_OK
)
346 /**************************************************************************
347 * Queue command implementations */
349 static void vsllink_end_state(tap_state_t state
)
351 if (tap_is_state_stable(state
))
352 tap_set_end_state(state
);
354 LOG_ERROR("BUG: %i is not a valid end state", state
);
359 /* Goes to the end state. */
360 static void vsllink_state_move(void)
363 uint8_t tms_scan
= tap_get_tms_path(tap_get_state(),
364 tap_get_end_state());
365 uint8_t tms_scan_bits
= tap_get_tms_path_len(tap_get_state(),
366 tap_get_end_state());
368 for (i
= 0; i
< tms_scan_bits
; i
++)
369 vsllink_tap_append_step((tms_scan
>> i
) & 1, 0);
371 tap_set_state(tap_get_end_state());
374 static void vsllink_path_move(unsigned int num_states
, tap_state_t
*path
)
376 for (unsigned int i
= 0; i
< num_states
; i
++) {
377 if (path
[i
] == tap_state_transition(tap_get_state(), false))
378 vsllink_tap_append_step(0, 0);
379 else if (path
[i
] == tap_state_transition(tap_get_state(), true))
380 vsllink_tap_append_step(1, 0);
382 LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition",
383 tap_state_name(tap_get_state()),
384 tap_state_name(path
[i
]));
388 tap_set_state(path
[i
]);
391 tap_set_end_state(tap_get_state());
394 static void vsllink_tms(int num_bits
, const uint8_t *bits
)
396 for (int i
= 0; i
< num_bits
; i
++)
397 vsllink_tap_append_step((bits
[i
/ 8] >> (i
% 8)) & 1, 0);
400 static void vsllink_stableclocks(unsigned int num_cycles
, int tms
)
402 while (num_cycles
> 0) {
403 vsllink_tap_append_step(tms
, 0);
408 static void vsllink_runtest(unsigned int num_cycles
)
410 tap_state_t saved_end_state
= tap_get_end_state();
412 if (tap_get_state() != TAP_IDLE
) {
413 /* enter IDLE state */
414 vsllink_end_state(TAP_IDLE
);
415 vsllink_state_move();
418 vsllink_stableclocks(num_cycles
, 0);
422 vsllink_end_state(saved_end_state
);
423 if (tap_get_end_state() != tap_get_end_state())
424 vsllink_state_move();
427 static void vsllink_scan(bool ir_scan
, enum scan_type type
, uint8_t *buffer
,
428 int scan_size
, struct scan_command
*command
)
430 tap_state_t saved_end_state
;
432 saved_end_state
= tap_get_end_state();
434 /* Move to appropriate scan state */
435 vsllink_end_state(ir_scan
? TAP_IRSHIFT
: TAP_DRSHIFT
);
437 if (tap_get_state() != tap_get_end_state())
438 vsllink_state_move();
439 vsllink_end_state(saved_end_state
);
442 vsllink_tap_append_scan(scan_size
, buffer
, command
);
444 /* Goto Pause and record position to insert tms:0 */
445 vsllink_tap_append_step(0, 0);
446 vsllink_tms_offset
= tap_length
;
448 tap_set_state(ir_scan
? TAP_IRPAUSE
: TAP_DRPAUSE
);
450 if (tap_get_state() != tap_get_end_state())
451 vsllink_state_move();
454 static int vsllink_reset(int trst
, int srst
)
456 LOG_DEBUG("trst: %i, srst: %i", trst
, srst
);
459 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, 0, GPIO_SRST
, GPIO_SRST
);
461 versaloon_interface
.adaptors
.gpio
.config(0, GPIO_SRST
, GPIO_SRST
, 0, 0);
465 versaloon_interface
.adaptors
.gpio
.out(0, GPIO_TRST
, GPIO_TRST
);
467 versaloon_interface
.adaptors
.gpio
.out(0, GPIO_TRST
, 0);
470 return versaloon_interface
.adaptors
.peripheral_commit();
473 COMMAND_HANDLER(vsllink_handle_usb_vid_command
)
476 return ERROR_COMMAND_SYNTAX_ERROR
;
478 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[0],
479 versaloon_interface
.usb_setting
.vid
);
483 COMMAND_HANDLER(vsllink_handle_usb_pid_command
)
486 return ERROR_COMMAND_SYNTAX_ERROR
;
487 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[0],
488 versaloon_interface
.usb_setting
.pid
);
492 COMMAND_HANDLER(vsllink_handle_usb_bulkin_command
)
495 return ERROR_COMMAND_SYNTAX_ERROR
;
497 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
498 versaloon_interface
.usb_setting
.ep_in
);
500 versaloon_interface
.usb_setting
.ep_in
|= 0x80;
505 COMMAND_HANDLER(vsllink_handle_usb_bulkout_command
)
508 return ERROR_COMMAND_SYNTAX_ERROR
;
510 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
511 versaloon_interface
.usb_setting
.ep_out
);
513 versaloon_interface
.usb_setting
.ep_out
&= ~0x80;
518 COMMAND_HANDLER(vsllink_handle_usb_interface_command
)
521 return ERROR_COMMAND_SYNTAX_ERROR
;
523 COMMAND_PARSE_NUMBER(u8
, CMD_ARGV
[0],
524 versaloon_interface
.usb_setting
.interface
);
528 /**************************************************************************
529 * VSLLink tap functions */
531 static void vsllink_tap_init(void)
534 pending_scan_results_length
= 0;
535 vsllink_tms_offset
= 0;
538 static void vsllink_tap_ensure_pending(int scans
)
540 int available_scans
=
541 MAX_PENDING_SCAN_RESULTS
- pending_scan_results_length
;
543 if (scans
> available_scans
)
544 vsllink_tap_execute();
547 static void vsllink_tap_append_step(int tms
, int tdi
)
549 int index_var
= tap_length
/ 8;
551 int bit_index
= tap_length
% 8;
552 uint8_t bit
= 1 << bit_index
;
555 tms_buffer
[index_var
] |= bit
;
557 tms_buffer
[index_var
] &= ~bit
;
560 tdi_buffer
[index_var
] |= bit
;
562 tdi_buffer
[index_var
] &= ~bit
;
566 if (tap_buffer_size
* 8 <= tap_length
)
567 vsllink_tap_execute();
570 static void vsllink_tap_append_scan(int length
, uint8_t *buffer
,
571 struct scan_command
*command
)
573 struct pending_scan_result
*pending_scan_result
;
574 int len_tmp
, len_all
, i
;
577 while (len_all
< length
) {
578 vsllink_tap_ensure_pending(1);
579 pending_scan_result
=
580 &pending_scan_results_buffer
[
581 pending_scan_results_length
];
583 if ((length
- len_all
) > (tap_buffer_size
* 8 - tap_length
)) {
584 /* Use all memory available
585 vsllink_tap_append_step will commit automatically */
586 len_tmp
= tap_buffer_size
* 8 - tap_length
;
587 pending_scan_result
->last
= false;
589 len_tmp
= length
- len_all
;
590 pending_scan_result
->last
= true;
592 pending_scan_result
->src_offset
= tap_length
;
593 pending_scan_result
->dest_offset
= len_all
;
594 pending_scan_result
->length
= len_tmp
;
595 pending_scan_result
->command
= command
;
596 pending_scan_result
->buffer
= buffer
;
597 pending_scan_results_length
++;
599 for (i
= 0; i
< len_tmp
; i
++) {
600 vsllink_tap_append_step(((len_all
+ i
) < length
-1
602 (buffer
[(len_all
+ i
)/8]
603 >> ((len_all
+ i
)%8)) & 1);
610 static int vsllink_jtag_execute(void)
618 versaloon_interface
.adaptors
.jtag_raw
.execute(0, tdi_buffer
, tms_buffer
,
619 tdo_buffer
, tap_length
);
621 result
= versaloon_interface
.adaptors
.peripheral_commit();
623 if (result
== ERROR_OK
) {
624 for (i
= 0; i
< pending_scan_results_length
; i
++) {
625 struct pending_scan_result
*pending_scan_result
=
626 &pending_scan_results_buffer
[i
];
627 uint8_t *buffer
= pending_scan_result
->buffer
;
628 int length
= pending_scan_result
->length
;
629 int src_first
= pending_scan_result
->src_offset
;
630 int dest_first
= pending_scan_result
->dest_offset
;
631 bool last
= pending_scan_result
->last
;
633 struct scan_command
*command
;
635 command
= pending_scan_result
->command
;
636 buf_set_buf(tdo_buffer
, src_first
, buffer
, dest_first
, length
);
639 "JTAG scan read(%d bits, from src %d bits to dest %d bits):",
640 length
, src_first
, dest_first
);
641 if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO
))
642 vsllink_debug_buffer(buffer
+ dest_first
/ 8, DIV_ROUND_UP(length
, 7));
645 if (jtag_read_buffer(buffer
, command
)
648 return ERROR_JTAG_QUEUE_FAILED
;
651 free(pending_scan_result
->buffer
);
655 LOG_ERROR("vsllink_jtag_execute failure");
656 return ERROR_JTAG_QUEUE_FAILED
;
664 static int vsllink_tap_execute(void)
669 return vsllink_jtag_execute();
672 static int vsllink_swd_init(void)
674 LOG_INFO("VSLLink SWD mode enabled");
680 static int_least32_t vsllink_swd_frequency(int_least32_t hz
)
682 const int_least32_t delay2hz
[] = {
683 1850000, 235000, 130000, 102000, 85000, 72000
687 uint16_t delay
= UINT16_MAX
;
689 for (uint16_t i
= 0; i
< ARRAY_SIZE(delay2hz
); i
++) {
690 if (hz
>= delay2hz
[i
]) {
697 if (delay
== UINT16_MAX
)
698 delay
= (500000 / hz
) - 1;
700 /* Calculate retry count after a WAIT response. This will give
701 * a retry timeout at about ~250 ms. 54 is the number of bits
702 * found in a transaction. */
703 uint16_t retry_count
= 250 * hz
/ 1000 / 54;
705 LOG_DEBUG("SWD delay: %d, retry count: %d", delay
, retry_count
);
707 versaloon_interface
.adaptors
.swd
.config(0, 2, retry_count
, delay
);
713 static int vsllink_swd_switch_seq(enum swd_special_seq seq
)
717 LOG_DEBUG("SWD line reset");
718 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_line_reset
,
719 swd_seq_line_reset_len
);
722 LOG_DEBUG("JTAG-to-SWD");
723 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_jtag_to_swd
,
724 swd_seq_jtag_to_swd_len
);
727 LOG_DEBUG("SWD-to-JTAG");
728 versaloon_interface
.adaptors
.swd
.seqout(0, swd_seq_swd_to_jtag
,
729 swd_seq_swd_to_jtag_len
);
732 LOG_ERROR("Sequence %d not supported", seq
);
739 static void vsllink_swd_read_reg(uint8_t cmd
, uint32_t *value
, uint32_t ap_delay_clk
)
741 versaloon_interface
.adaptors
.swd
.transact(0, cmd
, value
, NULL
);
744 static void vsllink_swd_write_reg(uint8_t cmd
, uint32_t value
, uint32_t ap_delay_clk
)
746 versaloon_interface
.adaptors
.swd
.transact(0, cmd
, &value
, NULL
);
749 static int vsllink_swd_run_queue(void)
751 return versaloon_interface
.adaptors
.peripheral_commit();
754 /****************************************************************************
755 * VSLLink USB low-level functions */
757 static int vsllink_check_usb_strings(
758 struct libusb_device_handle
*usb_device_handle
,
759 struct libusb_device_descriptor
*usb_desc
)
761 char desc_string
[256];
764 if (adapter_get_required_serial()) {
765 retval
= libusb_get_string_descriptor_ascii(usb_device_handle
,
766 usb_desc
->iSerialNumber
, (unsigned char *)desc_string
,
767 sizeof(desc_string
));
771 if (strncmp(desc_string
, adapter_get_required_serial(),
772 sizeof(desc_string
)))
776 retval
= libusb_get_string_descriptor_ascii(usb_device_handle
,
777 usb_desc
->iProduct
, (unsigned char *)desc_string
,
778 sizeof(desc_string
));
782 if (!strstr(desc_string
, "Versaloon"))
788 static int vsllink_usb_open(struct vsllink
*vsllink
)
790 ssize_t num_devices
, i
;
791 struct libusb_device
**usb_devices
;
792 struct libusb_device_descriptor usb_desc
;
793 struct libusb_device_handle
*usb_device_handle
;
796 num_devices
= libusb_get_device_list(vsllink
->libusb_ctx
, &usb_devices
);
798 if (num_devices
<= 0)
801 for (i
= 0; i
< num_devices
; i
++) {
802 struct libusb_device
*device
= usb_devices
[i
];
804 retval
= libusb_get_device_descriptor(device
, &usb_desc
);
808 if (usb_desc
.idVendor
!= versaloon_interface
.usb_setting
.vid
||
809 usb_desc
.idProduct
!= versaloon_interface
.usb_setting
.pid
)
812 retval
= libusb_open(device
, &usb_device_handle
);
816 retval
= vsllink_check_usb_strings(usb_device_handle
, &usb_desc
);
817 if (retval
== ERROR_OK
)
820 libusb_close(usb_device_handle
);
823 libusb_free_device_list(usb_devices
, 1);
825 if (i
== num_devices
)
828 retval
= libusb_claim_interface(usb_device_handle
,
829 versaloon_interface
.usb_setting
.interface
);
831 LOG_ERROR("unable to claim interface");
832 libusb_close(usb_device_handle
);
836 vsllink
->usb_device_handle
= usb_device_handle
;
840 static void vsllink_usb_close(struct vsllink
*vsllink
)
842 libusb_release_interface(vsllink
->usb_device_handle
,
843 versaloon_interface
.usb_setting
.interface
);
844 libusb_close(vsllink
->usb_device_handle
);
847 #define BYTES_PER_LINE 16
849 static void vsllink_debug_buffer(uint8_t *buffer
, int length
)
856 for (i
= 0; i
< length
; i
+= BYTES_PER_LINE
) {
857 snprintf(line
, 5, "%04x", i
& 0xffff);
858 for (j
= i
; j
< i
+ BYTES_PER_LINE
&& j
< length
; j
++) {
859 snprintf(s
, 4, " %02x", buffer
[j
]);
862 LOG_DEBUG_IO("%s", line
);
866 static const struct command_registration vsllink_subcommand_handlers
[] = {
869 .handler
= &vsllink_handle_usb_vid_command
,
870 .mode
= COMMAND_CONFIG
,
871 .help
= "Set USB VID",
876 .handler
= &vsllink_handle_usb_pid_command
,
877 .mode
= COMMAND_CONFIG
,
878 .help
= "Set USB PID",
882 .name
= "usb_bulkin",
883 .handler
= &vsllink_handle_usb_bulkin_command
,
884 .mode
= COMMAND_CONFIG
,
885 .help
= "Set USB input endpoint",
889 .name
= "usb_bulkout",
890 .handler
= &vsllink_handle_usb_bulkout_command
,
891 .mode
= COMMAND_CONFIG
,
892 .help
= "Set USB output endpoint",
896 .name
= "usb_interface",
897 .handler
= &vsllink_handle_usb_interface_command
,
898 .mode
= COMMAND_CONFIG
,
899 .help
= "Set USB output interface",
900 .usage
= "<interface>",
902 COMMAND_REGISTRATION_DONE
905 static const struct command_registration vsllink_command_handlers
[] = {
909 .help
= "perform vsllink management",
910 .chain
= vsllink_subcommand_handlers
,
913 COMMAND_REGISTRATION_DONE
916 static const char * const vsllink_transports
[] = {"jtag", "swd", NULL
};
918 static const struct swd_driver vsllink_swd_driver
= {
919 .init
= vsllink_swd_init
,
920 .switch_seq
= vsllink_swd_switch_seq
,
921 .read_reg
= vsllink_swd_read_reg
,
922 .write_reg
= vsllink_swd_write_reg
,
923 .run
= vsllink_swd_run_queue
,
926 static struct jtag_interface vsllink_interface
= {
927 .supported
= DEBUG_CAP_TMS_SEQ
,
928 .execute_queue
= vsllink_execute_queue
,
931 struct adapter_driver vsllink_adapter_driver
= {
933 .transports
= vsllink_transports
,
934 .commands
= vsllink_command_handlers
,
936 .init
= vsllink_init
,
937 .quit
= vsllink_quit
,
938 .reset
= vsllink_reset
,
939 .speed
= vsllink_speed
,
941 .speed_div
= vsllink_speed_div
,
943 .jtag_ops
= &vsllink_interface
,
944 .swd_ops
= &vsllink_swd_driver
,