From: Franck Jullien Date: Sun, 3 Feb 2013 17:15:13 +0000 (+0100) Subject: jtag_interface: .speed can be NULL when not needed X-Git-Tag: v0.7.0-rc1~82 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=87668aebf1851c06af2513ab5f27ebb9ebf1ff16 jtag_interface: .speed can be NULL when not needed adapter_init (core.c) won't check speed configuration of the selected interface if it's not needed (.speed = NULL). When it's not needed, we can now omit adapter_khz in init scripts and we don't have to implement dummy handlers for speed_div and khz functions. It also removes calls to adapter_khz in interface configuration files when not used anymore. Change-Id: I6eb1894385503fede542a368f297cec6565eed44 Signed-off-by: Franck Jullien Reviewed-on: http://openocd.zylin.com/1131 Tested-by: jenkins Reviewed-by: Andreas Fritiofson --- diff --git a/src/jtag/core.c b/src/jtag/core.c index 9f1e4cf039..86ba706bac 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1371,6 +1371,11 @@ int adapter_init(struct command_context *cmd_ctx) return retval; } + if (jtag->speed == NULL) { + LOG_INFO("This adapter doesn't support configurable speed"); + return ERROR_OK; + } + if (CLOCK_MODE_UNSELECTED == clock_mode) { LOG_ERROR("An adapter speed is not selected in the init script." " Insert a call to adapter_khz or jtag_rclk to proceed."); diff --git a/src/jtag/drivers/at91rm9200.c b/src/jtag/drivers/at91rm9200.c index 3bba368fab..066d6b68a3 100644 --- a/src/jtag/drivers/at91rm9200.c +++ b/src/jtag/drivers/at91rm9200.c @@ -115,7 +115,6 @@ static int at91rm9200_read(void); static void at91rm9200_write(int tck, int tms, int tdi); static void at91rm9200_reset(int trst, int srst); -static int at91rm9200_speed(int speed); static int at91rm9200_init(void); static int at91rm9200_quit(void); @@ -163,12 +162,6 @@ static void at91rm9200_reset(int trst, int srst) pio_base[device->SRST_PIO + PIO_CODR] = device->SRST_MASK; } -static int at91rm9200_speed(int speed) -{ - - return ERROR_OK; -} - COMMAND_HANDLER(at91rm9200_handle_device_command) { if (CMD_ARGC == 0) @@ -196,7 +189,6 @@ static const struct command_registration at91rm9200_command_handlers[] = { struct jtag_interface at91rm9200_interface = { .name = "at91rm9200", .execute_queue = bitbang_execute_queue, - .speed = at91rm9200_speed, .commands = at91rm9200_command_handlers, .init = at91rm9200_init, .quit = at91rm9200_quit, diff --git a/src/jtag/drivers/buspirate.c b/src/jtag/drivers/buspirate.c index 10b5e0fde6..ad9be41e2c 100644 --- a/src/jtag/drivers/buspirate.c +++ b/src/jtag/drivers/buspirate.c @@ -32,8 +32,6 @@ #undef DEBUG_SERIAL /*#define DEBUG_SERIAL */ static int buspirate_execute_queue(void); -static int buspirate_speed(int speed); -static int buspirate_khz(int khz, int *jtag_speed); static int buspirate_init(void); static int buspirate_quit(void); @@ -117,19 +115,6 @@ static int buspirate_serial_read(int fd, char *buf, int size); static void buspirate_serial_close(int fd); static void buspirate_print_buffer(char *buf, int size); -static int buspirate_speed(int speed) -{ - /* TODO */ - LOG_INFO("Want to set speed to %dkHz, but not implemented yet", speed); - return ERROR_OK; -} - -static int buspirate_khz(int khz, int *jtag_speed) -{ - *jtag_speed = khz; - return ERROR_OK; -} - static int buspirate_execute_queue(void) { /* currently processed command */ @@ -426,8 +411,6 @@ static const struct command_registration buspirate_command_handlers[] = { struct jtag_interface buspirate_interface = { .name = "buspirate", .execute_queue = buspirate_execute_queue, - .speed = buspirate_speed, - .khz = buspirate_khz, .commands = buspirate_command_handlers, .init = buspirate_init, .quit = buspirate_quit diff --git a/src/jtag/drivers/ep93xx.c b/src/jtag/drivers/ep93xx.c index 978113076e..ff4535bd3e 100644 --- a/src/jtag/drivers/ep93xx.c +++ b/src/jtag/drivers/ep93xx.c @@ -47,7 +47,6 @@ static int ep93xx_read(void); static void ep93xx_write(int tck, int tms, int tdi); static void ep93xx_reset(int trst, int srst); -static int ep93xx_speed(int speed); static int ep93xx_init(void); static int ep93xx_quit(void); @@ -59,7 +58,6 @@ struct jtag_interface ep93xx_interface = { .supported = DEBUG_CAP_TMS_SEQ, .execute_queue = bitbang_execute_queue, - .speed = ep93xx_speed, .init = ep93xx_init, .quit = ep93xx_quit, }; @@ -114,12 +112,6 @@ static void ep93xx_reset(int trst, int srst) nanosleep(&ep93xx_zzzz, NULL); } -static int ep93xx_speed(int speed) -{ - - return ERROR_OK; -} - static int set_gonk_mode(void) { void *syscon; diff --git a/src/jtag/drivers/gw16012.c b/src/jtag/drivers/gw16012.c index bf027f8fe9..a37f8caff4 100644 --- a/src/jtag/drivers/gw16012.c +++ b/src/jtag/drivers/gw16012.c @@ -146,12 +146,6 @@ static void gw16012_reset(int trst, int srst) gw16012_control(0x0b); } -static int gw16012_speed(int speed) -{ - - return ERROR_OK; -} - static void gw16012_end_state(tap_state_t state) { if (tap_is_state_stable(state)) @@ -547,6 +541,5 @@ struct jtag_interface gw16012_interface = { .init = gw16012_init, .quit = gw16012_quit, - .speed = gw16012_speed, .execute_queue = gw16012_execute_queue, }; diff --git a/src/jtag/drivers/opendous.c b/src/jtag/drivers/opendous.c index 3a6cf5c693..b13cbe054a 100644 --- a/src/jtag/drivers/opendous.c +++ b/src/jtag/drivers/opendous.c @@ -86,9 +86,6 @@ static uint8_t usb_out_buffer[OPENDOUS_OUT_BUFFER_SIZE]; /* External interface functions */ static int opendous_execute_queue(void); -static int opendous_speed(int speed); -static int opendous_speed_div(int speed, int *khz); -static int opendous_khz(int khz, int *jtag_speed); static int opendous_init(void); static int opendous_quit(void); @@ -194,9 +191,6 @@ struct jtag_interface opendous_interface = { .name = "opendous", .commands = opendous_command_handlers, .execute_queue = opendous_execute_queue, - .speed = opendous_speed, - .speed_div = opendous_speed_div, - .khz = opendous_khz, .init = opendous_init, .quit = opendous_quit, }; @@ -276,33 +270,6 @@ static int opendous_execute_queue(void) return opendous_tap_execute(); } -/* Sets speed in kHz. */ -static int opendous_speed(int speed) -{ - if (speed <= OPENDOUS_MAX_SPEED) { - /* one day... */ - return ERROR_OK; - } else - LOG_INFO("Requested speed %dkHz exceeds maximum of %dkHz, ignored", speed, OPENDOUS_MAX_SPEED); - - return ERROR_OK; -} - -static int opendous_speed_div(int speed, int *khz) -{ - *khz = speed; - - return ERROR_OK; -} - -static int opendous_khz(int khz, int *jtag_speed) -{ - *jtag_speed = khz; - /* TODO: convert this into delay value for opendous */ - - return ERROR_OK; -} - static int opendous_init(void) { int check_cnt; diff --git a/src/jtag/drivers/osbdm.c b/src/jtag/drivers/osbdm.c index 66dbf3de1d..2560db18f2 100644 --- a/src/jtag/drivers/osbdm.c +++ b/src/jtag/drivers/osbdm.c @@ -690,33 +690,12 @@ static int osbdm_init(void) return ERROR_OK; } -static int osbdm_khz(int khz, int *speed) -{ - *speed = khz; - return ERROR_OK; -} - -static int osbdm_speed(int speed) -{ - return ERROR_OK; -} - -static int osbdm_speed_div(int speed, int *khz) -{ - *khz = speed; - return ERROR_OK; -} - struct jtag_interface osbdm_interface = { .name = "osbdm", .transports = jtag_only, .execute_queue = osbdm_execute_queue, - .khz = osbdm_khz, - .speed = osbdm_speed, - .speed_div = osbdm_speed_div, - .init = osbdm_init, .quit = osbdm_quit }; diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c index 73d9cfcc0d..f6691bb625 100644 --- a/src/jtag/drivers/remote_bitbang.c +++ b/src/jtag/drivers/remote_bitbang.c @@ -130,11 +130,6 @@ static struct bitbang_interface remote_bitbang_bitbang = { .blink = &remote_bitbang_blink, }; -static int remote_bitbang_speed(int speed) -{ - return ERROR_OK; -} - static int remote_bitbang_init_tcp(void) { LOG_INFO("Connecting to %s:%i", remote_bitbang_host, remote_bitbang_port); @@ -235,19 +230,6 @@ static int remote_bitbang_init(void) return remote_bitbang_init_tcp(); } -static int remote_bitbang_khz(int khz, int *jtag_speed) -{ - *jtag_speed = 0; - return ERROR_OK; -} - -static int remote_bitbang_speed_div(int speed, int *khz) -{ - /* I don't think this really matters any. */ - *khz = 1; - return ERROR_OK; -} - COMMAND_HANDLER(remote_bitbang_handle_remote_bitbang_port_command) { if (CMD_ARGC == 1) { @@ -290,10 +272,7 @@ static const struct command_registration remote_bitbang_command_handlers[] = { struct jtag_interface remote_bitbang_interface = { .name = "remote_bitbang", .execute_queue = &bitbang_execute_queue, - .speed = &remote_bitbang_speed, .commands = remote_bitbang_command_handlers, .init = &remote_bitbang_init, .quit = &remote_bitbang_quit, - .khz = &remote_bitbang_khz, - .speed_div = &remote_bitbang_speed_div, }; diff --git a/src/jtag/drivers/sysfsgpio.c b/src/jtag/drivers/sysfsgpio.c index 1cad268936..283ec445a2 100644 --- a/src/jtag/drivers/sysfsgpio.c +++ b/src/jtag/drivers/sysfsgpio.c @@ -258,28 +258,6 @@ static void sysfsgpio_reset(int trst, int srst) } } -/* No speed control is implemented yet */ -static int sysfsgpio_speed(int speed) -{ - return ERROR_OK; -} - -static int sysfsgpio_khz(int khz, int *jtag_speed) -{ - /* no adaptive clocking */ - if (khz == 0) - return ERROR_FAIL; - - *jtag_speed = 0; - return ERROR_OK; -} - -static int sysfsgpio_speed_div(int speed, int *khz) -{ - *khz = 1; - return ERROR_OK; -} - /* gpio numbers for each gpio. Negative values are invalid */ static int tck_gpio = -1; static int tms_gpio = -1; @@ -415,9 +393,6 @@ struct jtag_interface sysfsgpio_interface = { .supported = DEBUG_CAP_TMS_SEQ, .execute_queue = bitbang_execute_queue, .transports = jtag_only, - .speed = sysfsgpio_speed, - .khz = sysfsgpio_khz, - .speed_div = sysfsgpio_speed_div, .commands = sysfsgpio_command_handlers, .init = sysfsgpio_init, .quit = sysfsgpio_quit, diff --git a/src/jtag/drivers/usb_blaster.c b/src/jtag/drivers/usb_blaster.c index 088ae34f80..91c4836538 100644 --- a/src/jtag/drivers/usb_blaster.c +++ b/src/jtag/drivers/usb_blaster.c @@ -297,27 +297,6 @@ static void usb_blaster_write(int tck, int tms, int tdi) usb_blaster_addtowritebuffer(out_value, false); } -static int usb_blaster_speed(int speed) -{ -#if BUILD_USB_BLASTER_FTD2XX == 1 - LOG_DEBUG("TODO: usb_blaster_speed() isn't implemented for libftd2xx!"); -#elif BUILD_USB_BLASTER_LIBFTDI == 1 - LOG_DEBUG("TODO: usb_blaster_speed() isn't optimally implemented!"); - - /* TODO: libftdi's ftdi_set_baudrate chokes on high rates, use lowlevel - * usb function instead! And additionally allow user to throttle. - */ - if (ftdi_set_baudrate(&ftdic, 3000000 / 4) < 0) { - LOG_ERROR("Can't set baud rate to max: %s", - ftdi_get_error_string(&ftdic)); - return ERROR_JTAG_DEVICE_ERROR; - } - ; -#endif - - return ERROR_OK; -} - static void usb_blaster_reset(int trst, int srst) { LOG_DEBUG("TODO: usb_blaster_reset(%d,%d) isn't implemented!", @@ -588,7 +567,6 @@ struct jtag_interface usb_blaster_interface = { .execute_queue = bitbang_execute_queue, - .speed = usb_blaster_speed, .init = usb_blaster_init, .quit = usb_blaster_quit, }; diff --git a/src/jtag/drivers/usbprog.c b/src/jtag/drivers/usbprog.c index e90d56931e..77e7a7a824 100644 --- a/src/jtag/drivers/usbprog.c +++ b/src/jtag/drivers/usbprog.c @@ -96,11 +96,6 @@ static void usbprog_jtag_write_slice(struct usbprog_jtag *usbprog_jtag, unsigned static void usbprog_jtag_set_bit(struct usbprog_jtag *usbprog_jtag, int bit, int value); /* static int usbprog_jtag_get_bit(struct usbprog_jtag *usbprog_jtag, int bit); */ -static int usbprog_speed(int speed) -{ - return ERROR_OK; -} - static int usbprog_execute_queue(void) { struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ @@ -621,7 +616,6 @@ struct jtag_interface usbprog_interface = { .name = "usbprog", .execute_queue = usbprog_execute_queue, - .speed = usbprog_speed, .init = usbprog_init, .quit = usbprog_quit }; diff --git a/src/jtag/hla/hla_interface.c b/src/jtag/hla/hla_interface.c index 5f493ffe24..53ad8e7173 100644 --- a/src/jtag/hla/hla_interface.c +++ b/src/jtag/hla/hla_interface.c @@ -108,25 +108,6 @@ static int hl_interface_quit(void) return ERROR_OK; } -static int hl_interface_speed(int speed) -{ - LOG_DEBUG("hl_interface_speed: ignore speed %d", speed); - - return ERROR_OK; -} - -static int hl_speed_div(int speed, int *khz) -{ - *khz = speed; - return ERROR_OK; -} - -static int hl_khz(int khz, int *jtag_speed) -{ - *jtag_speed = khz; - return ERROR_OK; -} - static int hl_interface_execute_queue(void) { LOG_DEBUG("hl_interface_execute_queue: ignored"); @@ -279,8 +260,5 @@ struct jtag_interface hl_interface = { .transports = hl_transports, .init = hl_interface_init, .quit = hl_interface_quit, - .speed = hl_interface_speed, - .speed_div = hl_speed_div, - .khz = hl_khz, .execute_queue = hl_interface_execute_queue, }; diff --git a/tcl/interface/altera-usb-blaster.cfg b/tcl/interface/altera-usb-blaster.cfg index 9f542d0a4c..f19abfebe4 100644 --- a/tcl/interface/altera-usb-blaster.cfg +++ b/tcl/interface/altera-usb-blaster.cfg @@ -8,4 +8,3 @@ interface usb_blaster # These are already the defaults. # usb_blaster_vid_pid 0x09FB 0x6001 # usb_blaster_device_desc "USB-Blaster" -adapter_khz 3000 diff --git a/tcl/interface/osbdm.cfg b/tcl/interface/osbdm.cfg index 4d0c79d3d9..e88ce50b59 100644 --- a/tcl/interface/osbdm.cfg +++ b/tcl/interface/osbdm.cfg @@ -5,8 +5,3 @@ # interface osbdm reset_config srst_only - -# -# OSBDM doesn't support speed control -# -adapter_khz 1 diff --git a/tcl/interface/stlink-v1.cfg b/tcl/interface/stlink-v1.cfg index 7f4a6720b2..13f207dc6b 100644 --- a/tcl/interface/stlink-v1.cfg +++ b/tcl/interface/stlink-v1.cfg @@ -7,5 +7,3 @@ hla_layout stlink hla_device_desc "ST-LINK/V1" hla_vid_pid 0x0483 0x3744 -# unused but set to disable warnings -adapter_khz 1000 diff --git a/tcl/interface/stlink-v2.cfg b/tcl/interface/stlink-v2.cfg index da0a2002f9..e145d6353f 100644 --- a/tcl/interface/stlink-v2.cfg +++ b/tcl/interface/stlink-v2.cfg @@ -7,5 +7,3 @@ hla_layout stlink hla_device_desc "ST-LINK/V2" hla_vid_pid 0x0483 0x3748 -# unused but set to disable warnings -adapter_khz 1000 diff --git a/tcl/interface/sysfsgpio-raspberrypi.cfg b/tcl/interface/sysfsgpio-raspberrypi.cfg index 105173c94a..3636422847 100644 --- a/tcl/interface/sysfsgpio-raspberrypi.cfg +++ b/tcl/interface/sysfsgpio-raspberrypi.cfg @@ -10,9 +10,6 @@ interface sysfsgpio -# This has no effect on the driver, but is required -adapter_khz 100 - # Each of the JTAG lines need a gpio number set: tck tms tdi tdo # Header pin numbers: 23 22 19 21 sysfsgpio_jtag_nums 11 25 10 9 diff --git a/tcl/interface/ti-icdi.cfg b/tcl/interface/ti-icdi.cfg index 16a901e931..0fc3a9b675 100644 --- a/tcl/interface/ti-icdi.cfg +++ b/tcl/interface/ti-icdi.cfg @@ -11,5 +11,3 @@ interface hla hla_layout ti-icdi hla_vid_pid 0x1cbe 0x00fd -# unused but set to disable warnings -adapter_khz 1000 diff --git a/tcl/interface/usb-jtag.cfg b/tcl/interface/usb-jtag.cfg index a3db11e363..f0164cafd7 100644 --- a/tcl/interface/usb-jtag.cfg +++ b/tcl/interface/usb-jtag.cfg @@ -7,5 +7,3 @@ interface usb_blaster usb_blaster_vid_pid 0x16C0 0x06AD usb_blaster_device_desc "USB-JTAG-IF" -adapter_khz 3000 -