swd: Remove support for turnaround periods other than 1
[openocd.git] / src / jtag / swd.h
1 /***************************************************************************
2 * Copyright (C) 2009-2010 by David Brownell *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 ***************************************************************************/
19
20 #ifndef SWD_H
21 #define SWD_H
22
23 #include <target/arm_adi_v5.h>
24
25 /* Bits in SWD command packets, written from host to target
26 * first bit on the wire is START
27 */
28 #define SWD_CMD_START (1 << 0) /* always set */
29 #define SWD_CMD_APnDP (1 << 1) /* set only for AP access */
30 #define SWD_CMD_RnW (1 << 2) /* set only for read access */
31 #define SWD_CMD_A32 (3 << 3) /* bits A[3:2] of register addr */
32 #define SWD_CMD_PARITY (1 << 5) /* parity of APnDP|RnW|A32 */
33 #define SWD_CMD_STOP (0 << 6) /* always clear for synch SWD */
34 #define SWD_CMD_PARK (1 << 7) /* driven high by host */
35 /* followed by TRN, 3-bits of ACK, TRN */
36
37 /**
38 * Construct a "cmd" byte, in lSB bit order, which swd_driver.read_reg()
39 * and swd_driver.write_reg() methods will use directly.
40 */
41 static inline uint8_t swd_cmd(bool is_read, bool is_ap, uint8_t regnum)
42 {
43 uint8_t cmd = (is_ap ? SWD_CMD_APnDP : 0)
44 | (is_read ? SWD_CMD_RnW : 0)
45 | ((regnum & 0xc) << 1);
46
47 /* 8 cmd bits 4:1 may be set */
48 if (parity_u32(cmd))
49 cmd |= SWD_CMD_PARITY;
50
51 /* driver handles START, STOP, and TRN */
52
53 return cmd;
54 }
55
56 /* SWD_ACK_* bits are defined in <target/arm_adi_v5.h> */
57
58 struct swd_driver {
59 /**
60 * Initialize the debug link so it can perform SWD operations.
61 *
62 * As an example, this would switch a dual-mode debug adapter
63 * into SWD mode and out of JTAG mode.
64 *
65 * @return ERROR_OK on success, else a negative fault code.
66 */
67 int (*init)(void);
68
69 /**
70 * Queued read of an AP or DP register.
71 *
72 * @param dap The DAP controlled by the SWD link.
73 * @param Command byte with APnDP/RnW/addr/parity bits
74 * @param Where to store value to read from register
75 */
76 void (*read_reg)(struct adiv5_dap *dap, uint8_t cmd, uint32_t *value);
77
78 /**
79 * Queued write of an AP or DP register.
80 *
81 * @param dap The DAP controlled by the SWD link.
82 * @param Command byte with APnDP/RnW/addr/parity bits
83 * @param Value to be written to the register
84 */
85 void (*write_reg)(struct adiv5_dap *dap, uint8_t cmd, uint32_t value);
86
87 /**
88 * Execute any queued transactions and collect the result.
89 *
90 * @param dap The DAP controlled by the SWD link.
91 * @return ERROR_OK on success, Ack response code on WAIT/FAULT
92 * or negative error code on other kinds of failure.
93 */
94 int (*run)(struct adiv5_dap *dap);
95
96 /**
97 * Configures data collection from the Single-wire
98 * trace (SWO) signal.
99 * @param swo true if SWO data collection should be routed.
100 *
101 * For example, some debug adapters include a UART which
102 * is normally connected to a microcontroller's UART TX,
103 * but which may instead be connected to SWO for use in
104 * collecting ITM (and possibly ETM) trace data.
105 *
106 * @return ERROR_OK on success, else a negative fault code.
107 */
108 int *(*trace)(struct adiv5_dap *dap, bool swo);
109 };
110
111 int swd_init_reset(struct command_context *cmd_ctx);
112 void swd_add_reset(int req_srst);
113
114 bool transport_is_swd(void);
115 bool transport_is_cmsis_dap(void);
116
117 #endif /* SWD_H */

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)