summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-03-13 11:07:21 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-03-13 11:07:21 +0000
commit9bf081192f2a1ad8c3ef424c9564b0c1f733461d (patch)
tree902ab49d1b8779a0ee361a7d2dd94604df23d2d3 /src
parent7de7bc80fcca79e72c45040dc0ff3467e4b10dea (diff)
downloadopenocd_libswd-9bf081192f2a1ad8c3ef424c9564b0c1f733461d.tar.gz
openocd_libswd-9bf081192f2a1ad8c3ef424c9564b0c1f733461d.tar.bz2
openocd_libswd-9bf081192f2a1ad8c3ef424c9564b0c1f733461d.tar.xz
openocd_libswd-9bf081192f2a1ad8c3ef424c9564b0c1f733461d.zip
added jtag_khz for use with target library
git-svn-id: svn://svn.berlios.de/openocd/trunk@512 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/jtag/jtag.c50
-rw-r--r--src/jtag/jtag.h2
2 files changed, 52 insertions, 0 deletions
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index c2db331d..fc89d248 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -234,6 +234,7 @@ int jtag_cancel_queue(void);
/* jtag commands */
int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
+int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
@@ -1409,6 +1410,8 @@ int jtag_register_commands(struct command_context_s *cmd_ctx)
COMMAND_CONFIG, NULL);
register_command(cmd_ctx, NULL, "jtag_speed", handle_jtag_speed_command,
COMMAND_ANY, "set jtag speed (if supported) <reset speed> [<post reset speed, default value is reset speed>]");
+ register_command(cmd_ctx, NULL, "jtag_khz", handle_jtag_khz_command,
+ COMMAND_ANY, "same as jtag_speed, except it takes khz as arguments");
register_command(cmd_ctx, NULL, "jtag_device", handle_jtag_device_command,
COMMAND_CONFIG, "jtag_device <ir_length> <ir_expected> <ir_mask>");
register_command(cmd_ctx, NULL, "reset_config", handle_reset_config_command,
@@ -1499,6 +1502,12 @@ int jtag_init(struct command_context_s *cmd_ctx)
}
+static int default_khz(int khz, int *jtag_speed)
+{
+ ERROR("Translation from khz to jtag_speed not implemented");
+ return ERROR_FAIL;
+}
+
int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
int i;
@@ -1524,6 +1533,11 @@ int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char
exit(-1);
jtag_interface = jtag_interfaces[i];
+
+ if (jtag_interface->khz == NULL)
+ {
+ jtag_interface->khz = default_khz;
+ }
return ERROR_OK;
}
}
@@ -1713,6 +1727,42 @@ int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cmd, char
return ERROR_OK;
}
+int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+ int cur_speed = 0;
+ int speed1, speed2;
+ if ((argc<1) || (argc>2))
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
+ if (jtag == NULL)
+ {
+ ERROR("Interface not selected yet");
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+
+ if (argc >= 1)
+ speed1 = strtoul(args[0], NULL, 0);
+ if (argc == 2)
+ speed2 = strtoul(args[1], NULL, 0);
+
+ if (jtag->khz(speed1, &speed1)!=ERROR_OK)
+ return ERROR_OK;
+
+ if (jtag->khz(speed2, &speed2)!=ERROR_OK)
+ return ERROR_OK;
+
+ if (argc >= 1)
+ cur_speed = jtag_speed = jtag_speed_post_reset = speed1;
+
+ if (argc == 2)
+ cur_speed = jtag_speed_post_reset = speed2;
+
+ jtag->speed(cur_speed);
+
+ return ERROR_OK;
+}
+
+
int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
enum tap_state state;
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index 0e9a9302..16eb84dd 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -195,6 +195,8 @@ typedef struct jtag_interface_s
int (*register_commands)(struct command_context_s *cmd_ctx);
int (*init)(void);
int (*quit)(void);
+ /* returns JTAG speed for KHz. */
+ int (*khz)(int khz, int *jtag_speed);
} jtag_interface_t;