72 static int first_time;
83 if (tdi != last_tdi) {
96 if (tck != last_tck) {
212 int retval1 = 0, retval2 = 0;
283 int dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT, flags = 0, val = 0, retval;
300 dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT;
303 dir = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT;
307 dir = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT;
316 flags |= GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN;
319 flags |= GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE;
325 #ifdef GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE
326 flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE;
330 #ifdef GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP
331 flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP;
333 LOG_WARNING(
"linuxgpiod: ignoring request for pull-up on %s: not supported by gpiod v%s",
338 #ifdef GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN
339 flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN;
341 LOG_WARNING(
"linuxgpiod: ignoring request for pull-down on %s: not supported by gpiod v%s",
348 flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW;
350 struct gpiod_line_request_config
config = {
351 .consumer =
"OpenOCD",
367 LOG_INFO(
"Linux GPIOD JTAG/SWD bitbang driver");
379 LOG_ERROR(
"Require tck, tms, tdi and tdo gpios for JTAG mode");
392 int retval1, retval2;
394 LOG_ERROR(
"Require swclk and swdio gpio for SWD mode");
438 .
name =
"linuxgpiod",
const struct adapter_gpio_config * adapter_gpio_get_config(void)
Retrieves gpio configuration set with command "adapter gpio <signal_name>".
const char * adapter_gpio_get_name(enum adapter_gpio_config_index idx)
Retrieves gpio name.
@ ADAPTER_GPIO_INIT_STATE_ACTIVE
@ ADAPTER_GPIO_INIT_STATE_INPUT
@ ADAPTER_GPIO_INIT_STATE_INACTIVE
adapter_gpio_config_index
Adapter GPIO.
@ ADAPTER_GPIO_IDX_SWDIO_DIR
@ ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE
@ ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN
@ ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL
bool transport_is_swd(void)
Returns true if the current debug session is using SWD as its transport.
int bitbang_execute_queue(void)
const struct swd_driver bitbang_swd
#define DEBUG_CAP_TMS_SEQ
static struct device_config config
bool transport_is_jtag(void)
Returns true if the current debug session is using JTAG as its transport.
#define ERROR_JTAG_INIT_FAILED
static int linuxgpiod_quit(void)
struct adapter_driver linuxgpiod_adapter_driver
static const char *const linuxgpiod_transport[]
static bb_value_t linuxgpiod_read(void)
static void helper_release(enum adapter_gpio_config_index idx)
static bool linuxgpiod_jtag_mode_possible(void)
static struct bitbang_interface linuxgpiod_bitbang
static bool is_gpio_config_valid(enum adapter_gpio_config_index idx)
static struct gpiod_line * gpiod_line[ADAPTER_GPIO_IDX_NUM]
static struct jtag_interface linuxgpiod_interface
static int linuxgpiod_swdio_read(void)
static int helper_get_line(enum adapter_gpio_config_index idx)
static const struct adapter_gpio_config * adapter_gpio_config
static void linuxgpiod_swdio_drive(bool is_output)
static int linuxgpiod_write(int tck, int tms, int tdi)
static struct gpiod_chip * gpiod_chip[ADAPTER_GPIO_IDX_NUM]
static int linuxgpiod_swd_write(int swclk, int swdio)
static int linuxgpiod_reset(int trst, int srst)
static int linuxgpiod_init(void)
static bool linuxgpiod_swd_mode_possible(void)
static int linuxgpiod_blink(int on)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
Represents a driver for a debugging interface.
const char *const name
The name of the interface driver.
Configuration options for a single GPIO.
Low level callbacks (for bitbang).
bb_value_t(* read)(void)
Sample TDO and return the value.
Represents a driver for a debugging interface.
unsigned supported
Bit vector listing capabilities exposed by this driver.