jtag: align adapter speed code to new structure
[openocd.git] / src / jtag / adapter.h
bloba66fef1a7b0cce2a845eba6bb781e6f142b38e00
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Copyright (c) 2018 Pengutronix, Oleksij Rempel <kernel@pengutronix.de>
4 */
6 #ifndef OPENOCD_JTAG_ADAPTER_H
7 #define OPENOCD_JTAG_ADAPTER_H
9 #include <stdbool.h>
10 #include <stddef.h>
11 #include <stdint.h>
13 struct command_context;
15 /** Initialize debug adapter upon startup. */
16 int adapter_init(struct command_context *cmd_ctx);
18 /** Shutdown the debug adapter upon program exit. */
19 int adapter_quit(void);
21 /** @returns true if adapter has been initialized */
22 bool is_adapter_initialized(void);
24 /** @returns USB location string set with command 'adapter usb location' */
25 const char *adapter_usb_get_location(void);
27 /** @returns true if USB location string is "<dev_bus>-<port_path[0]>[.<port_path[1]>[...]]" */
28 bool adapter_usb_location_equal(uint8_t dev_bus, uint8_t *port_path, size_t path_len);
30 /** @returns The current adapter speed setting. */
31 int adapter_get_speed(int *speed);
33 /**
34 * Given a @a speed setting, use the interface @c speed_div callback to
35 * adjust the setting.
36 * @param speed The speed setting to convert back to readable kHz.
37 * @returns ERROR_OK if the interface has not been initialized or on success;
38 * otherwise, the error code produced by the @c speed_div callback.
40 int adapter_get_speed_readable(int *speed);
42 /** Attempt to configure the adapter for the specified kHz. */
43 int adapter_config_khz(unsigned int khz);
45 /**
46 * Attempt to enable RTCK/RCLK. If that fails, fallback to the
47 * specified frequency.
49 int adapter_config_rclk(unsigned int fallback_speed_khz);
51 /** Retrieves the clock speed of the adapter in kHz. */
52 unsigned int adapter_get_speed_khz(void);
54 #endif /* OPENOCD_JTAG_ADAPTER_H */