jtag: align adapter speed code to new structure
Rename the jtag_XXX functions as adapter_XXX. Rename internal variables. Adapt log messages and comments text. Change-Id: I67f209c67074899cd58bad495055def03f0d1bcf Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6644 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
This commit is contained in:
parent
679dcd0b52
commit
3c50288612
|
@ -85,18 +85,18 @@ int adapter_init(struct command_context *cmd_ctx)
|
|||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
int requested_khz = jtag_get_speed_khz();
|
||||
int requested_khz = adapter_get_speed_khz();
|
||||
int actual_khz = requested_khz;
|
||||
int jtag_speed_var = 0;
|
||||
retval = jtag_get_speed(&jtag_speed_var);
|
||||
int speed_var = 0;
|
||||
retval = adapter_get_speed(&speed_var);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
retval = adapter_driver->speed(jtag_speed_var);
|
||||
retval = adapter_driver->speed(speed_var);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
retval = jtag_get_speed_readable(&actual_khz);
|
||||
retval = adapter_get_speed_readable(&actual_khz);
|
||||
if (retval != ERROR_OK)
|
||||
LOG_INFO("adapter-specific clock speed value %d", jtag_speed_var);
|
||||
LOG_INFO("adapter-specific clock speed value %d", speed_var);
|
||||
else if (actual_khz) {
|
||||
/* Adaptive clocking -- JTAG-specific */
|
||||
if ((adapter_config.clock_mode == CLOCK_MODE_RCLK)
|
||||
|
@ -130,31 +130,31 @@ int adapter_quit(void)
|
|||
return ERROR_OK;
|
||||
}
|
||||
|
||||
unsigned jtag_get_speed_khz(void)
|
||||
unsigned int adapter_get_speed_khz(void)
|
||||
{
|
||||
return adapter_config.speed_khz;
|
||||
}
|
||||
|
||||
static int adapter_khz_to_speed(unsigned khz, int *speed)
|
||||
static int adapter_khz_to_speed(unsigned int khz, int *speed)
|
||||
{
|
||||
LOG_DEBUG("convert khz to interface specific speed value");
|
||||
LOG_DEBUG("convert khz to adapter specific speed value");
|
||||
adapter_config.speed_khz = khz;
|
||||
if (!is_adapter_initialized())
|
||||
return ERROR_OK;
|
||||
LOG_DEBUG("have interface set up");
|
||||
LOG_DEBUG("have adapter set up");
|
||||
if (!adapter_driver->khz) {
|
||||
LOG_ERROR("Translation from khz to jtag_speed not implemented");
|
||||
LOG_ERROR("Translation from khz to adapter speed not implemented");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
int speed_div1;
|
||||
int retval = adapter_driver->khz(jtag_get_speed_khz(), &speed_div1);
|
||||
int retval = adapter_driver->khz(adapter_get_speed_khz(), &speed_div1);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
*speed = speed_div1;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int jtag_rclk_to_speed(unsigned fallback_speed_khz, int *speed)
|
||||
static int adapter_rclk_to_speed(unsigned int fallback_speed_khz, int *speed)
|
||||
{
|
||||
int retval = adapter_khz_to_speed(0, speed);
|
||||
if ((retval != ERROR_OK) && fallback_speed_khz) {
|
||||
|
@ -164,61 +164,61 @@ static int jtag_rclk_to_speed(unsigned fallback_speed_khz, int *speed)
|
|||
return retval;
|
||||
}
|
||||
|
||||
static int jtag_set_speed(int speed)
|
||||
static int adapter_set_speed(int speed)
|
||||
{
|
||||
/* this command can be called during CONFIG,
|
||||
* in which case jtag isn't initialized */
|
||||
* in which case adapter isn't initialized */
|
||||
return is_adapter_initialized() ? adapter_driver->speed(speed) : ERROR_OK;
|
||||
}
|
||||
|
||||
int jtag_config_khz(unsigned khz)
|
||||
int adapter_config_khz(unsigned int khz)
|
||||
{
|
||||
LOG_DEBUG("handle jtag khz");
|
||||
LOG_DEBUG("handle adapter khz");
|
||||
adapter_config.clock_mode = CLOCK_MODE_KHZ;
|
||||
int speed = 0;
|
||||
int retval = adapter_khz_to_speed(khz, &speed);
|
||||
return (retval != ERROR_OK) ? retval : jtag_set_speed(speed);
|
||||
return (retval != ERROR_OK) ? retval : adapter_set_speed(speed);
|
||||
}
|
||||
|
||||
int jtag_config_rclk(unsigned fallback_speed_khz)
|
||||
int adapter_config_rclk(unsigned int fallback_speed_khz)
|
||||
{
|
||||
LOG_DEBUG("handle jtag rclk");
|
||||
LOG_DEBUG("handle adapter rclk");
|
||||
adapter_config.clock_mode = CLOCK_MODE_RCLK;
|
||||
adapter_config.rclk_fallback_speed_khz = fallback_speed_khz;
|
||||
int speed = 0;
|
||||
int retval = jtag_rclk_to_speed(fallback_speed_khz, &speed);
|
||||
return (retval != ERROR_OK) ? retval : jtag_set_speed(speed);
|
||||
int retval = adapter_rclk_to_speed(fallback_speed_khz, &speed);
|
||||
return (retval != ERROR_OK) ? retval : adapter_set_speed(speed);
|
||||
}
|
||||
|
||||
int jtag_get_speed(int *speed)
|
||||
int adapter_get_speed(int *speed)
|
||||
{
|
||||
switch (adapter_config.clock_mode) {
|
||||
case CLOCK_MODE_KHZ:
|
||||
adapter_khz_to_speed(jtag_get_speed_khz(), speed);
|
||||
adapter_khz_to_speed(adapter_get_speed_khz(), speed);
|
||||
break;
|
||||
case CLOCK_MODE_RCLK:
|
||||
jtag_rclk_to_speed(adapter_config.rclk_fallback_speed_khz, speed);
|
||||
adapter_rclk_to_speed(adapter_config.rclk_fallback_speed_khz, speed);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("BUG: unknown jtag clock mode");
|
||||
LOG_ERROR("BUG: unknown adapter clock mode");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int jtag_get_speed_readable(int *khz)
|
||||
int adapter_get_speed_readable(int *khz)
|
||||
{
|
||||
int jtag_speed_var = 0;
|
||||
int retval = jtag_get_speed(&jtag_speed_var);
|
||||
int speed_var = 0;
|
||||
int retval = adapter_get_speed(&speed_var);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
if (!is_adapter_initialized())
|
||||
return ERROR_OK;
|
||||
if (!adapter_driver->speed_div) {
|
||||
LOG_ERROR("Translation from jtag_speed to khz not implemented");
|
||||
LOG_ERROR("Translation from adapter speed to khz not implemented");
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
return adapter_driver->speed_div(jtag_speed_var, khz);
|
||||
return adapter_driver->speed_div(speed_var, khz);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -640,13 +640,13 @@ COMMAND_HANDLER(handle_adapter_speed_command)
|
|||
unsigned khz = 0;
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz);
|
||||
|
||||
retval = jtag_config_khz(khz);
|
||||
retval = adapter_config_khz(khz);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
}
|
||||
|
||||
int cur_speed = jtag_get_speed_khz();
|
||||
retval = jtag_get_speed_readable(&cur_speed);
|
||||
int cur_speed = adapter_get_speed_khz();
|
||||
retval = adapter_get_speed_readable(&cur_speed);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
|
|
|
@ -27,28 +27,28 @@ const char *adapter_usb_get_location(void);
|
|||
/** @returns true if USB location string is "<dev_bus>-<port_path[0]>[.<port_path[1]>[...]]" */
|
||||
bool adapter_usb_location_equal(uint8_t dev_bus, uint8_t *port_path, size_t path_len);
|
||||
|
||||
/** @returns The current JTAG speed setting. */
|
||||
int jtag_get_speed(int *speed);
|
||||
/** @returns The current adapter speed setting. */
|
||||
int adapter_get_speed(int *speed);
|
||||
|
||||
/**
|
||||
* Given a @a speed setting, use the interface @c speed_div callback to
|
||||
* adjust the setting.
|
||||
* @param speed The speed setting to convert back to readable KHz.
|
||||
* @param speed The speed setting to convert back to readable kHz.
|
||||
* @returns ERROR_OK if the interface has not been initialized or on success;
|
||||
* otherwise, the error code produced by the @c speed_div callback.
|
||||
*/
|
||||
int jtag_get_speed_readable(int *speed);
|
||||
int adapter_get_speed_readable(int *speed);
|
||||
|
||||
/** Attempt to configure the interface for the specified KHz. */
|
||||
int jtag_config_khz(unsigned khz);
|
||||
/** Attempt to configure the adapter for the specified kHz. */
|
||||
int adapter_config_khz(unsigned int khz);
|
||||
|
||||
/**
|
||||
* Attempt to enable RTCK/RCLK. If that fails, fallback to the
|
||||
* specified frequency.
|
||||
*/
|
||||
int jtag_config_rclk(unsigned fallback_speed_khz);
|
||||
int adapter_config_rclk(unsigned int fallback_speed_khz);
|
||||
|
||||
/** Retrieves the clock speed of the JTAG interface in KHz. */
|
||||
unsigned jtag_get_speed_khz(void);
|
||||
/** Retrieves the clock speed of the adapter in kHz. */
|
||||
unsigned int adapter_get_speed_khz(void);
|
||||
|
||||
#endif /* OPENOCD_JTAG_ADAPTER_H */
|
||||
|
|
|
@ -199,7 +199,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 = 0;
|
||||
int retval = jtag_get_speed(&jtag_speed);
|
||||
int retval = adapter_get_speed(&jtag_speed);
|
||||
assert(retval == ERROR_OK);
|
||||
if (jtag_speed > 3 || rtck_enabled)
|
||||
amt_wait_scan_busy();
|
||||
|
@ -255,7 +255,7 @@ static void amt_jtagaccel_scan(bool ir_scan, enum scan_type type, uint8_t *buffe
|
|||
uint8_t aw_tms_scan;
|
||||
uint8_t tms_scan[2];
|
||||
int jtag_speed_var;
|
||||
int retval = jtag_get_speed(&jtag_speed_var);
|
||||
int retval = adapter_get_speed(&jtag_speed_var);
|
||||
assert(retval == ERROR_OK);
|
||||
|
||||
if (ir_scan)
|
||||
|
|
|
@ -1145,7 +1145,7 @@ static int cmsis_dap_swd_switch_seq(enum swd_special_seq seq)
|
|||
|
||||
/* Atmel EDBG needs renew clock setting after SWJ_Sequence
|
||||
* otherwise default frequency is used */
|
||||
return cmsis_dap_cmd_dap_swj_clock(jtag_get_speed_khz());
|
||||
return cmsis_dap_cmd_dap_swj_clock(adapter_get_speed_khz());
|
||||
}
|
||||
|
||||
static int cmsis_dap_swd_open(void)
|
||||
|
@ -1262,7 +1262,7 @@ static int cmsis_dap_init(void)
|
|||
|
||||
/* Now try to connect to the target
|
||||
* TODO: This is all SWD only @ present */
|
||||
retval = cmsis_dap_cmd_dap_swj_clock(jtag_get_speed_khz());
|
||||
retval = cmsis_dap_cmd_dap_swj_clock(adapter_get_speed_khz());
|
||||
if (retval != ERROR_OK)
|
||||
goto init_err;
|
||||
|
||||
|
|
|
@ -699,7 +699,7 @@ static int ftdi_initialize(void)
|
|||
|
||||
mpsse_loopback_config(mpsse_ctx, false);
|
||||
|
||||
freq = mpsse_set_frequency(mpsse_ctx, jtag_get_speed_khz() * 1000);
|
||||
freq = mpsse_set_frequency(mpsse_ctx, adapter_get_speed_khz() * 1000);
|
||||
|
||||
return mpsse_flush(mpsse_ctx);
|
||||
}
|
||||
|
|
|
@ -811,7 +811,7 @@ static int jlink_init(void)
|
|||
jtag_sleep(3000);
|
||||
jlink_tap_init();
|
||||
|
||||
jlink_speed(jtag_get_speed_khz());
|
||||
jlink_speed(adapter_get_speed_khz());
|
||||
|
||||
if (iface == JAYLINK_TIF_JTAG) {
|
||||
/*
|
||||
|
|
|
@ -458,9 +458,9 @@ COMMAND_HANDLER(parport_handle_parport_toggling_time_command)
|
|||
}
|
||||
|
||||
parport_toggling_time_ns = ns;
|
||||
retval = jtag_get_speed(&wait_states);
|
||||
retval = adapter_get_speed(&wait_states);
|
||||
if (retval != ERROR_OK) {
|
||||
/* if jtag_get_speed fails then the clock_mode
|
||||
/* if adapter_get_speed fails then the clock_mode
|
||||
* has not been configured, this happens if parport_toggling_time is
|
||||
* called before the adapter speed is set */
|
||||
LOG_INFO("no parport speed set - defaulting to zero wait states");
|
||||
|
|
|
@ -324,7 +324,7 @@ static int vsllink_init(void)
|
|||
versaloon_interface.adaptors.gpio.config(0, GPIO_TRST, 0,
|
||||
GPIO_TRST, GPIO_TRST);
|
||||
versaloon_interface.adaptors.swd.init(0);
|
||||
vsllink_swd_frequency(jtag_get_speed_khz() * 1000);
|
||||
vsllink_swd_frequency(adapter_get_speed_khz() * 1000);
|
||||
vsllink_swd_switch_seq(JTAG_TO_SWD);
|
||||
|
||||
} else {
|
||||
|
@ -340,7 +340,7 @@ static int vsllink_init(void)
|
|||
}
|
||||
|
||||
versaloon_interface.adaptors.jtag_raw.init(0);
|
||||
versaloon_interface.adaptors.jtag_raw.config(0, jtag_get_speed_khz());
|
||||
versaloon_interface.adaptors.jtag_raw.config(0, adapter_get_speed_khz());
|
||||
versaloon_interface.adaptors.gpio.config(0, GPIO_SRST | GPIO_TRST,
|
||||
GPIO_TRST, GPIO_SRST, GPIO_SRST);
|
||||
}
|
||||
|
|
|
@ -1041,13 +1041,13 @@ COMMAND_HANDLER(handle_jtag_rclk_command)
|
|||
unsigned khz = 0;
|
||||
COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz);
|
||||
|
||||
retval = jtag_config_rclk(khz);
|
||||
retval = adapter_config_rclk(khz);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
}
|
||||
|
||||
int cur_khz = jtag_get_speed_khz();
|
||||
retval = jtag_get_speed_readable(&cur_khz);
|
||||
int cur_khz = adapter_get_speed_khz();
|
||||
retval = adapter_get_speed_readable(&cur_khz);
|
||||
if (retval != ERROR_OK)
|
||||
return retval;
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ int mips32_pracc_queue_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_in
|
|||
}
|
||||
|
||||
unsigned num_clocks =
|
||||
((uint64_t)(ejtag_info->scan_delay) * jtag_get_speed_khz() + 500000) / 1000000;
|
||||
((uint64_t)(ejtag_info->scan_delay) * adapter_get_speed_khz() + 500000) / 1000000;
|
||||
|
||||
uint32_t ejtag_ctrl = ejtag_info->ejtag_ctrl & ~EJTAG_CTRL_PRACC;
|
||||
mips_ejtag_set_instr(ejtag_info, EJTAG_INST_ALL);
|
||||
|
@ -1011,7 +1011,7 @@ int mips32_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info, struct working_are
|
|||
|
||||
unsigned num_clocks = 0; /* like in legacy code */
|
||||
if (ejtag_info->mode != 0)
|
||||
num_clocks = ((uint64_t)(ejtag_info->scan_delay) * jtag_get_speed_khz() + 500000) / 1000000;
|
||||
num_clocks = ((uint64_t)(ejtag_info->scan_delay) * adapter_get_speed_khz() + 500000) / 1000000;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
jtag_add_clocks(num_clocks);
|
||||
|
|
|
@ -1387,7 +1387,7 @@ int mips64_pracc_fastdata_xfer(struct mips_ejtag *ejtag_info,
|
|||
/* like in legacy code */
|
||||
unsigned num_clocks = 0;
|
||||
if (ejtag_info->mode != 0)
|
||||
num_clocks = ((uint64_t)(ejtag_info->scan_delay) * jtag_get_speed_khz() + 500000) / 1000000;
|
||||
num_clocks = ((uint64_t)(ejtag_info->scan_delay) * adapter_get_speed_khz() + 500000) / 1000000;
|
||||
LOG_DEBUG("num_clocks=%d", num_clocks);
|
||||
for (i = 0; i < count; i++) {
|
||||
jtag_add_clocks(num_clocks);
|
||||
|
|
Loading…
Reference in New Issue