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();
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);
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;
{
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)
{
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))
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;
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 */
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 {
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;
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;
tap_state_queue_init();
dtc_queue_init();
- rlink_speed(jtag_speed);
+ rlink_speed(jtag_get_speed());
rlink_reset(0, 0);
return ERROR_OK;
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;
}
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;
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;
}
/* 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;
}