-
- return ERROR_OK;
-}
-
-static int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
-{
- int new_cfg = 0;
- int mask = 0;
-
- if (argc < 1)
- return ERROR_COMMAND_SYNTAX_ERROR;
-
- /* Original versions cared about the order of these tokens:
- * reset_config signals [combination [trst_type [srst_type]]]
- * They also clobbered the previous configuration even on error.
- *
- * Here we don't care about the order, and only change values
- * which have been explicitly specified.
- */
- for (; argc; argc--, args++) {
- int tmp = 0;
- int m;
-
- m = RESET_SRST_GATES_JTAG;
- tmp = 0;
- if (strcmp(*args, "srst_gates_jtag") == 0)
- {
- tmp = RESET_SRST_GATES_JTAG;
- goto next;
- }
-
- /* signals */
- m = RESET_HAS_TRST | RESET_HAS_SRST;
- if (strcmp(*args, "none") == 0)
- tmp = RESET_NONE;
- else if (strcmp(*args, "trst_only") == 0)
- tmp = RESET_HAS_TRST;
- else if (strcmp(*args, "srst_only") == 0)
- tmp = RESET_HAS_SRST;
- else if (strcmp(*args, "trst_and_srst") == 0)
- tmp = RESET_HAS_TRST | RESET_HAS_SRST;
- else
- m = 0;
- if (mask & m) {
- LOG_ERROR("extra reset_config %s spec (%s)",
- "signal", *args);
- return ERROR_INVALID_ARGUMENTS;
- }
- if (m)
- goto next;
-
- /* combination (options for broken wiring) */
- m = RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST;
- if (strcmp(*args, "separate") == 0)
- /* separate reset lines - default */;
- else if (strcmp(*args, "srst_pulls_trst") == 0)
- tmp |= RESET_SRST_PULLS_TRST;
- else if (strcmp(*args, "trst_pulls_srst") == 0)
- tmp |= RESET_TRST_PULLS_SRST;
- else if (strcmp(*args, "combined") == 0)
- tmp |= RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST;
- else
- m = 0;
- if (mask & m) {
- LOG_ERROR("extra reset_config %s spec (%s)",
- "combination", *args);
- return ERROR_INVALID_ARGUMENTS;
- }
- if (m)
- goto next;
-
- /* trst_type (NOP without HAS_TRST) */
- m = RESET_TRST_OPEN_DRAIN;
- if (strcmp(*args, "trst_open_drain") == 0)
- tmp |= RESET_TRST_OPEN_DRAIN;
- else if (strcmp(*args, "trst_push_pull") == 0)
- /* push/pull from adapter - default */;
- else
- m = 0;
- if (mask & m) {
- LOG_ERROR("extra reset_config %s spec (%s)",
- "trst_type", *args);
- return ERROR_INVALID_ARGUMENTS;
- }
- if (m)
- goto next;
-
- /* srst_type (NOP without HAS_SRST) */
- m |= RESET_SRST_PUSH_PULL;
- if (strcmp(*args, "srst_push_pull") == 0)
- tmp |= RESET_SRST_PUSH_PULL;
- else if (strcmp(*args, "srst_open_drain") == 0)
- /* open drain from adapter - default */;
- else
- m = 0;
- if (mask & m) {
- LOG_ERROR("extra reset_config %s spec (%s)",
- "srst_type", *args);
- return ERROR_INVALID_ARGUMENTS;
- }
- if (m)
- goto next;
-
- /* caller provided nonsense; fail */
- LOG_ERROR("unknown reset_config flag (%s)", *args);
- return ERROR_INVALID_ARGUMENTS;
-
-next:
- /* Remember the bits which were specified (mask)
- * and their new values (new_cfg).
- */
- mask |= m;
- new_cfg |= tmp;
- }
-
- /* clear previous values of those bits, save new values */
- enum reset_types old_cfg = jtag_get_reset_config();
- old_cfg &= ~mask;
- new_cfg |= old_cfg;
- jtag_set_reset_config(new_cfg);
-
- return ERROR_OK;
-}
-
-static int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx,
- char *cmd, char **args, int argc)
-{
- if (argc > 1)
- return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
- {
- unsigned delay;
- int retval = parse_uint(args[0], &delay);
- if (ERROR_OK != retval)
- return retval;
- jtag_set_nsrst_delay(delay);
- }
- command_print(cmd_ctx, "jtag_nsrst_delay: %u", jtag_get_nsrst_delay());
- return ERROR_OK;
-}
-
-static int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx,
- char *cmd, char **args, int argc)
-{
- if (argc > 1)
- return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
- {
- unsigned delay;
- int retval = parse_uint(args[0], &delay);
- if (ERROR_OK != retval)
- return retval;
- jtag_set_ntrst_delay(delay);
- }
- command_print(cmd_ctx, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay());
- return ERROR_OK;
-}
-
-static int handle_jtag_nsrst_assert_width_command(struct command_context_s *cmd_ctx,
- char *cmd, char **args, int argc)
-{
- if (argc > 1)
- return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
- {
- unsigned delay;
- int retval = parse_uint(args[0], &delay);
- if (ERROR_OK != retval)
- return retval;
- jtag_set_nsrst_assert_width(delay);
- }
- command_print(cmd_ctx, "jtag_nsrst_assert_width: %u", jtag_get_nsrst_assert_width());
- return ERROR_OK;
-}
-
-static int handle_jtag_ntrst_assert_width_command(struct command_context_s *cmd_ctx,
- char *cmd, char **args, int argc)
-{
- if (argc > 1)
- return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
- {
- unsigned delay;
- int retval = parse_uint(args[0], &delay);
- if (ERROR_OK != retval)
- return retval;
- jtag_set_ntrst_assert_width(delay);
- }
- command_print(cmd_ctx, "jtag_ntrst_assert_width: %u", jtag_get_ntrst_assert_width());