OpenOCD
|
Implementation of SWD protocol with a Linux SPI device. More...
Go to the source code of this file.
Data Structures | |
struct | queue_info |
Macros | |
#define | ACK_BITS 3 |
#define | AP_DELAY_BYTES (DIV_ROUND_UP(AP_DELAY_CLOCKS, SPI_BITS)) |
#define | AP_DELAY_CLOCKS 8 |
#define | CMD_BITS 8 |
#define | DATA_BITS 32 |
#define | END_IDLE_BYTES (DIV_ROUND_UP(END_IDLE_CLOCKS, SPI_BITS)) |
#define | END_IDLE_CLOCKS 8 |
#define | MAX_QUEUE_ENTRIES 64 |
#define | PARITY_BITS 1 |
#define | SPI_BITS 8 |
#define | SPI_DESELECT_DELAY 0 |
#define | SWD_OP_BITS (MAX(SWD_WR_BITS, SWD_RD_BITS)) |
#define | SWD_OP_BYTES (DIV_ROUND_UP(SWD_OP_BITS, SPI_BITS)) |
#define | SWD_RD_BITS (CMD_BITS + TURN_BITS + ACK_BITS + DATA_BITS + PARITY_BITS + TURN_BITS) |
#define | SWD_WR_BITS (CMD_BITS + TURN_BITS + ACK_BITS + TURN_BITS + DATA_BITS + PARITY_BITS) |
#define | TURN_BITS 1 |
Functions | |
COMMAND_HANDLER (spidev_handle_mode_command) | |
COMMAND_HANDLER (spidev_handle_path_command) | |
COMMAND_HANDLER (spidev_handle_queue_entries_command) | |
static void | spi_exchange (const uint8_t *tx_data, uint8_t *rx_data, unsigned int len) |
static int | spidev_alloc_queue (unsigned int new_queue_entries) |
static void | spidev_clear_queue (void) |
static void | spidev_free_queue (void) |
static int | spidev_init (void) |
static int | spidev_khz (int khz, int *jtag_speed) |
static int | spidev_quit (void) |
static int | spidev_speed (int speed) |
static int | spidev_speed_div (int speed, int *khz) |
static int | spidev_swd_execute_queue (unsigned int end_idle_bytes) |
static int | spidev_swd_init (void) |
static void | spidev_swd_queue_cmd (uint8_t cmd, uint32_t *dst, uint32_t data, uint32_t ap_delay_clk) |
static void | spidev_swd_read_reg (uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk) |
static int | spidev_swd_run_queue (void) |
static int | spidev_swd_switch_seq (enum swd_special_seq seq) |
static void | spidev_swd_write_reg (uint8_t cmd, uint32_t value, uint32_t ap_delay_clk) |
Variables | |
struct adapter_driver | linuxspidev_adapter_driver |
static unsigned int | max_queue_entries |
static unsigned int | queue_buf_fill |
static unsigned int | queue_buf_size |
static unsigned int | queue_fill |
static struct queue_info * | queue_infos |
static int | queue_retval |
static uint8_t * | queue_rx_buf |
static uint8_t * | queue_tx_buf |
static int | spi_fd = -1 |
static uint32_t | spi_mode = SPI_MODE_3 |
static char * | spi_path |
static uint32_t | spi_speed |
static const struct command_registration | spidev_command_handlers [] |
static const struct command_registration | spidev_subcommand_handlers [] |
const struct swd_driver | spidev_swd |
static const char *const | spidev_transports [] = { "swd", NULL } |
static uint8_t * | tx_flip_buf |
Implementation of SWD protocol with a Linux SPI device.
Definition in file linuxspidev.c.
#define ACK_BITS 3 |
Definition at line 71 of file linuxspidev.c.
#define AP_DELAY_BYTES (DIV_ROUND_UP(AP_DELAY_CLOCKS, SPI_BITS)) |
Definition at line 81 of file linuxspidev.c.
#define AP_DELAY_CLOCKS 8 |
Definition at line 80 of file linuxspidev.c.
#define CMD_BITS 8 |
Definition at line 69 of file linuxspidev.c.
#define DATA_BITS 32 |
Definition at line 72 of file linuxspidev.c.
#define END_IDLE_BYTES (DIV_ROUND_UP(END_IDLE_CLOCKS, SPI_BITS)) |
Definition at line 84 of file linuxspidev.c.
#define END_IDLE_CLOCKS 8 |
Definition at line 83 of file linuxspidev.c.
#define MAX_QUEUE_ENTRIES 64 |
Definition at line 67 of file linuxspidev.c.
#define PARITY_BITS 1 |
Definition at line 73 of file linuxspidev.c.
#define SPI_BITS 8 |
Definition at line 61 of file linuxspidev.c.
#define SPI_DESELECT_DELAY 0 |
Definition at line 64 of file linuxspidev.c.
#define SWD_OP_BITS (MAX(SWD_WR_BITS, SWD_RD_BITS)) |
Definition at line 77 of file linuxspidev.c.
#define SWD_OP_BYTES (DIV_ROUND_UP(SWD_OP_BITS, SPI_BITS)) |
Definition at line 78 of file linuxspidev.c.
Definition at line 76 of file linuxspidev.c.
Definition at line 75 of file linuxspidev.c.
#define TURN_BITS 1 |
Definition at line 70 of file linuxspidev.c.
COMMAND_HANDLER | ( | spidev_handle_mode_command | ) |
Definition at line 554 of file linuxspidev.c.
References CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and spi_mode.
COMMAND_HANDLER | ( | spidev_handle_path_command | ) |
Definition at line 539 of file linuxspidev.c.
References CMD_ARGC, CMD_ARGV, ERROR_COMMAND_SYNTAX_ERROR, ERROR_FAIL, ERROR_OK, LOG_ERROR, and spi_path.
COMMAND_HANDLER | ( | spidev_handle_queue_entries_command | ) |
Definition at line 563 of file linuxspidev.c.
References CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, ERROR_COMMAND_SYNTAX_ERROR, and spidev_alloc_queue().
|
static |
Definition at line 112 of file linuxspidev.c.
References flip_u32(), LOG_DEBUG, LOG_ERROR, LOG_OUTPUT, NULL, queue_buf_size, SPI_BITS, SPI_DESELECT_DELAY, spi_fd, spi_speed, and tx_flip_buf.
Referenced by spidev_swd_execute_queue(), and spidev_swd_switch_seq().
|
static |
Definition at line 244 of file linuxspidev.c.
References AP_DELAY_BYTES, END_IDLE_BYTES, ERROR_FAIL, ERROR_OK, LOG_DEBUG, LOG_ERROR, max_queue_entries, queue_buf_fill, queue_buf_size, queue_fill, queue_infos, queue_rx_buf, queue_tx_buf, spidev_clear_queue(), spidev_free_queue(), SWD_OP_BYTES, and tx_flip_buf.
Referenced by COMMAND_HANDLER(), and spidev_init().
|
static |
Definition at line 233 of file linuxspidev.c.
References max_queue_entries, queue_buf_fill, queue_buf_size, queue_fill, queue_infos, queue_rx_buf, queue_tx_buf, and tx_flip_buf.
Referenced by spidev_alloc_queue(), and spidev_swd_execute_queue().
|
static |
Definition at line 215 of file linuxspidev.c.
References max_queue_entries, NULL, queue_buf_size, queue_infos, queue_rx_buf, queue_tx_buf, and tx_flip_buf.
Referenced by spidev_alloc_queue(), and spidev_quit().
|
static |
Definition at line 286 of file linuxspidev.c.
References ERROR_JTAG_INIT_FAILED, ERROR_OK, LOG_ERROR, LOG_INFO, MAX_QUEUE_ENTRIES, max_queue_entries, mode, SPI_BITS, spi_fd, spi_mode, spi_path, and spidev_alloc_queue().
|
static |
Definition at line 204 of file linuxspidev.c.
References ERROR_FAIL, ERROR_OK, and LOG_DEBUG.
|
static |
Definition at line 344 of file linuxspidev.c.
References ERROR_OK, NULL, spi_fd, spi_path, and spidev_free_queue().
|
static |
Definition at line 183 of file linuxspidev.c.
References ERROR_FAIL, ERROR_OK, LOG_ERROR, spi_fd, and spi_speed.
|
static |
Definition at line 198 of file linuxspidev.c.
References ERROR_OK.
|
static |
Definition at line 366 of file linuxspidev.c.
References ACK_BITS, buf_get_u32(), queue_info::buf_idx, cmd, CMD_BITS, DATA_BITS, ERROR_FAIL, ERROR_OK, LOG_CUSTOM_LEVEL, LOG_DEBUG_IO, LOG_ERROR, LOG_LVL_DEBUG, LOG_LVL_DEBUG_IO, parity(), PARITY_BITS, parity_u32(), queue_buf_fill, queue_fill, queue_infos, queue_retval, queue_rx_buf, queue_tx_buf, queue_info::rx_ptr, spi_exchange(), spidev_clear_queue(), SWD_ACK_FAULT, SWD_ACK_OK, swd_ack_to_error_code(), SWD_ACK_WAIT, SWD_CMD_A32, SWD_CMD_APNDP, swd_cmd_returns_ack(), SWD_CMD_RNW, true, and TURN_BITS.
Referenced by spidev_swd_queue_cmd(), and spidev_swd_run_queue().
|
static |
Definition at line 360 of file linuxspidev.c.
|
static |
Definition at line 445 of file linuxspidev.c.
References ACK_BITS, queue_info::buf_idx, buf_set_u32(), cmd, CMD_BITS, DATA_BITS, DIV_ROUND_UP, END_IDLE_BYTES, ERROR_OK, max_queue_entries, PARITY_BITS, parity_u32(), queue_buf_fill, queue_buf_size, queue_fill, queue_infos, queue_retval, queue_tx_buf, queue_info::rx_ptr, SPI_BITS, spidev_swd_execute_queue(), SWD_CMD_PARK, SWD_CMD_RNW, SWD_CMD_START, SWD_OP_BITS, and TURN_BITS.
Referenced by spidev_swd_read_reg(), and spidev_swd_write_reg().
|
static |
Definition at line 488 of file linuxspidev.c.
References cmd, spidev_swd_queue_cmd(), and SWD_CMD_RNW.
|
static |
Definition at line 436 of file linuxspidev.c.
References END_IDLE_BYTES, and spidev_swd_execute_queue().
|
static |
Definition at line 500 of file linuxspidev.c.
References DORMANT_TO_JTAG, DORMANT_TO_SWD, ERROR_FAIL, ERROR_OK, JTAG_TO_DORMANT, JTAG_TO_SWD, LINE_RESET, LOG_DEBUG, LOG_DEBUG_IO, LOG_ERROR, NULL, SPI_BITS, spi_exchange(), swd_seq_dormant_to_jtag, swd_seq_dormant_to_jtag_len, swd_seq_dormant_to_swd, swd_seq_dormant_to_swd_len, swd_seq_jtag_to_dormant, swd_seq_jtag_to_dormant_len, swd_seq_jtag_to_swd, swd_seq_jtag_to_swd_len, swd_seq_line_reset, swd_seq_line_reset_len, swd_seq_swd_to_dormant, swd_seq_swd_to_dormant_len, swd_seq_swd_to_jtag, swd_seq_swd_to_jtag_len, SWD_TO_DORMANT, and SWD_TO_JTAG.
|
static |
Definition at line 494 of file linuxspidev.c.
References cmd, NULL, spidev_swd_queue_cmd(), and SWD_CMD_RNW.
struct adapter_driver linuxspidev_adapter_driver |
Definition at line 620 of file linuxspidev.c.
|
static |
Definition at line 100 of file linuxspidev.c.
Referenced by spidev_alloc_queue(), spidev_clear_queue(), spidev_free_queue(), spidev_init(), and spidev_swd_queue_cmd().
|
static |
Definition at line 102 of file linuxspidev.c.
Referenced by spidev_alloc_queue(), spidev_clear_queue(), spidev_swd_execute_queue(), and spidev_swd_queue_cmd().
|
static |
Definition at line 103 of file linuxspidev.c.
Referenced by spi_exchange(), spidev_alloc_queue(), spidev_clear_queue(), spidev_free_queue(), and spidev_swd_queue_cmd().
|
static |
Definition at line 101 of file linuxspidev.c.
Referenced by spidev_alloc_queue(), spidev_clear_queue(), spidev_swd_execute_queue(), and spidev_swd_queue_cmd().
|
static |
Definition at line 104 of file linuxspidev.c.
Referenced by spidev_alloc_queue(), spidev_clear_queue(), spidev_free_queue(), spidev_swd_execute_queue(), and spidev_swd_queue_cmd().
|
static |
Definition at line 99 of file linuxspidev.c.
Referenced by spidev_swd_execute_queue(), and spidev_swd_queue_cmd().
|
static |
Definition at line 106 of file linuxspidev.c.
Referenced by spidev_alloc_queue(), spidev_clear_queue(), spidev_free_queue(), and spidev_swd_execute_queue().
|
static |
Definition at line 105 of file linuxspidev.c.
Referenced by spidev_alloc_queue(), spidev_clear_queue(), spidev_free_queue(), spidev_swd_execute_queue(), and spidev_swd_queue_cmd().
|
static |
Definition at line 87 of file linuxspidev.c.
Referenced by spi_exchange(), spidev_init(), spidev_quit(), and spidev_speed().
|
static |
Definition at line 91 of file linuxspidev.c.
Referenced by COMMAND_HANDLER(), and spidev_init().
|
static |
Definition at line 90 of file linuxspidev.c.
Referenced by COMMAND_HANDLER(), spidev_init(), and spidev_quit().
|
static |
Definition at line 92 of file linuxspidev.c.
Referenced by spi_exchange(), and spidev_speed().
|
static |
Definition at line 563 of file linuxspidev.c.
|
static |
Definition at line 563 of file linuxspidev.c.
const struct swd_driver spidev_swd |
Definition at line 563 of file linuxspidev.c.
|
static |
Definition at line 620 of file linuxspidev.c.
|
static |
Definition at line 107 of file linuxspidev.c.
Referenced by spi_exchange(), spidev_alloc_queue(), spidev_clear_queue(), and spidev_free_queue().