2008-02-25 08:50:31 -06:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2005 by Dominic Rath *
|
|
|
|
|
* Dominic.Rath@gmx.de *
|
|
|
|
|
* *
|
2008-09-20 05:50:53 -05:00
|
|
|
|
* Copyright (C) 2007,2008 <EFBFBD>yvind Harboe *
|
2008-07-25 01:54:17 -05:00
|
|
|
|
* oyvind.harboe@zylin.com *
|
|
|
|
|
* *
|
2008-02-25 08:50:31 -06:00
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
#ifndef JTAG_H
|
|
|
|
|
#define JTAG_H
|
|
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
#include "binarybuffer.h"
|
2008-02-28 03:21:56 -06:00
|
|
|
|
#include "log.h"
|
2008-02-25 08:50:31 -06:00
|
|
|
|
|
|
|
|
|
#include "command.h"
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
#define _DEBUG_JTAG_IO_
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-12-13 00:25:50 -06:00
|
|
|
|
/* 16 Tap States, from page 21 of ASSET InterTech, Inc.'s svf.pdf
|
2008-02-25 08:50:31 -06:00
|
|
|
|
*/
|
|
|
|
|
enum tap_state
|
|
|
|
|
{
|
2008-12-13 00:25:50 -06:00
|
|
|
|
TAP_RESET = 0x0, TAP_IDLE = 0x8,
|
|
|
|
|
TAP_DRSELECT = 0x1, TAP_DRCAPTURE = 0x2, TAP_DRSHIFT = 0x3, TAP_DREXIT1 = 0x4,
|
|
|
|
|
TAP_DRPAUSE = 0x5, TAP_DREXIT2 = 0x6, TAP_DRUPDATE = 0x7,
|
|
|
|
|
TAP_IRSELECT = 0x9, TAP_IRCAPTURE = 0xa, TAP_IRSHIFT = 0xb, TAP_IREXIT1 = 0xc,
|
|
|
|
|
TAP_IRPAUSE = 0xd, TAP_IREXIT2 = 0xe, TAP_IRUPDATE = 0xf
|
2008-02-25 08:50:31 -06:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct tap_transition_s
|
|
|
|
|
{
|
|
|
|
|
enum tap_state high;
|
|
|
|
|
enum tap_state low;
|
|
|
|
|
} tap_transition_t;
|
|
|
|
|
|
|
|
|
|
extern char* tap_state_strings[16];
|
|
|
|
|
extern int tap_move_map[16]; /* map 16 TAP states to 6 stable states */
|
|
|
|
|
extern u8 tap_move[6][6]; /* value scanned to TMS to move from one of six stable states to another */
|
|
|
|
|
extern tap_transition_t tap_transitions[16]; /* describe the TAP state diagram */
|
|
|
|
|
|
|
|
|
|
extern enum tap_state end_state; /* finish DR scans in dr_end_state */
|
|
|
|
|
extern enum tap_state cur_state; /* current TAP state */
|
|
|
|
|
|
|
|
|
|
extern enum tap_state cmd_queue_end_state; /* finish DR scans in dr_end_state */
|
|
|
|
|
extern enum tap_state cmd_queue_cur_state; /* current TAP state */
|
|
|
|
|
|
|
|
|
|
#define TAP_MOVE(from, to) tap_move[tap_move_map[from]][tap_move_map[to]]
|
|
|
|
|
|
|
|
|
|
typedef void * error_handler_t; /* Later on we can delete error_handler_t, but keep it for now to make patches more readable */
|
|
|
|
|
|
|
|
|
|
struct scan_field_s;
|
|
|
|
|
typedef int (*in_handler_t)(u8 *in_value, void *priv, struct scan_field_s *field);
|
|
|
|
|
|
|
|
|
|
typedef struct scan_field_s
|
|
|
|
|
{
|
2008-11-30 16:25:43 -06:00
|
|
|
|
jtag_tap_t *tap; /* tap pointer this instruction refers to */
|
2008-02-25 08:50:31 -06:00
|
|
|
|
int num_bits; /* number of bits this field specifies (up to 32) */
|
|
|
|
|
u8 *out_value; /* value to be scanned into the device */
|
|
|
|
|
u8 *out_mask; /* only masked bits care */
|
|
|
|
|
u8 *in_value; /* pointer to a 32-bit memory location to take data scanned out */
|
|
|
|
|
/* in_check_value/mask, in_handler_error_handler, in_handler_priv can be used by the in handler, otherwise they contain garbage */
|
2008-11-05 01:45:31 -06:00
|
|
|
|
u8 *in_check_value; /* used to validate scan results */
|
2008-02-26 00:25:22 -06:00
|
|
|
|
u8 *in_check_mask; /* check specified bits against check_value */
|
2008-02-25 08:50:31 -06:00
|
|
|
|
in_handler_t in_handler; /* process received buffer using this handler */
|
|
|
|
|
void *in_handler_priv; /* additional information for the in_handler */
|
|
|
|
|
} scan_field_t;
|
|
|
|
|
|
2008-02-26 00:25:22 -06:00
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
enum scan_type
|
|
|
|
|
{
|
|
|
|
|
/* IN: from device to host, OUT: from host to device */
|
|
|
|
|
SCAN_IN = 1, SCAN_OUT = 2, SCAN_IO = 3
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct scan_command_s
|
|
|
|
|
{
|
|
|
|
|
int ir_scan; /* instruction/not data scan */
|
|
|
|
|
int num_fields; /* number of fields in *fields array */
|
|
|
|
|
scan_field_t *fields; /* pointer to an array of data scan fields */
|
|
|
|
|
enum tap_state end_state; /* TAP state in which JTAG commands should finish */
|
|
|
|
|
} scan_command_t;
|
|
|
|
|
|
|
|
|
|
typedef struct statemove_command_s
|
|
|
|
|
{
|
|
|
|
|
enum tap_state end_state; /* TAP state in which JTAG commands should finish */
|
|
|
|
|
} statemove_command_t;
|
|
|
|
|
|
|
|
|
|
typedef struct pathmove_command_s
|
|
|
|
|
{
|
|
|
|
|
int num_states; /* number of states in *path */
|
|
|
|
|
enum tap_state *path; /* states that have to be passed */
|
|
|
|
|
} pathmove_command_t;
|
|
|
|
|
|
|
|
|
|
typedef struct runtest_command_s
|
|
|
|
|
{
|
|
|
|
|
int num_cycles; /* number of cycles that should be spent in Run-Test/Idle */
|
|
|
|
|
enum tap_state end_state; /* TAP state in which JTAG commands should finish */
|
|
|
|
|
} runtest_command_t;
|
|
|
|
|
|
|
|
|
|
typedef struct reset_command_s
|
|
|
|
|
{
|
|
|
|
|
int trst; /* trst/srst 0: deassert, 1: assert, -1: don't change */
|
|
|
|
|
int srst;
|
|
|
|
|
} reset_command_t;
|
|
|
|
|
|
|
|
|
|
typedef struct end_state_command_s
|
|
|
|
|
{
|
|
|
|
|
enum tap_state end_state; /* TAP state in which JTAG commands should finish */
|
|
|
|
|
} end_state_command_t;
|
|
|
|
|
|
|
|
|
|
typedef struct sleep_command_s
|
|
|
|
|
{
|
|
|
|
|
u32 us; /* number of microseconds to sleep */
|
|
|
|
|
} sleep_command_t;
|
|
|
|
|
|
|
|
|
|
typedef union jtag_command_container_u
|
|
|
|
|
{
|
|
|
|
|
scan_command_t *scan;
|
|
|
|
|
statemove_command_t *statemove;
|
|
|
|
|
pathmove_command_t *pathmove;
|
|
|
|
|
runtest_command_t *runtest;
|
|
|
|
|
reset_command_t *reset;
|
|
|
|
|
end_state_command_t *end_state;
|
|
|
|
|
sleep_command_t *sleep;
|
|
|
|
|
} jtag_command_container_t;
|
|
|
|
|
|
|
|
|
|
enum jtag_command_type
|
|
|
|
|
{
|
|
|
|
|
JTAG_SCAN = 1,
|
|
|
|
|
JTAG_STATEMOVE = 2, JTAG_RUNTEST = 3,
|
|
|
|
|
JTAG_RESET = 4, JTAG_END_STATE = 5,
|
|
|
|
|
JTAG_PATHMOVE = 6, JTAG_SLEEP = 7
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct jtag_command_s
|
|
|
|
|
{
|
|
|
|
|
jtag_command_container_t cmd;
|
|
|
|
|
enum jtag_command_type type;
|
|
|
|
|
struct jtag_command_s *next;
|
|
|
|
|
} jtag_command_t;
|
|
|
|
|
|
|
|
|
|
extern jtag_command_t *jtag_command_queue;
|
|
|
|
|
|
2008-11-30 16:25:43 -06:00
|
|
|
|
// this is really: typedef jtag_tap_t
|
|
|
|
|
// But - the typedef is done in "types.h"
|
|
|
|
|
// due to "forward decloration reasons"
|
|
|
|
|
struct jtag_tap_s
|
2008-02-25 08:50:31 -06:00
|
|
|
|
{
|
2008-11-30 16:25:43 -06:00
|
|
|
|
const char *chip;
|
|
|
|
|
const char *tapname;
|
|
|
|
|
const char *dotted_name;
|
|
|
|
|
int abs_chain_position;
|
|
|
|
|
int enabled;
|
2008-02-25 08:50:31 -06:00
|
|
|
|
int ir_length; /* size of instruction register */
|
2008-11-30 16:25:43 -06:00
|
|
|
|
u32 ir_capture_value;
|
2008-02-25 08:50:31 -06:00
|
|
|
|
u8 *expected; /* Capture-IR expected value */
|
2008-11-30 16:25:43 -06:00
|
|
|
|
u32 ir_capture_mask;
|
2008-02-25 08:50:31 -06:00
|
|
|
|
u8 *expected_mask; /* Capture-IR expected mask */
|
|
|
|
|
u32 idcode; /* device identification code */
|
2008-12-11 18:21:07 -06:00
|
|
|
|
u32 *expected_ids; /* Array of expected identification codes */
|
|
|
|
|
u8 expected_ids_cnt;/* Number of expected identification codes */
|
2008-02-25 08:50:31 -06:00
|
|
|
|
u8 *cur_instr; /* current instruction */
|
|
|
|
|
int bypass; /* bypass register selected */
|
2008-11-30 16:25:43 -06:00
|
|
|
|
jtag_tap_t *next_tap;
|
|
|
|
|
};
|
|
|
|
|
extern jtag_tap_t *jtag_AllTaps(void);
|
|
|
|
|
extern jtag_tap_t *jtag_TapByPosition(int n);
|
|
|
|
|
extern jtag_tap_t *jtag_TapByPosition( int n );
|
|
|
|
|
extern jtag_tap_t *jtag_TapByString( const char *dotted_name );
|
|
|
|
|
extern jtag_tap_t *jtag_TapByJimObj( Jim_Interp *interp, Jim_Obj *obj );
|
|
|
|
|
extern jtag_tap_t *jtag_TapByAbsPosition( int abs_position );
|
|
|
|
|
extern int jtag_NumEnabledTaps(void);
|
|
|
|
|
extern int jtag_NumTotalTaps(void);
|
|
|
|
|
|
|
|
|
|
|
2008-12-01 08:21:24 -06:00
|
|
|
|
static __inline__ jtag_tap_t *
|
|
|
|
|
jtag_NextEnabledTap( jtag_tap_t *p )
|
|
|
|
|
{
|
|
|
|
|
if( p == NULL ){
|
|
|
|
|
// start at the head of list
|
|
|
|
|
p = jtag_AllTaps();
|
|
|
|
|
} else {
|
|
|
|
|
// start *after* this one
|
|
|
|
|
p = p->next_tap;
|
|
|
|
|
}
|
|
|
|
|
while( p ){
|
|
|
|
|
if( p->enabled ){
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
p = p->next_tap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum reset_line_mode
|
|
|
|
|
{
|
|
|
|
|
LINE_OPEN_DRAIN = 0x0,
|
|
|
|
|
LINE_PUSH_PULL = 0x1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct jtag_interface_s
|
|
|
|
|
{
|
|
|
|
|
char* name;
|
2008-11-05 01:45:31 -06:00
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
/* queued command execution
|
|
|
|
|
*/
|
|
|
|
|
int (*execute_queue)(void);
|
2008-11-05 01:45:31 -06:00
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
/* interface initalization
|
|
|
|
|
*/
|
|
|
|
|
int (*speed)(int speed);
|
|
|
|
|
int (*register_commands)(struct command_context_s *cmd_ctx);
|
|
|
|
|
int (*init)(void);
|
|
|
|
|
int (*quit)(void);
|
2008-03-13 08:58:07 -05:00
|
|
|
|
/* returns JTAG maxium speed for KHz. 0=RTCK. The function returns
|
2008-11-05 01:45:31 -06:00
|
|
|
|
a failure if it can't support the KHz/RTCK.
|
|
|
|
|
|
2008-08-27 01:05:27 -05:00
|
|
|
|
WARNING!!!! if RTCK is *slow* then think carefully about
|
|
|
|
|
whether you actually want to support this in the driver.
|
|
|
|
|
Many target scripts are written to handle the absence of RTCK
|
|
|
|
|
and use a fallback kHz TCK.
|
|
|
|
|
*/
|
2008-03-13 06:07:21 -05:00
|
|
|
|
int (*khz)(int khz, int *jtag_speed);
|
2008-04-30 04:13:54 -05:00
|
|
|
|
/* returns the KHz for the provided JTAG speed. 0=RTCK. The function returns
|
|
|
|
|
a failure if it can't support the KHz/RTCK. */
|
2008-04-30 04:34:31 -05:00
|
|
|
|
int (*speed_div)(int speed, int *khz);
|
2008-11-05 01:45:31 -06:00
|
|
|
|
|
|
|
|
|
/* Read and clear the power dropout flag. Note that a power dropout
|
|
|
|
|
can be transitionary, easily much less than a ms.
|
|
|
|
|
|
|
|
|
|
So to find out if the power is *currently* on, you must invoke
|
|
|
|
|
this method twice. Once to clear the power dropout flag and a
|
|
|
|
|
second time to read the current state.
|
|
|
|
|
|
|
|
|
|
Currently the default implementation is never to detect power dropout.
|
|
|
|
|
*/
|
|
|
|
|
int (*power_dropout)(int *power_dropout);
|
|
|
|
|
/* Read and clear the srst asserted detection flag.
|
|
|
|
|
*
|
|
|
|
|
* NB!!!! like power_dropout this does *not* read the current
|
|
|
|
|
* state. srst assertion is transitionary and *can* be much
|
|
|
|
|
* less than 1ms.
|
|
|
|
|
*/
|
|
|
|
|
int (*srst_asserted)(int *srst_asserted);
|
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
} jtag_interface_t;
|
|
|
|
|
|
|
|
|
|
enum jtag_event
|
|
|
|
|
{
|
2008-03-11 16:16:57 -05:00
|
|
|
|
JTAG_TRST_ASSERTED
|
2008-02-25 08:50:31 -06:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern char* jtag_event_strings[];
|
|
|
|
|
|
|
|
|
|
extern int jtag_trst;
|
|
|
|
|
extern int jtag_srst;
|
|
|
|
|
|
|
|
|
|
typedef struct jtag_event_callback_s
|
|
|
|
|
{
|
|
|
|
|
int (*callback)(enum jtag_event event, void *priv);
|
|
|
|
|
void *priv;
|
|
|
|
|
struct jtag_event_callback_s *next;
|
|
|
|
|
} jtag_event_callback_t;
|
|
|
|
|
|
|
|
|
|
extern jtag_event_callback_t *jtag_event_callbacks;
|
|
|
|
|
|
|
|
|
|
extern jtag_interface_t *jtag; /* global pointer to configured JTAG interface */
|
|
|
|
|
extern enum tap_state end_state;
|
|
|
|
|
extern enum tap_state cur_state;
|
|
|
|
|
|
|
|
|
|
extern int jtag_speed;
|
2008-03-13 05:14:41 -05:00
|
|
|
|
extern int jtag_speed_post_reset;
|
2008-02-25 08:50:31 -06:00
|
|
|
|
|
|
|
|
|
enum reset_types
|
|
|
|
|
{
|
2008-11-05 01:45:31 -06:00
|
|
|
|
RESET_NONE = 0x0,
|
|
|
|
|
RESET_HAS_TRST = 0x1,
|
|
|
|
|
RESET_HAS_SRST = 0x2,
|
|
|
|
|
RESET_TRST_AND_SRST = 0x3,
|
2008-02-25 08:50:31 -06:00
|
|
|
|
RESET_SRST_PULLS_TRST = 0x4,
|
|
|
|
|
RESET_TRST_PULLS_SRST = 0x8,
|
|
|
|
|
RESET_TRST_OPEN_DRAIN = 0x10,
|
|
|
|
|
RESET_SRST_PUSH_PULL = 0x20,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern enum reset_types jtag_reset_config;
|
|
|
|
|
|
2008-11-05 01:45:31 -06:00
|
|
|
|
/* initialize interface upon startup. A successful no-op
|
2008-04-11 09:06:42 -05:00
|
|
|
|
* upon subsequent invocations
|
|
|
|
|
*/
|
|
|
|
|
extern int jtag_interface_init(struct command_context_s *cmd_ctx);
|
2008-12-13 00:59:24 -06:00
|
|
|
|
/* initialize JTAG chain using only a RESET reset. If init fails,
|
2008-04-09 00:50:34 -05:00
|
|
|
|
* try reset + init.
|
|
|
|
|
*/
|
2008-02-25 08:50:31 -06:00
|
|
|
|
extern int jtag_init(struct command_context_s *cmd_ctx);
|
2008-04-09 00:50:34 -05:00
|
|
|
|
/* reset, then initialize JTAG chain */
|
|
|
|
|
extern int jtag_init_reset(struct command_context_s *cmd_ctx);
|
2008-02-25 08:50:31 -06:00
|
|
|
|
extern int jtag_register_commands(struct command_context_s *cmd_ctx);
|
|
|
|
|
|
2008-03-26 08:29:48 -05:00
|
|
|
|
/* JTAG interface, can be implemented with a software or hardware fifo
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-12-13 00:59:24 -06:00
|
|
|
|
* TAP_DRSHIFT and TAP_IRSHIFT are illegal end states. TAP_DRSHIFT/IRSHIFT as end states
|
2008-03-31 08:18:03 -05:00
|
|
|
|
* can be emulated by using a larger scan.
|
|
|
|
|
*
|
|
|
|
|
* Code that is relatively insensitive to the path(as long
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* as it is JTAG compliant) taken through state machine can use
|
|
|
|
|
* endstate for jtag_add_xxx_scan(). Otherwise the pause state must be
|
|
|
|
|
* specified as end state and a subsequent jtag_add_pathmove() must
|
|
|
|
|
* be issued.
|
2008-03-31 08:18:03 -05:00
|
|
|
|
*
|
2008-03-26 08:29:48 -05:00
|
|
|
|
*/
|
2008-03-11 04:06:00 -05:00
|
|
|
|
extern void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
|
2008-02-26 00:25:22 -06:00
|
|
|
|
extern int interface_jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
|
2008-03-11 04:06:00 -05:00
|
|
|
|
extern void jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
|
2008-02-26 00:25:22 -06:00
|
|
|
|
extern int interface_jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
|
2008-03-11 04:06:00 -05:00
|
|
|
|
extern void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
|
2008-02-26 00:25:22 -06:00
|
|
|
|
extern int interface_jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
|
2008-03-11 04:06:00 -05:00
|
|
|
|
extern void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
|
2008-02-26 00:25:22 -06:00
|
|
|
|
extern int interface_jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state endstate);
|
2008-12-13 00:25:50 -06:00
|
|
|
|
/* run a TAP_RESET reset. End state is TAP_RESET, regardless
|
2008-03-31 08:18:03 -05:00
|
|
|
|
* of start state.
|
|
|
|
|
*/
|
2008-08-05 07:27:18 -05:00
|
|
|
|
extern void jtag_add_tlr(void);
|
|
|
|
|
extern int interface_jtag_add_tlr(void);
|
2008-03-31 08:18:03 -05:00
|
|
|
|
/* Do not use jtag_add_pathmove() unless you need to, but do use it
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* if you have to.
|
2008-02-25 08:50:31 -06:00
|
|
|
|
*
|
2008-03-31 08:18:03 -05:00
|
|
|
|
* DANGER! If the target is dependent upon a particular sequence
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* of transitions for things to work correctly(e.g. as a workaround
|
|
|
|
|
* for an errata that contradicts the JTAG standard), then pathmove
|
|
|
|
|
* must be used, even if some jtag interfaces happen to use the
|
|
|
|
|
* desired path. Worse, the jtag interface used for testing a
|
|
|
|
|
* particular implementation, could happen to use the "desired"
|
2008-03-31 08:18:03 -05:00
|
|
|
|
* path when transitioning to/from end
|
|
|
|
|
* state.
|
2008-02-25 08:50:31 -06:00
|
|
|
|
*
|
2008-03-31 08:18:03 -05:00
|
|
|
|
* A list of unambigious single clock state transitions, not
|
2008-02-25 08:50:31 -06:00
|
|
|
|
* all drivers can support this, but it is required for e.g.
|
|
|
|
|
* XScale and Xilinx support
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-12-13 00:25:50 -06:00
|
|
|
|
* Note! TAP_RESET must not be used in the path!
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
|
|
|
|
* Note that the first on the list must be reachable
|
|
|
|
|
* via a single transition from the current state.
|
2008-03-31 08:18:03 -05:00
|
|
|
|
*
|
|
|
|
|
* All drivers are required to implement jtag_add_pathmove().
|
|
|
|
|
* However, if the pathmove sequence can not be precisely
|
|
|
|
|
* executed, an interface_jtag_add_pathmove() or jtag_execute_queue()
|
|
|
|
|
* must return an error. It is legal, but not recommended, that
|
|
|
|
|
* a driver returns an error in all cases for a pathmove if it
|
|
|
|
|
* can only implement a few transitions and therefore
|
|
|
|
|
* a partial implementation of pathmove would have little practical
|
|
|
|
|
* application.
|
2008-02-25 08:50:31 -06:00
|
|
|
|
*/
|
2008-03-11 04:06:00 -05:00
|
|
|
|
extern void jtag_add_pathmove(int num_states, enum tap_state *path);
|
2008-02-26 00:25:22 -06:00
|
|
|
|
extern int interface_jtag_add_pathmove(int num_states, enum tap_state *path);
|
2008-12-13 00:25:50 -06:00
|
|
|
|
/* go to TAP_IDLE, if we're not already there and cycle
|
|
|
|
|
* precisely num_cycles in the TAP_IDLE after which move
|
|
|
|
|
* to the end state, if it is != TAP_IDLE
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-05-21 11:57:20 -05:00
|
|
|
|
* nb! num_cycles can be 0, in which case the fn will navigate
|
2008-12-13 00:25:50 -06:00
|
|
|
|
* to endstate via TAP_IDLE
|
2008-03-06 08:16:45 -06:00
|
|
|
|
*/
|
2008-03-11 04:06:00 -05:00
|
|
|
|
extern void jtag_add_runtest(int num_cycles, enum tap_state endstate);
|
2008-02-26 00:25:22 -06:00
|
|
|
|
extern int interface_jtag_add_runtest(int num_cycles, enum tap_state endstate);
|
2008-03-31 14:39:05 -05:00
|
|
|
|
/* A reset of the TAP state machine can be requested.
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
|
|
|
|
* Whether tms or trst reset is used depends on the capabilities of
|
2008-03-31 14:39:05 -05:00
|
|
|
|
* the target and jtag interface(reset_config command configures this).
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-03-31 14:39:05 -05:00
|
|
|
|
* srst can driver a reset of the TAP state machine and vice
|
|
|
|
|
* versa
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-03-31 14:39:05 -05:00
|
|
|
|
* Application code may need to examine value of jtag_reset_config
|
|
|
|
|
* to determine the proper codepath
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-03-31 14:39:05 -05:00
|
|
|
|
* DANGER! Even though srst drives trst, trst might not be connected to
|
|
|
|
|
* the interface, and it might actually be *harmful* to assert trst in this case.
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-03-31 14:39:05 -05:00
|
|
|
|
* This is why combinations such as "reset_config srst_only srst_pulls_trst"
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* are supported.
|
2008-03-31 14:39:05 -05:00
|
|
|
|
*
|
2008-04-09 00:50:34 -05:00
|
|
|
|
* only req_tlr_or_trst and srst can have a transition for a
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* call as the effects of transitioning both at the "same time"
|
2008-04-09 00:50:34 -05:00
|
|
|
|
* are undefined, but when srst_pulls_trst or vice versa,
|
|
|
|
|
* then trst & srst *must* be asserted together.
|
2008-03-31 14:39:05 -05:00
|
|
|
|
*/
|
2008-04-08 08:08:36 -05:00
|
|
|
|
extern void jtag_add_reset(int req_tlr_or_trst, int srst);
|
2008-03-31 14:39:05 -05:00
|
|
|
|
/* this drives the actual srst and trst pins. srst will always be 0
|
|
|
|
|
* if jtag_reset_config & RESET_SRST_PULLS_TRST != 0 and ditto for
|
|
|
|
|
* trst.
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
|
|
|
|
* the higher level jtag_add_reset will invoke jtag_add_tlr() if
|
2008-03-31 14:39:05 -05:00
|
|
|
|
* approperiate
|
2008-03-11 04:06:00 -05:00
|
|
|
|
*/
|
2008-02-26 00:25:22 -06:00
|
|
|
|
extern int interface_jtag_add_reset(int trst, int srst);
|
2008-03-11 04:06:00 -05:00
|
|
|
|
extern void jtag_add_end_state(enum tap_state endstate);
|
2008-02-26 05:53:54 -06:00
|
|
|
|
extern int interface_jtag_add_end_state(enum tap_state endstate);
|
2008-03-11 04:06:00 -05:00
|
|
|
|
extern void jtag_add_sleep(u32 us);
|
2008-02-26 00:25:22 -06:00
|
|
|
|
extern int interface_jtag_add_sleep(u32 us);
|
2008-02-28 03:21:56 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
/*
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* For software FIFO implementations, the queued commands can be executed
|
2008-02-25 08:50:31 -06:00
|
|
|
|
* during this call or earlier. A sw queue might decide to push out
|
|
|
|
|
* some of the jtag_add_xxx() operations once the queue is "big enough".
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
|
|
|
|
* This fn will return an error code if any of the prior jtag_add_xxx()
|
2008-02-25 08:50:31 -06:00
|
|
|
|
* calls caused a failure, e.g. check failure. Note that it does not
|
|
|
|
|
* matter if the operation was executed *before* jtag_execute_queue(),
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* jtag_execute_queue() will still return an error code.
|
|
|
|
|
*
|
2008-02-25 08:50:31 -06:00
|
|
|
|
* All jtag_add_xxx() calls that have in_handler!=NULL will have been
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* executed when this fn returns, but if what has been queued only
|
|
|
|
|
* clocks data out, without reading anything back, then JTAG could
|
|
|
|
|
* be running *after* jtag_execute_queue() returns. The API does
|
|
|
|
|
* not define a way to flush a hw FIFO that runs *after*
|
|
|
|
|
* jtag_execute_queue() returns.
|
|
|
|
|
*
|
|
|
|
|
* jtag_add_xxx() commands can either be executed immediately or
|
|
|
|
|
* at some time between the jtag_add_xxx() fn call and jtag_execute_queue().
|
2008-02-25 08:50:31 -06:00
|
|
|
|
*/
|
|
|
|
|
extern int jtag_execute_queue(void);
|
2008-02-26 00:25:22 -06:00
|
|
|
|
/* can be implemented by hw+sw */
|
|
|
|
|
extern int interface_jtag_execute_queue(void);
|
2008-11-05 01:45:31 -06:00
|
|
|
|
extern int jtag_power_dropout(int *dropout);
|
|
|
|
|
extern int jtag_srst_asserted(int *srst_asserted);
|
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
|
|
|
|
|
/* JTAG support functions */
|
|
|
|
|
extern void jtag_set_check_value(scan_field_t *field, u8 *value, u8 *mask, error_handler_t *in_error_handler);
|
|
|
|
|
extern enum scan_type jtag_scan_type(scan_command_t *cmd);
|
|
|
|
|
extern int jtag_scan_size(scan_command_t *cmd);
|
|
|
|
|
extern int jtag_read_buffer(u8 *buffer, scan_command_t *cmd);
|
|
|
|
|
extern int jtag_build_buffer(scan_command_t *cmd, u8 **buffer);
|
2008-11-30 16:25:43 -06:00
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
extern void jtag_sleep(u32 us);
|
|
|
|
|
extern int jtag_call_event_callbacks(enum jtag_event event);
|
|
|
|
|
extern int jtag_register_event_callback(int (*callback)(enum jtag_event event, void *priv), void *priv);
|
|
|
|
|
|
|
|
|
|
extern int jtag_verify_capture_ir;
|
|
|
|
|
|
|
|
|
|
/* error codes
|
|
|
|
|
* JTAG subsystem uses codes between -100 and -199 */
|
|
|
|
|
|
|
|
|
|
#define ERROR_JTAG_INIT_FAILED (-100)
|
|
|
|
|
#define ERROR_JTAG_INVALID_INTERFACE (-101)
|
|
|
|
|
#define ERROR_JTAG_NOT_IMPLEMENTED (-102)
|
|
|
|
|
#define ERROR_JTAG_TRST_ASSERTED (-103)
|
|
|
|
|
#define ERROR_JTAG_QUEUE_FAILED (-104)
|
|
|
|
|
#define ERROR_JTAG_DEVICE_ERROR (-107)
|
2008-02-26 00:25:22 -06:00
|
|
|
|
|
|
|
|
|
|
2008-02-28 03:21:56 -06:00
|
|
|
|
|
2008-03-05 13:21:22 -06:00
|
|
|
|
/* this allows JTAG devices to implement the entire jtag_xxx() layer in hw/sw */
|
|
|
|
|
#ifdef HAVE_JTAG_MINIDRIVER_H
|
|
|
|
|
/* Here a #define MINIDRIVER() and an inline version of hw fifo interface_jtag_add_dr_out can be defined */
|
|
|
|
|
#include "jtag_minidriver.h"
|
2008-11-05 01:45:31 -06:00
|
|
|
|
#define MINIDRIVER(a) notused ## a
|
2008-03-05 13:21:22 -06:00
|
|
|
|
#else
|
|
|
|
|
#define MINIDRIVER(a) a
|
2008-11-05 01:45:31 -06:00
|
|
|
|
/* jtag_add_dr_out() is a faster version of jtag_add_dr_scan()
|
|
|
|
|
*
|
2008-12-13 00:25:50 -06:00
|
|
|
|
* Current or end_state can not be TAP_RESET. end_state can be -1
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-03-05 13:21:22 -06:00
|
|
|
|
* num_bits[i] is the number of bits to clock out from value[i] LSB first.
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-03-05 13:21:22 -06:00
|
|
|
|
* If the device is in bypass, then that is an error condition in
|
|
|
|
|
* the caller code that is not detected by this fn, whereas jtag_add_dr_scan()
|
|
|
|
|
* does detect it. Similarly if the device is not in bypass, data must
|
2008-11-05 01:45:31 -06:00
|
|
|
|
* be passed to it.
|
|
|
|
|
*
|
2008-03-05 13:21:22 -06:00
|
|
|
|
* If anything fails, then jtag_error will be set and jtag_execute() will
|
|
|
|
|
* return an error. There is no way to determine if there was a failure
|
|
|
|
|
* during this function call.
|
2008-11-05 01:45:31 -06:00
|
|
|
|
*
|
2008-03-05 13:21:22 -06:00
|
|
|
|
* Note that this jtag_add_dr_out can be defined as an inline function.
|
2008-02-28 03:21:56 -06:00
|
|
|
|
*/
|
2008-11-30 16:25:43 -06:00
|
|
|
|
extern void interface_jtag_add_dr_out(jtag_tap_t *tap,
|
2008-03-05 13:21:22 -06:00
|
|
|
|
int num_fields,
|
2008-05-07 09:25:34 -05:00
|
|
|
|
const int *num_bits,
|
|
|
|
|
const u32 *value,
|
2008-03-05 13:21:22 -06:00
|
|
|
|
enum tap_state end_state);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-11-30 16:25:43 -06:00
|
|
|
|
static __inline__ void jtag_add_dr_out(jtag_tap_t *tap,
|
2008-03-05 13:21:22 -06:00
|
|
|
|
int num_fields,
|
2008-05-07 09:25:34 -05:00
|
|
|
|
const int *num_bits,
|
|
|
|
|
const u32 *value,
|
2008-03-05 13:21:22 -06:00
|
|
|
|
enum tap_state end_state)
|
2008-02-28 03:21:56 -06:00
|
|
|
|
{
|
2008-03-05 13:21:22 -06:00
|
|
|
|
if (end_state != -1)
|
|
|
|
|
cmd_queue_end_state=end_state;
|
|
|
|
|
cmd_queue_cur_state=cmd_queue_end_state;
|
2008-11-30 16:25:43 -06:00
|
|
|
|
interface_jtag_add_dr_out(tap, num_fields, num_bits, value, cmd_queue_end_state);
|
2008-02-28 03:21:56 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-25 08:50:31 -06:00
|
|
|
|
#endif /* JTAG_H */
|