+// SPDX-License-Identifier: GPL-2.0-or-later
+
/***************************************************************************
*
* Copyright (C) 2010 by David Brownell
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
***************************************************************************/
/**
* is a transport level interface, with "target/arm_adi_v5.[hc]" code
* understanding operation semantics, shared with the JTAG transport.
*
- * Single-DAP support only.
+ * Single DAP and multidrop-SWD support.
*
* for details, see "ARM IHI 0031A"
* ARM Debug Interface v5 Architecture Specification
assert(dap_is_multidrop(dap));
swd_send_sequence(dap, LINE_RESET);
+ /* From ARM IHI 0074C ADIv6.0, chapter B4.3.3 "Connection and line reset
+ * sequence":
+ * - line reset sets DP_SELECT_DPBANK to zero;
+ * - read of DP_DPIDR takes the connection out of reset;
+ * - write of DP_TARGETSEL keeps the connection in reset;
+ * - other accesses return protocol error (SWDIO not driven by target).
+ *
+ * Read DP_DPIDR to get out of reset. Initialize dap->select to zero to
+ * skip the write to DP_SELECT, avoiding the protocol error. Set again
+ * dap->select to DP_SELECT_INVALID because the rest of the register is
+ * unknown after line reset.
+ */
+ dap->select = 0;
retval = swd_queue_dp_write_inner(dap, DP_TARGETSEL, dap->multidrop_targetsel);
if (retval != ERROR_OK)
return retval;
}
+ dap->select = DP_SELECT_INVALID;
+
retval = swd_queue_dp_read_inner(dap, DP_DLPIDR, &dlpidr);
if (retval != ERROR_OK)
return retval;
LOG_DEBUG("Failed to select multidrop %s, retrying...",
adiv5_dap_name(dap));
+ /* we going to retry localy, do not ask for full reconnect */
+ dap->do_reconnect = false;
}
return retval;
dap->switch_through_dormant = !dap->switch_through_dormant;
} while (timeval_ms() < timeout);
+
dap->select = DP_SELECT_INVALID;
if (retval != ERROR_OK) {
* REVISIT can we verify "just one SWD DAP" here/early?
*/
.name = "newdap",
- .jim_handler = jim_jtag_newtap,
+ .handler = handle_jtag_newtap,
.mode = COMMAND_CONFIG,
- .help = "declare a new SWD DAP"
+ .help = "declare a new SWD DAP",
+ .usage = "basename dap_type ['-irlen' count] "
+ "['-enable'|'-disable'] "
+ "['-expected_id' number] "
+ "['-ignore-version'] "
+ "['-ignore-bypass'] "
+ "['-ircapture' number] "
+ "['-mask' number]",
},
COMMAND_REGISTRATION_DONE
};