drivers/ftdi: drscan: Skip DR-PAUSE when endstate == IDLE

Currently, all drscan commands will cycle through DR-PAUSE before reaching
TAP-IDLE. This patch provides a different path on FTDI driver.

This change is required for the ST On Chip Emulator (OnCE), to avoid
re-enabling the OnCE tap after every DRSCAN. This is because the OnCE
TAP (see ST Application Note AN4035) gets disabled if DR-PAUSE is entered
before DR-UPDATE.

With this commit, the current path:

DR-SHIFT -> DR-EXIT1 -> DR-PAUSE -> DR-EXIT2 -> DR-UPDATE -> IDLE

is changed to:

DR-SHIFT -> DR-EXIT1 -> DR-UPDATE -> IDLE

only if IDLE is the endstate (which is the driver default).

Before this patch, once the SHIFT sequence is complete, the driver would
normally move to the nearest stable state, which is DR-PAUSE, by clocking
out a '10' binary sequence. Then it would follow the path provided by
tap_get_tms_path() to reach endstate. It is done this way because
tap_get_tms_path() only supports stable states.

After this patch, the strategy is mostly the same, with the exception that,
if TAP_IDLE is the endstate, a '110' binary sequence is output after completing
the SHIFT sequence. This takes the TAP directly to IDLE, with no further action
required.

A scheme of the DR chain is shown below. A * character is used to mark the
stable states.

 ----------------------------------------------------------------------
 |                                                                    | 0
 v    1         0          0         1        0         1        1    |
IDLE* -> SEL-DR -> CAPTURE -> SHIFT* -> EXIT1 -> PAUSE* -> EXIT2 -> UPDATE
                                          |                           ^
                                        1 |                           |
                                          -----------------------------

Change-Id: Ib413e5c4c0bbf75dae0b4672119bae4ef03d0258
Signed-off-by: Luis de Arquer <luis.dearquer@inertim.com>
Reviewed-on: http://openocd.zylin.com/6123
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
This commit is contained in:
Luis de Arquer 2021-03-24 17:12:14 +01:00 committed by Antonio Borneo
parent d10141ef07
commit b44948985f
1 changed files with 23 additions and 8 deletions

View File

@ -482,7 +482,11 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
uint8_t last_bit = 0;
if (field->out_value)
bit_copy(&last_bit, 0, field->out_value, field->num_bits - 1, 1);
uint8_t tms_bits = 0x01;
/* If endstate is TAP_IDLE, clock out 1-1-0 (->EXIT1 ->UPDATE ->IDLE)
* Otherwise, clock out 1-0 (->EXIT1 ->PAUSE)
*/
uint8_t tms_bits = 0x03;
mpsse_clock_tms_cs(mpsse_ctx,
&tms_bits,
0,
@ -492,13 +496,24 @@ static void ftdi_execute_scan(struct jtag_command *cmd)
last_bit,
ftdi_jtag_mode);
tap_set_state(tap_state_transition(tap_get_state(), 1));
mpsse_clock_tms_cs_out(mpsse_ctx,
&tms_bits,
1,
1,
last_bit,
ftdi_jtag_mode);
tap_set_state(tap_state_transition(tap_get_state(), 0));
if (tap_get_end_state() == TAP_IDLE) {
mpsse_clock_tms_cs_out(mpsse_ctx,
&tms_bits,
1,
2,
last_bit,
ftdi_jtag_mode);
tap_set_state(tap_state_transition(tap_get_state(), 1));
tap_set_state(tap_state_transition(tap_get_state(), 0));
} else {
mpsse_clock_tms_cs_out(mpsse_ctx,
&tms_bits,
2,
1,
last_bit,
ftdi_jtag_mode);
tap_set_state(tap_state_transition(tap_get_state(), 0));
}
} else
mpsse_clock_data(mpsse_ctx,
field->out_value,