summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jtag/amt_jtagaccel.c4
-rw-r--r--src/jtag/core.c12
-rw-r--r--src/jtag/ft2232.c2
-rw-r--r--src/jtag/gw16012.c2
-rw-r--r--src/jtag/jlink.c2
-rw-r--r--src/jtag/jtag.h12
-rw-r--r--src/jtag/parport.c2
-rw-r--r--src/jtag/presto.c2
-rw-r--r--src/jtag/rlink/rlink.c2
-rw-r--r--src/jtag/tcl.c15
-rw-r--r--src/jtag/zy1000/zy1000.c2
11 files changed, 39 insertions, 18 deletions
diff --git a/src/jtag/amt_jtagaccel.c b/src/jtag/amt_jtagaccel.c
index b19fae17..4071c25c 100644
--- a/src/jtag/amt_jtagaccel.c
+++ b/src/jtag/amt_jtagaccel.c
@@ -187,6 +187,7 @@ static void amt_jtagaccel_state_move(void)
aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
AMT_AW(aw_scan_tms_5);
+ int jtag_speed = jtag_get_speed();
if (jtag_speed > 3 || rtck_enabled)
amt_wait_scan_busy();
@@ -244,6 +245,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, u8 *buffer, in
u8 dr_tdo;
u8 aw_tms_scan;
u8 tms_scan[2];
+ int jtag_speed = jtag_get_speed();
if (ir_scan)
amt_jtagaccel_end_state(TAP_IRSHIFT);
@@ -496,7 +498,7 @@ static int amt_jtagaccel_init(void)
aw_control_fsm |= 0x04;
AMT_AW(aw_control_fsm);
- amt_jtagaccel_speed(jtag_speed);
+ amt_jtagaccel_speed(jtag_get_speed());
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
aw_control_rst &= ~0x8;
diff --git a/src/jtag/core.c b/src/jtag/core.c
index 5edcce22..f6db00a5 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -1153,6 +1153,18 @@ unsigned jtag_get_speed_khz(void)
{
return speed_khz;
}
+int jtag_get_speed(void)
+{
+ return jtag_speed;
+}
+
+int jtag_set_speed(int speed)
+{
+ jtag_speed = speed;
+ /* this command can be called during CONFIG,
+ * in which case jtag isn't initialized */
+ return jtag ? jtag->speed(speed) : ERROR_OK;
+}
void jtag_set_verify(bool enable)
{
diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c
index ae3bd863..734833b1 100644
--- a/src/jtag/ft2232.c
+++ b/src/jtag/ft2232.c
@@ -2099,7 +2099,7 @@ static int ft2232_init(void)
if (layout->init() != ERROR_OK)
return ERROR_JTAG_INIT_FAILED;
- ft2232_speed(jtag_speed);
+ ft2232_speed(jtag_get_speed());
buf[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */
if (((retval = ft2232_write(buf, 1, &bytes_written)) != ERROR_OK) || (bytes_written != 1))
diff --git a/src/jtag/gw16012.c b/src/jtag/gw16012.c
index a89a5f7e..0ea66340 100644
--- a/src/jtag/gw16012.c
+++ b/src/jtag/gw16012.c
@@ -557,7 +557,7 @@ static int gw16012_init(void)
gw16012_input(&status_port);
gw16012_msb = (status_port & 0x80) ^ 0x80;
- gw16012_speed(jtag_speed);
+ gw16012_speed(jtag_get_speed());
gw16012_reset(0, 0);
return ERROR_OK;
diff --git a/src/jtag/jlink.c b/src/jtag/jlink.c
index 22b058df..ce0489c0 100644
--- a/src/jtag/jlink.c
+++ b/src/jtag/jlink.c
@@ -340,7 +340,7 @@ static int jlink_init(void)
jlink_reset(0, 0);
jtag_sleep(3000);
jlink_tap_init();
- jlink_speed(jtag_speed);
+ jlink_speed(jtag_get_speed());
/* v5/6 jlink seems to have an issue if the first tap move
* is not divisible by 8, so we send a TLR on first power up */
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index fd4953ec..0e21738e 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -255,7 +255,17 @@ typedef struct jtag_event_callback_s
struct jtag_event_callback_s* next;
} jtag_event_callback_t;
-extern int jtag_speed;
+/// @returns The current JTAG speed setting.
+int jtag_get_speed(void);
+/**
+ * Set the JTAG speed. This routine will call the underlying
+ * interface @c speed callback, if the interface has been initialized.
+ * @param speed The new speed setting.
+ * @returns ERROR_OK during configuration or on success, or an error
+ * code returned from the interface @c speed callback.
+ */
+int jtag_set_speed(int speed);
+
extern int jtag_speed_post_reset;
enum reset_types {
diff --git a/src/jtag/parport.c b/src/jtag/parport.c
index 3f026b04..4ee2202d 100644
--- a/src/jtag/parport.c
+++ b/src/jtag/parport.c
@@ -189,7 +189,7 @@ static __inline__ void parport_write_data(void)
static void parport_write(int tck, int tms, int tdi)
{
- int i = jtag_speed + 1;
+ int i = jtag_get_speed() + 1;
if (tck)
dataport_value |= cable->TCK_MASK;
diff --git a/src/jtag/presto.c b/src/jtag/presto.c
index 6123259c..125658be 100644
--- a/src/jtag/presto.c
+++ b/src/jtag/presto.c
@@ -787,7 +787,7 @@ static int presto_jtag_init(void)
LOG_INFO("PRESTO open, serial number '%s'", presto->serial);
/* use JTAG speed setting from configuration file */
- presto_jtag_speed(jtag_speed);
+ presto_jtag_speed(jtag_get_speed());
bitq_interface = &presto_bitq;
return ERROR_OK;
diff --git a/src/jtag/rlink/rlink.c b/src/jtag/rlink/rlink.c
index f47e189c..121de01f 100644
--- a/src/jtag/rlink/rlink.c
+++ b/src/jtag/rlink/rlink.c
@@ -1849,7 +1849,7 @@ int rlink_init(void)
tap_state_queue_init();
dtc_queue_init();
- rlink_speed(jtag_speed);
+ rlink_speed(jtag_get_speed());
rlink_reset(0, 0);
return ERROR_OK;
diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c
index 8836b484..ed24498b 100644
--- a/src/jtag/tcl.c
+++ b/src/jtag/tcl.c
@@ -960,14 +960,11 @@ static int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cm
LOG_DEBUG("handle jtag speed");
int cur_speed = 0;
- cur_speed = jtag_speed = strtoul(args[0], NULL, 0);
+ cur_speed = strtoul(args[0], NULL, 0);
+ retval = jtag_set_speed(cur_speed);
- /* this command can be called during CONFIG,
- * in which case jtag isn't initialized */
- if (jtag)
- retval = jtag->speed(cur_speed);
}
- command_print(cmd_ctx, "jtag_speed: %d", jtag_speed);
+ command_print(cmd_ctx, "jtag_speed: %d", jtag_get_speed());
return retval;
}
@@ -994,9 +991,9 @@ static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd,
jtag_set_speed_khz(0);
return retval;
}
- cur_speed = jtag_speed = speed_div1;
+ cur_speed = speed_div1;
- retval = jtag->speed(cur_speed);
+ retval = jtag_set_speed(cur_speed);
}
else
hasKHz = true;
@@ -1005,7 +1002,7 @@ static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd,
cur_speed = jtag_get_speed_khz();
if (jtag != NULL)
{
- retval = jtag->speed_div(jtag_speed, &cur_speed);
+ retval = jtag->speed_div(jtag_get_speed(), &cur_speed);
if (ERROR_OK != retval)
return retval;
}
diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c
index ad148f1d..05bbd4c5 100644
--- a/src/jtag/zy1000/zy1000.c
+++ b/src/jtag/zy1000/zy1000.c
@@ -356,7 +356,7 @@ int zy1000_init(void)
/* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
zy1000_reset(0, 0);
- zy1000_speed(jtag_speed);
+ zy1000_speed(jtag_get_speed());
return ERROR_OK;
}