jtag: getting the JTAG speed can fail
If the JTAG speed has not been set, then it has no defined value, add code to propagate the error. No change to actual behavior as no new failure paths have been introduced. This is a no-op patch to make subsequent patches smaller. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>__archive__
parent
5cd931ed1c
commit
740b9e25b4
|
@ -1384,9 +1384,13 @@ int adapter_init(struct command_context *cmd_ctx)
|
||||||
|
|
||||||
int requested_khz = jtag_get_speed_khz();
|
int requested_khz = jtag_get_speed_khz();
|
||||||
int actual_khz = requested_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)
|
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)
|
else if (actual_khz)
|
||||||
{
|
{
|
||||||
/* Adaptive clocking -- JTAG-specific */
|
/* Adaptive clocking -- JTAG-specific */
|
||||||
|
@ -1632,30 +1636,33 @@ int jtag_config_rclk(unsigned fallback_speed_khz)
|
||||||
return (ERROR_OK != retval) ? retval : jtag_set_speed(speed);
|
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)
|
switch(clock_mode)
|
||||||
{
|
{
|
||||||
case CLOCK_MODE_SPEED:
|
case CLOCK_MODE_SPEED:
|
||||||
speed = jtag_speed;
|
*speed = jtag_speed;
|
||||||
break;
|
break;
|
||||||
case CLOCK_MODE_KHZ:
|
case CLOCK_MODE_KHZ:
|
||||||
adapter_khz_to_speed(jtag_get_speed_khz(), &speed);
|
adapter_khz_to_speed(jtag_get_speed_khz(), speed);
|
||||||
break;
|
break;
|
||||||
case CLOCK_MODE_RCLK:
|
case CLOCK_MODE_RCLK:
|
||||||
jtag_rclk_to_speed(rclk_fallback_speed_khz, &speed);
|
jtag_rclk_to_speed(rclk_fallback_speed_khz, speed);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_ERROR("BUG: unknown jtag clock mode");
|
LOG_ERROR("BUG: unknown jtag clock mode");
|
||||||
break;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
return speed;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int jtag_get_speed_readable(int *khz)
|
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)
|
void jtag_set_verify(bool enable)
|
||||||
|
|
|
@ -191,7 +191,8 @@ static void amt_jtagaccel_state_move(void)
|
||||||
|
|
||||||
aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
|
aw_scan_tms_5 = 0x40 | (tms_scan[0] & 0x1f);
|
||||||
AMT_AW(aw_scan_tms_5);
|
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)
|
if (jtag_speed > 3 || rtck_enabled)
|
||||||
amt_wait_scan_busy();
|
amt_wait_scan_busy();
|
||||||
|
|
||||||
|
@ -249,7 +250,9 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||||
uint8_t dr_tdo;
|
uint8_t dr_tdo;
|
||||||
uint8_t aw_tms_scan;
|
uint8_t aw_tms_scan;
|
||||||
uint8_t tms_scan[2];
|
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)
|
if (ir_scan)
|
||||||
amt_jtagaccel_end_state(TAP_IRSHIFT);
|
amt_jtagaccel_end_state(TAP_IRSHIFT);
|
||||||
|
@ -267,7 +270,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||||
|
|
||||||
dw_tdi_scan = buf_get_u32(buffer, bit_count, (scan_size - 1) % 8) & 0xff;
|
dw_tdi_scan = buf_get_u32(buffer, bit_count, (scan_size - 1) % 8) & 0xff;
|
||||||
AMT_DW(dw_tdi_scan);
|
AMT_DW(dw_tdi_scan);
|
||||||
if (jtag_speed > 3 || rtck_enabled)
|
if (jtag_speed_var > 3 || rtck_enabled)
|
||||||
amt_wait_scan_busy();
|
amt_wait_scan_busy();
|
||||||
|
|
||||||
if ((type == SCAN_IN) || (type == SCAN_IO))
|
if ((type == SCAN_IN) || (type == SCAN_IO))
|
||||||
|
@ -285,7 +288,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||||
{
|
{
|
||||||
dw_tdi_scan = buf_get_u32(buffer, bit_count, 8) & 0xff;
|
dw_tdi_scan = buf_get_u32(buffer, bit_count, 8) & 0xff;
|
||||||
AMT_DW(dw_tdi_scan);
|
AMT_DW(dw_tdi_scan);
|
||||||
if (jtag_speed > 3 || rtck_enabled)
|
if (jtag_speed_var > 3 || rtck_enabled)
|
||||||
amt_wait_scan_busy();
|
amt_wait_scan_busy();
|
||||||
|
|
||||||
if ((type == SCAN_IN) || (type == SCAN_IO))
|
if ((type == SCAN_IN) || (type == SCAN_IO))
|
||||||
|
@ -302,7 +305,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||||
tms_scan[1] = amt_jtagaccel_tap_move[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())][1];
|
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);
|
aw_tms_scan = 0x40 | (tms_scan[0] & 0x1f) | (buf_get_u32(buffer, bit_count, 1) << 5);
|
||||||
AMT_AW(aw_tms_scan);
|
AMT_AW(aw_tms_scan);
|
||||||
if (jtag_speed > 3 || rtck_enabled)
|
if (jtag_speed_var > 3 || rtck_enabled)
|
||||||
amt_wait_scan_busy();
|
amt_wait_scan_busy();
|
||||||
|
|
||||||
if ((type == SCAN_IN) || (type == SCAN_IO))
|
if ((type == SCAN_IN) || (type == SCAN_IO))
|
||||||
|
@ -316,7 +319,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
||||||
{
|
{
|
||||||
aw_tms_scan = 0x40 | (tms_scan[1] & 0x1f);
|
aw_tms_scan = 0x40 | (tms_scan[1] & 0x1f);
|
||||||
AMT_AW(aw_tms_scan);
|
AMT_AW(aw_tms_scan);
|
||||||
if (jtag_speed > 3 || rtck_enabled)
|
if (jtag_speed_var > 3 || rtck_enabled)
|
||||||
amt_wait_scan_busy();
|
amt_wait_scan_busy();
|
||||||
}
|
}
|
||||||
tap_set_state(tap_get_end_state());
|
tap_set_state(tap_get_end_state());
|
||||||
|
@ -502,7 +505,9 @@ static int amt_jtagaccel_init(void)
|
||||||
aw_control_fsm |= 0x04;
|
aw_control_fsm |= 0x04;
|
||||||
AMT_AW(aw_control_fsm);
|
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();
|
enum reset_types jtag_reset_config = jtag_get_reset_config();
|
||||||
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
|
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
|
||||||
|
|
|
@ -2395,7 +2395,11 @@ static int ft2232_init(void)
|
||||||
return ERROR_JTAG_INIT_FAILED;
|
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 */
|
buf[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */
|
||||||
if ((retval = ft2232_write(buf, 1, &bytes_written)) != ERROR_OK)
|
if ((retval = ft2232_write(buf, 1, &bytes_written)) != ERROR_OK)
|
||||||
|
|
|
@ -529,7 +529,11 @@ static int gw16012_init(void)
|
||||||
gw16012_input(&status_port);
|
gw16012_input(&status_port);
|
||||||
gw16012_msb = (status_port & 0x80) ^ 0x80;
|
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);
|
gw16012_reset(0, 0);
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
|
|
@ -321,7 +321,11 @@ static int jlink_init(void)
|
||||||
jlink_reset(0, 0);
|
jlink_reset(0, 0);
|
||||||
jtag_sleep(3000);
|
jtag_sleep(3000);
|
||||||
jlink_tap_init();
|
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
|
/* 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 */
|
* is not divisible by 8, so we send a TLR on first power up */
|
||||||
|
|
|
@ -384,7 +384,9 @@ static int parport_init(void)
|
||||||
|
|
||||||
bitbang_interface = &parport_bitbang;
|
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;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
@ -475,7 +477,9 @@ COMMAND_HANDLER(parport_handle_parport_toggling_time_command)
|
||||||
}
|
}
|
||||||
|
|
||||||
parport_toggling_time_ns = ns;
|
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",
|
command_print(CMD_CTX, "parport toggling time = %" PRIu32 " ns",
|
||||||
|
|
|
@ -770,7 +770,11 @@ static int presto_jtag_init(void)
|
||||||
LOG_INFO("PRESTO open, serial number '%s'", presto->serial);
|
LOG_INFO("PRESTO open, serial number '%s'", presto->serial);
|
||||||
|
|
||||||
/* use JTAG speed setting from configuration file */
|
/* 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;
|
bitq_interface = &presto_bitq;
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
|
|
@ -1771,7 +1771,11 @@ int rlink_init(void)
|
||||||
|
|
||||||
tap_state_queue_init();
|
tap_state_queue_init();
|
||||||
dtc_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);
|
rlink_reset(0, 0);
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
|
|
@ -442,7 +442,11 @@ static int usb_blaster_init(void)
|
||||||
|
|
||||||
bitbang_interface = &usb_blaster_bitbang;
|
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 0
|
||||||
#if BUILD_USB_BLASTER_FTD2XX == 1
|
#if BUILD_USB_BLASTER_FTD2XX == 1
|
||||||
|
|
|
@ -239,7 +239,7 @@ int jtag_call_event_callbacks(enum jtag_event event);
|
||||||
|
|
||||||
|
|
||||||
/// @returns The current JTAG speed setting.
|
/// @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
|
* Given a @a speed setting, use the interface @c speed_div callback to
|
||||||
|
|
|
@ -1620,7 +1620,11 @@ int zy1000_init(void)
|
||||||
|
|
||||||
/* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
|
/* deassert resets. Important to avoid infinite loop waiting for SRST to deassert */
|
||||||
zy1000_reset(0, 0);
|
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
|
#if BUILD_ECOSBOARD
|
||||||
|
|
Loading…
Reference in New Issue