*
* Assume here that there will be less than 10000 gpios on a system
*/
-static int is_gpio_valid(int gpio)
+static bool is_gpio_valid(int gpio)
{
return gpio >= 0 && gpio < 10000;
}
snprintf(gpiostr, sizeof(gpiostr), "%d", gpio);
if (open_write_close("/sys/class/gpio/unexport", gpiostr) < 0)
LOG_ERROR("Couldn't unexport gpio %d", gpio);
-
- return;
}
/*
static const char * const sysfsgpio_transports[] = { "jtag", "swd", NULL };
-struct jtag_interface sysfsgpio_interface = {
- .name = "sysfsgpio",
+static struct jtag_interface sysfsgpio_interface = {
.supported = DEBUG_CAP_TMS_SEQ,
.execute_queue = bitbang_execute_queue,
+};
+
+struct adapter_driver sysfsgpio_adapter_driver = {
+ .name = "sysfsgpio",
.transports = sysfsgpio_transports,
- .swd = &bitbang_swd,
.commands = sysfsgpio_command_handlers,
+
.init = sysfsgpio_init,
.quit = sysfsgpio_quit,
+ .reset = sysfsgpio_reset,
+
+ .jtag_ops = &sysfsgpio_interface,
+ .swd_ops = &bitbang_swd,
};
static struct bitbang_interface sysfsgpio_bitbang = {
.read = sysfsgpio_read,
.write = sysfsgpio_write,
- .reset = sysfsgpio_reset,
.swdio_read = sysfsgpio_swdio_read,
.swdio_drive = sysfsgpio_swdio_drive,
.blink = 0
static bool sysfsgpio_jtag_mode_possible(void)
{
if (!is_gpio_valid(tck_gpio))
- return 0;
+ return false;
if (!is_gpio_valid(tms_gpio))
- return 0;
+ return false;
if (!is_gpio_valid(tdi_gpio))
- return 0;
+ return false;
if (!is_gpio_valid(tdo_gpio))
- return 0;
- return 1;
+ return false;
+ return true;
}
static bool sysfsgpio_swd_mode_possible(void)
{
if (!is_gpio_valid(swclk_gpio))
- return 0;
+ return false;
if (!is_gpio_valid(swdio_gpio))
- return 0;
- return 1;
+ return false;
+ return true;
}
static int sysfsgpio_init(void)
goto out_error;
}
- if (sysfsgpio_swd_mode_possible()) {
- if (swd_mode)
- bitbang_swd_switch_seq(JTAG_TO_SWD);
- else
- bitbang_swd_switch_seq(SWD_TO_JTAG);
- }
-
return ERROR_OK;
out_error:
cleanup_all_fds();
return ERROR_OK;
}
-