int requested_khz = jtag_get_speed_khz();
int actual_khz = requested_khz;
- int retval = jtag_get_speed_readable(&actual_khz);
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ retval = jtag_get_speed_readable(&actual_khz);
if (ERROR_OK != retval)
- LOG_INFO("adapter-specific clock speed value %d", jtag_get_speed());
+ LOG_INFO("adapter-specific clock speed value %d", jtag_speed_var);
else if (actual_khz)
{
/* Adaptive clocking -- JTAG-specific */
return (ERROR_OK != retval) ? retval : jtag_set_speed(speed);
}
-int jtag_get_speed(void)
+int jtag_get_speed(int *speed)
{
- int speed = 0; /* avoid -O3 warning */
switch(clock_mode)
{
case CLOCK_MODE_SPEED:
- speed = jtag_speed;
+ *speed = jtag_speed;
break;
case CLOCK_MODE_KHZ:
- adapter_khz_to_speed(jtag_get_speed_khz(), &speed);
+ adapter_khz_to_speed(jtag_get_speed_khz(), speed);
break;
case CLOCK_MODE_RCLK:
- jtag_rclk_to_speed(rclk_fallback_speed_khz, &speed);
+ jtag_rclk_to_speed(rclk_fallback_speed_khz, speed);
break;
default:
LOG_ERROR("BUG: unknown jtag clock mode");
- break;
+ return ERROR_FAIL;
}
- return speed;
+ return ERROR_OK;
}
int jtag_get_speed_readable(int *khz)
{
- return jtag ? jtag->speed_div(jtag_get_speed(), khz) : ERROR_OK;
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ return jtag ? jtag->speed_div(jtag_speed_var, khz) : ERROR_OK;
}
void jtag_set_verify(bool enable)
aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
AMT_AW(aw_scan_tms_5);
- int jtag_speed = jtag_get_speed();
+ int retval = jtag_get_speed(&jtag_speed);
+ assert(retval == ERROR_OK);
if (jtag_speed > 3 || rtck_enabled)
amt_wait_scan_busy();
uint8_t dr_tdo;
uint8_t aw_tms_scan;
uint8_t tms_scan[2];
- int jtag_speed = jtag_get_speed();
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ assert(retval == ERROR_OK);
if (ir_scan)
amt_jtagaccel_end_state(TAP_IRSHIFT);
dw_tdi_scan = buf_get_u32(buffer, bit_count, (scan_size - 1) % 8) & 0xff;
AMT_DW(dw_tdi_scan);
- if (jtag_speed > 3 || rtck_enabled)
+ if (jtag_speed_var > 3 || rtck_enabled)
amt_wait_scan_busy();
if ((type == SCAN_IN) || (type == SCAN_IO))
{
dw_tdi_scan = buf_get_u32(buffer, bit_count, 8) & 0xff;
AMT_DW(dw_tdi_scan);
- if (jtag_speed > 3 || rtck_enabled)
+ if (jtag_speed_var > 3 || rtck_enabled)
amt_wait_scan_busy();
if ((type == SCAN_IN) || (type == SCAN_IO))
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][1];
aw_tms_scan = 0x40 | (tms_scan[0] & 0x1f) | (buf_get_u32(buffer, bit_count, 1) << 5);
AMT_AW(aw_tms_scan);
- if (jtag_speed > 3 || rtck_enabled)
+ if (jtag_speed_var > 3 || rtck_enabled)
amt_wait_scan_busy();
if ((type == SCAN_IN) || (type == SCAN_IO))
{
aw_tms_scan = 0x40 | (tms_scan[1] & 0x1f);
AMT_AW(aw_tms_scan);
- if (jtag_speed > 3 || rtck_enabled)
+ if (jtag_speed_var > 3 || rtck_enabled)
amt_wait_scan_busy();
}
tap_set_state(tap_get_end_state());
aw_control_fsm |= 0x04;
AMT_AW(aw_control_fsm);
- amt_jtagaccel_speed(jtag_get_speed());
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ amt_jtagaccel_speed(jtag_speed_var);
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
return ERROR_JTAG_INIT_FAILED;
}
- ft2232_speed(jtag_get_speed());
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ ft2232_speed(jtag_speed_var);
buf[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */
if ((retval = ft2232_write(buf, 1, &bytes_written)) != ERROR_OK)
gw16012_input(&status_port);
gw16012_msb = (status_port & 0x80) ^ 0x80;
- gw16012_speed(jtag_get_speed());
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ gw16012_speed(jtag_speed_var);
gw16012_reset(0, 0);
return ERROR_OK;
jlink_reset(0, 0);
jtag_sleep(3000);
jlink_tap_init();
- jlink_speed(jtag_get_speed());
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ jlink_speed(jtag_speed_var);
/* 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 */
bitbang_interface = &parport_bitbang;
- wait_states = jtag_get_speed();
+ int retval = jtag_get_speed(&wait_states);
+ if (retval != ERROR_OK)
+ return retval;
return ERROR_OK;
}
}
parport_toggling_time_ns = ns;
- wait_states = jtag_get_speed();
+ int retval = jtag_get_speed(&wait_states);
+ if (retval != ERROR_OK)
+ return retval;
}
command_print(CMD_CTX, "parport toggling time = %" PRIu32 " ns",
LOG_INFO("PRESTO open, serial number '%s'", presto->serial);
/* use JTAG speed setting from configuration file */
- presto_jtag_speed(jtag_get_speed());
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ presto_jtag_speed(jtag_speed_var);
bitq_interface = &presto_bitq;
return ERROR_OK;
tap_state_queue_init();
dtc_queue_init();
- rlink_speed(jtag_get_speed());
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ rlink_speed(jtag_speed_var);
rlink_reset(0, 0);
return ERROR_OK;
bitbang_interface = &usb_blaster_bitbang;
- usb_blaster_speed(jtag_get_speed());
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ usb_blaster_speed(jtag_speed_var);
#if 0
#if BUILD_USB_BLASTER_FTD2XX == 1
/// @returns The current JTAG speed setting.
-int jtag_get_speed(void);
+int jtag_get_speed(int *speed);
/**
* Given a @a speed setting, use the interface @c speed_div callback to
/* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
zy1000_reset(0, 0);
- zy1000_speed(jtag_get_speed());
+ int jtag_speed_var;
+ int retval = jtag_get_speed(&jtag_speed_var);
+ if (retval != ERROR_OK)
+ return retval;
+ zy1000_speed(jtag_speed_var);
#if BUILD_ECOSBOARD