Add get and set accessors for jtag_speed:
- Setter calls the interface driver callback to improve core encapsulation. - Use getter in standard JTAG interface drivers and ZY1000 minidriver. git-svn-id: svn://svn.berlios.de/openocd/trunk@2159 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
parent
bcad121d2b
commit
cd7f89f6bc
|
@ -187,6 +187,7 @@ 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();
|
||||||
if (jtag_speed > 3 || rtck_enabled)
|
if (jtag_speed > 3 || rtck_enabled)
|
||||||
amt_wait_scan_busy();
|
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 dr_tdo;
|
||||||
u8 aw_tms_scan;
|
u8 aw_tms_scan;
|
||||||
u8 tms_scan[2];
|
u8 tms_scan[2];
|
||||||
|
int jtag_speed = jtag_get_speed();
|
||||||
|
|
||||||
if (ir_scan)
|
if (ir_scan)
|
||||||
amt_jtagaccel_end_state(TAP_IRSHIFT);
|
amt_jtagaccel_end_state(TAP_IRSHIFT);
|
||||||
|
@ -496,7 +498,7 @@ 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_speed);
|
amt_jtagaccel_speed(jtag_get_speed());
|
||||||
|
|
||||||
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
|
if (jtag_reset_config & RESET_TRST_OPEN_DRAIN)
|
||||||
aw_control_rst &= ~0x8;
|
aw_control_rst &= ~0x8;
|
||||||
|
|
|
@ -1153,6 +1153,18 @@ unsigned jtag_get_speed_khz(void)
|
||||||
{
|
{
|
||||||
return speed_khz;
|
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)
|
void jtag_set_verify(bool enable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2099,7 +2099,7 @@ static int ft2232_init(void)
|
||||||
if (layout->init() != ERROR_OK)
|
if (layout->init() != ERROR_OK)
|
||||||
return ERROR_JTAG_INIT_FAILED;
|
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 */
|
buf[0] = 0x85; /* Disconnect TDI/DO to TDO/DI for Loopback */
|
||||||
if (((retval = ft2232_write(buf, 1, &bytes_written)) != ERROR_OK) || (bytes_written != 1))
|
if (((retval = ft2232_write(buf, 1, &bytes_written)) != ERROR_OK) || (bytes_written != 1))
|
||||||
|
|
|
@ -557,7 +557,7 @@ 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_speed);
|
gw16012_speed(jtag_get_speed());
|
||||||
gw16012_reset(0, 0);
|
gw16012_reset(0, 0);
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
|
|
@ -340,7 +340,7 @@ 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_speed);
|
jlink_speed(jtag_get_speed());
|
||||||
|
|
||||||
/* 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 */
|
||||||
|
|
|
@ -255,7 +255,17 @@ typedef struct jtag_event_callback_s
|
||||||
struct jtag_event_callback_s* next;
|
struct jtag_event_callback_s* next;
|
||||||
} jtag_event_callback_t;
|
} 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;
|
extern int jtag_speed_post_reset;
|
||||||
|
|
||||||
enum reset_types {
|
enum reset_types {
|
||||||
|
|
|
@ -189,7 +189,7 @@ static __inline__ void parport_write_data(void)
|
||||||
|
|
||||||
static void parport_write(int tck, int tms, int tdi)
|
static void parport_write(int tck, int tms, int tdi)
|
||||||
{
|
{
|
||||||
int i = jtag_speed + 1;
|
int i = jtag_get_speed() + 1;
|
||||||
|
|
||||||
if (tck)
|
if (tck)
|
||||||
dataport_value |= cable->TCK_MASK;
|
dataport_value |= cable->TCK_MASK;
|
||||||
|
|
|
@ -787,7 +787,7 @@ 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_speed);
|
presto_jtag_speed(jtag_get_speed());
|
||||||
|
|
||||||
bitq_interface = &presto_bitq;
|
bitq_interface = &presto_bitq;
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
|
|
@ -1849,7 +1849,7 @@ int rlink_init(void)
|
||||||
|
|
||||||
tap_state_queue_init();
|
tap_state_queue_init();
|
||||||
dtc_queue_init();
|
dtc_queue_init();
|
||||||
rlink_speed(jtag_speed);
|
rlink_speed(jtag_get_speed());
|
||||||
rlink_reset(0, 0);
|
rlink_reset(0, 0);
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
|
|
|
@ -960,14 +960,11 @@ static int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cm
|
||||||
LOG_DEBUG("handle jtag speed");
|
LOG_DEBUG("handle jtag speed");
|
||||||
|
|
||||||
int cur_speed = 0;
|
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;
|
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);
|
jtag_set_speed_khz(0);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
cur_speed = jtag_speed = speed_div1;
|
cur_speed = speed_div1;
|
||||||
|
|
||||||
retval = jtag->speed(cur_speed);
|
retval = jtag_set_speed(cur_speed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
hasKHz = true;
|
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();
|
cur_speed = jtag_get_speed_khz();
|
||||||
if (jtag != NULL)
|
if (jtag != NULL)
|
||||||
{
|
{
|
||||||
retval = jtag->speed_div(jtag_speed, &cur_speed);
|
retval = jtag->speed_div(jtag_get_speed(), &cur_speed);
|
||||||
if (ERROR_OK != retval)
|
if (ERROR_OK != retval)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,7 +356,7 @@ 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_speed);
|
zy1000_speed(jtag_get_speed());
|
||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue