jtag/drivers/ftdi: require defining SWD_EN signal for SWD mode
[openocd.git] / src / jtag / drivers / ftdi.c
index 292a44107417075a74c646a231c88cb00e9bb96a..b65dd2ac444f66a265037597e3080fbe3bec1a9f 100644 (file)
@@ -127,8 +127,6 @@ static uint16_t output;
 static uint16_t direction;
 static uint16_t jtag_output_init;
 static uint16_t jtag_direction_init;
-static uint16_t swd_output_init;
-static uint16_t swd_direction_init;
 
 static int ftdi_swd_switch_seq(struct adiv5_dap *dap, enum swd_special_seq seq);
 
@@ -634,8 +632,19 @@ static int ftdi_initialize(void)
        if (!mpsse_ctx)
                return ERROR_JTAG_INIT_FAILED;
 
-       output = swd_mode ? swd_output_init : jtag_output_init;
-       direction = swd_mode ? swd_direction_init : jtag_direction_init;
+       output = jtag_output_init;
+       direction = jtag_direction_init;
+
+       if (swd_mode) {
+               struct signal *sig = find_signal_by_name("SWD_EN");
+               if (!sig) {
+                       LOG_ERROR("SWD mode is active but SWD_EN signal is not defined");
+                       return ERROR_JTAG_INIT_FAILED;
+               }
+               /* A dummy SWD_EN would have zero mask */
+               if (sig->data_mask)
+                       ftdi_set_signal(sig, '1');
+       }
 
        mpsse_set_data_bits_low_byte(mpsse_ctx, output & 0xff, direction & 0xff);
        mpsse_set_data_bits_high_byte(mpsse_ctx, output >> 8, direction >> 8);
@@ -707,17 +716,6 @@ COMMAND_HANDLER(ftdi_handle_layout_init_command)
        return ERROR_OK;
 }
 
-COMMAND_HANDLER(ftdi_handle_layout_init_swd_command)
-{
-       if (CMD_ARGC != 2)
-               return ERROR_COMMAND_SYNTAX_ERROR;
-
-       COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], swd_output_init);
-       COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], swd_direction_init);
-
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(ftdi_handle_layout_signal_command)
 {
        if (CMD_ARGC < 1)
@@ -863,17 +861,7 @@ static const struct command_registration ftdi_command_handlers[] = {
                .handler = &ftdi_handle_layout_init_command,
                .mode = COMMAND_CONFIG,
                .help = "initialize the FTDI GPIO signals used "
-                       "to control output-enables and reset signals"
-                       "when JTAG mode is selected",
-               .usage = "data direction",
-       },
-       {
-               .name = "ftdi_layout_init_swd",
-               .handler = &ftdi_handle_layout_init_swd_command,
-               .mode = COMMAND_CONFIG,
-               .help = "initialize the FTDI GPIO signals used "
-                       "to control output-enables and reset signals"
-                       "when SWD mode is selected",
+                       "to control output-enables and reset signals",
                .usage = "data direction",
        },
        {

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)