swim: fix adapter speed handling
[fw/openocd] / src / jtag / swim.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /*
4  * Copyright (C) 2020 by Antonio Borneo <borneo.antonio@gmail.com
5  */
6
7 /**
8  * @file
9  * This file implements support for STMicroelectronics debug protocol SWIM
10  * (Single Wire Interface Module).
11  */
12
13 #ifndef OPENOCD_JTAG_SWIM_H
14 #define OPENOCD_JTAG_SWIM_H
15
16 #define SWIM_FREQ_LOW   363
17 #define SWIM_FREQ_HIGH  800
18
19 struct swim_driver {
20         /**
21          * Send SRST (system reset) command to target.
22          *
23          * @return ERROR_OK on success, else a fault code.
24          */
25         int (*srst)(void);
26
27         /**
28          * Read target memory through ROTF (read on-the-fly) command.
29          *
30          * @param addr Start address to read data from target memory.
31          * @param size Size in bytes of data units, 1, 2 or 4.
32          * @param count Number of units (size units, not bytes) to read.
33          * @param buffer Data buffer to receive data.
34          * @return ERROR_OK on success, else a fault code.
35          */
36         int (*read_mem)(uint32_t addr, uint32_t size, uint32_t count,
37                                         uint8_t *buffer);
38
39         /**
40          * Write target memory through WOTF (write on-the-fly) command.
41          *
42          * @param addr Start address to write data to target memory.
43          * @param size Size in bytes of data units, 1, 2 or 4.
44          * @param count Number of units (size units, not bytes) to write.
45          * @param buffer Data buffer to write.
46          * @return ERROR_OK on success, else a fault code.
47          */
48         int (*write_mem)(uint32_t addr, uint32_t size, uint32_t count,
49                                          const uint8_t *buffer);
50
51         /**
52          * Reconnect to the target.
53          * Should be reworked to be more generic and not linked to current
54          * implementation in stlink driver.
55          *
56          * @return ERROR_OK on success, else a fault code.
57          */
58         int (*reconnect)(void);
59 };
60
61 int swim_system_reset(void);
62 int swim_read_mem(uint32_t addr, uint32_t size, uint32_t count,
63                                   uint8_t *buffer);
64 int swim_write_mem(uint32_t addr, uint32_t size, uint32_t count,
65                                    const uint8_t *buffer);
66 int swim_reconnect(void);
67
68 #endif /* OPENOCD_JTAG_SWIM_H */