1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de>
4 * Copyright (C) 2007-2010 Øyvind Harboe <oyvind.harboe@zylin.com>
5 * Copyright (C) 2009 SoftPLC Corporation, http://softplc.com, Dick Hollenbeck <dick@softplc.com>
6 * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net>
7 * Copyright (C) 2018 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>
16 #include "minidriver.h"
17 #include "interface.h"
18 #include "interfaces.h"
19 #include <transport/transport.h>
27 * Holds support for configuring debug adapters from TCl scripts.
30 struct adapter_driver
*adapter_driver
;
31 const char * const jtag_only
[] = { "jtag", NULL
};
33 enum adapter_clk_mode
{
34 CLOCK_MODE_UNSELECTED
= 0,
40 * Adapter configuration
43 bool adapter_initialized
;
46 enum adapter_clk_mode clock_mode
;
48 int rclk_fallback_speed_khz
;
51 bool is_adapter_initialized(void)
53 return adapter_config
.adapter_initialized
;
57 * Do low-level setup like initializing registers, output signals,
60 int adapter_init(struct command_context
*cmd_ctx
)
62 if (is_adapter_initialized())
65 if (!adapter_driver
) {
66 /* nothing was previously specified by "adapter driver" command */
67 LOG_ERROR("Debug Adapter has to be specified, "
68 "see \"adapter driver\" command");
69 return ERROR_JTAG_INVALID_INTERFACE
;
73 retval
= adapter_driver
->init();
74 if (retval
!= ERROR_OK
)
76 adapter_config
.adapter_initialized
= true;
78 if (!adapter_driver
->speed
) {
79 LOG_INFO("This adapter doesn't support configurable speed");
83 if (adapter_config
.clock_mode
== CLOCK_MODE_UNSELECTED
) {
84 LOG_ERROR("An adapter speed is not selected in the init script."
85 " Insert a call to \"adapter speed\" or \"jtag_rclk\" to proceed.");
86 return ERROR_JTAG_INIT_FAILED
;
89 int requested_khz
= adapter_get_speed_khz();
90 int actual_khz
= requested_khz
;
92 retval
= adapter_get_speed(&speed_var
);
93 if (retval
!= ERROR_OK
)
95 retval
= adapter_driver
->speed(speed_var
);
96 if (retval
!= ERROR_OK
)
98 retval
= adapter_get_speed_readable(&actual_khz
);
99 if (retval
!= ERROR_OK
)
100 LOG_INFO("adapter-specific clock speed value %d", speed_var
);
101 else if (actual_khz
) {
102 /* Adaptive clocking -- JTAG-specific */
103 if ((adapter_config
.clock_mode
== CLOCK_MODE_RCLK
)
104 || ((adapter_config
.clock_mode
== CLOCK_MODE_KHZ
) && !requested_khz
)) {
105 LOG_INFO("RCLK (adaptive clock speed) not supported - fallback to %d kHz"
108 LOG_INFO("clock speed %d kHz", actual_khz
);
110 LOG_INFO("RCLK (adaptive clock speed)");
115 int adapter_quit(void)
117 if (is_adapter_initialized() && adapter_driver
->quit
) {
118 /* close the JTAG interface */
119 int result
= adapter_driver
->quit();
120 if (result
!= ERROR_OK
)
121 LOG_ERROR("failed: %d", result
);
124 free(adapter_config
.serial
);
125 free(adapter_config
.usb_location
);
127 struct jtag_tap
*t
= jtag_all_taps();
129 struct jtag_tap
*n
= t
->next_tap
;
137 unsigned int adapter_get_speed_khz(void)
139 return adapter_config
.speed_khz
;
142 static int adapter_khz_to_speed(unsigned int khz
, int *speed
)
144 LOG_DEBUG("convert khz to adapter specific speed value");
145 adapter_config
.speed_khz
= khz
;
146 if (!is_adapter_initialized())
148 LOG_DEBUG("have adapter set up");
149 if (!adapter_driver
->khz
) {
150 LOG_ERROR("Translation from khz to adapter speed not implemented");
154 int retval
= adapter_driver
->khz(adapter_get_speed_khz(), &speed_div1
);
155 if (retval
!= ERROR_OK
)
161 static int adapter_rclk_to_speed(unsigned int fallback_speed_khz
, int *speed
)
163 int retval
= adapter_khz_to_speed(0, speed
);
164 if ((retval
!= ERROR_OK
) && fallback_speed_khz
) {
165 LOG_DEBUG("trying fallback speed...");
166 retval
= adapter_khz_to_speed(fallback_speed_khz
, speed
);
171 static int adapter_set_speed(int speed
)
173 /* this command can be called during CONFIG,
174 * in which case adapter isn't initialized */
175 return is_adapter_initialized() ? adapter_driver
->speed(speed
) : ERROR_OK
;
178 int adapter_config_khz(unsigned int khz
)
180 LOG_DEBUG("handle adapter khz");
181 adapter_config
.clock_mode
= CLOCK_MODE_KHZ
;
183 int retval
= adapter_khz_to_speed(khz
, &speed
);
184 return (retval
!= ERROR_OK
) ? retval
: adapter_set_speed(speed
);
187 int adapter_config_rclk(unsigned int fallback_speed_khz
)
189 LOG_DEBUG("handle adapter rclk");
190 adapter_config
.clock_mode
= CLOCK_MODE_RCLK
;
191 adapter_config
.rclk_fallback_speed_khz
= fallback_speed_khz
;
193 int retval
= adapter_rclk_to_speed(fallback_speed_khz
, &speed
);
194 return (retval
!= ERROR_OK
) ? retval
: adapter_set_speed(speed
);
197 int adapter_get_speed(int *speed
)
199 switch (adapter_config
.clock_mode
) {
201 adapter_khz_to_speed(adapter_get_speed_khz(), speed
);
203 case CLOCK_MODE_RCLK
:
204 adapter_rclk_to_speed(adapter_config
.rclk_fallback_speed_khz
, speed
);
207 LOG_ERROR("BUG: unknown adapter clock mode");
213 int adapter_get_speed_readable(int *khz
)
216 int retval
= adapter_get_speed(&speed_var
);
217 if (retval
!= ERROR_OK
)
219 if (!is_adapter_initialized())
221 if (!adapter_driver
->speed_div
) {
222 LOG_ERROR("Translation from adapter speed to khz not implemented");
225 return adapter_driver
->speed_div(speed_var
, khz
);
228 const char *adapter_get_required_serial(void)
230 return adapter_config
.serial
;
235 * 2 * 7 chars: max 7 ports
236 * 1 char: test for overflow
240 #define USB_MAX_LOCATION_LENGTH 16
242 #ifdef HAVE_LIBUSB_GET_PORT_NUMBERS
243 static void adapter_usb_set_location(const char *location
)
245 if (strnlen(location
, USB_MAX_LOCATION_LENGTH
) == USB_MAX_LOCATION_LENGTH
)
246 LOG_WARNING("usb location string is too long!!");
248 free(adapter_config
.usb_location
);
250 adapter_config
.usb_location
= strndup(location
, USB_MAX_LOCATION_LENGTH
);
252 #endif /* HAVE_LIBUSB_GET_PORT_NUMBERS */
254 const char *adapter_usb_get_location(void)
256 return adapter_config
.usb_location
;
259 bool adapter_usb_location_equal(uint8_t dev_bus
, uint8_t *port_path
, size_t path_len
)
261 size_t path_step
, string_length
;
265 if (!adapter_usb_get_location())
268 /* strtok need non const char */
269 loc
= strndup(adapter_usb_get_location(), USB_MAX_LOCATION_LENGTH
);
270 string_length
= strnlen(loc
, USB_MAX_LOCATION_LENGTH
);
272 ptr
= strtok(loc
, "-");
274 LOG_WARNING("no '-' in usb path\n");
278 string_length
-= strnlen(ptr
, string_length
);
279 /* check bus mismatch */
280 if (atoi(ptr
) != dev_bus
)
284 while (path_step
< path_len
) {
285 ptr
= strtok(NULL
, ".");
287 /* no more tokens in path */
291 /* path mismatch at some step */
292 if (path_step
< path_len
&& atoi(ptr
) != port_path
[path_step
])
296 string_length
-= strnlen(ptr
, string_length
) + 1;
299 /* walked the full path, all elements match */
300 if (path_step
== path_len
&& !string_length
)
308 static int jim_adapter_name(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
310 struct jim_getopt_info goi
;
311 jim_getopt_setup(&goi
, interp
, argc
-1, argv
+ 1);
313 /* return the name of the interface */
314 /* TCL code might need to know the exact type... */
315 /* FUTURE: we allow this as a means to "set" the interface. */
317 Jim_WrongNumArgs(goi
.interp
, 1, goi
.argv
-1, "(no params)");
320 const char *name
= adapter_driver
? adapter_driver
->name
: NULL
;
321 Jim_SetResultString(goi
.interp
, name
? name
: "undefined", -1);
325 COMMAND_HANDLER(adapter_transports_command
)
330 retval
= CALL_COMMAND_HANDLER(transport_list_parse
, &transports
);
331 if (retval
!= ERROR_OK
)
334 retval
= allow_transports(CMD_CTX
, (const char **)transports
);
336 if (retval
!= ERROR_OK
) {
337 for (unsigned i
= 0; transports
[i
]; i
++)
344 COMMAND_HANDLER(handle_adapter_list_command
)
346 if (strcmp(CMD_NAME
, "list") == 0 && CMD_ARGC
> 0)
347 return ERROR_COMMAND_SYNTAX_ERROR
;
349 command_print(CMD
, "The following debug adapters are available:");
350 for (unsigned i
= 0; adapter_drivers
[i
]; i
++) {
351 const char *name
= adapter_drivers
[i
]->name
;
352 command_print(CMD
, "%u: %s", i
+ 1, name
);
358 COMMAND_HANDLER(handle_adapter_driver_command
)
362 /* check whether the interface is already configured */
363 if (adapter_driver
) {
364 LOG_WARNING("Interface already configured, ignoring");
368 /* interface name is a mandatory argument */
369 if (CMD_ARGC
!= 1 || CMD_ARGV
[0][0] == '\0')
370 return ERROR_COMMAND_SYNTAX_ERROR
;
372 for (unsigned i
= 0; adapter_drivers
[i
]; i
++) {
373 if (strcmp(CMD_ARGV
[0], adapter_drivers
[i
]->name
) != 0)
376 if (adapter_drivers
[i
]->commands
) {
377 retval
= register_commands(CMD_CTX
, NULL
, adapter_drivers
[i
]->commands
);
378 if (retval
!= ERROR_OK
)
382 adapter_driver
= adapter_drivers
[i
];
384 return allow_transports(CMD_CTX
, adapter_driver
->transports
);
387 /* no valid interface was found (i.e. the configuration option,
388 * didn't match one of the compiled-in interfaces
390 LOG_ERROR("The specified debug interface was not found (%s)",
392 CALL_COMMAND_HANDLER(handle_adapter_list_command
);
393 return ERROR_JTAG_INVALID_INTERFACE
;
396 COMMAND_HANDLER(handle_reset_config_command
)
401 /* Original versions cared about the order of these tokens:
402 * reset_config signals [combination [trst_type [srst_type]]]
403 * They also clobbered the previous configuration even on error.
405 * Here we don't care about the order, and only change values
406 * which have been explicitly specified.
408 for (; CMD_ARGC
; CMD_ARGC
--, CMD_ARGV
++) {
413 m
= RESET_SRST_NO_GATING
;
414 if (strcmp(*CMD_ARGV
, "srst_gates_jtag") == 0)
415 /* default: don't use JTAG while SRST asserted */;
416 else if (strcmp(*CMD_ARGV
, "srst_nogate") == 0)
417 tmp
= RESET_SRST_NO_GATING
;
421 LOG_ERROR("extra reset_config %s spec (%s)",
422 "gating", *CMD_ARGV
);
423 return ERROR_COMMAND_SYNTAX_ERROR
;
429 m
= RESET_HAS_TRST
| RESET_HAS_SRST
;
430 if (strcmp(*CMD_ARGV
, "none") == 0)
432 else if (strcmp(*CMD_ARGV
, "trst_only") == 0)
433 tmp
= RESET_HAS_TRST
;
434 else if (strcmp(*CMD_ARGV
, "srst_only") == 0)
435 tmp
= RESET_HAS_SRST
;
436 else if (strcmp(*CMD_ARGV
, "trst_and_srst") == 0)
437 tmp
= RESET_HAS_TRST
| RESET_HAS_SRST
;
441 LOG_ERROR("extra reset_config %s spec (%s)",
442 "signal", *CMD_ARGV
);
443 return ERROR_COMMAND_SYNTAX_ERROR
;
448 /* combination (options for broken wiring) */
449 m
= RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
;
450 if (strcmp(*CMD_ARGV
, "separate") == 0)
451 /* separate reset lines - default */;
452 else if (strcmp(*CMD_ARGV
, "srst_pulls_trst") == 0)
453 tmp
|= RESET_SRST_PULLS_TRST
;
454 else if (strcmp(*CMD_ARGV
, "trst_pulls_srst") == 0)
455 tmp
|= RESET_TRST_PULLS_SRST
;
456 else if (strcmp(*CMD_ARGV
, "combined") == 0)
457 tmp
|= RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
;
461 LOG_ERROR("extra reset_config %s spec (%s)",
462 "combination", *CMD_ARGV
);
463 return ERROR_COMMAND_SYNTAX_ERROR
;
468 /* trst_type (NOP without HAS_TRST) */
469 m
= RESET_TRST_OPEN_DRAIN
;
470 if (strcmp(*CMD_ARGV
, "trst_open_drain") == 0)
471 tmp
|= RESET_TRST_OPEN_DRAIN
;
472 else if (strcmp(*CMD_ARGV
, "trst_push_pull") == 0)
473 /* push/pull from adapter - default */;
477 LOG_ERROR("extra reset_config %s spec (%s)",
478 "trst_type", *CMD_ARGV
);
479 return ERROR_COMMAND_SYNTAX_ERROR
;
484 /* srst_type (NOP without HAS_SRST) */
485 m
= RESET_SRST_PUSH_PULL
;
486 if (strcmp(*CMD_ARGV
, "srst_push_pull") == 0)
487 tmp
|= RESET_SRST_PUSH_PULL
;
488 else if (strcmp(*CMD_ARGV
, "srst_open_drain") == 0)
489 /* open drain from adapter - default */;
493 LOG_ERROR("extra reset_config %s spec (%s)",
494 "srst_type", *CMD_ARGV
);
495 return ERROR_COMMAND_SYNTAX_ERROR
;
500 /* connect_type - only valid when srst_nogate */
501 m
= RESET_CNCT_UNDER_SRST
;
502 if (strcmp(*CMD_ARGV
, "connect_assert_srst") == 0)
503 tmp
|= RESET_CNCT_UNDER_SRST
;
504 else if (strcmp(*CMD_ARGV
, "connect_deassert_srst") == 0)
505 /* connect normally - default */;
509 LOG_ERROR("extra reset_config %s spec (%s)",
510 "connect_type", *CMD_ARGV
);
511 return ERROR_COMMAND_SYNTAX_ERROR
;
516 /* caller provided nonsense; fail */
517 LOG_ERROR("unknown reset_config flag (%s)", *CMD_ARGV
);
518 return ERROR_COMMAND_SYNTAX_ERROR
;
521 /* Remember the bits which were specified (mask)
522 * and their new values (new_cfg).
528 /* clear previous values of those bits, save new values */
530 int old_cfg
= jtag_get_reset_config();
534 jtag_set_reset_config(new_cfg
);
536 new_cfg
= jtag_get_reset_config();
539 * Display the (now-)current reset mode
543 /* minimal JTAG has neither SRST nor TRST (so that's the default) */
544 switch (new_cfg
& (RESET_HAS_TRST
| RESET_HAS_SRST
)) {
546 modes
[0] = "srst_only";
549 modes
[0] = "trst_only";
551 case RESET_TRST_AND_SRST
:
552 modes
[0] = "trst_and_srst";
559 /* normally SRST and TRST are decoupled; but bugs happen ... */
560 switch (new_cfg
& (RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
)) {
561 case RESET_SRST_PULLS_TRST
:
562 modes
[1] = "srst_pulls_trst";
564 case RESET_TRST_PULLS_SRST
:
565 modes
[1] = "trst_pulls_srst";
567 case RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
:
568 modes
[1] = "combined";
571 modes
[1] = "separate";
575 /* TRST-less connectors include Altera, Xilinx, and minimal JTAG */
576 if (new_cfg
& RESET_HAS_TRST
) {
577 if (new_cfg
& RESET_TRST_OPEN_DRAIN
)
578 modes
[3] = " trst_open_drain";
580 modes
[3] = " trst_push_pull";
584 /* SRST-less connectors include TI-14, Xilinx, and minimal JTAG */
585 if (new_cfg
& RESET_HAS_SRST
) {
586 if (new_cfg
& RESET_SRST_NO_GATING
)
587 modes
[2] = " srst_nogate";
589 modes
[2] = " srst_gates_jtag";
591 if (new_cfg
& RESET_SRST_PUSH_PULL
)
592 modes
[4] = " srst_push_pull";
594 modes
[4] = " srst_open_drain";
596 if (new_cfg
& RESET_CNCT_UNDER_SRST
)
597 modes
[5] = " connect_assert_srst";
599 modes
[5] = " connect_deassert_srst";
606 command_print(CMD
, "%s %s%s%s%s%s",
608 modes
[2], modes
[3], modes
[4], modes
[5]);
613 COMMAND_HANDLER(handle_adapter_srst_delay_command
)
616 return ERROR_COMMAND_SYNTAX_ERROR
;
619 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], delay
);
621 jtag_set_nsrst_delay(delay
);
623 command_print(CMD
, "adapter srst delay: %u", jtag_get_nsrst_delay());
627 COMMAND_HANDLER(handle_adapter_srst_pulse_width_command
)
630 return ERROR_COMMAND_SYNTAX_ERROR
;
633 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], width
);
635 jtag_set_nsrst_assert_width(width
);
637 command_print(CMD
, "adapter srst pulse_width: %u", jtag_get_nsrst_assert_width());
641 COMMAND_HANDLER(handle_adapter_speed_command
)
644 return ERROR_COMMAND_SYNTAX_ERROR
;
646 int retval
= ERROR_OK
;
649 COMMAND_PARSE_NUMBER(uint
, CMD_ARGV
[0], khz
);
651 retval
= adapter_config_khz(khz
);
652 if (retval
!= ERROR_OK
)
656 int cur_speed
= adapter_get_speed_khz();
657 retval
= adapter_get_speed_readable(&cur_speed
);
658 if (retval
!= ERROR_OK
)
662 command_print(CMD
, "adapter speed: %d kHz", cur_speed
);
664 command_print(CMD
, "adapter speed: RCLK - adaptive");
669 COMMAND_HANDLER(handle_adapter_serial_command
)
672 return ERROR_COMMAND_SYNTAX_ERROR
;
674 free(adapter_config
.serial
);
675 adapter_config
.serial
= strdup(CMD_ARGV
[0]);
679 COMMAND_HANDLER(handle_adapter_reset_de_assert
)
682 VALUE_UNDEFINED
= -1,
687 enum values srst
= VALUE_UNDEFINED
;
688 enum values trst
= VALUE_UNDEFINED
;
689 enum reset_types jtag_reset_config
= jtag_get_reset_config();
693 if (transport_is_jtag()) {
694 if (jtag_reset_config
& RESET_HAS_TRST
)
695 signal
= jtag_get_trst() ? "asserted" : "deasserted";
697 signal
= "not present";
698 command_print(CMD
, "trst %s", signal
);
701 if (jtag_reset_config
& RESET_HAS_SRST
)
702 signal
= jtag_get_srst() ? "asserted" : "deasserted";
704 signal
= "not present";
705 command_print(CMD
, "srst %s", signal
);
710 if (CMD_ARGC
!= 1 && CMD_ARGC
!= 3)
711 return ERROR_COMMAND_SYNTAX_ERROR
;
713 value
= (strcmp(CMD_NAME
, "assert") == 0) ? VALUE_ASSERT
: VALUE_DEASSERT
;
714 if (strcmp(CMD_ARGV
[0], "srst") == 0)
716 else if (strcmp(CMD_ARGV
[0], "trst") == 0)
719 return ERROR_COMMAND_SYNTAX_ERROR
;
722 if (strcmp(CMD_ARGV
[1], "assert") == 0)
723 value
= VALUE_ASSERT
;
724 else if (strcmp(CMD_ARGV
[1], "deassert") == 0)
725 value
= VALUE_DEASSERT
;
727 return ERROR_COMMAND_SYNTAX_ERROR
;
729 if (strcmp(CMD_ARGV
[2], "srst") == 0 && srst
== VALUE_UNDEFINED
)
731 else if (strcmp(CMD_ARGV
[2], "trst") == 0 && trst
== VALUE_UNDEFINED
)
734 return ERROR_COMMAND_SYNTAX_ERROR
;
737 if (trst
== VALUE_UNDEFINED
) {
738 if (transport_is_jtag())
739 trst
= jtag_get_trst() ? VALUE_ASSERT
: VALUE_DEASSERT
;
741 trst
= VALUE_DEASSERT
; /* unused, safe value */
744 if (srst
== VALUE_UNDEFINED
) {
745 if (jtag_reset_config
& RESET_HAS_SRST
)
746 srst
= jtag_get_srst() ? VALUE_ASSERT
: VALUE_DEASSERT
;
748 srst
= VALUE_DEASSERT
; /* unused, safe value */
751 if (trst
== VALUE_ASSERT
&& !transport_is_jtag()) {
752 LOG_ERROR("transport has no trst signal");
756 if (srst
== VALUE_ASSERT
&& !(jtag_reset_config
& RESET_HAS_SRST
)) {
757 LOG_ERROR("adapter has no srst signal");
761 return adapter_resets((trst
== VALUE_DEASSERT
) ? TRST_DEASSERT
: TRST_ASSERT
,
762 (srst
== VALUE_DEASSERT
) ? SRST_DEASSERT
: SRST_ASSERT
);
765 #ifdef HAVE_LIBUSB_GET_PORT_NUMBERS
766 COMMAND_HANDLER(handle_usb_location_command
)
769 adapter_usb_set_location(CMD_ARGV
[0]);
771 command_print(CMD
, "adapter usb location: %s", adapter_usb_get_location());
775 #endif /* HAVE_LIBUSB_GET_PORT_NUMBERS */
777 static const struct command_registration adapter_usb_command_handlers
[] = {
778 #ifdef HAVE_LIBUSB_GET_PORT_NUMBERS
781 .handler
= &handle_usb_location_command
,
782 .mode
= COMMAND_CONFIG
,
783 .help
= "display or set the USB bus location of the USB device",
784 .usage
= "[<bus>-port[.port]...]",
786 #endif /* HAVE_LIBUSB_GET_PORT_NUMBERS */
787 COMMAND_REGISTRATION_DONE
790 static const struct command_registration adapter_srst_command_handlers
[] = {
793 .handler
= handle_adapter_srst_delay_command
,
795 .help
= "delay after deasserting SRST in ms",
796 .usage
= "[milliseconds]",
799 .name
= "pulse_width",
800 .handler
= handle_adapter_srst_pulse_width_command
,
802 .help
= "SRST assertion pulse width in ms",
803 .usage
= "[milliseconds]",
805 COMMAND_REGISTRATION_DONE
808 static const struct command_registration adapter_command_handlers
[] = {
811 .handler
= handle_adapter_driver_command
,
812 .mode
= COMMAND_CONFIG
,
813 .help
= "Select a debug adapter driver",
814 .usage
= "driver_name",
818 .handler
= handle_adapter_speed_command
,
820 .help
= "With an argument, change to the specified maximum "
821 "jtag speed. For JTAG, 0 KHz signifies adaptive "
823 "With or without argument, display current setting.",
828 .handler
= handle_adapter_serial_command
,
829 .mode
= COMMAND_CONFIG
,
830 .help
= "Set the serial number of the adapter",
831 .usage
= "serial_string",
835 .handler
= handle_adapter_list_command
,
837 .help
= "List all built-in debug adapter drivers",
843 .jim_handler
= jim_adapter_name
,
844 .help
= "Returns the name of the currently "
845 "selected adapter (driver)",
850 .help
= "srst adapter command group",
852 .chain
= adapter_srst_command_handlers
,
855 .name
= "transports",
856 .handler
= adapter_transports_command
,
857 .mode
= COMMAND_CONFIG
,
858 .help
= "Declare transports the adapter supports.",
859 .usage
= "transport ...",
864 .help
= "usb adapter command group",
866 .chain
= adapter_usb_command_handlers
,
870 .handler
= handle_adapter_reset_de_assert
,
871 .mode
= COMMAND_EXEC
,
872 .help
= "Controls SRST and TRST lines.",
873 .usage
= "|deassert [srst|trst [assert|deassert srst|trst]]",
877 .handler
= handle_adapter_reset_de_assert
,
878 .mode
= COMMAND_EXEC
,
879 .help
= "Controls SRST and TRST lines.",
880 .usage
= "|assert [srst|trst [deassert|assert srst|trst]]",
882 COMMAND_REGISTRATION_DONE
885 static const struct command_registration interface_command_handlers
[] = {
889 .help
= "adapter command group",
891 .chain
= adapter_command_handlers
,
894 .name
= "reset_config",
895 .handler
= handle_reset_config_command
,
897 .help
= "configure adapter reset behavior",
898 .usage
= "[none|trst_only|srst_only|trst_and_srst] "
899 "[srst_pulls_trst|trst_pulls_srst|combined|separate] "
900 "[srst_gates_jtag|srst_nogate] "
901 "[trst_push_pull|trst_open_drain] "
902 "[srst_push_pull|srst_open_drain] "
903 "[connect_deassert_srst|connect_assert_srst]",
905 COMMAND_REGISTRATION_DONE
909 * Register the commands which deal with arbitrary debug adapter drivers.
911 * @todo Remove internal assumptions that all debug adapters use JTAG for
912 * transport. Various types and data structures are not named generically.
914 int adapter_register_commands(struct command_context
*ctx
)
916 return register_commands(ctx
, NULL
, interface_command_handlers
);